1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
<meta charset="UTF-8">
<title>系统维护-数据字典</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8"/>
@@include('../include/common_css.html')
@@include('../include/common_js.html')
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="x-nav">
<span class="layui-breadcrumb">
<a href="">首页</a>
<a href="">系统维护</a>
<a><cite>数据字典</cite></a>
</span>
<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
onclick="location.reload()" title="刷新">
<i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
<div class="layui-row layui-col-space15">
<div class="layui-col-md12">
<div class="layui-card">
<button style="margin-left: 50px;margin-top: 10px" class="layui-btn layui-btn-mini" lay-event="add" onclick="xadmin.open('添加', './dict-add.html', 500, 400)"><i class="layui-icon"></i>添加</button>
<div class="layui-card-body " style="min-height: 300px">
<table id="ttauditing" lay-filter="survey" style="text-align: center"></table>
</div>
</div>
</div>
</div>
</div>
</body>
<style>
.layui-table-cell {
text-align: center;
}
.layui-table-cell .layui-table-link{
color: #666;
}
#layui-table-page1{
text-align: end;
}
</style>
<script>
layui.use('table', function() {
var table = layui.table;
//第一个实例
table.render({
id:'testReload',
elem: '#ttauditing'
,height:466
,method:"get"
,url:util.interfaceUrl + interfacenName.getDictionary
,limits:[10,20,30]
,headers:{
'Authorization': userToken,
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
},
limit:10,
done: function (res) {
console.log(res);
console.log(res.rows);
},
parseData: function (res) {
console.log(res)
return {
"code": 0, //解析接口状态
"msg": "", //解析提示文本
"count": res.total, //解析数据长度
"data": res.rows
};
}
, contentType: "json"
, request: {
pageName: "page",
limitName: "rows",
},
where:{
sort:"type desc , update_date desc",
}
, edit: "text"
, page: true //开启分页
, cols: [[ //表头
{
field: '', title: '序号', fixed: 'left', width: 145,type:'numbers',
}
, {
field: 'name', title: '名称', width: 235,
templet: function (d) {
return '<div>' + util.dealWithFormatTextByLen(d.name, 20, true) + '</a></div>'
}
}
, {
field: 'type', title: '类型', width: 235,
templet: function (d) {
return '<div>' + util.dealWithFormatTextByLen(d.type, 20, true) + '</a></div>'
}
}
, {
field: 'value', title: '值', width: 235,
templet: function (d) {
return '<div>' + util.dealWithFormatTextByLen(d.value, 20, true) + '</a></div>'
}
}
, {title: '操作',toolbar: '#barDemo', fixed: 'right',minWidth: 235,}
]]
});
var dictName = $('#dicName').val();
var dicType = $('#dicType').val();
var dicNumber = $('#dicNumber').val();
table.on('tool(survey)', function (obj){
var data = obj.data;
console.log(data)
if (obj.event === 'edit') {
console.log(data)
xadmin.open('编辑', './dict-edit.html?name='+data.name+'&&type='+data.type+'&&value='+data.value+'&&businessId='+data.businessId, 500, 400)
}else if (obj.event==='del'){
layer.confirm('是否确定删除?',function (index){
$('body').loading('show')
util.ajax({
url: util.interfaceUrl + interfacenName.getRemove + '/'+ data.businessId,
type: "delete",
success: function (result) {
setTimeout(function () {
$("body").loading('hide');
},1000)
var returnCode=result.code;
if (returnCode==200){
// result('删除成功')
layer.close(index);
location.reload()
} else {
// result('刪除失敗')
layer.close(index);
location.reload()
}
},
error: function (err) {
setTimeout(function () {
$("body").loading('hide');
},1000)
console.log(err)
}
})
})
}
//执行重载
var $=layui.$, active = {
reload: function(){
//执行重载
table.reload('testReload', {
page: {
curr: 1 //重新从第 1 页开始
}
,where: {
name:dictName
}
}, 'data');
}
}
$('.layui-layer-btn0').on('click', function(){
active['reload'] ? active['reload'].call(this) : '';
});
})
});
function refresh() {
location.reload()
}
</script>
<script type="text/html" id="barDemo">
<a class="layui-btn layui-btn-mini" lay-event="edit"><i class="layui-icon"></i>编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del" ><i class="layui-icon"></i> 删除</a>
</script>