/**
|
* 首页任务定义
|
*/
|
|
layui.define(['layer','element','form','table'],function(exports){
|
var BatchMakeOrder = function(){
|
this.moduleKey = "vciHomeTaskAction";
|
this.id='vciHomeTaskAction';
|
this.sourceData={};//来源数据
|
this.columns = [];
|
this.backPath = configData.compatibility?path:configData.frameworkPath;//默认流程和项目的路径是一样的
|
this.url={
|
dataGrid:'homeTaskController/dataGrid',
|
add:'homeTaskController/addSave',
|
edit:'homeTaskController/editSave',
|
del:'homeTaskController/delete',
|
referMenu:'smFunctionController/treeAllMenu'
|
};
|
this.buttonIconMap = {
|
SEARCH:'layui-icon-refresh-2',
|
SENIORSEARCH:'layui-icon-senior',
|
ADD:'layui-icon-add-1',
|
EDIT:'layui-icon-edit',
|
DELETE:'layui-icon-delete'
|
};
|
this.getContent=function(){//返回这个组件的基础html
|
var that = this;
|
var html = "";
|
html = [
|
'<div class="layui-layout" style="display:block;">',
|
'<div class="layui-layout-border">',
|
'<div class="layui-center">',
|
that.getToolbarHtml(),
|
'<table id="table_', that.id , '" lay-filter="table_',that.id , '" style="overflow:auto;"></table>',//主列表
|
'</div>',
|
'</div>',
|
'</div>'
|
].join("");
|
return html;
|
};
|
this.getToolbarHtml =function(){
|
var that = this;
|
var html = [
|
'<div layui-filter="toolbar_',that.id, '" class="layui-btn-container">',//主列表的按钮
|
'</div>'
|
].join("");
|
return html;
|
};
|
this.init=function(){//基础的html被添加后,再执行初始化
|
var that = this;
|
$webUtil.copyConfig(that,that.moduleKey);
|
//获取按钮
|
$webUtil.bindDefultButtonLisenter(that, that.id);
|
var table = layui.table;
|
that.checkColumns();//主列表中列。
|
table.render({
|
elem: '#table_' + that.id,
|
id: 'table_' + that.id,
|
url: that.backPath + that.url.dataGrid,
|
page: {
|
limit: 30,
|
page: 1
|
},
|
width:'100%',
|
cols: [that.columns]
|
});
|
};
|
this.checkColumns = function(){
|
var that = this;
|
var table = layui.table;//只有自加工的才是首批
|
if(that.columns==null || that.columns.length==0){//如果其他地方想使用这个组件的时候,可以自定义列
|
that.columns = [table.getIndexColumn(),table.getCheckColumn(),{
|
field:'name',
|
title:'所属菜单',
|
width:150
|
},{
|
field:'serviceName',
|
title:'服务名称',
|
width:100
|
},{
|
field:'countUrl',
|
title:'统计的地址',
|
width:350
|
},{
|
field:'uiUrl',
|
title:'页面地址',
|
width:350
|
}];
|
}
|
};
|
this.refresh = function () {
|
var that = this;
|
layui.table.reload("table_" + that.id);
|
};
|
this.ADD = function() {
|
var that = this;
|
var form = layui.form;
|
var filter =that.id;
|
var addSaveIndex = $webUtil.dialog({
|
title:'添加首页任务动作',
|
btn:['保存','取消'],
|
content:'<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px"></form>',
|
area:['800px','300px'],
|
resizing:function(layero){
|
form.doResize(filter);
|
},
|
success:function(layero){
|
form.addItems(filter,that.getFormItems(),
|
function(){},{},{defaultColumnOneRow:2,inDialog:true});
|
form.on('select('+ filter + ")",function (obj) {
|
if (obj.name == 'id') {
|
var selectData = obj.rowData[0];
|
form.setValues({
|
name: selectData.name,
|
uiUrl:selectData.url
|
},filter);
|
}
|
});
|
},
|
yes:function(layero){
|
if(form.validata(filter)){
|
var values = form.getValues(filter);
|
$webUtil.post(that.url.add,values,function(result){
|
if(result.success){
|
$webUtil.showMsgFromResult(result,"添加成功");
|
layer.close(addSaveIndex);
|
that.refresh();
|
}else{
|
$webUtil.showErrorMsg(result.msg);
|
}
|
},function (error) {
|
|
},that.backPath);
|
}
|
}
|
});
|
};
|
this.getFormItems = function () {
|
return [{
|
type:'refer',
|
name:'id',
|
text:'所属功能菜单',
|
required:true,
|
showField:'name',
|
referConfig:{
|
type:'tree',
|
url:that.url.referMenu,
|
extraParams:{
|
currentUserReferModelKey:that.sourceData['functionId'],
|
currentUserReferMethodKey:'ADD'//是告诉url当前使用参照的菜单和按钮
|
},
|
loadType:'all',
|
valueField:'attribute.oid',
|
textField:'attribute.name'
|
}
|
},{
|
name:'name',
|
text:'显示名称',
|
required:true
|
},{
|
name:'serviceName',
|
text:'服务名称',
|
required:true
|
},{
|
name:'countUrl',
|
text:'统计的路径',
|
useAllWidth:true,
|
required:true
|
},{
|
name:'uiUrl',
|
text:'显示路径',
|
useAllWidth:true,
|
required:true
|
}];
|
};
|
this.EDIT = function() {
|
var that = this;
|
var oid = $webUtil.getOidFromGrid("table_" + that.id,true,true);
|
if(!oid){
|
return false;
|
}
|
var selectData = layui.table.checkStatus("table_" + that.id);
|
if(selectData && selectData.data &&selectData.data.length>0){
|
var form = layui.form;
|
var filter =that.id;
|
var addSaveIndex = $webUtil.dialog({
|
title:'修改首页任务动作',
|
btn:['保存','取消'],
|
content:'<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px"></form>',
|
area:['800px','300px'],
|
resizing:function(layero){
|
form.doResize(filter);
|
},
|
success:function(layero){
|
form.addItems(filter,that.getFormItems(),
|
function(){
|
form.setValues(selectData.data[0],filter);
|
form.on('select('+ filter + ")",function (obj) {
|
if (obj.name == 'id') {
|
var selectData = obj.rowData[0];
|
form.setValues({
|
name: selectData.name,
|
uiUrl:selectData.url
|
},filter);
|
}
|
});
|
},{},{defaultColumnOneRow:2,inDialog:true});
|
},
|
yes:function(layero){
|
if(form.validata(filter)){
|
var values = form.getValues(filter);
|
values.oid = selectData.data[0].oid;
|
values.ts = selectData.data[0].ts;
|
$webUtil.put(that.url.edit,values,function(result){
|
if(result.success){
|
$webUtil.showMsgFromResult(result,"修改成功");
|
layer.close(addSaveIndex);
|
that.refresh();
|
}else{
|
$webUtil.showErrorMsg(result.msg);
|
}
|
},function (error) {
|
|
},that.backPath);
|
}
|
}
|
});
|
}
|
};
|
this.DELETE = function(){
|
var that = this;
|
var oid = $webUtil.getOidFromGrid("table_" + that.id,true,true);
|
if(!oid){
|
return false;
|
}
|
var selectData = layui.table.checkStatus("table_" + that.id);
|
if(selectData && selectData.data &&selectData.data.length>0){
|
$webUtil.showConfirmMsg("您确定要删除这条数据吗?",function () {
|
oid = selectData.data[0].oid;
|
var ts = selectData.data[0].ts;
|
$webUtil.deleteRequest(that.url.del,{oid:oid,ts:ts},function(result){
|
if(result.success){
|
$webUtil.showMsgFromResult("删除成功");
|
that.refresh();
|
}else{
|
$webUtil.showErrorMsg(result.msg);
|
}
|
},function(error){
|
|
},that.backPath);
|
});
|
}
|
};
|
};
|
var pml = new BatchMakeOrder();
|
exports('platform/home/vciHomeTaskAction',pml);
|
});
|