/**
|
* 供应商参照
|
* @author weidy
|
* @date 2021-1-10
|
*/
|
layui.define(['layer','element','vciWebReferGrid'],function(exports){
|
var ReferGrid = function(){
|
this.backPath = (configData.compatibility?path:configData.frameworkPath);
|
this.displayType = {
|
classify:'classify',
|
importtance:'importtance'
|
};
|
this.displayTypeTitle = {
|
classify:{
|
title:'基本分类',
|
url:'supplierClassifyController/referTreeSupplierClassify',
|
queryField:'conditionMap["pkSupplierClassify"]',
|
queryUserUrl:'supplierController/referDataGrid'
|
},
|
importtance:{
|
title:'重要度',
|
url:'supplierImporttanceController/referTreeImportance',
|
queryField:'conditionMap["pkSupplierImporttance"]',
|
queryUserUrl:'supplierController/referDataGrid'
|
}
|
};
|
};
|
ReferGrid.prototype.showReferDialog = function (referConfig){
|
var that = this;
|
var filter = referConfig.filter,
|
name = referConfig.name,
|
title = referConfig.title,
|
target = referConfig.target,
|
value = referConfig.value,
|
text = referConfig.text;
|
var options = referConfig.options;
|
var baseOptions = {};
|
for(var key in options){
|
baseOptions[key] = options[key];
|
}
|
baseOptions.filter = filter;
|
baseOptions.name = name;
|
baseOptions.value = value;
|
baseOptions.text = text;
|
baseOptions.title = title;
|
baseOptions.setValue = function (filter,name,value,rawValue,isClose,selectRecords){
|
target.setValue(filter,name,value,rawValue,isClose,selectRecords);
|
}
|
that.viewSupplierInDialog(baseOptions);
|
};
|
|
ReferGrid.prototype.viewSupplierInDialog = function (options){
|
var that = this;
|
options.supplierUrl = $webUtil.getValueFromObj(options,['url','referUrl'],'supplierController/referDataGrid');
|
options.textField = $webUtil.getValueFromObj(options,['textField'],"name");
|
options.valueField = $webUtil.getValueFromObj(options,['valueField'],"oid");
|
var filter = options.filter;
|
var name = options.name;
|
var valueInfo = ($webUtil.isNotNull(options.text)?("已设置的值为[" +options.text +"]"):'未设置值');
|
var referIndex = $webUtil.dialog({
|
title:(options.title?options.title:'请选择供应商'),
|
btn:['确定','取消'],
|
content:'<div id="referGrid_toolbar_' + filter + '" layui-filter="referGrid_toolbar_' + filter + '" class="layui-table-toolbar layui-form referGrid_toolbar_'+filter+'" style="height:550px;"></div>',
|
area:[(($webUtil.isNotNull(options.width) && options.width*1>1) ?options.width*1 : 1150) +'px',
|
(($webUtil.isNotNull(options.height) && options.height*1>1) ?options.height*1 : 670) + 'px'],
|
btnBefore:valueInfo,
|
yes:function(index,layero){
|
var selectValue = that.getSelectValue(filter,name);
|
if(selectValue){
|
options.setValue(filter,name,selectValue.value,selectValue.rawValue,true,selectValue.allValues);
|
layer.close(referIndex);
|
}
|
},
|
success:function(layero){
|
that.showGrid(filter,name,options);
|
}
|
});
|
return referIndex;
|
};
|
ReferGrid.prototype.setConfig=function(filter,name,options){
|
var that = this;
|
if(!that.referConfig){
|
that.referConfig = {};
|
}
|
that.referConfig[filter + "_" + name] = options;
|
};
|
ReferGrid.prototype.getConfig=function(filter,name){
|
var that = this;
|
if(!that.referConfig){
|
that.referConfig = {};
|
}
|
if((filter + "_" + name) in that.referConfig){
|
return that.referConfig[filter + "_" + name];
|
}
|
};
|
ReferGrid.prototype.showGrid = function (filter,name,options){
|
var that = this;
|
that.setConfig(filter,name,options);
|
var contentFilter = filter + "_" + name;
|
var html=[
|
'<div class="layui-layout-border vciWebReferGridInDojo" style="margin-left:5px;">',
|
'<div style="width:200px;float: left;background-color:#ffffff;display:',options.onlyTable?'none':'block','">',
|
'<div lay-filter="referTree_' + contentFilter + '" class="layui-tab layui-tab-card" lay-allowClose="false">',
|
'<ul class="layui-tab-title" lay-allowClose="false">',
|
'<li class="layui-this" >基本分类</li>',
|
'<li>重要度</li>',
|
'</ul>',
|
'<div class="layui-tab-content">',
|
'<div class="layui-tab-item layui-show">',
|
'<ul layui-filter="classify_',contentFilter,'" style="border:1px solid #6886ff;overflow-x:auto"></ul>',
|
'</div>',
|
'<div class="layui-tab-item">',
|
'<ul layui-filter="importtance_',contentFilter,'" style="border:1px solid #6886ff;overflow-x:auto"></ul>',
|
'</div>',
|
'</div>',
|
'</div>',
|
'</div>',
|
'<div class="layui-layout" style="margin-left:',options.onlyTable?'5':'205','px;">',
|
'<div layui-filter="referGrid_toolbar_',contentFilter, '" class="layui-btn-container">',
|
'</div>',
|
'<div class="layui-center" style="margin-left: 5px;">',
|
'<table class="layui-table layui-referGrid" lay-size="sm" lay-even layui-filter="referGrid_' + contentFilter + '" id="referGrid_' + contentFilter + '" ></table>',//主列表
|
'</div>',
|
'</div>'
|
];
|
$("#referGrid_toolbar_"+ filter ).html(html.join(''));
|
$("#referGrid_toolbar_"+filter+" .layui-layout-border").css({'height':'96%'});
|
that.showTree(that.displayType.classify,filter,name);
|
that.showTree(that.displayType.importtance,filter,name);
|
var tableId = 'referGrid_' + filter + '_' + name;
|
var table = layui.table;
|
var isMuti = options.isMuti;
|
var requestData = {};
|
//可以定义表格了
|
table.render({
|
elem: '#referGrid_' + filter + '_' + name,
|
id: tableId,
|
url: (options.supplierUrl ? options.supplierUrl : that.url.dataGrid),
|
page: {
|
limit: 15,
|
page: 1
|
},
|
backPath: (options.backPath ? options.backPath : that.backPath),
|
height: '475px',
|
where: requestData,
|
method: 'get',
|
selectMode: (isMuti ? table.selectMode.muti : table.selectMode.single),
|
cols: [[table.getIndexColumn(), table.getCheckColumn(),
|
{
|
field: 'id',
|
title: '供应商编号',
|
sort:true,
|
width: 120
|
}, {
|
field: 'name',
|
title: '供应商名称',
|
sort:true,
|
width: 150
|
}, {
|
field: 'pkSupplierClassifyText',
|
title: '基本分类',
|
sort:true,
|
width: 90
|
}, {
|
field: 'pkSupplierAdmittanceText',
|
title: '准入状态',
|
sort:true,
|
width: 85
|
}, {
|
field: 'pkSupplierImporttanceText',
|
title: '重要度',
|
sort:true,
|
width: 85
|
}, {
|
field: 'rateInfo',
|
title: '当前评分',
|
sort:true,
|
width: 85
|
}, {
|
field: 'contactor',
|
title:'联系人',
|
width: 150,
|
templet:function (d){
|
return (d.contactor||'') + " " + d.contacts;
|
}
|
},{
|
field: 'secretGradeText',
|
title: '密级',
|
width: 60,
|
hidden: (!configData.controllerSecret)
|
}
|
]]
|
});
|
var queryColumns = [ {
|
field: 'id',
|
title: '供应商编号'
|
}, {
|
field: 'name',
|
title: '供应商名称'
|
}];
|
that.showSearchHtml(queryColumns,tableId,filter,name,requestData);
|
};
|
ReferGrid.prototype.showTree = function (displayType,filter,name) {
|
var that = this;
|
var tree = layui.tree;
|
var requestData = {};
|
var options = that.getConfig(filter,name);
|
var url = that.displayTypeTitle[displayType].url;
|
//显示tree
|
var treeOptions = {
|
url:url,
|
extraParams:requestData,
|
treeFilter:filter,
|
treeName:name,
|
showSearch:true,
|
backPath:(options.backPath?options.backPath:that.backPath),
|
loadType:tree.loadType.all,
|
click:function(item,elem,treeOptions){
|
that.treeDoClick(item,elem,treeOptions,displayType,filter,name);
|
return false;
|
}
|
};
|
tree.init(displayType + "_" + filter+'_'+name,$('[layui-filter="'+ displayType + "_" + filter+'_'+name + '"]'),treeOptions);
|
};
|
ReferGrid.prototype.treeDoClick = function (item,elem,option,displayType,filter,name) {
|
var that = this;
|
var tableId = 'referGrid_' + filter + '_' + name;
|
var where = {};
|
where[that.displayTypeTitle[displayType].queryField] = item.oid;
|
var tableUrl = that.displayTypeTitle[displayType].queryUserUrl;
|
layui.table.reload(tableId,{
|
url:tableUrl,
|
where:where
|
});
|
};
|
ReferGrid.prototype.showSearchHtml = function (queryColumns,tableId,filter,name,requestData) {
|
var that = this;
|
var table = layui.table;
|
var toolbarElem = $('[layui-filter="referGrid_toolbar_' + filter + '_' + name +'"]');
|
if(queryColumns){
|
var toolbarHtml = '<div class="layui-form-item" style="height:24px;display:inline-block"> '
|
+ '<div class="layui-input-inline" style="height:24px;line-height:24px;width:150px"><select name="referGrid_search_'+ filter + '_' + name +'" style="height:24px;width:120px;padding-right:30px;font-size:15px;">';
|
layui.each(queryColumns,function(_index,queryRecord){
|
toolbarHtml += '<option value="' + queryRecord.field + '" >' + queryRecord.title + '</option>';
|
});
|
toolbarHtml += '</select></div>';
|
toolbarHtml += '<div class="layui-input-inline"><input type="text" style="height:24px;font-size:14px;" name="referGrid_searchvalue_'+ filter + '_' + name +'" placeholder="输入值后回车进行模糊查询" class="layui-input" ></div>';
|
toolbarHtml += '<div class="layui-input-inline" ><button class="layui-btn" style="height:24px;line-height:24px" name="referGrid_searchbtn_'+ filter + '_' + name +'" >查询</button></div>';
|
toolbarHtml += '</div>';
|
toolbarElem.html(toolbarHtml);
|
layui.form.render('select');
|
$('[name="referGrid_searchvalue_' + filter + "_" + name + '"]').keydown(function (e){
|
if(e.keyCode == 13){
|
var searchField = $(this).parent().parent().find('select').val();
|
var searchValue = $(this).val();
|
searchValue = "*" + searchValue + "*";
|
requestData['conditionMap["' + searchField + '"]'] = searchValue;
|
table.reload(
|
tableId, {
|
where: requestData
|
}
|
);
|
}
|
});
|
$('[name="referGrid_searchbtn_'+ filter + '_' + name +'"]').click(function(){
|
var searchField = $(this).parent().parent().find('select').val();
|
var searchValue = $(this).parent().parent().find('[name="referGrid_searchvalue_' + filter + '_' + name + '"]').val();
|
searchValue = "*" + searchValue + "*";
|
requestData['conditionMap["' + searchField + '"]'] = searchValue;
|
table.reload(
|
tableId, {
|
where: requestData
|
}
|
);
|
});
|
}
|
};
|
ReferGrid.prototype.destory = function (filter,name) {
|
//销毁
|
var that = this;
|
if($('#referGrid_' + filter + '_' + name)){
|
$('#referGrid_' + filter + '_' + name).remove();
|
}
|
};
|
ReferGrid.prototype.getSelectValue = function (filter,name) {
|
var that = this;
|
var table = layui.table;
|
var selectValue = {};
|
var checkStatus = table.checkStatus('referGrid_' + filter + "_" + name);
|
var options = that.getConfig(filter,name);
|
if(checkStatus.data.length>0){
|
if(!options.isMuti && checkStatus.data.length > 1){
|
$webUtil.showErrorMsg("只能选择一条数据");
|
return false;
|
}
|
var value = "";
|
var rawValue = "";
|
options.valueField = options.valueField?options.valueField:that.defaultConfig.valueField;
|
options.textField = options.textField?options.textField:that.defaultConfig.textField;
|
var isMutiValue = (options.valueField.indexOf(",")>-1);
|
var isMutiRaw = (options.textField.indexOf(",")>-1);
|
layui.each(checkStatus.data,function(_index,item){
|
if(isMutiValue){
|
var valueFieldArray = options.valueField.split(",");
|
layui.each(valueFieldArray,function(_indexField,_itemField){
|
value += item[_itemField] + (options.valueSep?options.valueSep:' ');
|
});
|
value+= ",";
|
}else {
|
value += item[options.valueField] + ",";
|
}
|
if(isMutiRaw) {
|
var rawFieldArray = options.textField.split(",");
|
layui.each(rawFieldArray,function(_indexField,_itemField){
|
rawValue += item[_itemField] + (options.textSep?options.textSep:' ');
|
});
|
rawValue+= ",";
|
}else{
|
rawValue += item[options.textField] + ",";
|
}
|
});
|
if($webUtil.endWith(value,",")){
|
value = value.substring(0,value.length - 1);
|
}
|
if($webUtil.endWith(rawValue,",")){
|
rawValue = rawValue.substring(0,rawValue.length -1);
|
}
|
selectValue = {
|
value : value,
|
rawValue : rawValue,
|
allValues: checkStatus.data
|
};
|
return selectValue;
|
}else{
|
return false;
|
}
|
};
|
|
|
|
var rg = new ReferGrid();
|
exports('platform/basedoc/BdSupplierRefer',rg);
|
});
|