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.
311 lines
10 KiB
311 lines
10 KiB
|
|
define(function (require, exports, module) {
|
|
var BaseBiz = require('system/base/biz');
|
|
var EnumWindow = require('apps/edp/frd/frd002/enumwin');
|
|
var RefWindow = require('apps/edp/frd/frd002/refwin');
|
|
var PropRef = require('apps/edp/frd/frd002/propref');
|
|
var customized = require('apps/edp/frd/frd002/customized');
|
|
var CopyProp = require('./copyprop');
|
|
|
|
function Biz(dict) {
|
|
BaseBiz.call(this, dict);
|
|
};
|
|
|
|
inherits(Biz, BaseBiz);
|
|
|
|
Biz.prototype.initialize = function () {
|
|
this.dsMaster.onlySaveCurrent = true;
|
|
};
|
|
|
|
Biz.prototype.beforeRefresh = function () {
|
|
var isOk = this.super('beforeRefresh');
|
|
return isOk;
|
|
};
|
|
|
|
Biz.prototype.initCompleted = function () {
|
|
this.super('initCompleted');
|
|
var self = this;
|
|
Store.bizDao.getData('000002', {}, function (isOk, data) {
|
|
if (isOk) {
|
|
var treedata = [];
|
|
treedata.push({
|
|
id: '*',
|
|
pId: '',
|
|
value: '*',
|
|
name: '全部',
|
|
colName: 'ModuleCode',
|
|
open: true
|
|
});
|
|
for (var i = 0; i < data.length; i++) {
|
|
var row = data[i];
|
|
treedata.push({
|
|
id: row['modulecode'],
|
|
pId: '*',
|
|
value: row['modulecode'],
|
|
name: row['modulename'],
|
|
colName: 'ModuleCode'
|
|
})
|
|
}
|
|
|
|
self.callView('setTreeData', treedata);
|
|
}
|
|
});
|
|
}
|
|
|
|
Biz.prototype.getTreeTitle = function (page) {
|
|
return ''
|
|
};
|
|
|
|
Biz.prototype.userRefDlg = function (args) {
|
|
if (args.col.fieldName === 'RefObj') {
|
|
var refType = args.row['RefType'];
|
|
if (refType == Store.Enums.RefType.ENUM) {
|
|
var enumWin = new EnumWindow(args);
|
|
enumWin.open();
|
|
}
|
|
if (refType == Store.Enums.RefType.TABLE) {
|
|
var refWin = new RefWindow(args);
|
|
refWin.open();
|
|
}
|
|
|
|
if (refType == Store.Enums.RefType.PROP) {
|
|
var propRef = new PropRef(args);
|
|
propRef.open();
|
|
}
|
|
return;
|
|
}
|
|
|
|
this.super('userRefDlg', args);
|
|
};
|
|
|
|
function processRefType(ds, dr, dc, value) {
|
|
dr.setColumnValue('RefObj', '');
|
|
dr.setColumnValue('RefField', '');
|
|
dr.setColumnValue('RefFieldName', '');
|
|
dr.setColumnValue('RefSeparator', '');
|
|
dr.setColumnText('EditStyle', '00');
|
|
|
|
//表参照-按钮文本;枚举参照-下拉选择
|
|
if (value === '1') {
|
|
dr.setColumnText('EditStyle', '02');
|
|
if (dr['RefSeparator'] === null || dr['RefSeparator'] === '') {
|
|
dr.setColumnText('RefSeparator', '-');
|
|
}
|
|
}
|
|
|
|
if (value === '2') {
|
|
dr.setColumnText('EditStyle', '01');
|
|
if (dr['RefSeparator'] === null || dr['RefSeparator'] === '') {
|
|
dr.setColumnText('RefSeparator', '-');
|
|
}
|
|
}
|
|
}
|
|
|
|
function processDataObjCode(ds, dr, dc, value, biz) {
|
|
if (!value) {
|
|
return;
|
|
}
|
|
|
|
Store.messager.confirm('是否导入物理字典数据?', function (r) {
|
|
if (r) {
|
|
var queryParams = {
|
|
DataObjCode: value
|
|
};
|
|
Store.bizDao.getData('000001', queryParams, function (isOk, data) {
|
|
if (!isOk) {
|
|
return;
|
|
}
|
|
var dsDetail = biz.dsDetail;
|
|
for (var i = 0; i < data.length; i++) {
|
|
var row = data[i];
|
|
var newRow = dsDetail.newRow();
|
|
newRow.FieldName = row['fieldname'];
|
|
newRow.DispName = row['fielddesc'];
|
|
newRow.DefaultValue = row['defaultvalue'];
|
|
newRow.IsRequired = row['isrequired'];
|
|
newRow.DispIndex = dsDetail.rows.length;
|
|
//加入其他参数headerwidth,labelwidth,dispwidth,dispscale,dispformat
|
|
if (!!row['realm']) {
|
|
newRow.HeaderWidth = !!row['headerwidth'] ? row['headerwidth'] : newRow.HeaderWidth;
|
|
newRow.LabelWidth = !!row['labelwidth'] ? row['labelwidth'] : newRow.LabelWidth;
|
|
newRow.DispWidth = !!row['dispwidth'] ? row['dispwidth'] : newRow.DispWidth;
|
|
newRow.DispScale = !!row['dispscale'] ? row['dispscale'] : newRow.DispScale;
|
|
newRow.DispFormat = !!row['dispformat'] ? row['dispformat'] : newRow.DispFormat;
|
|
//HISOS-876 报表平台1.0.1版本合并
|
|
newRow.KeyBoardType = !!row['keyboardtype'] ? row['keyboardtype'] : newRow.KeyBoardType;
|
|
}
|
|
if (customized) {
|
|
try {
|
|
customized.importDataObj(newRow, row);
|
|
} catch (e) {
|
|
console.log(e);
|
|
}
|
|
|
|
}
|
|
|
|
dsDetail.addRow(newRow);
|
|
}
|
|
}, 'FRD002');
|
|
}
|
|
});
|
|
}
|
|
|
|
Biz.prototype.dataColumnValidate = function (ds, dr, dc, value) {
|
|
if (ds.uiObjCode == 'tFrmUIProp') {
|
|
switch (dc.fieldName) {
|
|
case 'RefType':
|
|
processRefType(ds, dr, dc, value);
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (ds.uiObjCode == 'tFrmUIObj') {
|
|
switch (dc.fieldName) {
|
|
case 'DataObjCode':
|
|
processDataObjCode(ds, dr, dc, value, this);
|
|
break;
|
|
}
|
|
}
|
|
};
|
|
|
|
Biz.prototype.fieldChanged = function (dataSrc, dr, dc) {
|
|
if (dataSrc.uiObjCode === 'tFrmUIProp') {
|
|
switch (dc.fieldName) {
|
|
case 'DispIndex':
|
|
dispIndexChanged(dataSrc, dr)
|
|
break;
|
|
}
|
|
}
|
|
};
|
|
|
|
function dispIndexChanged(ds, dr) {
|
|
var newIndex = Number(dr['DispIndex'])
|
|
var idxMap = {}
|
|
var max = 0
|
|
ds.rows.forEach(r => {
|
|
if (r === dr) { return }
|
|
var idx = Number(r['DispIndex'])
|
|
if (idx > max)
|
|
if (idxMap[r['DispIndex']]) {
|
|
idxMap[r['DispIndex']].push(r)
|
|
} else {
|
|
idxMap[r['DispIndex']] = [r]
|
|
}
|
|
});
|
|
|
|
var idx = newIndex
|
|
for (var i = newIndex; i < ds.rows.length; i++) {
|
|
if (idxMap[i]) {
|
|
var rows = idxMap[i]
|
|
rows.forEach(r => {
|
|
idx++
|
|
r.setColumnValue('DispIndex', idx)
|
|
})
|
|
}
|
|
}
|
|
|
|
setTimeout(() => ds.sort('DispIndex'), 100)
|
|
}
|
|
|
|
Biz.prototype.beforeFieldEdit = function (ds, dr, dc) {
|
|
if (dc.fieldName == 'RefObj' || dc.fieldName == 'RefFieldName' || dc.fieldName == 'RefField') {
|
|
return dr['RefType'] !== Store.Enums.RefType.NONE;
|
|
}
|
|
|
|
return this.super('beforeFieldEdit', ds, dr, dc);
|
|
};
|
|
|
|
Biz.prototype.doOp = function (opCode) {
|
|
var self = this;
|
|
if (opCode == 'scriptoracle' || opCode == 'scriptmysql') {
|
|
let dbType = 'oracle';
|
|
if (opCode === 'scriptoracle') {
|
|
dbType = 'oracle';
|
|
} else if (opCode === 'scriptmysql') {
|
|
dbType = 'mysql'
|
|
} else {
|
|
Store.messager.warn('只能导出oracle、mysql脚本');
|
|
return;
|
|
}
|
|
|
|
var ScriptWin = require('./scriptwin2');
|
|
var win = new ScriptWin({
|
|
dataRow: self.dsMaster.currentRow,
|
|
dbType: dbType
|
|
});
|
|
win.open();
|
|
}
|
|
|
|
if (opCode == 'clone') {
|
|
clone(self);
|
|
}
|
|
|
|
if (opCode == 'copy') {
|
|
copyProp(self);
|
|
}
|
|
|
|
return self.super('doOp', opCode);
|
|
};
|
|
|
|
function copyProp(biz) {
|
|
var args = {
|
|
callback: function (data) {
|
|
data.forEach(function (r) {
|
|
var newRow = biz.dsDetail.addRow();
|
|
newRow.loadData(r);
|
|
//newRow.setColumnValue('DataObjCode', biz.dsMaster.currentRow.getColumnValue('DataObjCode'));
|
|
});
|
|
|
|
biz.dsDetail.getParentRelation().updateRelationValue(biz.dsMaster.currentRow);
|
|
}
|
|
};
|
|
|
|
var win = new CopyProp(args);
|
|
win.open();
|
|
}
|
|
|
|
function clone(biz) {
|
|
if (!biz.dsMaster.currentRow) {
|
|
return;
|
|
}
|
|
var uiObjCode = biz.dsMaster.currentRow['UIObjCode'];
|
|
Store.messager.prompt('请输入新字典编码', uiObjCode, function (newCode) {
|
|
if (newCode) {
|
|
var params = {
|
|
plugin: 'cloneUIObjPlugin',
|
|
sync: true,
|
|
pluginData: {
|
|
ps_UIObjCode: uiObjCode,
|
|
ps_NewUIObjCode: newCode,
|
|
}
|
|
}
|
|
var resultData = Store.services.executeplugin(params);
|
|
if (resultData && resultData.data_Proc.pi_Result == 1) {
|
|
Store.messager.tip(resultData.data_Proc.ps_msg);
|
|
biz.dsMaster.search();
|
|
} else {
|
|
Store.messager.tip(resultData.data_Proc.ps_msg);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
Biz.prototype.getOpEnabled = function (opCode) {
|
|
var self = this;
|
|
if (opCode == 'script') {
|
|
return self.dsMaster.currentRow;
|
|
}
|
|
|
|
if (opCode == 'clone') {
|
|
return Boolean(this.dsMaster.currentRow && this.callView('isList'));
|
|
}
|
|
|
|
if (opCode == 'copy') {
|
|
return this.isEdit();
|
|
}
|
|
|
|
return self.super('getOpEnabled', opCode);
|
|
};
|
|
|
|
return Biz;
|
|
}) |