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.
217 lines
6.4 KiB
217 lines
6.4 KiB
define(function (require, exports, module) {
|
|
var Window = require('system/views/pages/window');
|
|
var tpl = require('text!apps/edp/frd/frd002/refwin.tpl');
|
|
// var DataSource = require('system/base/datasource');
|
|
|
|
function RefWindow(args) {
|
|
this.options = {
|
|
title: '参照信息',
|
|
content: tpl,
|
|
width: 612,
|
|
height: 435,
|
|
modal: true,
|
|
closed: true,
|
|
closable: true,
|
|
data: null
|
|
}
|
|
|
|
this.args = args;
|
|
Window.call(this, this.options);
|
|
|
|
this.dsMaster = new DataSource({
|
|
funcObjCode: 'tFrmUIObj'
|
|
});
|
|
|
|
this.dsDetail = new DataSource({
|
|
funcObjCode: 'tFrmUIProp'
|
|
});
|
|
|
|
}
|
|
|
|
inherits(RefWindow, Window);
|
|
|
|
RefWindow.prototype.init = function () {
|
|
var self = this;
|
|
var tree = {
|
|
actions: {
|
|
// onDblClick: function(event, treeId, treeNode) {
|
|
// var newRow = treeNode.tag;
|
|
// if (newRow) {
|
|
// self.dsMaster.setCurrentRow(newRow);
|
|
// }
|
|
// },
|
|
onClick: function (event, treeNode) {
|
|
var newRow = treeNode.row;
|
|
if (newRow !== undefined) {
|
|
self.dsMaster.setCurrentRow(newRow);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
this.register('tree', 'tree_obj', tree);
|
|
}
|
|
|
|
RefWindow.prototype.open = function () {
|
|
var self = this;
|
|
var code = this.dsMaster.uiObjCode + ';' + this.dsDetail.uiObjCode;
|
|
var post_data = {
|
|
funcCode: '',
|
|
uiObjCodes: code
|
|
};
|
|
|
|
Store.services.getUiObjSchema(post_data, function (isOk, data) {
|
|
if (isOk) {
|
|
self.dsMaster.initUIObj(data[self.dsMaster.uiObjCode]);
|
|
self.dsDetail.initUIObj(data[self.dsDetail.uiObjCode]);
|
|
self.dsMaster.addRelation(self.dsDetail, 'UIObjCode', 'UIObjCode');
|
|
Window.prototype.open.call(self);
|
|
}
|
|
});
|
|
};
|
|
|
|
RefWindow.prototype.customerize = function ($container) {
|
|
var self = this;
|
|
this.$cmbField = this.getElement('.cmbField');
|
|
this.$cmbFieldName = this.getElement('.cmbFieldName');
|
|
var $btnOk = this.getElement('.btnOk');
|
|
if ($btnOk) {
|
|
$btnOk.on('click', function () {
|
|
self.doOp('ok');
|
|
});
|
|
}
|
|
|
|
var $btnCancel = this.getElement('.btnCancel');
|
|
if ($btnCancel) {
|
|
$btnCancel.click(function () {
|
|
self.doOp('exit');
|
|
});
|
|
}
|
|
|
|
this.dsMaster.search(function (isOk) {
|
|
self.dsMaster.setCurrentRow(null);
|
|
var nodes = parseTreeData(self.dsMaster);
|
|
self.vm.tree_obj.reset(nodes);
|
|
self.dsMaster.on('onCurrentChanged', function (ds, e) {
|
|
if (ds.currentRow) {
|
|
ds.loadDetails(function (isOk) {
|
|
if (isOk) {
|
|
var items = parseFieldItems(self.dsDetail);
|
|
self.$cmbField.combobox('loadData', items);
|
|
self.$cmbField.combobox('clear');
|
|
self.$cmbFieldName.combobox('loadData', items);
|
|
self.$cmbFieldName.combobox('clear');
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|
|
};
|
|
|
|
/**
|
|
* 转化ds数据为字段元素
|
|
* {text:[fieldName],value:[rowindex]}
|
|
* @param {Object} ds 数据源
|
|
* @return {Array} 字段数组
|
|
*/
|
|
function parseFieldItems(ds) {
|
|
var items = [];
|
|
for (var i = 0; i < ds.rows.length; i++) {
|
|
var row = ds.rows[i];
|
|
var item = {
|
|
text: row['DispName'],
|
|
value: row['FieldName']
|
|
}
|
|
|
|
items.push(item);
|
|
}
|
|
;
|
|
return items;
|
|
}
|
|
|
|
/**
|
|
* 转为ds数据为树节点数据
|
|
* {row:[rowindex],id:[UIObjCode],pId:[ModuleCode],name:[UIObjName]}
|
|
* @param {Object} ds 数据源
|
|
* @return {Array} 树数据
|
|
*/
|
|
function parseTreeData(ds) {
|
|
var nodes = [];
|
|
var root = {
|
|
pId: '',
|
|
id: '*',
|
|
name: '界面对象'
|
|
};
|
|
nodes.push(root);
|
|
var modules = [];
|
|
for (var i = 0; i < ds.rows.length; i++) {
|
|
var row = ds.rows[i];
|
|
if (modules.indexOf(row['ModuleCode']) < 0) {
|
|
modules.push(row['ModuleCode']);
|
|
var moduleNode = {
|
|
pId: '*',
|
|
id: row['ModuleCode'],
|
|
name: row['ModuleName']
|
|
};
|
|
nodes.push(moduleNode);
|
|
}
|
|
var treeNode = {
|
|
row: i,
|
|
uiObjCode: row['UIObjCode'],
|
|
pId: row['ModuleCode'],
|
|
id: row['UIObjCode'],
|
|
name: row['UIObjName']
|
|
};
|
|
nodes.push(treeNode);
|
|
}
|
|
;
|
|
|
|
return nodes;
|
|
}
|
|
|
|
RefWindow.prototype.select = function () {
|
|
var refObj = this.vm.tree_obj.getSelected().uiObjCode;
|
|
if (!refObj) {
|
|
Store.showError(Store.MSG.UIOBJ_NOT_SELECT);
|
|
return;
|
|
}
|
|
|
|
var refField = this.$cmbField.combobox('getValue');
|
|
var refFieldName = this.$cmbFieldName.combobox('getValue');
|
|
if (this.args.row) {
|
|
this.args.row.validator('RefObj', refObj);
|
|
this.args.row.validator('RefField', refField);
|
|
this.args.row.validator('RefFieldName', refFieldName);
|
|
}
|
|
if (this.args.callback) {
|
|
this.args.callback();
|
|
}
|
|
this.close();
|
|
};
|
|
|
|
RefWindow.prototype.doOp = function (opCode) {
|
|
var isHandled = false;
|
|
switch (opCode) {
|
|
case 'ok':
|
|
this.select();
|
|
break;
|
|
case 'exit':
|
|
this.close();
|
|
break;
|
|
case 'refresh':
|
|
this.refresh();
|
|
}
|
|
};
|
|
|
|
RefWindow.prototype.refresh = function () {
|
|
var self = this;
|
|
|
|
//表参照专用,表参照相关约束
|
|
this.args.refParam.ignoreValue = true;
|
|
this.dsMaster.refQuery = this.args.refParam;
|
|
this.dsMaster.search();
|
|
};
|
|
|
|
|
|
return RefWindow;
|
|
}) |