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.
140 lines
3.7 KiB
140 lines
3.7 KiB
4 years ago
|
|
||
|
define(function (require, exports, module) {
|
||
|
let Window = require('system/views/pages/window');
|
||
|
let tpl = require('text!./ingredient-win.tpl');
|
||
|
require('css!./ingredient-win.css')
|
||
|
|
||
|
//let DataSource = require('system/base/datasource');
|
||
|
|
||
|
function IngredientWindow(args) {
|
||
|
this.options = {
|
||
|
title: '加工工艺原料替换',
|
||
|
content: tpl,
|
||
|
width: 1280,
|
||
|
height: 600,
|
||
|
modal: true,
|
||
|
closed: true,
|
||
|
closable: true,
|
||
|
minimizable: false,
|
||
|
maximizable: false,
|
||
|
collapsible: false,
|
||
|
resizable: false,
|
||
|
data: null
|
||
|
}
|
||
|
|
||
|
this.args = args;
|
||
|
this.headerData = args.headerData
|
||
|
this.dsBody = args.dataSource
|
||
|
|
||
|
Window.call(this, this.options);
|
||
|
}
|
||
|
|
||
|
inherits(IngredientWindow, Window);
|
||
|
|
||
|
IngredientWindow.prototype.init = function () {
|
||
|
let self = this;
|
||
|
let mainGrid = {
|
||
|
opts: {
|
||
|
editable: true,
|
||
|
pageSize: 0,
|
||
|
showDelColumn: true
|
||
|
},
|
||
|
data: this.dsBody,
|
||
|
actions: {
|
||
|
onColumndeleteButtonClick: function (row) {
|
||
|
Store.messager.confirm(Store.MSG.DELETE_CONFIRM, function (r) {
|
||
|
if (r) {
|
||
|
row.delete();
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
let mainToolBar = {
|
||
|
opts: {},
|
||
|
data: [
|
||
|
{
|
||
|
opCode: 'refresh',
|
||
|
caption: '重置',
|
||
|
parentOp: '',
|
||
|
opClass: 'refresh'
|
||
|
}, {
|
||
|
opCode: 'save',
|
||
|
caption: '保存',
|
||
|
parentOp: '',
|
||
|
opClass: 'save'
|
||
|
}, {
|
||
|
opCode: 'exit',
|
||
|
caption: '退出',
|
||
|
parentOp: '',
|
||
|
opClass: 'cancel'
|
||
|
}],
|
||
|
actions: {
|
||
|
click: function (opCode) {
|
||
|
self.doOp(opCode);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
this.register('grid', 'grid_main', mainGrid);
|
||
|
this.register('toolbar', 'toolbar_main', mainToolBar);
|
||
|
|
||
|
};
|
||
|
|
||
|
IngredientWindow.prototype.save = function () {
|
||
|
let self = this;
|
||
|
this.dsBody.save(function (isOk) {
|
||
|
if (isOk) {
|
||
|
self.close()
|
||
|
}
|
||
|
})
|
||
|
};
|
||
|
|
||
|
IngredientWindow.prototype.doOp = function (opCode) {
|
||
|
switch (opCode) {
|
||
|
case 'save':
|
||
|
this.save();
|
||
|
break;
|
||
|
case 'exit':
|
||
|
this.dsBody.clear()
|
||
|
this.close();
|
||
|
break;
|
||
|
case 'refresh':
|
||
|
this.refresh();
|
||
|
}
|
||
|
};
|
||
|
|
||
|
IngredientWindow.prototype.refresh = function () {
|
||
|
this.dsBody.search();
|
||
|
};
|
||
|
|
||
|
IngredientWindow.prototype.buildHeader = function () {
|
||
|
let $header = this.getElement('.ingredient-header')
|
||
|
this.headerData.forEach(element => {
|
||
|
let domItem = Store.format('<div class="header-item" ><span class="header-item-label">{0}</span><span>{1}</span></div>',
|
||
|
element.label, element.value || 'N/A')
|
||
|
$header.append(domItem)
|
||
|
});
|
||
|
}
|
||
|
|
||
|
IngredientWindow.prototype.customerize = function ($container) {
|
||
|
this.buildHeader()
|
||
|
|
||
|
this.refresh();
|
||
|
this.resize();
|
||
|
};
|
||
|
|
||
|
IngredientWindow.prototype.resize = function () {
|
||
|
// this.updateGrids($body);
|
||
|
};
|
||
|
|
||
|
IngredientWindow.prototype.updateGrids = function ($e) {
|
||
|
let self = this;
|
||
|
//重置grid
|
||
|
self.resizeGrid($e);
|
||
|
};
|
||
|
|
||
|
return IngredientWindow;
|
||
|
}
|
||
|
);
|