2025-11-27 16:55:35 +08:00
|
|
|
|
var example = null;
|
|
|
|
|
|
var pers = null ;
|
|
|
|
|
|
var layer = null;
|
|
|
|
|
|
$(function () {
|
|
|
|
|
|
layui.use([ 'layer', 'laydate','form' ], function() {
|
|
|
|
|
|
layer = layui.layer;
|
|
|
|
|
|
});
|
|
|
|
|
|
pers = checkPermission();
|
|
|
|
|
|
init();
|
|
|
|
|
|
$("#searchBt").click(function(){
|
|
|
|
|
|
example.ajax.reload();
|
|
|
|
|
|
});
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
function init(){
|
|
|
|
|
|
example =
|
|
|
|
|
|
$('#dt-table').DataTable({
|
|
|
|
|
|
"sort": false,
|
|
|
|
|
|
"searching": false,
|
|
|
|
|
|
"processing": true, //加载数据时显示进度状态
|
|
|
|
|
|
"serverSide" : true,
|
|
|
|
|
|
"pagingType": "full_numbers", //首页|尾页
|
|
|
|
|
|
"language": {
|
2025-12-02 14:22:34 +08:00
|
|
|
|
"url": contentPath + "/js/plugin/datatables/Chinese.lang"
|
2025-11-27 16:55:35 +08:00
|
|
|
|
},
|
|
|
|
|
|
"ajax": {
|
|
|
|
|
|
"url" : ctxPath + "/Builder",
|
|
|
|
|
|
"type":"get",
|
|
|
|
|
|
"data":function(d){
|
|
|
|
|
|
d.name = $("#name").val();
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
"error":function(xhr, textStatus, errorThrown){
|
|
|
|
|
|
var msg = xhr.responseText;
|
|
|
|
|
|
console.log(msg);
|
|
|
|
|
|
var response = JSON.parse(msg);
|
|
|
|
|
|
var code = response.code;
|
|
|
|
|
|
var message = response.message;
|
|
|
|
|
|
if (code == 400) {
|
|
|
|
|
|
layer.msg(message);
|
|
|
|
|
|
} else if (code == 401) {
|
|
|
|
|
|
localStorage.removeItem("token");
|
|
|
|
|
|
layer.msg("token过期,请先登录", {shift: -1, time: 1000}, function(){
|
|
|
|
|
|
location.href = ctxPath + '/login.html';
|
|
|
|
|
|
});
|
|
|
|
|
|
} else if (code == 403) {
|
|
|
|
|
|
console.log("未授权:" + message);
|
|
|
|
|
|
layer.msg('未授权');
|
|
|
|
|
|
} else if (code == 500) {
|
|
|
|
|
|
console.log('系统错误:' + message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
"dom": "<'dt-toolbar'r>t<'dt-toolbar-footer'<'col-sm-4 col-xs-4 hidden-xs'i><'col-xs-8 col-sm-8' p v>>",
|
|
|
|
|
|
"columns": [
|
|
|
|
|
|
{
|
|
|
|
|
|
width : '40px',
|
|
|
|
|
|
data : function(row, type, set, meta) {
|
|
|
|
|
|
var c = meta.settings._iDisplayStart + meta.row + 1;
|
|
|
|
|
|
return c;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{ "data": "name","defaultContent": ""},
|
|
|
|
|
|
{ "data": "person","defaultContent": ""},
|
|
|
|
|
|
{ "data": "phone","defaultContent": ""},
|
|
|
|
|
|
// {
|
|
|
|
|
|
// "data": "status",
|
|
|
|
|
|
// "defaultContent": "",
|
|
|
|
|
|
// "render": function (data, type, row) {
|
|
|
|
|
|
// return userStatus[data];
|
|
|
|
|
|
// }
|
|
|
|
|
|
// },
|
|
|
|
|
|
{
|
|
|
|
|
|
"data": "",
|
|
|
|
|
|
"defaultContent": "",
|
|
|
|
|
|
"orderable": false,
|
|
|
|
|
|
"render": function (data, type, row) {
|
|
|
|
|
|
var id = row['id'];
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
|
|
html+= buttonView(id, "", pers);
|
|
|
|
|
|
html+= buttonEdits(id, "sys:builder:add", pers);
|
|
|
|
|
|
html+= buttonDel(id,"sys:builder:del",pers);
|
|
|
|
|
|
return html;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
"order": [[ 0, "desc" ],[1, "asc"]] //在栏目列上显示排序功能
|
|
|
|
|
|
} );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 新增页面
|
|
|
|
|
|
* */
|
|
|
|
|
|
function addBuilder() {
|
|
|
|
|
|
var height = '525px';
|
|
|
|
|
|
var width = '975px';
|
|
|
|
|
|
var index = layer.open({
|
|
|
|
|
|
title: ['新增', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|
|
|
|
|
type: 2,
|
|
|
|
|
|
content: 'builderManagerForm.html',
|
|
|
|
|
|
area: [width, height],
|
|
|
|
|
|
maxmin: false,
|
|
|
|
|
|
btn: ['确定', '关闭'],
|
|
|
|
|
|
yes: function (index, layero) {
|
|
|
|
|
|
// 获取弹出层中的form表单元素
|
|
|
|
|
|
var formSubmit = layer.getChildFrame('form', index);
|
|
|
|
|
|
var submited = formSubmit.find('button')[0];
|
|
|
|
|
|
// 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息
|
|
|
|
|
|
submited.click();
|
|
|
|
|
|
example.ajax.reload(); // 刷新页面
|
|
|
|
|
|
},
|
|
|
|
|
|
btn2: function (index, layero) {
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 编辑页面
|
|
|
|
|
|
*/
|
|
|
|
|
|
function edit(id) {
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
type: 'POST',
|
|
|
|
|
|
contentType: "application/x-www-form-urlencoded",
|
|
|
|
|
|
url: ctxPath + '/Builder/getBuilderById',
|
|
|
|
|
|
data: {"id": id},
|
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
|
var height = '525px';
|
|
|
|
|
|
var width = '975px';
|
|
|
|
|
|
var index = layer.open({
|
|
|
|
|
|
title: ['修改', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|
|
|
|
|
type: 2,
|
|
|
|
|
|
content: 'builderManagerForm.html',
|
|
|
|
|
|
area: [width, height],
|
|
|
|
|
|
maxmin: false,
|
|
|
|
|
|
btn: ['确定', '关闭'],
|
|
|
|
|
|
success: function (layero, index) {
|
|
|
|
|
|
var myIframe = window[layero.find('iframe')[0]['name']];
|
|
|
|
|
|
var fnc = myIframe.setData(data); //aaa()为子页面的方法
|
|
|
|
|
|
},
|
|
|
|
|
|
yes: function (index, layero) {
|
|
|
|
|
|
// 获取弹出层中的form表单元素
|
|
|
|
|
|
var formSubmit = layer.getChildFrame('form', index);
|
|
|
|
|
|
var submited = formSubmit.find('button')[0];
|
|
|
|
|
|
// 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息
|
|
|
|
|
|
submited.click();
|
|
|
|
|
|
example.ajax.reload(); // 刷新页面
|
|
|
|
|
|
},
|
|
|
|
|
|
btn2: function (index, layero) {
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查看
|
|
|
|
|
|
* */
|
|
|
|
|
|
|
|
|
|
|
|
function view(id) {
|
|
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
type: 'POST',
|
|
|
|
|
|
contentType: "application/x-www-form-urlencoded",
|
|
|
|
|
|
url: ctxPath + '/Builder/getBuilderById',
|
|
|
|
|
|
data: {"id": id},
|
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
|
var height = '525px';
|
|
|
|
|
|
var width = '975px';
|
|
|
|
|
|
var index = layer.open({
|
|
|
|
|
|
title: ['查看', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|
|
|
|
|
type: 2,
|
|
|
|
|
|
content: 'builderManagerForm.html',
|
|
|
|
|
|
area: [width, height],
|
|
|
|
|
|
maxmin: false,
|
|
|
|
|
|
btn: ['关闭'],
|
|
|
|
|
|
success: function (layero, index) {
|
|
|
|
|
|
var myIframe = window[layero.find('iframe')[0]['name']];
|
|
|
|
|
|
var fnc = myIframe.setData(data); //aaa()为子页面的方法
|
|
|
|
|
|
myIframe.setReadOnly();
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 删除工程
|
|
|
|
|
|
* */
|
|
|
|
|
|
function del(id) {
|
|
|
|
|
|
layer.confirm("确定删除吗?", function () {
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
type: 'delete',
|
|
|
|
|
|
url: ctxPath + '/Builder/' + id,
|
|
|
|
|
|
data: {},
|
|
|
|
|
|
dataType: 'text',
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
|
if (data == 'success') {
|
|
|
|
|
|
layer.alert('删除成功', {icon: 1});
|
|
|
|
|
|
example.ajax.reload(); // 刷新页面
|
|
|
|
|
|
} else {
|
|
|
|
|
|
layer.msg('删除失败', {icon: 2});
|
|
|
|
|
|
example.ajax.reload(); // 刷新页面
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 详情按钮
|
|
|
|
|
|
function buttonView(id, permission, pers) {
|
|
|
|
|
|
if (permission != "") {
|
|
|
|
|
|
if ($.inArray(permission, pers) < 0) {
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
var btn = $("<button class='layui-btn layui-btn-xs' title='详情' onclick='view(\""+id+"\")'><i class='layui-icon'></i></button>");
|
|
|
|
|
|
return btn.prop("outerHTML");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 编辑按钮
|
|
|
|
|
|
function buttonEdits(id, permission, pers) {
|
|
|
|
|
|
if (permission != "") {
|
|
|
|
|
|
if ($.inArray(permission, pers) < 0) {
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
var btn = $("<button class='layui-btn layui-btn-xs' title='编辑' onclick='edit(\"" + id + "\")'><i class='layui-icon'></i></button>");
|
|
|
|
|
|
return btn.prop("outerHTML");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 删除按钮
|
|
|
|
|
|
function buttonDel(data, permission, pers) {
|
|
|
|
|
|
if (permission != "") {
|
|
|
|
|
|
if ($.inArray(permission, pers) < 0) {
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
var btn = $("<button class='layui-btn layui-btn-xs' title='删除' onclick='del(\"" + data + "\")'><i class='layui-icon'></i></button>");
|
|
|
|
|
|
return btn.prop("outerHTML");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|