You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/OA/Viewsjs/Jiekuan/JiekuanEdit.js

1202 lines
44 KiB
JavaScript

2 years ago
///<reference path="../../../../Views/../TruckMng/Scripts/vswd-ext_2.0.2.js" />
Ext.namespace('DsTruck');
var C_cargoinfo_id="";
var HTHCount=0;
DsTruck.JiekuanEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.JiekuanEdit.superclass.constructor.call(this);
};
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //second
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o) if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length == 1 ? o[k] :
("00" + o[k]).substr(("" + o[k]).length));
return format;
}
var xhr = new XMLHttpRequest();
var currdate = new Date();
if (!xhr) {
//...其他生成xmlhttprequest方法
}
xhr.open("HEAD", location.href, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var datestr = xhr.getResponseHeader("Date");
currdate = new Date(datestr);
// alert(currdate.format('yyyy-MM-dd'));
}
}
xhr.send(null);
function getSaved() {
var feedirty = DsTruck.GetDirty(panelEdit.storeCHEQUE, panelEdit.storeCHEQUEDel);
if (panelEdit.formEdit.getForm().isDirty()== true )
{
return true;
}
else return false;
}
Ext.extend(DsTruck.JiekuanEdit, Ext.Panel, {
parentWin: null,
OpStatus: 'add',
StoreList: null,
editRecord: null,
// parentfunction: null,
_First: true,
initUIComponents: function () {
this.feeSerialNo = 0;
this.CHEQUEDel = [];
//#region 枚举参照相关(编辑form)
Ext.define('PayTypeMd', {
extend: 'Ext.data.Model',
fields: [
{ name: 'PayTypeID', type: 'string' },
{ name: 'PayTypeName', type: 'string' }
]
});
var PayTypeData = [{ "PayTypeID": "1", "PayTypeName": "成本" },
{ "PayTypeID": "2", "PayTypeName": "费用"}];
var storePayType = Ext.create('Ext.data.Store', {
model: 'PayTypeMd',
data: PayTypeData
});
this.comboxPayType = Ext.create('DsExt.ux.RefEnumCombox', {
//fieldLabel: '收付类型',
forceSelection: true,
store: storePayType,
name: 'Reason',
valueField: 'PayTypeName',
displayField: 'PayTypeName'
});
Ext.define('TFmb', {
extend: 'Ext.data.Model',
fields: [
{ name: 'TFID', type: 'string' },
{ name: 'TFName', type: 'string' }
]
});
var TFData = [{ "TFID": "0", "TFName": "未借出" },
{ "TFID": "1", "TFName": "已借出"}/*,
{ "PayTypeID": "2", "PayTypeName": "原单原转"}*/];
this.storeTF = Ext.create('Ext.data.Store', {
model: 'TFmb',
data: TFData
});
this.comboxTF = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '借款状态',
forceSelection: true,
store: this.storeTF,
name: 'ISOVER',
valueField: 'TFID',
displayField: 'TFName'
});
this.storeUser = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeUser.load({ params: { condition: " 1=1 "} });
this.comboxCreator = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '制单人',
forceSelection: true,
store: this.storeUser,
name: 'ENTEROPERATOR',
id: "ENTEROPERATOR",
valueField: 'GID',
displayField: 'CodeAndName',
allowBlank: false,
readOnly: true
});
this.comboxAuditor = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '审核人',
forceSelection: true,
store: this.storeUser,
name: 'AUDITOR',
id: "AUDITOR",
valueField: 'UserCode',
displayField: 'CodeAndName'
});
this.storecurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'currRef',
proxy: { url: '/CommMng/BasicDataRef/GetcurrRefList' }
});
this.storecurr.load({ params: { condition: ""} });
this.comboxcurr = Ext.create('DsExt.ux.RefTableCombox', {
forceSelection: true,
fieldLabel: '币别',
store: this.storecurr,
name: 'CURRENCY',
valueField: 'codename',
displayField: 'codename',
value: "RMB"
});
this.storeJKSTATUS = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeJKSTATUS.load({ params: { enumTypeId: 99024} });
this.comboxJKSTATUS = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '借款单状态',
//forceSelection :true,
store: this.storeJKSTATUS,
name: 'JKSTATUS',
readOnly: true,
id: "JKSTATUS"
});
this.storeFEESTATUS = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeFEESTATUS.load({ params: { enumTypeId: 99024} });
this.comboxFEESTATUS = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '费用状态',
forceSelection: true,
store: this.storeFEESTATUS,
name: 'FEESTATUS',
readOnly: true,
id: "STATUS"
});
this.storeAccitems = Ext.create('DsExt.ux.RefTableStore', {
model: 'Accitemsmb',
proxy: { url: '/CommMng/BasicDataRef/GetAccitems' }
});
this.storeAccitems.load({ params: { condition: ""} });
//通过mblno获取bsno
this.storeBS = Ext.create('DsExt.ux.RefTableStore', {
model: 'BSmb',
proxy: { url: '/OA/Baoxiao/GetBSNO' }
});
this.storeBS.load({ params: { COMPANYID: COMPANYID} });
this.comboxMAKETIMEUPPER = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '业务编号',
forceSelection: true,
store: this.storeBS,
name: 'MAKETIMEUPPER',
valueField: 'BSNO',
displayField: 'MBLNO'
});
this.comboxBANK = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '收支方式', //收支的银行账户
store: this.storeAccitems,
forceSelection: true,
name: 'OPERATORSIDE',
valueField: 'ACCID',
displayField: 'ACCIDNAME',
flex: 1
});
//#endregion
//编辑form:formEdit
this.formEdit = Ext.widget('form', {
// layout: "border",
region: 'center',
frame: true,
bodyPadding: 5,
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
//,split:true
},
bodyStyle: 'background:#FFF',
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{//container_1
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '借款单单号',
// allowBlank: false,
//disabled: true,
name: 'GID'
}, {
fieldLabel: '金额',
//allowBlank: false,
readOnly: true,
id: "AMOUNT_ALL",
name: 'AMOUNT', flex: 1,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
}
}, {
fieldLabel: 'COMPANYID',
hidden: true,
id: "COMPANYID",
name: 'COMPANYID', flex: 1
}, this.comboxCreator, {
fieldLabel: '制单时间',
format: 'Y-m-d H:i:s', id: "ENTERDATE",
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
name: 'ENTERDATE'
}, {
fieldLabel: 'DEPTID',
hidden: true,
id: "DEPTID",
name: 'DEPTID', flex: 1
}]
}, //container_1 end
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '剩余资金额度', id: "REMAIN",
name: 'REMAIN', readOnly: true,
flex: 1,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
}
}, this.comboxJKSTATUS,
{
fieldLabel: '备注',
name: 'REMARK',
flex: 2
}]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'COMPANY',
name: 'COMPANY', hidden: true,
flex: 1
}, {
fieldLabel: 'DEPTNAME',
name: 'DEPTNAME', hidden: true,
flex: 1
}, {
fieldLabel: 'BSNO', id: "BSNO",
name: 'BSNO', hidden: true,
flex: 1
}]
}]
}]
});
//////////////////////////////////
//明细 <<<< 收支费用明细 >>>>
//
/*
this.storeAccitems = Ext.create('DsExt.ux.RefTableStore', {
model: 'Accitemsmb',
proxy: { url: '/CommMng/BasicDataRef/GetAccitems' }
});
this.storeAccitems.load({ params: { condition: ""} });
*/
this.comboxAccitems = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '费用科目',
store: this.storeAccitems,
name: 'FEENAME',
valueField: 'ACCID',
displayField: 'ACCIDNAME'
});
this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.FeeTypeRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetFeeTypeRefList' }
});
this.storeFeeNameRef.load({ params: { condition: ""} });
this.comboxFeeNameRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeFeeNameRef,
name: 'FeeName',
valueField: 'Name',
displayField: 'CodeAndName'
});
this.storeCustomerNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustomerNameRef.load({ params: { condition: ""} });
this.comboxCustomerNameRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCustomerNameRef,
name: 'CUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndName'
});
this.storecurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'currRef',
proxy: { url: '/CommMng/BasicDataRef/GetcurrRefList' }
});
this.storecurr.load({ params: { condition: ""} });
this.comboxcurr = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storecurr,
name: 'currid',
valueField: 'gid',
displayField: 'codename'
//币别
});
this.storeTAXRATE = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeTAXRATE.load({ params: { enumTypeId: 25} });
this.comboxTAXRATE = Ext.create('DsExt.ux.RefEnumCombox', {
//fieldLabel: '税率',
store: this.storeTAXRATE,
name: 'TAXRATE',
valueField: 'EnumValueName',
displayField: 'EnumValueName',
id: "TAXRATE"
});
//数据集
this.storeCHEQUE = Ext.create('Ext.data.Store', {
model: 'CHEQUEmb',
remoteSort: false,
pruneModifiedRecords: true,
proxy: {
type: 'ajax',
url: '/OA/Jiekuan/GetCHEQUE',
reader: {
id: 'gid',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//表格
this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.CheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.formCHEQUE = new Ext.grid.GridPanel({
store: this.storeCHEQUE,
enableHdMenu: false,
region: 'north', bodyStyle: 'background:#FFF',
trackResetOnLoad: true,
//height: 160,
title: '费用明细',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditing],
selModel: this.CheckBoxModel,
selType: 'cellmodel',
tbar: [{
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddFeeClick(button, event);
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelFeeClick(button, event);
},
scope: this
}],
columns: [
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '客户名称',
editor: this.comboxCustomerNameRef,
width: 120
},
{
sortable: true, hidden: true,
dataIndex: 'BILLNO',
header: 'BILLNO',
width: 80
}, {
sortable: true,
dataIndex: 'MAKETIMEUPPER',
header: '业务编号(提单号)',
//hidden: true,
width: 150,
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.MBLNO;
},
editor: this.comboxMAKETIMEUPPER
},
{
sortable: true, id: "CHEQUENO",
dataIndex: 'CHEQUENO',
header: '支票号',
editor: {
xtype: 'textfield', //numberfield
selectOnFocus: true
},
width: 80
},
{
sortable: true,
dataIndex: 'CHEQUEAMOUNTUPPER',
header: '借款金额',
editor: {
xtype: 'textfield', //numberfield
selectOnFocus: true
},
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
}
},
{
sortable: true,
dataIndex: 'PURPOSE',
header: '用途',
editor: {
xtype: 'textfield', //numberfield
selectOnFocus: true
},
width: 80
},
{
sortable: true,
dataIndex: 'ModifiedTime',
header: '预计收回时间',
width: 80,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
format: 'Y-m-d',
xtype: 'datefield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'CHEQUEAMOUNT',
header: '实际支取金额',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
}
},
{
sortable: true,
dataIndex: 'PASSWORD',
header: '密码',
editor: {
xtype: 'textfield', //numberfield
selectOnFocus: true
},
width: 80
},
{
sortable: true,
dataIndex: 'CHEQUECUSTNAME',
header: '密码领取人',
width: 80
},
{
sortable: true,
dataIndex: 'CHEQUEMAKETIME',
header: '支取时间',
width: 80/*,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
xtype: 'datefield',
selectOnFocus: true
}*/
},
{
sortable: true,
dataIndex: 'PRINTTIME',
header: '开出时间',
width: 80,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
xtype: 'datefield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'PRINTUSER',
header: '开出人',
width: 80
}]
});
//////////////////////////////////////////////明细<<<< 收支费用明细 >>>>结束
//公共按钮Toolbar:panelBtn
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
// id: "saveandclose",
text: "保存",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, {
// id: "saveandclose",
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
},
{
// id: "saveandclose",
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
},
scope: this
}, '-',
{
// id: "saveandclose",
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}, '-',
{
// id: "saveandclose",
text: "打印",
handler: function (button, event) {
this.DoPrint();
},
scope: this
}
]
}); //end 按钮Toolbar
//布局
/* 3 */
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 32, bodyStyle: 'background:#FFF',
items: [this.panelBtn]//, this.formEdit]
});
this.page_1 = new Ext.Panel({
title: "借款单", bodyStyle: 'background:#FFF',
items: [this.formCHEQUE, this.formEdit]
});
/*
this.page_2 = new Ext.Panel({
title: "库存管理",
items: [this.formKC]
});
this.page_3 = new Ext.Panel({
title: "票据管理",
items: [this.gridListReceipt]
});
this.page_4 = new Ext.Panel({
title: "应收应付录入",
items: [this.gridListChFee]
});
this.panelReceipt = new Ext.Panel({
layout: "border",
region: "center",
items: [this.panelBodyReceipt]
});*/
this.MainTab = new Ext.tab.Panel({
layout: "border",
region: "center", bodyStyle: 'background:#FFF',
items: [
this.page_1
//, this.page_2
//, this.page_3
//, this.page_4
]
})
Ext.apply(this, {
items: [this.panelTop, this.MainTab]
});
parentWin = window.parent.opener;
this.InitData();
//集中绑定事件
this.formCHEQUE.on('edit', function (editor, e, eOpts) {
this.CHEQUEAfterEdit(editor, e, eOpts);
}, this);
this.cellEditing.on('beforeedit', function (editor, e) {
//Ext.getCmp("zongshu").setText("1234");
return this.cellEditingBeforeEdit(editor, e);
}, this);
}, //end initUIComponents
parentfunction: function (button, event) {
var ret1 = window.parent.opener.OprationSwap();
// alert(this.First);
ret1[3]();
},
onAddFeeClick: function (button, event, type) {
/*
if (this.OpStatus == 'add') {
this.Save('0');
this.onAddFeeClick(button, event);
}*/
function newID() {
var guid = "";
for (var i = 1; i <= 32; i++) {
var n = Math.floor(Math.random() * 16.0).toString(16);
guid += n;
if ((i == 8) || (i == 12) || (i == 16) || (i == 20))
guid += "-";
}
return guid.toUpperCase();
}
var store = null;
store = this.storeCHEQUE;
//var newSerialno = this.GetHandleSerialNo(store, type);
var record = null;
record = Ext.create('CHEQUEmb', {
GID: newID(),
BILLNO: '',
CHEQUENO: '',
CHEQUEAMOUNT: '0',
CHEQUEAMOUNTUPPER: '0',
PASSWORD: '',
CHEQUEMAKETIME: '',
CREATEUSER: '',
CREATETIME: '',
PRINTTIME: '',
PRINTUSER: '',
PURPOSE: ''
});
//alert(Ext.getCmp("CREATEDATE").getRawValue());
store.add(record);
cellediting = this.cellEditing;
var n = store.getCount();
cellediting.startEditByPosition({ row: n - 1, column: 2 });
},
onDelFeeClick: function (button, event) {
var selectedRecords = this.formCHEQUE.selModel.getSelection();
Ext.MessageBox.confirm('提示', '确定删除记录吗?', function (btn) {
if (btn == 'yes') {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.GID != "" || rec.GID != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.CHEQUEDel.push(rec);
}
this.storeCHEQUE.remove(selectedRecords[i]);
}
}
}, this);
//aftereditform();
},
CHEQUEAfterEdit: function (editor, e, eOpts) {
//需要自己实现里面的事件
if (e.field == 'MAKETIMEUPPER') {
var BSrecords = DsStoreQueryBy(this.storeBS, 'BSNO', e.value);
if (BSrecords.getCount() > 0) {
var BSdata = BSrecords.getAt(0).data;
e.record.set('MAKETIMEUPPER', BSdata.BSNO);
e.record.set('MBLNO', BSdata.MBLNO);
} else {
e.record.set('MAKETIMEUPPER', '');
e.record.set('MBLNO', '');
}
}
var Amount_ALL = 0;
for (var i = 0; i < this.storeCHEQUE.getCount(); i += 1) {
Amount_ALL = Amount_ALL + parseFloat(this.storeCHEQUE.getAt(i).get("CHEQUEAMOUNTUPPER"));
}
//this.editRecord.set('AMOUNT', Amount + '');
//this.formEdit.getForm().setValues(this.editRecord.data);
Ext.getCmp("AMOUNT_ALL").setValue(Amount_ALL + "");
//getElementById("AMOUNT_ALL").value = Amount + "";
},
cellEditingBeforeEdit: function (editor, e) {
if (this.OpStatus == "add") {
var JKStatus = "1";
} else {
var JKStatus = this.editRecord.get('JKSTATUS');
}
/* this.VISIBLERANGE
this.OPERATERANGE 可操作;*/
//可操作为0则全都可见3为可提交/驳回,2为可审核/驳回1为只能看
var canedit = true;
if (this.OPERATERANGE == 1) {
canedit = false;
} //chfeefeeStatus == 1 || chfeefeeStatus == 2 || chfeefeeStatus == 6
if (this.OPERATERANGE == 2) {
canedit = JKStatus == 0 || JKStatus == 2;
}
if (this.OPERATERANGE == 3) {
canedit = JKStatus == 1 || JKStatus == 6;
}
//alert(canedit);
return canedit;
},
InitData: function () {
this.OpStatus = 'add';
var condition = '';
if (parentWin) {
var ret = parentWin.OprationSwap();
this.OpStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
// this.parentfunction = ret[3];
}
if (this.OpStatus == 'edit') {
condition = " jk.GID='" + this.editRecord.get('GID') + "'";
}
else {
Ext.getCmp("AMOUNT_ALL").setValue("0");
//Ext.getCmp("CHEQUEAMOUNT").setValue("0");
}
var me = this;
Ext.Ajax.request({
waitMsg: '正在查询用户权限...',
url: '/CommMng/BasicDataRef/GetAuthorityRange',
params: {
modName: "mod_Baoxiao",
USERID: USERID
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
rec = result.data;
//alert(rec.VISIBLERANGE);
//alert(rec.OPERATERANGE);
//可操作为0则全都可见3为可提交/驳回,2为可审核/驳回1为只能看
this.VISIBLERANGE = rec.VISIBLERANGE;
this.OPERATERANGE = rec.OPERATERANGE;
if (this.OPERATERANGE == '0') {
//me.formPayBody.show();
} else
if (this.OPERATERANGE == '1') {
//me.formPayBody.hide();
} else
if (this.OPERATERANGE == '2') {
//me.formPayBody.show();
} else {//3
//me.formPayBody.hide();
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
}); //request over
this.LoadData(this.OpStatus, condition);
//Ext.getCmp("CHEQUENO").disable();
}, //end InitData
//载入数据
LoadData: function (OpStatus, condition) {
this.OpStatus = OpStatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/OA/Jiekuan/GetData',
params: {
handle: OpStatus,
condition: condition
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
var basicForm = this.formEdit.getForm();
var data = result.data;
// this.formEdit.getForm().reset();
if (data.ENTERDATE == "") { data.ENTERDATE = currdate.format('yyyy-MM-dd hh:mm:ss') };
if (data.ENTEROPERATOR == "") {
//basicForm.findField('ENTEROPERATOR').setDisabled(false);
data.ENTEROPERATOR = USERID;
//basicForm.findField('ENTEROPERATOR').setDisabled(true);
};
if (data.DEPTID == "") { data.DEPTID = DEPTID };
if (DEPTID == "") {
alert("登陆信息不完整,请重新登陆");
return;
}
if (data.AMOUNT == "") { data.AMOUNT = 0 };
//if (data.CHEQUEAMOUNT == "") { data.CHEQUEAMOUNT = 0 };
//if (data.BXSTATUS_REF == "") { data.BXSTATUS_REF = "录入状态" };
//if (data.BXSTATUS == "") { data.BXSTATUS = 1 };
if (this.OpStatus == 'add') {
data.COMPANYID = COMPANYID;
data.DEPTID = DEPTGID;
data.JKSTATUS = "1";
}
if (data.DEPTID == "" || data.ENTEROPERATOR == "" || data.COMPANYID == "") {
alert("登陆信息不完整,请重新登陆");
return;
}
basicForm.findField('GID').setDisabled(false);
//basicForm.findField('ENTEROPERATOR').setDisabled(false);
//basicForm.findField('BXSTATUS').setDisabled(false);
this.formEdit.getForm().setValues(data);
basicForm.findField('GID').setDisabled(true);
//basicForm.findField('ENTEROPERATOR').setDisabled(true);
//basicForm.findField('BXSTATUS').setDisabled(true);
//alert(data.TimeMark);
if (data.BSNO != '') {
Ext.getCmp("MBLNO").setRawValue(data.MBLNO);
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
}); //request over
if (this.OpStatus == 'edit') {
this.formEdit.getForm().findField('GID').setDisabled(false);
var bsno = this.editRecord.get('GID');
this.storeCHEQUE.load({ params: { condition: " BILLNO='" + this.editRecord.get('GID') + "' "} });
this.formEdit.getForm().findField('GID').setDisabled(true);
}
}, // end LoadDate
checkedit: function (status) {
/*
if (status != 1 && status != 2 && status != 6) {
alert("只有 录入状态/提交审核/驳回提交 的费用才能保存");
return false;
} else { return true; }*/
},
Save: function (type) {
var Amount_ALL = 0;
for (var i = 0; i < this.storeCHEQUE.getCount(); i += 1) {
Amount_ALL = Amount_ALL + parseFloat(this.storeCHEQUE.getAt(i).get("CHEQUEAMOUNTUPPER"));
}
Ext.getCmp("AMOUNT_ALL").setValue(Amount_ALL + "");
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
basicForm.findField('GID').setDisabled(false);
//basicForm.findField('AMOUNT').setDisabled(false);
//basicForm.findField('ENTEROPERATOR').setDisabled(false);
//basicForm.findField('JKSTATUS').setDisabled(false);
//basicForm.findField('MBLNO').setDisabled(true);
var data = this.formEdit.getForm().getValues();
var GID = data.GID;
basicForm.findField('GID').setDisabled(true);
//basicForm.findField('AMOUNT').setDisabled(true);
//basicForm.findField('ENTEROPERATOR').setDisabled(true);
//basicForm.findField('JKSTATUS').setDisabled(true);
//basicForm.findField('CUSTNO').setDisabled(false);
//basicForm.findField('MBLNO').setDisabled(false);
/*
if (!this.checkedit(status)) {
return;
}*/
var CHEQUEdatas = [];
for (var i = 0; i < this.storeCHEQUE.getCount(); i += 1) {
var member = this.storeCHEQUE.getAt(i);
CHEQUEdatas.push(member);
}
//明细
var CHEQUEBody = ConvertRecordsToJson(CHEQUEdatas);
var CHEQUEDelBody = ConvertRecordsToJsonAll(this.CHEQUEDel);
var _this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/OA/Jiekuan/Save',
scope: this,
async: false,
params: {
OpStatus: this.OpStatus,
data: Ext.JSON.encode(data),
CHEQUEBody: CHEQUEBody,
CHEQUEDelBody: CHEQUEDelBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
this.formEdit.getForm().setValues(returnData);
if (this.OpStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
this.OpStatus = 'edit';
}
else if (this.OpStatus == 'edit') {
var editp = Ext.create('Jiekuanmb', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
//alert(name + ' -- ' + editp.get(name));
if (name != 'GID')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
}
this.storeCHEQUE.commitChanges();
if (type == '0') {
this.OpStatus = 'edit';
//this.storeCHEQUE.load({ params: { condition: " BILLNO='" + this.editRecord.get('GID') + "' "} });
this.storeCHEQUE.each(function (record) {
var BILLNO = _this.editRecord.get('GID');
record.set('BILLNO', BILLNO);
});
this.storeCHEQUE.commitChanges();
} else if (type == '1') {//保存并关闭
window.close();
} else if (type == '2') {//保存并全部新建
this.LoadData('add', '');
}
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
//alert('03');
}
});
}
//end save
, DoPrint: function () {
var basicForm = this.formEdit.getForm();
var GID = this.editRecord.get('GID')
/*
if (ContractNo == '*' || ContractNo == '') {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}*/
function GetDateStr(AddDayCount) {
var dd = new Date();
dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
var y = dd.getFullYear();
var m = dd.getMonth() + 1; //获取当前月份的日期
var d = dd.getDate();
return y + "-" + m + "-" + d;
}
//alert(GetDateStr(+5));
//var needdate = GetDateStr(+5);
//var printdate = GetDateStr(0);
var _date = Ext.getCmp("ENTERDATE").getRawValue();
var printType = 'Jiekuan'; //打印借款单
//
var data = this.formEdit.getForm().getValues();
var JKUSERID = data.USERID;
var sql1 = " select jk.GID,jk.ENTEROPERATOR,u.showname,dbo.trimdate(jk.ENTERDATE) ENTERDATE,jk.COMPANYID,jk.DEPTID,jk.AMOUNT ";
var sql1 = sql1 + " ,sd.deptname,jk.ISDELETE,jk.DELETEUSER,jk.DELETETIME,vs.MBLNO,vs.CUSTNO,vs.customername,jk.remark ";
var sql1 = sql1 + " FROM OA_Jiekuan jk ";
var sql1 = sql1 + " left join sys_dept sd on sd.gid=jk.deptid ";
var sql1 = sql1 + " left join [user] u on u.gid=jk.ENTEROPERATOR ";
var sql1 = sql1 + " left join [vw_settlement] vs on vs.bsno=jk.bsno ";
var sql1 = sql1 + " where jk.GID='" + GID + "' ";
var sql2 = " select cfc.GID,BILLNO,CHEQUENO,convert(numeric(18,2),isnull(CHEQUEAMOUNTUPPER,0)) CHEQUEAMOUNTUPPER,PASSWORD,dbo.trimdate(CHEQUEMAKETIME) CHEQUEMAKETIME,PRINTTIME,PRINTUSER,PURPOSE,CHEQUECUSTNAME,vs.CUSTNO ";
var sql2 = sql2 + " ,vs.mblno,cfc.customername";
/*var sql2 = sql2 + " ,isnull((select sum(isnull(amount,0)) from ch_fee where FEETYPE=1 and CUSTOMERNAME=cfc.customername ";
var sql2 = sql2 + " and enterdate>(select starttime from Customer_Balance where CustomerGID=(select gid from info_client where SHORTNAME=cfc.customername)) ";
var sql2 = sql2 + " and enterdate<='" + _date + "' and ISADVANCEDPAY=0 ),0) w_w_amount ";
var sql2 = sql2 + " ,isnull((select sum(isnull(doamount,0)) from ch_fee_do cfd where CUSTOMERNAME=cfc.customername and feetype=1 and createtime> ";
var sql2 = sql2 + " (select starttime from Customer_Balance where CustomerGID=(select gid from info_client where SHORTNAME=cfc.customername)) ";
var sql2 = sql2 + " and createtime<='" + _date + "' and billno like '%iv%' and (ISDELETED is null or ISDELETED=0) and (select ISADVANCEDPAY from ch_fee where gid=cfd.feeid)='false'),0) y_w_amount ";
var sql2 = sql2 + " ,isnull((select sum(isnull(doamount,0)) from ch_fee_do cfd2 where CUSTOMERNAME=cfc.customername and feetype=1 and createtime> ";
var sql2 = sql2 + " (select starttime from Customer_Balance where CustomerGID=(select gid from info_client where SHORTNAME=cfc.customername)) ";
var sql2 = sql2 + " and billno like '%ad%' and (ISDELETED is null or ISDELETED=0) and (select isadvancedpay from ch_fee where ch_fee.gid=cfd2.feeid)='false'),0) y_y_amount,balance_1,balance_2 ";*/
var sql2 = sql2 + " ,Modifiedtime,(select email from op_seai where bsno=cfc.Maketimeupper) email "; //OPERATOREMAIL
var sql2 = sql2 + " ,(select OPERATOREMAIL from op_seae where mblno=vs.mblno) email_2 ";
var sql2 = sql2 + " ,(select email from info_client where shortname=cfc.customername) cust_email ";
var sql2 = sql2 + " from ch_fee_cheque cfc left join vw_settlement vs on vs.bsno=cfc.Maketimeupper ";
var sql2 = sql2 + " left join customer_balance cb on cb.customergid=(select gid from info_client where SHORTNAME=cfc.customername) and cb.DeptGID=(select top 1 DeptGID from VW_User where SHOWNAME=vs.inputby) ";
var sql2 = sql2 + " where billno= '" + GID + "' ";
var sql3 = "";
var sql4 = "select dbo.GetRemain_ZWC ((select gid from sys_dept where linkid= ";
var sql4 = sql4 + "(select companyid from user_company where userid='" + JKUSERID + "') ";
var sql4 = sql4 + "and deptname= ";
var sql4 = sql4 + "(select deptname from user_baseinfo where userid='" + JKUSERID + "') ";
var sql4 = sql4 + "),'" + _date + "')"; //获取该部门剩余资金
var sql5 = " select * from (select * from vw_customerbalance ";
sql5 = sql5 + " union all ";
sql5 = sql5 + " select '',ic.gid,0,0,0,0,0,ic.SHORTNAME,'','','','',ic.CODENAME,0,0,0,0,0,null from info_client ic ";
sql5 = sql5 + " where gid not in(select customergid from Customer_Balance))tt ";
sql5 = sql5 + " where tt.customername in( ";
sql5 = sql5 + " select distinct customername from ch_fee_cheque where billno='" + GID + "' ) ";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
});