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/TruckMng/Viewsjs/MsWl_LK_CargoInfo/MsWl_LK_CargoInfoIndex.js

671 lines
22 KiB
JavaScript

2 years ago
//集运管理-路单查询
Ext.namespace('DsTruck');
DsTruck.MsWl_LK_CargoInfoIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.MsWl_LK_CargoInfoIndex.superclass.constructor.call(this);
};
//201403060002
//13号
Ext.extend(DsTruck.MsWl_LK_CargoInfoIndex, Ext.Panel, {
PageSize: 500,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
this.bodyDel = [];
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
idProperty: 'GID',
model: 'MsWl_LK_CargoInfomb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/TruckMng/MsWl_LK_CargoInfo/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.formname = "MsWl_LK_CargoInfo";
this.storeParent = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsWl_LK_CargoInfomb',
proxy: { url: '/TruckMng/MsWl_LK_CargoInfo/GetDataList' }
,
listeners: {
load: function (store, records, successful, operation) {
if (successful) {
var ins_rec = Ext.create('MsWl_LK_CargoInfomb', {
GID: '',
CARGONAME: ''
});
store.insert(0, ins_rec);
}
}
}
});
this.storeParent.load({
params: { start: 0, limit: 500, condition: " CARGOTYPE='空桶' " }
});
this.comboxParent = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '车牌号',
store: this.storeParent,
name: 'PARENT_GID',
valueField: 'GID',
displayField: 'CARGONAME',
listeners: {
change: function (field, newValue, oldValue) {
//this.tonAndTruckNoChange(field, newValue, oldValue);
},
scope: this
}
});
this.storeParent2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsWl_LK_CargoInfomb',
proxy: { url: '/TruckMng/MsWl_LK_CargoInfo/GetDataList' }
,
listeners: {
load: function (store, records, successful, operation) {
if (successful) {
var ins_rec = Ext.create('MsWl_LK_CargoInfomb', {
GID: '',
CARGONAME: ''
});
store.insert(0, ins_rec);
}
}
}
});
this.storeParent2.load({
params: { start: 0, limit: 500, condition: " CARGOTYPE='空桶' " }
});
this.comboxParent2 = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '车牌号',
store: this.storeParent2,
name: 'PARENT_GID',
valueField: 'GID',
displayField: 'CARGONAME',
listeners: {
change: function (field, newValue, oldValue) {
//this.tonAndTruckNoChange(field, newValue, oldValue);
},
scope: this
}
});
Ext.define('AREAmb', {
extend: 'Ext.data.Model',
fields: [
{ name: 'AREA', type: 'string' }
]
});
var AREAData = [
{ "AREA": "" },
{ "AREA": "市内" },
{ "AREA": "周边" }
];
this.storeAREA = Ext.create('Ext.data.Store', {
model: 'AREAmb',
data: AREAData
});
this.comboxAREA = Ext.create('DsExt.ux.RefEnumCombox', {
//fieldLabel: '收付类型',
forceSelection: true,
store: this.storeAREA,
name: 'AREA',
valueField: 'AREA',
displayField: 'AREA'
});
this.column = [
{
sortable: true,
dataIndex: 'GID', hidden: true,
header: 'GID',
width: 80
},
{
sortable: true,
dataIndex: 'PARENT_GID',
header: '对应空桶(市内)',
width: 80,
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.PARENT_NAME;
},
editor: this.comboxParent
}, {
sortable: true,
dataIndex: 'PARENT_NAME', hidden: true,
header: 'PARENT_NAME',
width: 80
},
{
sortable: true,
dataIndex: 'PARENT_GID2',
header: '对应空桶(周边)',
width: 80,
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.PARENT_NAME2;
},
editor: this.comboxParent2
}, {
sortable: true,
dataIndex: 'PARENT_NAME2', hidden: true,
header: 'PARENT_NAME2',
width: 80
},
{
sortable: true,
dataIndex: 'CARGOTYPE',
header: '商品种类',
width: 80,
editor: { xtype: 'textfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'CARGONAME',
header: '商品名称',
width: 80,
editor: { xtype: 'textfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'AREA',
header: '所属区域(市内/周边)',
width: 80,
editor: this.comboxAREA
},
{
sortable: true,
dataIndex: 'SPECIFICATION',
header: '规格',
width: 80,
editor: { xtype: 'textfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'WEIGHT',
header: '单件重量',
width: 60,
editor: { xtype: 'numberfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'BOXCOUNT',
header: '每托数量',
tooltip: '每托盘有多少桶',
width: 80,
editor: { xtype: 'numberfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'STARTDATE',
header: '期初日期',
width: 120,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
xtype: 'datefield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'STARTNUM',
header: '期初数量',
width: 80,
editor: { xtype: 'numberfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'Remain',
header: '剩余库存',
width: 80
},
{
sortable: true,
dataIndex: 'Remark',
header: '备注',
width: 150,
editor: { xtype: 'textfield',
selectOnFocus: true
}
}, {
sortable: true,
dataIndex: 'INSERTED', hidden: true,
header: 'INSERTED',
width: 80
}];
this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.ProjectCBModel = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 50
});
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
trackResetOnLoad: true,
//height: 160,
title: '商品信息明细',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditing],
stateful: false,
selModel: this.ProjectCBModel,
selType: 'cellmodel',
columns: [new Ext.grid.RowNumberer()],
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
/////////////以下部分为获取存储的gridpanel显示样式
this.column = DsTruck.GetGridPanel(USERID, this.formname, this.column, 1);
//使用者id表名 中间column数组跳过一开始的几列
this.gridList.reconfigure(this.storeList, this.column);
this.gridList.columns[0] = new Ext.grid.RowNumberer();
////////////////////////////
//#region formSearch
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '商品名称',
name: 'CARGONAME', flex: 1
}, {
fieldLabel: '商品类型',
name: 'CARGOTYPE', flex: 1
}, {
xtype: 'hiddenfield', flex: 2
}
]
}
]//end items(fieldset 1)
}, //end fieldset 1
{//fieldset 2
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: []
}
]//end items(fieldset 2)
}//end fieldset 2
, {//fieldset 2
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: []
}]//end items(fieldset 2)
}//end fieldset 2
]//end root items
});
//查询工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
},
{
text: "导出Excel",
id: "btnExportExcel",
iconCls: 'btnexportexcel',
handler: function (button, event) {
this.onExportClick(button, event);
},
scope: this
},
{
text: "保存列表样式",
id: "btntest",
handler: function (button, event) {
this.column = DsTruck.SaveGridPanel(USERID, this.formname, this.gridList.columns, this.column, 1, true);
//alert(this.column[0].id);
},
scope: this
}, '-', {
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddProjectClick(button, event);
},
scope: this
}, {
text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelProjectClick(button, event);
},
scope: this
}, {
id: "btnSave",
text: '保存更改',
tooltip: '保存更改',
iconCls: "btnsave",
handler: function (button, event) {
this.Save();
//alert(USERID);
},
scope: this
}, '-'
]
});
//#endregion
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 100,
items: [this.formSearch, this.panelBtn]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList]
});
this.storeList.on('beforeload', function (store) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.gridList.on('edit', function (editor, e, eOpts) {
this.CargoInfoAfterEdit(editor, e, eOpts);
}, this);
this.onRefreshClick();
}, //end initUIComponents
CargoInfoAfterEdit: function (editor, e, eOpts) {
if (e.field == 'PARENT_GID') {
var records = DsStoreQueryBy(this.storeParent, 'GID', e.value);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
e.record.set('PARENT_NAME', data.CARGONAME);
} else {
e.record.set('PARENT_NAME', '');
}
}
if (e.field == 'PARENT_GID2') {
var records = DsStoreQueryBy(this.storeParent, 'GID', e.value);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
e.record.set('PARENT_NAME2', data.CARGONAME);
} else {
e.record.set('PARENT_NAME2', '');
}
}
},
onAddProjectClick: function (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 record = Ext.create('MsWl_LK_CargoInfomb', {
'GID': newID(),
'PARENT_GID': '',
'PARENT_NAME': '',
'CARGOTYPE': '',
'CARGONAME': '',
'SPECIFICATION': '',
'WEIGHT': '0',
'BOXCOUNT': '0',
'BOXWEIGHT': '0',
'STARTDATE': '',
'STARTNUM': '0',
'Remark': '',
'INSERTED': '',
'Remain': '0'
});
this.storeList.add(record);
var n = this.storeList.getCount();
this.cellEditing.startEditByPosition({ row: n - 1, column: 3 });
},
onDelProjectClick: function (button, event) {
var selectedRecords = this.gridList.selModel.getSelection();
Ext.MessageBox.confirm('提示', '确定删除记录吗?', function (btn) {
if (btn == 'yes') {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.INSERTED != "") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.bodyDel.push(rec);
}
this.storeList.remove(selectedRecords[i]);
}
}
}, this);
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
return ret;
},
onRefreshClick: function (button, event) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: this.PageSize, condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
this.bodyDel = [];
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
var CARGONAME = form.findField('CARGONAME').getValue();
sql = sql + getAndConSql(sql, CARGONAME, "CARGONAME like '%" + CARGONAME + "%'");
var CARGOTYPE = form.findField('CARGOTYPE').getValue();
sql = sql + getAndConSql(sql, CARGOTYPE, "CARGOTYPE like '%" + CARGOTYPE + "%'");
return sql;
},
checkSearchCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return false;
}
return true;
},
onExportClick: function (button, event) {
GridExportExcelPage(this.gridList);
},
getStrValue: function (list) {
var _list = [];
for (var _i = 0; _i < list.length; _i++) {
_list.push("'" + list[_i] + "'");
}
return _list;
},
Save: function (type) {
//费用
var bodyList = [];
for (i = 0; i < this.storeList.getCount(); i += 1) {
var member = this.storeList.getAt(i);
bodyList.push(member);
var CARGOTYPE = member.data.CARGOTYPE;
var CARGONAME = member.data.CARGONAME;
if (CARGOTYPE == '' || CARGONAME == '') {
Ext.Msg.show({ title: '警告',
msg: '商品名称和类别均不允许为空,请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
var repeat = 0;
for (j = 0; j < this.storeList.getCount(); j += 1) {
var _c = this.storeList.getAt(j);
if (_c.data.CARGOTYPE == member.data.CARGOTYPE && _c.data.CARGONAME == member.data.CARGONAME) {
repeat++;
}
if (repeat > 2) {
alert("不能商品名称和类型同时重复");
return;
}
}
};
var jsonBody = ConvertRecordsToJson(bodyList);
var jsonDelBody = ConvertRecordsToJsonAll(this.bodyDel);
if (jsonBody == '' && jsonDelBody == '') {
return;
}
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/TruckMng/MsWl_LK_CargoInfo/Save',
scope: this,
params: {
Body: jsonBody,
DelBody: jsonDelBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//alert("保存成功");
var returnData = jsonresult.Data;
this.storeList.commitChanges();
} 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');
}
});
}
});