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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
layui.define([ 'form', 'laydate', 'table' ], function(exports) {
var form = layui.form;
var laydate = layui.laydate;
var table = layui.table;
var budgetDeclaratioTable = null;
var view ={
init:function(){
this.initTable();
this.initSearchForm();
this.initToolBar();
window.dataReload = function(){
Lib.doSearchForm($("#searchForm"),budgetDeclaratioTable)
}
},
initTable:function(){
budgetDeclaratioTable = table.render({
elem : '#budgetDeclaratioTable',
height : Lib.getTableHeight(1),
cellMinWidth: 100,
method : 'post',
url : Common.ctxPath + '/dubget/budgetDeclaratio/list.json?dtype=1' // 数据接口
,page : Lib.tablePage // 开启分页
,limit : 10,
cols : [ [ // 表头
{
type : 'checkbox',
fixed:'left',
width: 40
},
{
field : 'number',
title : '预算编号',
},
{
field : 'typename',
title : '预算类型',
},
{
field : 'name',
title : '名称',
},
{
field : 'budget',
title : '预算金额',
},
{
field : 'user',
title : '申报人员',
},
{
field : 'stateText',
title : '状态',
},
{
field : 'year',
title : '年度',
},
{
field : '',
title : '操作记录',
templet:function(d){
return '<a class="layui-table-link" lay-event="instList">操作记录</a>'
},
},
{
title: '操作',
//rowspan: 2,
align: 'center',
fixed: 'right',
minWidth: '160',
templet: function (d) {
var edit =null;
if (d.state=='-1'||d.state=='0') {
edit= '<button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="dit" title="编辑">编辑</button>'
+'<button class="layui-btn layui-btn-sm layui-btn-warm" lay-event="view" title="查看">查看</button>'
;
}/*else if (d.state=='0') {
edit= '<button class="layui-btn layui-btn-sm layui-btn" lay-event="edit" title="提交">提交</button>';
}else if (d.state=='1') {
edit= '<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="delete" title="取回">取回</button>';
}*/
else {
edit= '<button class="layui-btn layui-btn-sm layui-btn-warm" lay-event="view" title="查看">查看</button>';
}
//var ret;
// ret = edit;
return edit;
}
}
] ],done: function (res, curr, count) {// 表格渲染完成之后的回调
var that = this.elem.next();
res.data.forEach(function (item, index) {
if (item.type == "") {
var tr = that.find(".layui-table-box tbody tr[data-index='" + index + "']");
tr.css("background-color", "red");
tr.css("color", "white");
}
});
}
});
table.on('tool(budgetDeclaratioTable)', function(obj){
var data = obj.data;
//var wagesType = $("input[name='wagesType']").val();
var opinion="";
if(obj.event === 'dit'){
var url = "/dubget/budgetDeclaratio/edit.do?id="+data.id;
Common.openDlg(url,"预算>"+data.type+">编辑");
} else if (obj.event === 'view') {
var url = "/dubget/budgetDeclaratio/view.do?id="+data.id;
Common.openDlg(url,"预算>"+data.type+">查看");
}else if(obj.event === 'instList'){
layer.open({
type: 2,
shade: false,
area: ['1000px', '480px'],
btn: [ '关闭'],
maxmin: true,
title:"操作记录",
content: Common.ctxPath + '/re/record/index.do?relationId='+data.id,
zIndex: layer.zIndex, //重点1
success: function(layero){
layer.setTop(layero); //重点2
}
});
}
/* if(obj.event === 'view'){
$.post(Common.ctxPath+"/dubget/budgetDeclaratio/view.json?id="+data.id,{},function(result){
opinion=result.data.replyOpinion;
var ip='<div class="layui-inline"><label class="layui-form-label">批复人</label><div class="layui-form-mid">'+result.data.replyUser+'</div>'
var is='<div class="layui-inline"><label class="layui-form-label">批复时间</label><div class="layui-form-mid">'+result.data.updateTime+'</div>'
var ada="<div class='layui-form-item'><textarea placeholder='意见' readonly class='layui-textarea'> "+opinion+"</textarea></div><div class='layui-row'>"+ip+is +'</div></form>'
layer.open({
title: '查看'
,type : 2
,content: Common.ctxPath+"/dubget/budgetDeclaratio/view.do?id="+data.id
//,area: ['500px', '400px']
,closeBtn : 2
,anim: 3
,isOutAnim : true
,btn: ['关闭']
}); */
/* dataReload();
layer.close(index);
layer.msg('提交成功');
});
} else if(obj.event === 'delete'){
layer.open({
title: '取回申报'
,content: '是否取回'
, btn: ['是', '否'] //可以无限个按钮
,yes: function(index, layero){
$.post(Common.ctxPath+"/dubget/budgetDeclaratio/state.json?id="+data.id,{state:'0'},function(result){
dataReload();
layer.close(index);
layer.msg('提交成功');
});
}/*, function(index){
}*/
//});
/* }else if(obj.event === 'edit'){
layer.open({
title: '申报提交'
,content: '是否提交'
, btn: ['是', '否'] //可以无限个按钮
,yes: function(index, layero){
$.post(Common.ctxPath+"/dubget/budgetDeclaratio/state.json?id="+data.id,{state:'1'},function(result){
dataReload();
layer.close(index);
layer.msg('提交成功');
});
}
});
}
else if(obj.event === 'delete'){
layer.open({
title: '申报提交'
,content: '是否提取回'
, btn: ['是', '否'] //可以无限个按钮
,yes: function(index, layero){
$.post(Common.ctxPath+"/dubget/budgetDeclaratio/state.json?id="+data.id,{state:'0'},function(result){
dataReload();
layer.close(index);
layer.msg('取回成功');
});
}, function(index){
}
});
}*/
})
},
initSearchForm:function(){
Lib.initSearchForm( $("#searchForm"),budgetDeclaratioTable,form);
},
initToolBar:function(){
toolbar = {
add : function() { // 获取选中数据
var url = "/dubget/budgetDeclaratio/add.do";
Common.openDlg(url,"预算申报管理>新增");
},
edit : function() { // 获取选中数目
var data = Common.getMoreDataFromTable(table,"budgetDeclaratioTable");
var ids="";
for (var i = 0; i < data.length; i++) {
ids=ids+data[i].id+",";
}
layer.open({
title: '申报提交'
,content: '是否提交'
, btn: ['是', '否'] //可以无限个按钮
,yes: function(index, layero){
$.post(Common.ctxPath+"/dubget/budgetDeclaratio/batchOpinion.json",{ids:ids,state:'2',ry:'cwc',opinion:""},function(result){
//opinion=result.data.opinion
dataReload();
layer.close(index);
layer.msg('提交成功成功');
})
}
});
/* var data = Common.getOneFromTable(table,"budgetDeclaratioTable");
if(data==null){
return ;
}
var url = "/dubget/budgetDeclaratio/edit.do?id="+data.id;
Common.openDlg(url,"预算申报管理>"+data.id+">编辑");*/
},
del : function() {
layui.use(['del'], function(){
var delView = layui.del
delView.delBatch();
});
}
,
exportDocument : function() {
layui.use([ 'budgetDeclaratioApi' ], function() {
var budgetDeclaratioApi = layui.budgetDeclaratioApi
Common.openConfirm("确认要导出这些预算申报数据?", function() {
budgetDeclaratioApi.exportExcel($("#searchForm"), function(fileId) {
Lib.download(fileId);
})
})
});
},
};
$('.ext-toolbar').on('click', function() {
var type = $(this).data('type');
toolbar[type] ? toolbar[type].call(this) : '';
});
}
}
exports('index',view);
});