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/MvcShipping/Viewsjs/MsCwAccitemsFt/MsCwAccitemsFtEdit.js

779 lines
25 KiB
JavaScript

2 years ago
Ext.namespace('Shipping');
Shipping.MsCwAccitemsFtEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCwAccitemsFtEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsCwAccitemsFtEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
feeType: 0,
StoreFee: null,
//需求编号SR2017061200005-3
initUIComponents: function () {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.formname = 'MsCwAccitemsFtEdit';
//#region 编辑form
//枚举参照相关(编辑form)
this.storeCwAccitems = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CwAccitemsGlModel',
proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsGl' }
});
this.storeCwAccitems.load({ params: { condition: "DETAILED=1 and ISENABLE=1" } });
this.comboxAccitems= Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '科目名称',
store: this.storeCwAccitems,
forceSelection: true, //输入值是否严格为待选列表中存在的值
id: 'ACCID',
name: 'ACCID',
valueField: 'ACCID', //ACCNAME
displayField: 'ACCIDNAME',
allowBlank: false, //不允许为空
listeners: {
scope: this,
blur: function (field, The, eOpts) {
var selectrecords = DsStoreQueryBy(_this.storeCwAccitems, 'ACCIDNAME', _this.comboxAccitems.rawValue);
if (selectrecords.getCount() > 0) {
var selectdata = selectrecords.getAt(0).data;
this.formEdit.getForm().findField('ACCNAME').setValue(selectdata.ACCNAME);
}
},
expand: function (field, eOpts) {
//var port = this.formEdit.getForm().findField('PORTDISCHARGEID').getValue();
// _this.storeCodeDisport.load({ params: { PORT: port } });
return;
},
'select': function (combo, records, eOpts) {
if (records.length > 0) {
this.formEdit.getForm().findField('ACCNAME').setValue(records[0].data.ACCNAME);
}
}
}
});
2 years ago
this.storeOFFICEADDR2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsExtEnumModel',
proxy: { url: '/CommMng/PubSys/GetEnumValueList' }
});
this.storeOFFICEADDR2.load({ params: { enumTypeId: 97304 } });
this.comboxOFFICEADDR2 = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeOFFICEADDR2,
fieldLabel: '办公地点',
// forceSelection: true,
name: 'OFFICE',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
2 years ago
//表参照相关(编辑form)
//编辑form
this.formEdit = Ext.widget('form', {
region: 'center',
frame: true,
bodyPadding: 5,
autoScroll: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: Zi.LAN.GID, //'GID',
name: 'GID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: Zi.LAN.CORPID, //'CORPID',
name: 'CORPID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: Zi.LAN.CREATEUSER, //'CREATEUSER',
name: 'CREATEUSER', flex: 0, hidden: true, margins: '0'
}, this.comboxAccitems, {
fieldLabel: Zi.LAN.ACCNAME, //'录入人',
readOnly: true,
name: 'ACCNAME'
2 years ago
}, this.comboxOFFICEADDR2,{
2 years ago
fieldLabel: Zi.LAN.CREATEUSERREF, //'录入人',
readOnly: true,
name: 'CREATEUSERREF'
}, {
fieldLabel: Zi.LAN.CREATETIME, //'录入日期',
readOnly: true,
name: 'CREATETIME'
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//#endregion
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: Zi.LAN.btnSave, //"保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
},
{
text: Zi.LAN.btnSaveAndClose, //"保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
},
'-',
{
text: Zi.LAN.btnSaveAndNew, //"保存并新建",
handler: function (button, event) {
this.Save('2');
},
scope: this
},
'-',
{
text: Zi.LAN.btnCopyAndNew, //"复制新建",
handler: function (button, event) {
var basicForm = this.formEdit.getForm();
this.opStatus = 'add';
basicForm.findField('GID').setDisabled(false);
var field = basicForm.findField('GID');
field.setValue(NewGuid());
basicForm.findField('GID').setDisabled(true);
field = basicForm.findField('CREATEUSERREF');
field.setValue('');
field = basicForm.findField('ACCID');
field.setValue('');
field = basicForm.findField('ACCNAME');
field.setValue('');
for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
var memberbody = this.storeBodyList.getAt(j);
memberbody.set("LINKGID", '*');
memberbody.commit();
};
},
scope: this
}, '-', {
text: "打印",
iconCls: "btnprint",
handler: function (button, event) {
this.Print();
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#region 明细表
//明细表表格相关
//明细表-数据集
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'MsCwAccitemsFtDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCwAccitemsFt/GetBodyList',
reader: {
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.storeCwAccitems2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CwAccitemsGlModel',
proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsGl' }
});
this.storeCwAccitems2.load({ params: { condition: "DETAILED=1 and ISENABLE=1" } });
this.comboxAccitems2 = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCwAccitems2,
forceSelection: true, //输入值是否严格为待选列表中存在的值
name: 'ACCID',
valueField: 'ACCID', //ACCNAME
displayField: 'ACCIDNAME'
});
//所属部门
this.storeDept = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.DeptModel',
proxy: { url: '/CommMng/BasicDataRef/GetDeptList' }
});
this.storeDept.load();
this.comboxDept = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeDept,
//flex: 0.5,
//labelWidth: 55,
forceSelection: true,
name: 'SALEDEPT',
valueField: 'DeptName',
displayField: 'DeptName'
//,hidden: true
});
this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
2 years ago
proxy: { url: '/CommMng/BasicDataRef/GetEmployeeListRm' }
2 years ago
});
this.storeOpCode.load();
this.comboxOP = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeOpCode,
forceSelection: true,
queryMode: 'remote',
minChars: 0,
queryParam: 'CODENAME',
valueField: 'UserName',
displayField: 'CodeAndName'
});
this.storeOFFICEADDR = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsExtEnumModel',
proxy: { url: '/CommMng/PubSys/GetEnumValueList' }
});
this.storeOFFICEADDR.load({ params: { enumTypeId: 97304 } });
this.comboxOFFICEADDR = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeOFFICEADDR,
// forceSelection: true,
name: 'OFFICEADDR',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
this.gridList = new Ext.grid.GridPanel({
store: this.storeBodyList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: Zi.LAN.ShuJuJiaZaiZhong },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
tbar: [{
text: Zi.LAN.btnAddDetail, //'增加费用明细',
tooltip: Zi.LAN.btnAddDetail, //'增加费用明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddDetailClick(button, event, 1);
},
scope: this
}, '-', {
text: Zi.LAN.btnDeleteDetail, //'删除费用明细',
tooltip: Zi.LAN.btnDeleteDetail, //'删除费用明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelDetailClick(button, event, 1);
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'GID',
header: Zi.LAN.GID, //'GID',
hidden: true,
width: 120
}, {
sortable: true,
dataIndex: 'ACCID',
header: Zi.LAN.ACCID, //'模板名称',
editor: this.comboxAccitems2,
width: 160
}, {
sortable: true,
dataIndex: 'DEPT',
header: Zi.LAN.DEPT, //'模板名称',
editor: this.comboxDept,
width: 160
}, {
sortable: true,
dataIndex: 'EMP',
header: Zi.LAN.EMP, //'模板名称',
editor: this.comboxOP,
width: 160
}, {
sortable: true,
dataIndex: 'OFFICE',
header: Zi.LAN.OFFICE, //'模板名称',
editor: this.comboxOFFICEADDR,
width: 160
}
]
});
this.panelService = new Ext.Panel({
title: Zi.LAN.FeeField, //'费用字段',
layout: "border",
region: 'center',
margin: '5 10',
items: [this.gridList]
});
this.paneldetail = new Ext.Panel({
layout: "border",
region: "center",
items: [
this.panelService
]
});
//#endregion 明细表
//#region 条件明细表
//明细表表格相关
this.panelService = new Ext.Panel({
title: Zi.LAN.FeeField, //'费用字段',
layout: "border",
region: 'center',
//margin: '5 10',
items: [this.gridList]
});
this.paneldetail = new Ext.tab.Panel({
layout: "border",
region: "center",
items: [
this.panelService,
this.panelCondit
]
});
//#endregion 明细表
//#region 布局
//控件布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 90,
items: [this.panelBtn, this.formEdit]
});
Ext.apply(this, {
items: [this.panelTop, this.paneldetail]
});
//#endregion
//绑定查询窗体
//初始化数据
if (this.feeaddtemplate == undefined) {
this.ParentWin = window.parent.opener;
this.InitData();
} else {
this.opStatus = 'add';
}
//绑定事件
this.gridList.on('edit', function (editor, e, eOpts) {
this.gridAfterEdit(editor, e, eOpts);
}, this);
this.storeBodyList.on('beforeload', function (store) {
var cargoid = 0;
if (this.opStatus == 'edit') {
cargoid = this.editRecord.get('GID');
}
var sql = " LINKGID='" + cargoid + "'";
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
}, //end initUIComponents
InitData: function () {
this.opStatus = 'add';
var condition = '';
if (this.ParentWin) {
var ret = this.ParentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
}
if (this.opStatus == 'edit')
condition = " GID='" + this.editRecord.get('GID') + "'";
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: Zi.LAN.ZhengZaiChaXunShuJu, //'正在查询主表数据...',
url: '/MvcShipping/MsCwAccitemsFt/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: Zi.LAN.TiShi, //'提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
var data = result.data;
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
} else {
Ext.MessageBox.alert(Zi.LAN.FuWuQiXiangYingChuCuo, response.responseText);
}
},
scope: this
});
var billno = '*';
var cargoid = 0;
if (this.opStatus == 'edit') {
cargoid = this.editRecord.get('GID');
}
this.storeBodyList.load({ params: { condition: " LINKGID='" + cargoid + "'" } });
}, // end LoadDate
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
//判断表格数据是否合法
if (!validateEditorGridPanel(this.gridList)) {
return;
}
basicForm.findField('GID').setDisabled(false);
var data = basicForm.getValues();
basicForm.findField('GID').setDisabled(true);
if (this.opStatus == 'add') {
data.GID = NewGuid();
}
var bodydatas = [];
for (var i = 0; i < this.storeBodyList.getCount(); i += 1) {
var member = this.storeBodyList.getAt(i);
bodydatas.push(member);
}
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
Ext.Msg.wait(Zi.LAN.ZhengZaiCaoZuoShuJu);
Ext.Ajax.request({
waitMsg: Zi.LAN.ZhengZaiCaoZuoShuJu, //'正在保存数据...',
url: '/MvcShipping/MsCwAccitemsFt/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
body: jsonBody
},
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];
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsCwAccitemsFt', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'id')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
}
if (type == '0') {
this.opStatus = 'edit';
basicForm.findField('GID').setDisabled(true);
for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
var memberbody = this.storeBodyList.getAt(j);
memberbody.set("LINKGID", this.editRecord.get('GID'));
memberbody.commit();
};
} else if (type == '1') {
window.close();
} else {
this.LoadData('add', '');
basicForm.findField('GID').setDisabled(false);
}
} else {
Ext.Msg.show({ title: Zi.LAN.CuoWu, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: Zi.LAN.TiShi,
msg: Zi.LAN.FuWuQiXiangYingChuCuo,
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
}, //end save
onAddDetailClick: function (button, event, type) {
this.addDetail(type);
}, //end onAddDetailClick
onDelDetailClick: function (button, event, type) {
this.deleteDetail(type);
}, //onDelDetailClick
gridAfterEdit: function (editor, e, eOpts) {
//需要自己实现里面的事件
if (e.field == 'CLIENT') {
var records = DsStoreQueryBy(this.storeCustType, 'EnumValueId', e.value);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
var CLIENTNAME = data.EnumValueName;
e.record.set('CLIENTREF', CLIENTNAME);
}
}
if (e.field == 'ISCTN') {
var isctn = e.value;
if (isctn == true)
e.record.set('ISCTNREF', "是");
else
e.record.set('ISCTNREF', "否");
}
if (e.field == 'CURRENCY') {
var isctn = e.value;
if (isctn == 'RMB')
e.record.set('EXCHANGERATE', 1);
else
e.record.set('EXCHANGERATE', 0);
} if (e.field == 'UNITPRICE') {
var unitPrice = e.record.data['UNITPRICE'];
var taxrate = e.record.data['TAXRATE'];
if (taxrate != null) {
var taxrateb = Add(1, Div(taxrate, 100, 4), 4);
//parseFloat(1 + parseFloat(taxrate).mul(0.01));
var TaxUnitPrice = Mul(unitPrice, taxrateb, 4);
//(parseFloat(unitPrice).mul(taxrateb)).toFixed(2);
e.record.set('TAXUNITPRICE', TaxUnitPrice);
}
// var PreAmountttl = Mul(PreAmount, quantity);
// e.record.set('PreAmountttl', PreAmountttl);
} else if (e.field == 'TAXUNITPRICE') {
var TaxUnitPrice = e.record.data['TAXUNITPRICE'];
var taxrate = e.record.data['TAXRATE'];
var taxrateb = Add(1, Div(taxrate, 100, 4), 4); //parseFloat(1 + parseFloat(taxrate).mul(0.01));
var unitPrice = Div(TaxUnitPrice, taxrateb, 4); //(parseFloat(TaxUnitPrice).div(parseFloat(taxrateb))).toFixed(2);
e.record.set('UNITPRICE', unitPrice);
} else if (e.field == 'FEENAME' || e.field == 'FEEDESCRIPTION') {
if (e.field == 'FEEDESCRIPTION') {
if (e.value == '') return;
}
if (e.field == 'FEEDESCRIPTION') {
var records = DsStoreQueryBy(this.storeFeeNameRef, 'Description', e.value);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
e.record.set('FEENAME', data.Name);
}
} else {
var records = DsStoreQueryBy(this.storeFeeNameRef, 'Name', e.value);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
e.record.set('FEEDESCRIPTION', data.Description);
}
}
}
},
addDetail: function (type) {
var newSerialno = 0;
store = this.storeBodyList;
var newSerialno = this.GetHandleSerialNo(store);
var record = Ext.create('MsCwAccitemsFtDetail', {
GID: '',
LINKGID: '',
ACCID: "",
ACCNAME: ""
});
store.add(record);
var n = store.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 1 });
},
GetHandleSerialNo: function (store) {
var result = 0;
if (result == 0) {
for (var i = 0; i < store.getCount(); i += 1) {
var member = store.getAt(i);
if (parseInt(member.data.SORT) > parseInt(result)) {
result = member.data.SORT;
}
}
}
result = parseInt(result) + 1;
return result;
},
deleteDetail: function (type) {
var selectedRecords = this.gridList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
this.storeBodyList.remove(rec);
}
},
onClearCustomerClick: function () {
for (var i = 0; i < this.storeBodyList.getCount(); i += 1) {
var member = this.storeBodyList.getAt(i);
member.set("CUSTOMERNAME", "");
member.commit();
}
},
Print: function () {
var basicForm = this.formEdit.getForm();
var billNo = basicForm.findField('GID').value;
if (billNo == '*' || billNo == '') {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var printType = 'MSCODEFEETEMPLATEEDI';
var sql1 = "SET LANGUAGE 'us_english' SELECT * FROM code_fee_template_auto WHERE GID = '" + billNo + "'";
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
});