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.

715 lines
22 KiB
JavaScript

12 months ago

Ext.namespace('DsTruck');
var C_cargoinfo_id = "";
var HTHCount = 0;
DsTruck.CargoNameEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.CargoNameEdit.superclass.constructor.call(this);
};
function getSaved() {
var feedirty = DsTruck.GetDirty(panelEdit.storeFactoryNo, panelEdit.storeCargoName);
if (feedirty == true) {
return true;
}
else return false;
}
Ext.extend(DsTruck.CargoNameEdit, Ext.Panel, {
parentWin: null,
OpStatus: 'add',
StoreList: null,
editRecord: null,
ClintType: "",
BXSTATUS: 1,
// parentfunction: null,
_First: true,
VISIBLERANGE: 0,
OPERATERANGE: 0,
WorkFlowName: "",
WorkFlowID: "",
PageSize: 500,
initUIComponents: function () {
this.feeSerialNo = 0;
this.FactoryNoDel = [];
this.CargoNameDel = [];
//////////////////////////////////
//明细 <<<< 厂号 >>>>
//数据集
this.storeFactoryNo = Ext.create('Ext.data.Store', {
model: 'FactoryNomb',
remoteSort: false,
pruneModifiedRecords: true,
proxy: {
type: 'ajax',
url: '/Import/CargoName/GetFactoryNoList',
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.formFactoryNo = new Ext.grid.GridPanel({
store: this.storeFactoryNo,
enableHdMenu: false,
//layout: 'border',
region: 'north',
collapsed: true,
collapsible: true,
title: '厂号管理',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditing],
selModel: this.CheckBoxModel,
selType: 'cellmodel',
tbar: [{
text: '增加明细', id: "add1",
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddFactoryNoClick(button, event);
},
scope: this
}, {
text: '删除', id: "del1",
tooltip: '删除',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelFactoryNoClick(button, event);
},
scope: this
}],
columns: [
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true,
dataIndex: 'CLIENTGID', hidden: true,
header: 'CLIENTGID',
width: 80
},
{
sortable: true,
dataIndex: 'FACTORYNO',
header: '厂号',
editor: {
xtype: 'textfield'
},
width: 120
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
editor: {
xtype: 'textfield'
},
width: 160
}]
});
//////////////////////////////////////////////明细<<<< 厂号 >>>>结束
//#region 商品名称
this.storeCargoinfo = Ext.create('DsExt.ux.RefTableStore', {
model: 'CargoRef',
proxy: { url: '/CommMng/BasicDataRef/GetCargoRefList' }
});
this.storeCargoinfo.load({ params: { condition: ""} });
this.comboxCargoinfo = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCargoinfo,
forceSelection: true,
name: 'HS_ID',
valueField: 'id',
displayField: 'codeandname'
//HS代码
});
this.storeCargociq = Ext.create('DsExt.ux.RefTableStore', {
model: 'CargociqRef',
proxy: { url: '/CommMng/BasicDataRef/GetCargociqRefList' }
});
this.storeCargociq.load({ params: { condition: ""} });
this.comboxCargociq = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCargociq,
forceSelection: true,
name: 'CIQ_ID',
valueField: 'id',
displayField: 'codeandname',
async: false
//ciq代码
});
this.storeCARGOTYPE = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeCARGOTYPE.load({ params: { enumTypeId: 30} });
this.comboxCARGOTYPE = Ext.create('DsExt.ux.RefEnumCombox', {
//fieldLabel: '商品类型',
forceSelection: true,
store: this.storeCARGOTYPE,
name: 'CARGOTYPE',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
//数据集
this.storeCargoName = Ext.create('Ext.data.Store', {
model: 'CargoNamemb',
remoteSort: false,
pruneModifiedRecords: true,
proxy: {
type: 'ajax',
url: '/Import/CargoName/GetCargoNameList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//表格
this.cellEditing_S = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.CheckBoxModel_S = Ext.create('Ext.selection.CheckboxModel');
this.formCargoName = new Ext.grid.GridPanel({
layout: 'border',
store: this.storeCargoName,
enableHdMenu: false,
region: 'center', //bodyStyle: 'background:#FFF',
trackResetOnLoad: true,
//split:true,
//height: 160,
title: '商品名称',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditing_S],
selModel: this.CheckBoxModel_S,
selType: 'cellmodel',
tbar: [{
text: '增加明细',
tooltip: '增加明细', id: "add2",
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddCargoNameClick(button, event);
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细', id: "del2",
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelCargoNameClick(button, event);
},
scope: this
}],
columns: [
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'CLIENTGID',
header: 'CLIENTGID',
width: 80
},
{
sortable: true,
dataIndex: 'CODENAME',
header: '代码',
editor: {
xtype: 'textfield'
},
width: 50
},
{
sortable: true,
dataIndex: 'ENNAME',
header: '英文名称',
editor: {
xtype: 'textfield'
},
width: 110
},
{
sortable: true,
dataIndex: 'CNNAME',
header: '中文名称',
editor: {
xtype: 'textfield'
},
width: 110
},
{
dataIndex: 'HS_ID',
header: 'HS代码',
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.HSREF;
},
editor: this.comboxCargoinfo,
width: 140
},
{
dataIndex: 'CIQ_ID',
header: 'CIQ代码',
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.CIQREF;
},
editor: this.comboxCargociq,
width: 140
},
{
sortable: true, hidden: true,
dataIndex: 'MODIFIEDUSER',
header: 'MODIFIEDUSER',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'MODIFIEDTIME',
header: 'MODIFIEDTIME',
width: 80
},
{
sortable: true,
dataIndex: 'AREA',
header: '区域',
editor: {
xtype: 'textfield'
},
width: 60
},
{
sortable: true,
dataIndex: 'SBYS',
header: '申报要素',
editor: {
xtype: 'textfield'
},
width: 160
},
{
sortable: true,
dataIndex: 'CARGOTYPE',
header: '商品类型',
editor: this.comboxCARGOTYPE,
width: 80
}]
});
//#endregion
//公共按钮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) {
window.close();
},
scope: this
}
, '-',
{ xtype: "label", id: "ClineName", text: "" }
, '-', {
text: '引入商品信息',
tooltip: '从商品信息处引入初始信息',
iconCls: "btnconfirm",
handler: function (button, event) {
this.onGetGoodCode(button, event);
},
scope: this
}
]
}); //end 按钮Toolbar
//布局
/*
this.panelTop = new Ext.Panel({
layout: "border",
region: 'center',
margin: '1 1',
//height: 230,
split: true,
items: [this.panelBtn, this.formFactoryNo]
});*/
this.panelCargoName = new Ext.Panel({
layout: 'border',
border: true,
frame: false,
region: 'center',
split: true,
height: 300,
margin: '1 1',
items: [this.formCargoName]
});
Ext.apply(this, {
items: [this.panelBtn, this.formFactoryNo, this.panelCargoName]
});
parentWin = window.parent.opener;
this.InitData();
//集中绑定事件
this.formCargoName.on('edit', function (editor, e, eOpts) {
this.CargoNameAfterEdit(editor, e, eOpts);
}, this);
this.cellEditing_S.on('beforeedit', function (editor, e) {
//Ext.getCmp("zongshu").setText("1234");
return this.CargoNameBeforeEdit(editor, e);
}, this);
}, //end initUIComponents
parentfunction: function (button, event) {
var ret1 = window.parent.opener.OprationSwap();
// alert(this.First);
ret1[3]();
},
onAddFactoryNoClick: function (button, event, type) {
var store = null;
store = this.storeFactoryNo;
var record = null;
record = Ext.create('FactoryNomb', {
GID: NewGuid(),
CLIENTGID: "",
FACTORYNO: "",
REMARK: ""
});
store.add(record);
cellediting = this.cellEditing;
var n = store.getCount();
cellediting.startEditByPosition({ row: n - 1, column: 2 });
},
onDelFactoryNoClick: function (button, event) {
var selectedRecords = this.formFactoryNo.selModel.getSelection();
Ext.MessageBox.confirm('提示', '确定删除记录吗?', function (btn) {
if (btn == 'yes') {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.CLIENTGID != "" || rec.CLIENTGID != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.FactoryNoDel.push(rec);
}
this.storeFactoryNo.remove(selectedRecords[i]);
}
}
}, this);
},
onAddCargoNameClick: function (button, event, type) {
var store = null;
store = this.storeCargoName;
var record = null;
var SBYS = "部位: 瘦肉率: % 带肉率: %";
if (this.ClintType == "ISAIRLINES") {
SBYS = "";
}
record = Ext.create('CargoNamemb', {
GID: NewGuid(),
CLIENTGID: "",
ENNAME: "",
CNNAME: "",
HS_ID: "",
CIQ_ID: "",
MODIFIEDUSER: "",
MODIFIEDTIME: "",
AREA: "国内",
CODENAME: "",
SBYS: SBYS
});
store.add(record);
cellediting = this.cellEditing_S;
var n = store.getCount();
cellediting.startEditByPosition({ row: n - 1, column: 2 });
},
onDelCargoNameClick: function (button, event) {
var selectedRecords = this.formCargoName.selModel.getSelection();
Ext.MessageBox.confirm('提示', '确定删除记录吗?', function (btn) {
if (btn == 'yes') {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.CLIENTGID != "" || rec.CLIENTGID != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.CargoNameDel.push(rec);
}
this.storeCargoName.remove(selectedRecords[i]);
}
}
}, this);
},
CargoNameAfterEdit: function (editor, e, eOpts) {
//需要自己实现里面的事件
if (COMPANYID == "" || DEPTGID == "") {
alert("登录信息不全,请退出重新登录");
returen;
}
if (e.field == 'HS_ID') {
var Cargoinforecords = DsStoreQueryBy(this.storeCargoinfo, 'id', e.value);
if (Cargoinforecords.getCount() > 0) {
var Cargoinfodata = Cargoinforecords.getAt(0).data;
e.record.set('HSREF', Cargoinfodata.codeandname);
if (e.value != e.originalValue) {
e.record.set('CIQ_ID', '');
e.record.set('CIQREF', '');
}
} else {
e.record.set('HSREF', '');
}
}
if (e.field == 'CIQ_ID') {
var Cargociqrecords = DsStoreQueryBy(this.storeCargociq, 'id', e.value);
if (Cargociqrecords.getCount() > 0) {
var Cargociqdata = Cargociqrecords.getAt(0).data;
e.record.set('CIQREF', Cargociqdata.codeandname);
} else {
e.record.set('CIQREF', '');
}
}
},
CargoNameBeforeEdit: function (editor, e) {
var canedit = false;
var HS_ID = e.record.get('HS_ID');
if (e.field != "CIQ_ID") { canedit = true; }
else
if (HS_ID == "") {
alert("请先选择HS代码");
} else {
canedit = true;
var cargoinfoid = e.record.get('HS_ID');
var s = " cargoinfoid=" + cargoinfoid;
this.storeCargociq.load({ params: { condition: s} });
}
return canedit;
},
InitData: function () {
this.OpStatus = 'edit';
var condition = '';
if (parentWin) {
var ret = parentWin.OprationSwap();
this.OpStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
this.ClintType = ret[3];
// this.parentfunction = ret[3];
}
//alert(this.ClintType);
//Ext.getCmp("ClineName").setText("往来单位:" + this.editRecord.get('codename'));
//SetTitle(this.editRecord.get('name') + "_商品信息");
document.title = this.editRecord.get('name') + "_商品信息";
condition = " CLIENTGID='" + this.editRecord.get('gid') + "'";
this.LoadData(this.OpStatus, condition);
}, //end InitData
//载入数据
LoadData: function (OpStatus, condition) {
if (COMPANYID == "" || DEPTGID == "") {
alert("登录信息不全,请退出重新登录");
return;
}
this.OpStatus = OpStatus;
if (this.OpStatus == 'edit') {
//this.formEdit.getForm().findField('BXGID').setDisabled(false);
//var BXGID = this.editRecord.get('BXGID');
this.storeFactoryNo.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: condition },
waitMsg: "正在查询数据...",
scope: this
});
this.storeCargoName.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: condition },
waitMsg: "正在查询数据...",
scope: this
});
}
}, // end LoadDate
Save: function (type) {
if (COMPANYID == "" || DEPTGID == "") {
alert("登录信息不全,请退出重新登录");
return;
}
var FactoryNoDatas = [];
for (var i = 0; i < this.storeFactoryNo.getCount(); i += 1) {
var member = this.storeFactoryNo.getAt(i);
FactoryNoDatas.push(member);
}
var FactoryNoBody = ConvertRecordsToJson(FactoryNoDatas);
var FactoryNoDelBody = ConvertRecordsToJsonAll(this.FactoryNoDel);
var CargoNameDatas = [];
for (var i = 0; i < this.storeCargoName.getCount(); i += 1) {
var member = this.storeCargoName.getAt(i);
CargoNameDatas.push(member);
}
var CargoNameBody = ConvertRecordsToJson(CargoNameDatas);
var CargoNameDelBody = ConvertRecordsToJsonAll(this.CargoNameDel);
if (FactoryNoBody == "" && FactoryNoDelBody == "" && CargoNameBody == "" && CargoNameDelBody == "") {
return;
}
var _this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/CargoName/Save',
scope: this,
async: false,
params: {
CLIENTGID: this.editRecord.get('gid'),
FactoryNobody: FactoryNoBody,
FactoryNoDelbody: FactoryNoDelBody,
CargoNameBody: CargoNameBody,
CargoNameDelbody: CargoNameDelBody
},
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') {
}
else if (this.OpStatus == 'edit') {
}
this.storeFactoryNo.commitChanges();
this.storeCargoName.commitChanges();
if (type == '0') {
} else if (type == '1') {//保存并关闭
window.close();
}
} 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
onExportClick: function (button, event) {
GridExportExcelPage(this.formFeeBody);
},
onGetGoodCode: function (button, event) {//初始化库存,
//var data = this.formEdit.getForm().getValues();
var CLIENTGID = this.editRecord.get('gid');
Ext.Ajax.request({//
waitMsg: '正在引入商品信息...',
url: '/Import/CargoName/GetGoodCode',
params: {
CLIENTGID: CLIENTGID
},
callback: function (_count) {
this.storeCargoName.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: " CLIENTGID='" + CLIENTGID + "'" },
waitMsg: "正在查询数据...",
scope: this
});
},
scope: this
}); //request over
}
});