define(function (require, exports, module) { var Window = require('system/views/pages/window'); var tpl = require('text!apps/edp/frd/frd002/enumwin.tpl'); function EnumWindow(args) { this.options = { title: '选择枚举', content: tpl, width: 600, height: 400, modal: true, closed: true, closable: true, data: null } this.args = args; Window.call(this, this.options); this.dsMaster = new DataSource({ funcObjCode: 'tFrmEnum' }); } inherits(EnumWindow, Window); EnumWindow.prototype.init = function () { var self = this; var mainGrid = { opts: { editable: false }, data: this.dsMaster, actions: { onDblClick: function (e, args) { self.select(); } } }; var mainToolBar = { opts: {}, data: [{ opCode: 'ok', caption: '确认', parentOp: '', opClass: 'ok' }, { opCode: 'exit', caption: '退出', parentOp: '', opClass: 'cancel' }, { opCode: 'refresh', caption: '刷新', parentOp: '', opClass: 'refresh' }], actions: { click: function (opCode) { self.doOp(opCode); } } }; this.register('grid', 'grid_main', mainGrid); this.register('toolbar', 'toolbar_main', mainToolBar); } EnumWindow.prototype.select = function () { var curRow = this.dsMaster.currentRow; if (!curRow) { alert('请先选择一条数据。'); return; } this.args.col.refItem = _.clone(curRow); var newValue = curRow['EnumType']; if (this.args.row) { this.args.row.validator(this.args.col, newValue); } this.close(); }; EnumWindow.prototype.doOp = function (opCode) { var isHandled = false; switch (opCode) { case 'ok': this.select(); break; case 'exit': this.close(); break; case 'refresh' : this.refresh(); } }; EnumWindow.prototype.refresh = function () { var self = this; this.dsMaster.search(); }; EnumWindow.prototype.open = function () { var self = this; var code = this.dsMaster.uiObjCode; var post_data = { funcCode: '', uiObjCodes: code } Store.services.getUiObjSchema(post_data, function (isOk, data) { if (isOk) { self.dsMaster.initUIObj(data[code]); Window.prototype.open.call(self); } }); }; return EnumWindow; })