You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

206 lines
5.9 KiB

4 years ago
define(function (require, exports, module) {
let Window = require('system/views/pages/window');
let tpl = require('text!./addwindow.tpl');
//let DataSource = require('system/base/datasource');
function BatchPdWindow(args) {
this.options = {
title: '批量选择配送客户',
content: tpl,
width: 800,
height: 536,
modal: true,
closed: true,
closable: true,
minimizable: false,
maximizable: false,
collapsible: false,
resizable: false,
data: null
}
this.args = args;
Window.call(this, this.options);
let uiObjCode = this.args.uiObjCode;
this.dsMaster = new DataSource({
funcCode: this.args.funcCode,
funcObjCode: uiObjCode,
isMultiPage: '0'
});
this.dsMaster.setServerBiz(args.serverBiz)
_.extend(this.dsMaster.fixQuery, args.fixQuery);
}
inherits(BatchPdWindow, Window);
BatchPdWindow.prototype.init = function () {
let self = this;
let mainGrid = {
opts: {
editable: false,
pageSize: 5000,
enablePager: self.args.enablePager || false,
showCheckColumn: true
},
data: this.dsMaster,
actions: {
onDblClick: function (e, args) {
}
}
}
let mainToolBar = {
opts: {},
data: [{
opCode: 'close',
caption: '关闭',
parentOp: '',
opClass: 'close'
}, {
opCode: 'save',
caption: '保存',
parentOp: '',
opClass: 'save'
}, {
opCode: 'refresh',
caption: '刷新',
parentOp: '',
opClass: 'refresh'
}, {
opCode: 'selectAll',
caption: '全选',
parentOp: '',
opClass: 'selectAll'
}, {
opCode: 'unselectAll',
caption: '全不选',
parentOp: '',
opClass: 'unselectAll'
}, {
opCode: 'inverseSelect',
caption: '反选',
parentOp: '',
opClass: 'inverseSelect'
}],
actions: {
click: function (opCode) {
self.doOp(opCode);
}
}
};
this.register('grid', 'grid_main', mainGrid);
this.register('toolbar', 'toolbar_main', mainToolBar);
};
BatchPdWindow.prototype.doOp = function (opCode) {
switch (opCode) {
case 'save':
this.save();
break;
case 'close':
this.close();
break;
case 'refresh':
this.refresh();
break;
case 'selectAll':
this.selectAll()
break;
case 'unselectAll':
this.unselectAll()
break
case 'inverseSelect':
this.inverseSelect()
break
}
};
BatchPdWindow.prototype.selectAll = function () {
this.dsMaster.rows.forEach(r => {
r['$is_sel'] = true
})
this.vm.grid_main.updateSelection()
}
BatchPdWindow.prototype.unselectAll = function () {
this.dsMaster.rows.forEach(r => {
r['$is_sel'] = false
})
this.vm.grid_main.updateSelection()
}
BatchPdWindow.prototype.inverseSelect = function () {
this.dsMaster.rows.forEach(r => {
r['$is_sel'] = !r['$is_sel']
})
this.vm.grid_main.updateSelection()
}
BatchPdWindow.prototype.save = function () {
let self = this
let sPsCycleCode = self.$storeType.textbox('getValue');
if (sPsCycleCode.length > 0 ){
sPsCycleCode = sPsCycleCode.toUpperCase();
if (!((sPsCycleCode == "DH") || (sPsCycleCode == "SH") || (sPsCycleCode == "DSH")
|| ((sPsCycleCode.length == 2) && (sPsCycleCode >= "W0") && (sPsCycleCode <= "W6"))
|| ((sPsCycleCode.length == 3) && (sPsCycleCode >= "D01") && (sPsCycleCode <= "D31")))){
Store.messager.err("配送周期码非法,请参照说明设置。");
return false;
}
}
else{
Store.messager.err("请填写配送周期码。");
return false;
}
if (self.args.callback) {
self.args.callback(self.dsMaster.getSelectedRows(),sPsCycleCode)
}
}
BatchPdWindow.prototype.refresh = function () {
let self = this;
//表参照专用,表参照相关约束
this.dsMaster.state = {
storeType: self.$storeType.textbox('getValue'),
}
this.dsMaster.search();
};
BatchPdWindow.prototype.customerize = function ($container) {
if (this.args.autoRefresh) {
this.refresh();
}
this.$storeType = this.getElement('.store-type')
};
BatchPdWindow.prototype.open = function () {
let self = this;
let code = this.dsMaster.uiObjCode;
let post_data = {
funcCode: self.args.biz.getFuncCode(),
uiObjCodes: code
}
Store.services.getUiObjSchema(post_data, function (isOk, data) {
if (isOk) {
self.dsMaster.initUIObj(data[code]);
self.dsMaster.isShowSelCol = true
self.dsMaster.funcCode = self.args.biz.getFuncCode();
Window.prototype.open.call(self);
}
});
};
return BatchPdWindow;
}
);