/**
* 主数据申请处理
* @author wangting
* @date 2022-4-15
*/
layui.define(['layer','element','form','table','dynamicCondition' ,'tree','transfer','mdm/MdmEngineForm'],function(exports){
var webUtil = $webUtil;
var Class = function(){
this.MODELNAME = "mdm/MdmApply";
this.moduleKey = "MdmApply";
this.backPath = configData.compatibility? path:configData.mdmService;
this.url = {
controller:'ducking/',
gridPreDataFinish:'gridPreDataFinish',
gridPreDataUnFinish:'gridPreDataUnFinish',
editSave:'editSave'
};
this.getContent = function (){
var that = this;
if(that.sourceData && "page" in that.sourceData){
that.id = that.id + "_" + that.sourceData.page;
}
return '
';
};
this.showContent=function(){
var html = "";
var that = this;
html = [
'',
that.getToolbarHtml(),
'
',
'
',
].join("");
$("#UIContent_" + that.id).html(html);
};
this.getToolbarHtml =function(){
var that = this;
var html = [
'',
(that.sourceData.page=='executing'?'':''),
'',
'',
'
'];
return html.join('');
};
this.createSearchHtml = function () {
var that = this;
webUtil.createSearchHtml({id:"模板编号",name:"模板名称"},$("[layui-filter='toolbar_" + that.id + "']"),'table_'+that.id);
webUtil.bindDefultButtonLisenter(that, that.id);
};
this.config={}
this.init = function(){
var that = this;
webUtil.copyConfig(that,that.moduleKey);
this.config[that.id] = {
sourceData:that.sourceData
};
that.showContent();
that.initTable(that.id)
this.createSearchHtml()
};
this.initTable=function (configId){
var that = this;
var table=layui.table;
that.checkColumns(configId);
table.render({
elem: '#table_' + configId,
id: 'table_'+configId,
url:that.url.controller+(that.config[configId].sourceData.page=='executing'?that.url.gridPreDataUnFinish:that.url.gridPreDataFinish),
backPath: that.backPath,
page: {
limit: 20,
page: 1
},
selectMode: table.selectMode.single,
cols: [that.columns],
done: function (res, cur, total) {
}
});
}
this.checkColumns=function (configId) {
var that = this;
var table = layui.table;
if (that.columns == null || that.columns.length == 0) {
that.columns = [table.getIndexColumn(), table.getCheckColumn(),
{
field: 'unique',
title: '图号',
sort: true,
width: 120
}, {
field: 'num',
title: '编码',
sort: true,
width: 120
}, {
field: 'model',
title: '规格型号',
width: 120
}, {
field: 'parttype',
title: '零件类型',
width: 100
}, {
field: 'unit',
title: '计量单位',
width: 60
}, {
field: 'type',
title: '主题库编号',
width: 100
}, {
field: 'classifyname',
title: '分类名称',
width: 100
}, {
field: 'datacode',
title: '数据返回状态',
width: 90
}, {
field: 'datamsg',
title: '数据返回提示',
width: 150
}];
that.dataFields = [{
field: 'unique',
title: '图号'
}, {
field: 'num',
title: '编码'
}, {
field: 'model',
title: '规格型号'
}, {
field: 'parttype',
title: '零件类型'
}, {
field: 'type',
title: '主题库编号'
}, {
field: 'classifyname',
title: '分类名称'
}, {
field: 'datacode',
title: '数据返回状态',
type: 'combox',
comboxKey: [{key: "200", value: "200"}, {key: "400", value: "400"}, {key: "500", value: "500"}]
}]
}
}
this.refresh = function (type,button){
var that = this;
var configId=$(button).attr('layui-filter').split('_')[1]
layui.table.reload('table_' + configId);
};
this.ADVQUERY = function (type,button) {
var that = this;
var configId=$(button).attr('layui-filter').split('_')[1]
if (!that.config[configId].serinorQueryInstance) {
var dynamicCondition = layui.dynamicCondition;
$('[layui-filter="toolbar_' + configId + '"]').append('');
that.checkColumns(configId);
that.config[configId].serinorQueryInstance = dynamicCondition.create({
fields: that.dataFields//查询字段
, tableId: "table_" + configId//需要查询的表格
, type: "complex" //type:"simple"/"complex" 查询的方法 暂时写死为 complex
, queryCallBack: function (requestData) {//查询之后的callback
}
});
}
that.config[configId].serinorQueryInstance.open();
};
this.SETCLASS=function (type,button) {
var that = this;
var configId = $(button).attr('layui-filter').split('_')[1];
var oid = webUtil.getOidFromGrid('table_' + configId,true,true);
if(!oid){
return;
}
layui.use('vciWebReferTree',function (){
var treeRefer = layui['vciWebReferTree'];
treeRefer.showReferDialog({
filter:configId+"_classify",
name:"wupin",
title:'选择分类',
target: {
setValue: function (filter,name,value,rawValue,closeDialog,allValues){
webUtil.manualAjax('put', that.url.controller+that.url.editSave, JSON.stringify({oid:oid,classifyoid:value}), function (result) {
if (result.success) {
webUtil.showMsgFromResult(result, "分类设置成功");
that.refresh(null,button);
} else {
webUtil.showErrorMsg(result.msg);
}
}, function (xhr, err) {
webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启");
}, that.backPath);
}
},
options: {
backPath:that.backPath,
url:'codeClassifyController/referTree',
isMuti:false,
isQueryAllColumn: true,
onlyLeaf:true,
rootParams:{
"conditionMap['id']":'wupin'
},
}
});
});
}
};
var cs = new Class();
exports(cs.MODELNAME,cs);
});