|
|
|
|
|
|
|
|
|
define(function(require, exports, module) {
|
|
|
|
|
var Biz = require('system/base/biz');
|
|
|
|
|
var optionTpl = require('text!apps/edp/frs/frs006/option.tpl');
|
|
|
|
|
//var MSG = require('../../../../locale/{lang}/ssm_frs');
|
|
|
|
|
// _.extend(Store.MSG, MSG);
|
|
|
|
|
var fixQuery = {
|
|
|
|
|
'OptionType': '1',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function OptionManageBiz(vm) {
|
|
|
|
|
Biz.call(this, vm);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
inherits(OptionManageBiz, Biz);
|
|
|
|
|
|
|
|
|
|
OptionManageBiz.prototype.initCompleted = function() {
|
|
|
|
|
this.super('initCompleted');
|
|
|
|
|
var self = this;
|
|
|
|
|
var params = {
|
|
|
|
|
plugin: 'getOptionLevel',
|
|
|
|
|
pluginData: {}
|
|
|
|
|
};
|
|
|
|
|
Store.services.executeplugin(params, function(isOk, result) {
|
|
|
|
|
if (isOk) {
|
|
|
|
|
var treedata = parseMenuData(result);
|
|
|
|
|
self.callView('setTreeData', treedata);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
OptionManageBiz.prototype.getTreeTitle = function() {
|
|
|
|
|
return Store.MSG.FRS006_01
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
OptionManageBiz.prototype.treeSelected = function(selectValue, selectColName) {
|
|
|
|
|
var dsMaster = this.dsMaster;
|
|
|
|
|
if (selectValue) {
|
|
|
|
|
if (selectValue == '*') {
|
|
|
|
|
fixQuery = {
|
|
|
|
|
'OptionType': '1'
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
_.extend(fixQuery, {
|
|
|
|
|
'*CateCode': selectValue
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
dsMaster.fixQuery = fixQuery;
|
|
|
|
|
dsMaster.search();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OptionManageBiz.prototype.getCustomTpl = function() {
|
|
|
|
|
//多语言转换
|
|
|
|
|
optionTpl = Store.compile(optionTpl, {
|
|
|
|
|
FRS005_09: Store.MSG.FRS005_09
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return $('<div data-options="region:\'south\',split:false" style="height:180px">')
|
|
|
|
|
.append(optionTpl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OptionManageBiz.prototype.beforeRefresh = function() {
|
|
|
|
|
this.dsMaster.fixQuery = fixQuery;
|
|
|
|
|
return this.super("beforeRefresh");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
OptionManageBiz.prototype.beforeEdit = function() {
|
|
|
|
|
var self = this;
|
|
|
|
|
var currentRow = self.dsMaster.currentRow;
|
|
|
|
|
if (currentRow === null)
|
|
|
|
|
return false;
|
|
|
|
|
var isEdit = currentRow["IsEditable"];
|
|
|
|
|
if (isEdit === '0') {
|
|
|
|
|
Store.messager.warn(Store.MSG.FRS006_02); //此选项值,不允许用户编辑。
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return this.super('beforeEdit');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
OptionManageBiz.prototype.afterEdit = function() {
|
|
|
|
|
this.super('afterEdit');
|
|
|
|
|
var self = this;
|
|
|
|
|
var currentRow = self.dsMaster.currentRow;
|
|
|
|
|
var detailSetType = currentRow["DetailSetType"];
|
|
|
|
|
self.view.vm.grid_dsDetail.setOptions({
|
|
|
|
|
editable: true,
|
|
|
|
|
enableAddRow: true
|
|
|
|
|
});
|
|
|
|
|
if (detailSetType === '0') {
|
|
|
|
|
self.view.vm.grid_dsDetail.setOptions({
|
|
|
|
|
editable: false,
|
|
|
|
|
enableAddRow: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
this.view.setEditLimit(self.dsMaster, 'DetailSetType', false);
|
|
|
|
|
this.view.setEditLimit(self.dsMaster, 'OptionName', false);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
OptionManageBiz.prototype.currentChanged = function(dataSrc, oldRow, newRow) {
|
|
|
|
|
//this.super('currentChanged', dataSrc, oldRow, newRow);
|
|
|
|
|
var self = this;
|
|
|
|
|
if (newRow && newRow.Remark && $('.remarkContent1')[0]) {
|
|
|
|
|
$('.remarkContent2').html(newRow.Remark);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
OptionManageBiz.prototype.beforeSave = function() {
|
|
|
|
|
var currentRow = this.dsMaster.currentRow;
|
|
|
|
|
if (currentRow === null) return false;
|
|
|
|
|
|
|
|
|
|
var pOptionCode = currentRow["OptionCode"];
|
|
|
|
|
var pOptionValue = currentRow["OptionValue"];
|
|
|
|
|
var params = {
|
|
|
|
|
plugin: 'proFrsOptionPrcCheck',
|
|
|
|
|
sync: true,
|
|
|
|
|
pluginData: {
|
|
|
|
|
ps_OptionCode: pOptionCode,
|
|
|
|
|
ps_OptionNewValue: pOptionValue,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
var resultData = Store.services.executeplugin(params);
|
|
|
|
|
if (resultData) {
|
|
|
|
|
var checkResult = resultData.data_Proc.ps_CheckResult;
|
|
|
|
|
if (checkResult === '0') {
|
|
|
|
|
Store.messager.err(Store.format(Store.MSG.FRS005_04, resultData.data_Proc.ps_ErrMsg)); //一般选项保存失败,原因:{0}
|
|
|
|
|
return false;
|
|
|
|
|
} else if (checkResult === '2') {
|
|
|
|
|
//是否继续修改?
|
|
|
|
|
Store.messager.confirm(resultData.data_Proc.ps_ErrMsg + '\n' + Store.MSG.FRS005_05, function(cfm) {
|
|
|
|
|
if (cfm)
|
|
|
|
|
return this.super('beforeSave');
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return this.super('beforeSave');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OptionManageBiz.prototype.dataColumnValidate = function(dataSrc, dr, dc, value) {
|
|
|
|
|
|
|
|
|
|
if ((dataSrc.uiObjCode === "tFrsOption01" || dataSrc.uiObjCode === "tFrsOptionDetail01") && dc.fieldName === "OptionValue" && value !== null) {
|
|
|
|
|
var pOptionCode = dr["OptionCode"];
|
|
|
|
|
var pOptionValue = value;
|
|
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
|
plugin: 'proFrsCheckOptionValue',
|
|
|
|
|
sync: true,
|
|
|
|
|
pluginData: {
|
|
|
|
|
ps_OptionCode: pOptionCode,
|
|
|
|
|
ps_OptionValue: pOptionValue,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
var resultData = Store.services.executeplugin(params);
|
|
|
|
|
if (resultData) {
|
|
|
|
|
var valid = resultData.data_Proc.ps_Valid;
|
|
|
|
|
if (valid === '0') {
|
|
|
|
|
if (dataSrc.uiObjCode === "tFrsOption01") {
|
|
|
|
|
Store.messager.warn(Store.MSG.FRS006_05); //主表录入的全局选项值不合法,具体设置请参考选项说明。
|
|
|
|
|
} else {
|
|
|
|
|
Store.messager.warn(Store.MSG.FRS006_06); //从表录入的选项值不合法,具体设置请参考选项说明。
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return this.super('dataColumnValidate');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OptionManageBiz.prototype.afterSave = function() {
|
|
|
|
|
this.super('afterSave');
|
|
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
var currentRow = self.dsMaster.currentRow;
|
|
|
|
|
var enableType = currentRow.getColumnText('EnableType');
|
|
|
|
|
var indexStart = enableType.indexOf('-') + 1;
|
|
|
|
|
var indexEnd = enableType.length;
|
|
|
|
|
var typeStr = enableType.substring(indexStart, indexEnd);
|
|
|
|
|
Store.messager.tip(Store.format(Store.MSG.FRS006_07, typeStr)); //保存成功,{0}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* [强制转换为树结构数据]
|
|
|
|
|
* @param {[type]} data [要转换树菜单结构的数据,此处为本地选项菜单数据]
|
|
|
|
|
*/
|
|
|
|
|
function parseMenuData(data) {
|
|
|
|
|
var nodes = [];
|
|
|
|
|
var preNode = {
|
|
|
|
|
id: '*',
|
|
|
|
|
pId: '',
|
|
|
|
|
value: '*',
|
|
|
|
|
name: Store.MSG.FRS006_08, //选项
|
|
|
|
|
open: true
|
|
|
|
|
};
|
|
|
|
|
nodes.push(preNode);
|
|
|
|
|
$.each(data, function(index, item) {
|
|
|
|
|
var node = {};
|
|
|
|
|
node.id = item.catecode;
|
|
|
|
|
node.pId = item.precatecode;
|
|
|
|
|
node.value = item.catecode;
|
|
|
|
|
node.name = item.catename;
|
|
|
|
|
nodes.push(node);
|
|
|
|
|
});
|
|
|
|
|
return nodes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return OptionManageBiz;
|
|
|
|
|
});
|