|
|
Ext.namespace('DsTruck');
|
|
|
|
|
|
DsTruck.MsKfLyEdit = function (config) {
|
|
|
Ext.applyIf(this, config);
|
|
|
this.initUIComponents();
|
|
|
window.DsTruck.MsKfLyEdit.superclass.constructor.call(this);
|
|
|
};
|
|
|
|
|
|
Ext.extend(DsTruck.MsKfLyEdit, Ext.Panel, {
|
|
|
|
|
|
ParentWin: null,
|
|
|
OpStatus: 'add',
|
|
|
StoreList: null,
|
|
|
EditRecord: null,
|
|
|
|
|
|
initUIComponents: function () {
|
|
|
this.serialNo = 0;
|
|
|
this.bodyDel = [];
|
|
|
|
|
|
//#region 编辑form
|
|
|
|
|
|
//枚举参照相关(编辑form)
|
|
|
|
|
|
|
|
|
//表参照相关(编辑form)
|
|
|
|
|
|
this.storeLyrCode = Ext.create('DsExt.ux.RefTableStore', {
|
|
|
model: 'DsTruckMng.ux.UserRefModel',
|
|
|
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
|
|
|
});
|
|
|
this.storeLyrCode.load({ params: { condition: ""} });
|
|
|
|
|
|
this.comboxLyrCode = Ext.create('DsExt.ux.RefTableCombox', {
|
|
|
fieldLabel: '领用人',
|
|
|
store: this.storeLyrCode,
|
|
|
name: 'LyrCode',
|
|
|
valueField: 'UserCode',
|
|
|
displayField: 'CodeAndName'
|
|
|
});
|
|
|
|
|
|
this.storeTruckNo = Ext.create('DsExt.ux.RefTableStore', {
|
|
|
model: 'MsKfLyHeadRefMsWlTruck',
|
|
|
proxy: { url: '/TruckMng/MsKfLy/GetTruckNoList' }
|
|
|
});
|
|
|
this.storeTruckNo.load({ params: { condition: ""} });
|
|
|
|
|
|
this.comboxTruckNo = Ext.create('DsExt.ux.RefTableCombox', {
|
|
|
fieldLabel: '车牌号',
|
|
|
store: this.storeTruckNo,
|
|
|
name: 'TruckNo',
|
|
|
valueField: 'TruckNo',
|
|
|
displayField: 'TruckSpec'
|
|
|
});
|
|
|
|
|
|
|
|
|
//编辑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: '录入日期',
|
|
|
name: 'LrDate', flex: 0, hidden: true, margins: '0'
|
|
|
}, {
|
|
|
fieldLabel: '记账日期',
|
|
|
name: 'JzDate', flex: 0, hidden: true, margins: '0'
|
|
|
}, {
|
|
|
fieldLabel: '用户',
|
|
|
name: 'UserCode', flex: 0, hidden: true, margins: '0'
|
|
|
}, {
|
|
|
fieldLabel: '用户姓名',
|
|
|
name: 'UserName', flex: 0, hidden: true, margins: '0'
|
|
|
}, {
|
|
|
fieldLabel: '时间戳',
|
|
|
name: 'TimeMark', flex: 0, hidden: true, margins: '0'
|
|
|
}, {
|
|
|
fieldLabel: '单据类型',
|
|
|
name: 'BillType', flex: 0, hidden: true, margins: '0'
|
|
|
}, {
|
|
|
fieldLabel: '组织',
|
|
|
name: 'OrgCode', flex: 0, hidden: true, margins: '0'
|
|
|
}, {
|
|
|
fieldLabel: '组织名称',
|
|
|
name: 'OrgName', flex: 0, hidden: true, margins: '0'
|
|
|
}, {
|
|
|
fieldLabel: '仓库',
|
|
|
name: 'CkCode', flex: 0, hidden: true, margins: '0'
|
|
|
}, {
|
|
|
fieldLabel: '仓库名称',
|
|
|
name: 'CkName', flex: 0, hidden: true, margins: '0'
|
|
|
}, {
|
|
|
fieldLabel: '领用人姓名',
|
|
|
name: 'LyrName', flex: 0, hidden: true, margins: '0'
|
|
|
}, {
|
|
|
fieldLabel: '领用数量',
|
|
|
name: 'LyCount', flex: 0, hidden: true, margins: '0'
|
|
|
}, {
|
|
|
fieldLabel: '配件类型',
|
|
|
name: 'PluType', flex: 0, hidden: true, margins: '0'
|
|
|
}, {
|
|
|
fieldLabel: '维修单号',
|
|
|
name: 'WxBillNo', flex: 0, hidden: true, margins: '0'
|
|
|
}, {
|
|
|
fieldLabel: '单据号',
|
|
|
allowBlank: false,
|
|
|
disabled: true,
|
|
|
name: 'BillNo'
|
|
|
}, {
|
|
|
fieldLabel: '领用日期',
|
|
|
format: 'Y-m-d',
|
|
|
xtype: 'datefield',
|
|
|
name: 'LyDate'
|
|
|
}, this.comboxLyrCode
|
|
|
]
|
|
|
}, {
|
|
|
xtype: 'container',
|
|
|
layout: 'hbox',
|
|
|
defaultType: 'textfield',
|
|
|
items: [this.comboxTruckNo, {
|
|
|
fieldLabel: '备注',
|
|
|
name: 'Remark'
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
]//end items(fieldset 1)
|
|
|
}//end fieldset 1
|
|
|
]//end root items
|
|
|
}); //end this.formEdit
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
//#region 按钮Toolbar
|
|
|
this.panelBtn = new Ext.Panel({
|
|
|
region: "north",
|
|
|
tbar: [
|
|
|
{
|
|
|
id: 'btnESave',
|
|
|
text: "保存",
|
|
|
iconCls: "btnsave",
|
|
|
handler: function (button, event) {
|
|
|
this.Save('0');
|
|
|
},
|
|
|
scope: this
|
|
|
},
|
|
|
{
|
|
|
id: 'btnESaveAndClose',
|
|
|
text: "保存并关闭",
|
|
|
handler: function (button, event) {
|
|
|
this.Save('1');
|
|
|
},
|
|
|
scope: this
|
|
|
},
|
|
|
|
|
|
{
|
|
|
id: 'btnESaveAndNew',
|
|
|
text: "保存并新建",
|
|
|
handler: function (button, event) {
|
|
|
this.Save('2');
|
|
|
},
|
|
|
scope: this
|
|
|
},
|
|
|
'-',
|
|
|
{
|
|
|
text: "关闭",
|
|
|
handler: function (button, event) {
|
|
|
window.close();
|
|
|
},
|
|
|
scope: this
|
|
|
},
|
|
|
{
|
|
|
text: "新建",
|
|
|
handler: function (button, event) {
|
|
|
this.LoadData('add', '');
|
|
|
var basicForm = this.formEdit.getForm();
|
|
|
basicForm.findField('BillNo').setDisabled(false);
|
|
|
},
|
|
|
scope: this
|
|
|
},
|
|
|
'-',
|
|
|
{
|
|
|
id: 'btnEAccount',
|
|
|
text: "记账",
|
|
|
handler: function (button, event) {
|
|
|
this.onAccountClick(button, event);
|
|
|
},
|
|
|
scope: this
|
|
|
},
|
|
|
'-',
|
|
|
{
|
|
|
text: "打印",
|
|
|
iconCls: "btnprint",
|
|
|
handler: function (button, event) {
|
|
|
this.Print();
|
|
|
},
|
|
|
scope: this
|
|
|
}
|
|
|
]
|
|
|
}); //end 按钮Toolbar
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
//#region 明细表
|
|
|
|
|
|
//明细表表格相关
|
|
|
this.storeTyreTypeRef = Ext.create('DsExt.ux.RefEnumStore', {});
|
|
|
this.storeTyreTypeRef.load({ params: { enumTypeId: 99013} });
|
|
|
|
|
|
this.comboxTyreTypeRef = Ext.create('DsExt.ux.RefEnumCombox', {
|
|
|
store: this.storeTyreTypeRef,
|
|
|
name: 'TyreType'
|
|
|
});
|
|
|
|
|
|
this.storeTyrePosRef = Ext.create('DsExt.ux.RefEnumStore', {});
|
|
|
this.storeTyrePosRef.load({ params: { enumTypeId: 99015} });
|
|
|
|
|
|
this.comboxTyrePosRef = Ext.create('DsExt.ux.RefEnumCombox', {
|
|
|
store: this.storeTyrePosRef,
|
|
|
name: 'TyrePos'
|
|
|
});
|
|
|
|
|
|
|
|
|
this.storePluCodeRef = Ext.create('DsExt.ux.RefTableStore', {
|
|
|
model: 'DsTruckMng.ux.PluRefModel',
|
|
|
proxy: { url: '/CommMng/BasicDataRef/GetPluRefList' }
|
|
|
});
|
|
|
this.storePluCodeRef.load({ params: { condition: ""} });
|
|
|
|
|
|
this.comboxPluCodeRef = Ext.create('DsExt.ux.RefTableCombox', {
|
|
|
store: this.storePluCodeRef,
|
|
|
name: 'PluCode',
|
|
|
valueField: 'PluCode',
|
|
|
displayField: 'CodeAndName'
|
|
|
});
|
|
|
|
|
|
this.storeJhinfo = Ext.create('DsExt.ux.RefTableStore', {
|
|
|
model: 'MsKflyJhinfo',
|
|
|
proxy: { url: '/TruckMng/MsKfJh/GetBodyInfoList' }
|
|
|
});
|
|
|
// this.storeJhinfo.load({ params: { condition: ""} });
|
|
|
|
|
|
//明细表-数据集
|
|
|
this.storeBodyList = Ext.create('Ext.data.Store', {
|
|
|
model: 'MsKfLyBody',
|
|
|
remoteSort: true,
|
|
|
proxy: {
|
|
|
type: 'ajax',
|
|
|
url: '/TruckMng/MsKfLy/GetBodyList',
|
|
|
reader: {
|
|
|
id: 'BillNo,SerialNo',
|
|
|
root: 'data',
|
|
|
totalProperty: 'totalCount'
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//明细表表格
|
|
|
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
|
|
|
clicksToEdit: 1
|
|
|
});
|
|
|
|
|
|
this.gridList = new Ext.grid.GridPanel({
|
|
|
store: this.storeBodyList,
|
|
|
enableHdMenu: false,
|
|
|
region: 'center',
|
|
|
loadMask: { msg: "数据加载中,请稍等..." },
|
|
|
trackMouseOver: true,
|
|
|
disableSelection: false,
|
|
|
plugins: [this.gridListCellEditing],
|
|
|
selType: 'cellmodel',
|
|
|
tbar: [{
|
|
|
text: '增加明细',
|
|
|
tooltip: '增加明细',
|
|
|
iconCls: "btnadddetail",
|
|
|
handler: function (button, event) {
|
|
|
this.onAddDetailClick(button, event);
|
|
|
},
|
|
|
scope: this
|
|
|
}, '-', {
|
|
|
text: '删除明细',
|
|
|
tooltip: '删除明细',
|
|
|
iconCls: "btndeletedetail",
|
|
|
handler: function (button, event) {
|
|
|
this.onDelDetailClick(button, event);
|
|
|
},
|
|
|
scope: this
|
|
|
}],
|
|
|
columns: [{
|
|
|
sortable: true,
|
|
|
dataIndex: 'BillNo',
|
|
|
header: '单据号',
|
|
|
hidden: true,
|
|
|
width: 120
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'SerialNo',
|
|
|
header: '录入序号',
|
|
|
width: 100
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'PcNo',
|
|
|
header: '轮胎串号',
|
|
|
editor: {
|
|
|
xtype: 'textfield',
|
|
|
selectOnFocus: true
|
|
|
},
|
|
|
width: 120
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'PluCode',
|
|
|
header: '轮胎编码',
|
|
|
renderer: function (value, p, record) {
|
|
|
if (value == null || value == '')
|
|
|
return '';
|
|
|
else
|
|
|
return value + '-' + record.data.PluCode_Ref;
|
|
|
},
|
|
|
// editor: this.comboxPluCodeRef,
|
|
|
width: 120
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'PluName',
|
|
|
header: '轮胎名称',
|
|
|
width: 160
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'Spec',
|
|
|
header: '规格',
|
|
|
width: 160
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'TyreType',
|
|
|
header: '轮胎类型',
|
|
|
renderer: function (value, p, record) {
|
|
|
if (value == null || value == '')
|
|
|
return '';
|
|
|
else
|
|
|
return value + '-' + record.data.TyreType_Ref;
|
|
|
},
|
|
|
// editor: this.comboxTyreTypeRef,
|
|
|
width: 80
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'TyrePos',
|
|
|
header: '轮胎位置',
|
|
|
renderer: function (value, p, record) {
|
|
|
if (value == null || value == '')
|
|
|
return '';
|
|
|
else
|
|
|
return value + '-' + record.data.TyrePos_Ref;
|
|
|
},
|
|
|
editor: this.comboxTyrePosRef,
|
|
|
width: 80
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'Unit',
|
|
|
header: '单位',
|
|
|
editor: {
|
|
|
xtype: 'textfield',
|
|
|
selectOnFocus: true
|
|
|
},
|
|
|
width: 80
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'Price',
|
|
|
header: '单价',
|
|
|
//hidden: true,
|
|
|
// editor: {
|
|
|
// xtype: 'numberfield',
|
|
|
// allowBlank: false,
|
|
|
// selectOnFocus: true
|
|
|
// },
|
|
|
width: 100
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'LyCount',
|
|
|
header: '领用数量',
|
|
|
width: 100
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'PlanMil',
|
|
|
header: '计划里程',
|
|
|
editor: {
|
|
|
xtype: 'numberfield',
|
|
|
allowBlank: false,
|
|
|
selectOnFocus: true
|
|
|
}, width: 100
|
|
|
},
|
|
|
{
|
|
|
sortable: true,
|
|
|
dataIndex: 'Remark',
|
|
|
header: '备注',
|
|
|
editor: {
|
|
|
xtype: 'textfield',
|
|
|
selectOnFocus: true
|
|
|
},
|
|
|
width: 200
|
|
|
}
|
|
|
]
|
|
|
});
|
|
|
|
|
|
//#endregion 明细表
|
|
|
|
|
|
//#region 布局
|
|
|
//控件布局
|
|
|
this.panelTop = new Ext.Panel({
|
|
|
layout: "border",
|
|
|
region: "north",
|
|
|
height: 115,
|
|
|
items: [this.panelBtn, this.formEdit]
|
|
|
});
|
|
|
|
|
|
Ext.apply(this, {
|
|
|
items: [this.panelTop, this.gridList]
|
|
|
});
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
//绑定查询窗体
|
|
|
this.ParentWin = window.parent.opener;
|
|
|
|
|
|
//初始化数据
|
|
|
this.InitData();
|
|
|
|
|
|
//绑定事件
|
|
|
this.gridList.on('edit', function (editor, e, eOpts) {
|
|
|
this.gridAfterEdit(editor, e, eOpts);
|
|
|
}, 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 = " BillNo='" + this.editRecord.get('BillNo') + "'";
|
|
|
|
|
|
this.LoadData(this.opStatus, condition);
|
|
|
|
|
|
}, //end InitData
|
|
|
|
|
|
LoadData: function (opstatus, condition) {
|
|
|
this.serialNo = 0;
|
|
|
this.bodyDel = [];
|
|
|
|
|
|
this.opStatus = opstatus;
|
|
|
Ext.Ajax.request({
|
|
|
waitMsg: '正在查询主表数据...',
|
|
|
url: '/TruckMng/MsKfLy/GetDataTyre',
|
|
|
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 data = result.data;
|
|
|
this.formEdit.getForm().reset();
|
|
|
this.formEdit.getForm().setValues(data);
|
|
|
|
|
|
if (data.JzDate == null || data.JzDate == '') {
|
|
|
this.setSaveBtnStatus(true);
|
|
|
} else {
|
|
|
this.setSaveBtnStatus(false);
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
|
|
|
}
|
|
|
},
|
|
|
scope: this
|
|
|
});
|
|
|
|
|
|
var billno = '*';
|
|
|
if (this.opStatus == 'edit') {
|
|
|
billno = this.editRecord.get('BillNo');
|
|
|
this.formEdit.getForm().findField('BillNo').setDisabled(false);
|
|
|
}
|
|
|
this.storeBodyList.load({ params: { billno: billno} });
|
|
|
}, // end LoadDate
|
|
|
|
|
|
|
|
|
Save: function (type) {
|
|
|
var basicForm = this.formEdit.getForm();
|
|
|
|
|
|
if (!basicForm.isValid()) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//判断表格数据是否合法
|
|
|
if (!validateEditorGridPanel(this.gridList)) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
basicForm.findField('BillNo').setDisabled(false);
|
|
|
var data = basicForm.getValues();
|
|
|
basicForm.findField('BillNo').setDisabled(true);
|
|
|
|
|
|
var bodydatas = [];
|
|
|
for (var i = 0; i < this.storeBodyList.getCount(); i += 1) {
|
|
|
var member = this.storeBodyList.getAt(i);
|
|
|
bodydatas.push(member);
|
|
|
}
|
|
|
|
|
|
var jsonBody = ConvertRecordsToJson(bodydatas);
|
|
|
var jsonDelBody = ConvertRecordsToJsonAll(this.bodyDel);
|
|
|
|
|
|
Ext.Msg.wait('正在保存数据, 请稍侯..');
|
|
|
Ext.Ajax.request({
|
|
|
waitMsg: '正在保存数据...',
|
|
|
url: '/TruckMng/MsKfLy/Save',
|
|
|
scope: this,
|
|
|
params: {
|
|
|
opstatus: this.opStatus,
|
|
|
data: Ext.JSON.encode(data),
|
|
|
body: jsonBody,
|
|
|
delbody: jsonDelBody
|
|
|
},
|
|
|
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('MsKfLyHead', 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('BillNo').setDisabled(true);
|
|
|
|
|
|
for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
|
|
|
var memberbody = this.storeBodyList.getAt(j);
|
|
|
memberbody.set("BillNo", this.editRecord.get('BillNo'));
|
|
|
memberbody.commit();
|
|
|
};
|
|
|
} else if (type == '1') {
|
|
|
window.close();
|
|
|
} else {
|
|
|
this.LoadData('add', '');
|
|
|
basicForm.findField('BillNo').setDisabled(false);
|
|
|
}
|
|
|
} 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
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}, //end save
|
|
|
|
|
|
onAddDetailClick: function (button, event) {
|
|
|
this.addDetail();
|
|
|
}, //end onAddDetailClick
|
|
|
|
|
|
onDelDetailClick: function (button, event) {
|
|
|
this.deleteDetail();
|
|
|
}, //onDelDetailClick
|
|
|
|
|
|
gridAfterEdit: function (editor, e, eOpts) {
|
|
|
//需要自己实现里面的事件
|
|
|
if (e.field == 'PluCode') {
|
|
|
|
|
|
// //判断配件库存是否>0
|
|
|
// var opStatus = 'edit';
|
|
|
var plucode = e.value;
|
|
|
// var basicForm = this.formEdit.getForm();
|
|
|
// var orgcode = basicForm.findField('OrgCode').getValue();
|
|
|
// var ckcode = basicForm.findField('CkCode').getValue();
|
|
|
// var condition = "OrgCode='" + orgcode + "' and CkCode='" + ckcode + "' and PluCode='" + plucode + "' and JxCount > 0";
|
|
|
// Ext.Ajax.request({
|
|
|
// waitMsg: '正在查询配件库存数据...',
|
|
|
// url: '/TruckMng/MsLsKc/GetData',
|
|
|
// async: false,
|
|
|
// 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 pluData = result.data;
|
|
|
// if (pluData == null || pluData.PluCode == '') {
|
|
|
// Ext.Msg.show({
|
|
|
// title: '提示',
|
|
|
// msg: '组织:' + orgcode + '配件:' + plucode + '库存数量为0!',
|
|
|
// icon: Ext.MessageBox.INFO,
|
|
|
// buttons: Ext.Msg.OK
|
|
|
// });
|
|
|
// e.record.set('PcNo', '');
|
|
|
// e.record.set('PluCode_Ref', '');
|
|
|
// e.record.set('PluName', '');
|
|
|
// e.record.set('Unit', '');
|
|
|
// e.record.set('Spec', '');
|
|
|
// e.record.set('LyCount', '1');
|
|
|
// }
|
|
|
|
|
|
// } else {
|
|
|
// Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
|
|
|
// }
|
|
|
// },
|
|
|
// scope: this
|
|
|
// });
|
|
|
|
|
|
var records = DsStoreQueryBy(this.storePluCodeRef, 'PluCode', plucode);
|
|
|
|
|
|
if (records.getCount() > 0) {
|
|
|
var data = records.getAt(0).data;
|
|
|
e.record.set('PluCode_Ref', data.PluName);
|
|
|
e.record.set('PluName', data.PluName);
|
|
|
e.record.set('Unit', data.Unit);
|
|
|
e.record.set('Spec', data.Spec);
|
|
|
e.record.set('LyCount', '1');
|
|
|
} else {
|
|
|
e.record.set('PluCode_Ref', '');
|
|
|
e.record.set('PluName', '');
|
|
|
e.record.set('Unit', '');
|
|
|
e.record.set('Spec', '');
|
|
|
e.record.set('LyCount', '1');
|
|
|
}
|
|
|
}
|
|
|
else if (e.field == 'PcNo') {
|
|
|
var opStatus = 'edit';
|
|
|
var pcno = e.value;
|
|
|
var condition = "PcNo='" + pcno + "'";
|
|
|
|
|
|
var basicForm = this.formEdit.getForm();
|
|
|
var orgcode = basicForm.findField('OrgCode').getValue();
|
|
|
var ckcode = basicForm.findField('CkCode').getValue();
|
|
|
var plucode = '';
|
|
|
|
|
|
//判断车辆轮胎信息中是否已经存在该串号
|
|
|
Ext.Ajax.request({
|
|
|
waitMsg: '正在查询车辆轮胎串号数据...',
|
|
|
url: '/TruckMng/MsWlTyre/GetData',
|
|
|
async: false,
|
|
|
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 pcData = result.data;
|
|
|
if (pcData != null && pcData.PcNo != '') {
|
|
|
Ext.Msg.show({
|
|
|
title: '提示',
|
|
|
msg: '车辆轮胎串号已经存在!',
|
|
|
icon: Ext.MessageBox.INFO,
|
|
|
buttons: Ext.Msg.OK
|
|
|
});
|
|
|
e.record.set('PcNo', '');
|
|
|
e.record.set('PluCode', '');
|
|
|
e.record.set('PluCode_Ref', '');
|
|
|
e.record.set('PluName', '');
|
|
|
e.record.set('Unit', '');
|
|
|
e.record.set('Spec', '');
|
|
|
e.record.set('LyCount', '1');
|
|
|
pcno = '';
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
|
|
|
}
|
|
|
},
|
|
|
scope: this
|
|
|
});
|
|
|
|
|
|
//从进货记录里获取价格
|
|
|
/*
|
|
|
this.storeJhinfo.load({ params: { condition: condition} });
|
|
|
|
|
|
var records = DsStoreQueryBy(this.storeJhinfo, 'PcNo', pcno);
|
|
|
|
|
|
if (records.getCount() > 0) {
|
|
|
var data = records.getAt(0).data;
|
|
|
e.record.set('Price', data.Price);
|
|
|
} else {
|
|
|
e.record.set('Price', '0');
|
|
|
}
|
|
|
*/
|
|
|
//////////////
|
|
|
|
|
|
if (pcno != null && pcno != '') {
|
|
|
Ext.Ajax.request({
|
|
|
waitMsg: '正在查询串号数据...',
|
|
|
url: '/TruckMng/MsJhSparepart/GetData',
|
|
|
async: false,
|
|
|
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
|
|
|
});
|
|
|
|
|
|
this.copyPcData(e, null);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
var pcData = result.data;
|
|
|
if (pcData == null || pcData.PcNo == '') {
|
|
|
Ext.Msg.show({
|
|
|
title: '提示',
|
|
|
msg: '无此轮胎串号!',
|
|
|
icon: Ext.MessageBox.INFO,
|
|
|
buttons: Ext.Msg.OK
|
|
|
});
|
|
|
e.record.set('PcNo', '');
|
|
|
}
|
|
|
plucode = pcData.PluCode;
|
|
|
this.copyPcData(e, pcData);
|
|
|
|
|
|
} else {
|
|
|
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
|
|
|
this.copyPcData(e, null);
|
|
|
}
|
|
|
},
|
|
|
scope: this
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
//改为检查配件连锁库存批次
|
|
|
if (plucode != null && plucode != '') {
|
|
|
|
|
|
var conditionplu = "OrgCode='" + orgcode + "' and CkCode='" + ckcode + "' and PluCode='"
|
|
|
+ plucode + "' and JhCount > 0 and PcNo='" + pcno + "'";
|
|
|
|
|
|
Ext.Ajax.request({
|
|
|
waitMsg: '正在查询配件库存数据...',
|
|
|
url: '/TruckMng/MsLsKcPc/GetData',
|
|
|
async: false,
|
|
|
params: {
|
|
|
handle: opStatus,
|
|
|
condition: conditionplu
|
|
|
},
|
|
|
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 pluData = result.data;
|
|
|
if (pluData == null || pluData.PluCode == '') {
|
|
|
Ext.Msg.show({
|
|
|
title: '提示',
|
|
|
msg: '组织:' + orgcode + '配件:' + plucode + '批次:' + pcno + '库存数量为0!',
|
|
|
icon: Ext.MessageBox.INFO,
|
|
|
buttons: Ext.Msg.OK
|
|
|
});
|
|
|
e.record.set('PcNo', '');
|
|
|
e.record.set('PluCode', '');
|
|
|
e.record.set('PluCode_Ref', '');
|
|
|
e.record.set('PluName', '');
|
|
|
e.record.set('Unit', '');
|
|
|
e.record.set('Spec', '');
|
|
|
e.record.set('LyCount', '1');
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
|
|
|
}
|
|
|
},
|
|
|
scope: this
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
Ext.Ajax.request({
|
|
|
waitMsg: '正在查询串号单价...',
|
|
|
url: '/TruckMng/MsKfJh/GetBodyInfoList',
|
|
|
async: false,
|
|
|
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
|
|
|
});
|
|
|
|
|
|
e.record.set('Price', '0');
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
var pPData = result.data;
|
|
|
this.copyPcPrice(e, pPData);
|
|
|
} else {
|
|
|
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
|
|
|
e.record.set('Price', '0');
|
|
|
}
|
|
|
},
|
|
|
scope: this
|
|
|
});
|
|
|
*/
|
|
|
|
|
|
|
|
|
}
|
|
|
else if (e.field == 'TyrePos') {
|
|
|
//判断该车辆每个车轴只能有一条轮胎
|
|
|
var opStatus = 'edit';
|
|
|
var tyrepos = e.value;
|
|
|
var basicForm = this.formEdit.getForm();
|
|
|
var truckNo = basicForm.findField('TruckNo').getValue();
|
|
|
var condition = "TruckNo='" + truckNo + "' and TyrePos='" + tyrepos + "'";
|
|
|
Ext.Ajax.request({
|
|
|
waitMsg: '正在查询车辆轮胎数据...',
|
|
|
url: '/TruckMng/MsWlTyre/GetData',
|
|
|
async: false,
|
|
|
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 pcData = result.data;
|
|
|
if (pcData != null && pcData.PcNo != '') {
|
|
|
Ext.Msg.show({
|
|
|
title: '提示',
|
|
|
msg: '车辆:' + truckNo + '该位置上已经存在轮胎!',
|
|
|
icon: Ext.MessageBox.INFO,
|
|
|
buttons: Ext.Msg.OK
|
|
|
});
|
|
|
e.record.set('TyrePos', '');
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
|
|
|
}
|
|
|
},
|
|
|
scope: this
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
|
|
|
copyPcData: function (e, pcData) {
|
|
|
if (pcData == null) {
|
|
|
e.record.set('PluCode', '');
|
|
|
e.record.set('PluCode_Ref', '');
|
|
|
e.record.set('PluName', '');
|
|
|
e.record.set('Unit', '');
|
|
|
e.record.set('Spec', '');
|
|
|
e.record.set('Price', '');
|
|
|
// e.record.set('TyreType', '*');
|
|
|
// e.record.set('TyreType_Ref', '*');
|
|
|
//e.record.set('TyrePos', data.Spec);
|
|
|
|
|
|
} else {
|
|
|
e.record.set('PluCode', pcData.PluCode);
|
|
|
e.record.set('PluCode_Ref', pcData.PluName);
|
|
|
e.record.set('PluName', pcData.PluName);
|
|
|
e.record.set('Unit', pcData.Unit);
|
|
|
e.record.set('Spec', pcData.Spec);
|
|
|
e.record.set('TyreType', pcData.TyreType);
|
|
|
e.record.set('TyreType_Ref', pcData.TyreType_Ref);
|
|
|
e.record.set('Price', pcData.FPrice);
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
copyPcPrice: function (e, pcData) {
|
|
|
if (pcData == null) {
|
|
|
e.record.set('Price', '');
|
|
|
} else {
|
|
|
e.record.set('Price', pcData.Price);
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
addDetail: function () {
|
|
|
var newSerialno = DsGetNewSerialNo(this.storeBodyList, this.serialNo);
|
|
|
this.serialNo = newSerialno;
|
|
|
|
|
|
var tyreType_Ref = "";
|
|
|
var records = DsStoreQueryBy(this.storeTyreTypeRef, 'EnumValueId', 0);
|
|
|
if (records.getCount() > 0) {
|
|
|
var data = records.getAt(0).data;
|
|
|
tyreType_Ref = data.EnumValueName;
|
|
|
}
|
|
|
var tyrePos_Ref = "";
|
|
|
var recordsPos = DsStoreQueryBy(this.storeTyrePosRef, 'EnumValueId', 0);
|
|
|
if (recordsPos.getCount() > 0) {
|
|
|
var data = recordsPos.getAt(0).data;
|
|
|
tyrePos_Ref = data.EnumValueName;
|
|
|
}
|
|
|
|
|
|
var record = Ext.create('MsKfLyBody', {
|
|
|
BillNo: '*',
|
|
|
SerialNo: newSerialno,
|
|
|
PluCode: '',
|
|
|
PluCode_Ref: '',
|
|
|
PluName: '',
|
|
|
Spec: '',
|
|
|
PcNo: '',
|
|
|
TyreType: "0",
|
|
|
TyreType_Ref: tyreType_Ref,
|
|
|
TyrePos: '',
|
|
|
TyrePos_Ref: tyrePos_Ref,
|
|
|
Unit: '',
|
|
|
Price: 0,
|
|
|
LyCount: 1,
|
|
|
Remark: ''
|
|
|
});
|
|
|
|
|
|
this.storeBodyList.add(record);
|
|
|
|
|
|
var n = this.storeBodyList.getCount();
|
|
|
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 2 });
|
|
|
},
|
|
|
|
|
|
deleteDetail: function () {
|
|
|
this.serialNo = DsGetCurSerialNo(this.storeBodyList, this.serialNo);
|
|
|
|
|
|
var selectedRecords = this.gridList.selModel.getSelection();
|
|
|
|
|
|
for (var i = 0; i < selectedRecords.length; i++) {
|
|
|
var rec = selectedRecords[i];
|
|
|
if (rec.BillNo != "" || rec.BillNo != "*") //如果是新增但没有保存的数据,没有必要提交到后台
|
|
|
{
|
|
|
this.bodyDel.push(rec);
|
|
|
}
|
|
|
|
|
|
this.storeBodyList.remove(selectedRecords[i]);
|
|
|
}
|
|
|
},
|
|
|
onAccountClick: function (button, event) {
|
|
|
Ext.MessageBox.confirm('提示', '记账后数据无法修改,确认记账吗?', function (btn) {
|
|
|
if (btn == 'yes') {
|
|
|
this.Account();
|
|
|
}
|
|
|
}, this);
|
|
|
},
|
|
|
|
|
|
Account: function () {
|
|
|
var basicForm = this.formEdit.getForm();
|
|
|
|
|
|
basicForm.findField('BillNo').setDisabled(false);
|
|
|
var headdata = basicForm.getValues();
|
|
|
basicForm.findField('BillNo').setDisabled(true);
|
|
|
|
|
|
Ext.MessageBox.wait("正在记账,请稍侯.");
|
|
|
Ext.Ajax.request({
|
|
|
waitMsg: '正在记账...',
|
|
|
scope: this,
|
|
|
url: '/CommMng/PubSys/Account',
|
|
|
params: {
|
|
|
billno: headdata.BillNo,
|
|
|
ywtype: '3'//headdata.YwType
|
|
|
},
|
|
|
callback: function (options, success, response) {
|
|
|
if (success) {
|
|
|
var jsonresult = Ext.JSON.decode(response.responseText);
|
|
|
if (jsonresult.Success) //成功
|
|
|
{
|
|
|
var returnData = jsonresult.Data;
|
|
|
this.formEdit.getForm().setValues(returnData);
|
|
|
|
|
|
var editp = Ext.create('MsKfLyHead', 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();
|
|
|
|
|
|
this.setSaveBtnStatus(false);
|
|
|
|
|
|
Ext.MessageBox.alert("提示", jsonresult.Message);
|
|
|
} else //记账失败失败
|
|
|
{
|
|
|
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
Ext.Msg.show({ title: '请重试', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
|
|
|
}
|
|
|
},
|
|
|
failure: function (response, options) {
|
|
|
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
|
|
|
}
|
|
|
}); //end Ext.Ajax.request
|
|
|
},
|
|
|
setSaveBtnStatus: function (enable) {
|
|
|
var btnESave = Ext.getCmp('btnESave');
|
|
|
var btnESaveAndClose = Ext.getCmp('btnESaveAndClose');
|
|
|
var btnESaveAndNew = Ext.getCmp('btnESaveAndNew');
|
|
|
var btnEbtnEAccount = Ext.getCmp('btnEAccount');
|
|
|
|
|
|
|
|
|
if (enable) {
|
|
|
btnESave.enable();
|
|
|
btnESaveAndClose.enable();
|
|
|
btnESaveAndNew.enable();
|
|
|
btnEbtnEAccount.enable();
|
|
|
} else {
|
|
|
btnESave.disable();
|
|
|
btnESaveAndClose.disable();
|
|
|
btnESaveAndNew.disable();
|
|
|
btnEbtnEAccount.disable();
|
|
|
}
|
|
|
},
|
|
|
Print: function () {
|
|
|
var basicForm = this.formEdit.getForm();
|
|
|
var billNo = basicForm.findField('BillNo').value;
|
|
|
if (billNo == '*' || billNo == '') {
|
|
|
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
var printType = 'MSKFLYTYRE';
|
|
|
var sql1 = "SET LANGUAGE 'us_english' SELECT * FROM tMsKfLyHead WHERE BillNo = '" + billNo + "'";
|
|
|
var sql2 = "SET LANGUAGE 'us_english' SELECT * FROM tMsKfLyBody WHERE BillNo = '" + billNo + "'"; ;
|
|
|
var sql3 = "";
|
|
|
var sql4 = "";
|
|
|
var sql5 = "";
|
|
|
var sql6 = "";
|
|
|
|
|
|
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|