Browse Source

费用申请及项目转移模块Bug修复

ly 1 month ago
parent
commit
86e031eaa2

+ 69 - 16
src/main/java/com/liang/controller/StaBudgetapprovalController.java

@@ -21,8 +21,10 @@ import org.springframework.stereotype.Controller;
21 21
 import org.springframework.transaction.annotation.Transactional;
22 22
 import org.springframework.ui.Model;
23 23
 import org.springframework.web.bind.annotation.*;
24
+import springfox.documentation.spring.web.json.Json;
24 25
 
25 26
 import javax.annotation.Resource;
27
+import java.text.SimpleDateFormat;
26 28
 import java.time.Period;
27 29
 import java.util.*;
28 30
 
@@ -317,20 +319,25 @@ public class StaBudgetapprovalController extends BaseController {
317 319
             for (int i = 0;i<accounts.size();i++){
318 320
                 if (accounts.get(i).getUserPostName().equals("科研专责")){
319 321
                     PrjProject project = prjProjectDao.queryById(budgetapproval.getXmid());
320
-                    budgetapproval.setSqrxm(getSysUserInfo().getName());
321
-                    budgetapproval.setSqr(getSysUserId());
322
-                    budgetapproval.setSfth(0);
323
-                    budgetapproval.setSfbz(false);
324
-                    budgetapproval.setSsbm(project.getSsbm());
325
-                    budgetapproval.setSsbmmc(project.getSsbmmc());
326
-                    budgetapproval.setErpbh(project.getErpbh());
327
-                    budgetapproval.setXmlx(project.getXmlx());
328
-                    budgetapproval.setXmlxmc(project.getXmlxmc());
329
-                    budgetapproval.setDkyfzr(String.valueOf(project.getDkyfzr()));
330
-                    int num = staBudgetapprovalService.insert(budgetapproval);
331
-                    if (num > 0) {
332
-                        a = 0;
333
-                        break;
322
+                    if(project != null){
323
+                        budgetapproval.setSqrxm(getSysUserInfo().getName());
324
+                        budgetapproval.setSqr(getSysUserId());
325
+                        budgetapproval.setSfth(0);
326
+                        budgetapproval.setSfbz(false);
327
+                        budgetapproval.setSsbm(project.getSsbm());
328
+                        budgetapproval.setSsbmmc(project.getSsbmmc());
329
+                        budgetapproval.setErpbh(project.getErpbh());
330
+                        budgetapproval.setXmlx(project.getXmlx());
331
+                        budgetapproval.setXmlxmc(project.getXmlxmc());
332
+                        budgetapproval.setDkyfzr(String.valueOf(project.getDkyfzr()));
333
+                        int num = staBudgetapprovalService.insert(budgetapproval);
334
+                        if (num > 0) {
335
+                            a = 0;
336
+                            break;
337
+                        }
338
+
339
+                    }else {
340
+                        return BaseResult.failure(-1,"项目数据为空,费用申请失败!");
334 341
                     }
335 342
                 }
336 343
                 a++;
@@ -2056,11 +2063,57 @@ public class StaBudgetapprovalController extends BaseController {
2056 2063
     @ApiOperation(value = "页面初始化", notes = "页面初始化")
2057 2064
     @RequestMapping(value = "/updateSsbm", method = RequestMethod.GET)
2058 2065
     public String updateSsbm(Model model ,@RequestParam Integer id){
2066
+        model.addAttribute("dept",sysDeptInfoService.list());
2067
+        if (id != null ){
2068
+            StaBudgetapproval staBudgetapproval =  staBudgetapprovalService.queryById(id);
2069
+            model.addAttribute("sta",staBudgetapproval);
2070
+            return "stabudgetapproval/bmbg";
2071
+        }else {
2072
+            return "数据异常,请联系管理员";
2073
+        }
2074
+    }
2075
+
2076
+    @ResponseBody
2077
+    @RequestMapping(value = "bgbm",method = RequestMethod.POST)
2078
+    public BaseResult bgbm(@RequestBody String formData){
2079
+
2080
+        StaBudgetapproval sta = JsonTool.parseObject(formData,StaBudgetapproval.class);
2081
+        StaBudgetapproval staBudgetapproval = staBudgetapprovalService.queryById(sta.getId());
2082
+        // 增加审批列表留痕选项
2083
+        // 获取当前系统时间
2084
+        Date data = new Date();
2085
+        // 转换时间格式
2086
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
2087
+        // 审批列表记录
2088
+        PrjApproverecord prjApproverecord = new PrjApproverecord();
2089
+        prjApproverecord.setTablename("sta_BudgetApproval");
2090
+        prjApproverecord.setXmid(staBudgetapproval.getXmid());
2091
+        prjApproverecord.setYj( "项目名称:"+staBudgetapproval.getXmmc()+",ERP编号:"+staBudgetapproval.getErpbh()+","+"'部门'从'"+
2092
+                staBudgetapproval.getSsbmmc()+"'转移至'"+sta.getSsbmmc()+","+
2093
+                ",操作员:"+
2094
+                sysUserInfoService.queryById(getSysUserId()).getName());
2095
+        prjApproverecord.setSfsjsh(true);
2096
+        prjApproverecord.setSjshr(getSysUserId());
2097
+        prjApproverecord.setShsj(format.format(data));
2098
+        prjApproverecord.setTjsj(format.format(data));
2099
+        prjApproverecord.setTjr(getSysUserId());
2100
+        prjApproverecord.setShr(getSysUserId());
2101
+        prjApproverecord.setSpcz("项目转移");
2102
+        prjApproverecord.setXm(staBudgetapproval.getXmmc());
2103
+        prjApproverecord.setZt("已完成");
2104
+        prjApproverecord.setWc(true);
2105
+        if (staBudgetapproval != null){
2106
+            staBudgetapproval.setSsbm(staBudgetapproval.getSsbm());
2107
+            int num = staBudgetapprovalService.update(staBudgetapproval);
2108
+            if (num > 0){
2109
+                int muns = prjApproverecordService.insert(prjApproverecord);
2110
+                return  BaseResult.success("'"+staBudgetapproval.getErpbh()+"'部门转移成功!");
2059 2111
 
2112
+            }
2113
+        }
2114
+            return BaseResult.failure(-1, "数据转移失败!");
2060 2115
 
2061
-        return "prjproject/updatessbm";
2062 2116
     }
2063 2117
 
2064
-
2065 2118
 }
2066 2119
 

+ 5 - 1
src/main/resources/mapper/StaBudgetapprovalDao.xml

@@ -41,13 +41,15 @@
41 41
         <result property="zbzje" column="ZBZJE" jdbcType="NUMERIC"/>
42 42
         <result property="sfth" column="SFTH" jdbcType="INTEGER"/>
43 43
         <result property="sl" column="SL" jdbcType="VARCHAR"/>
44
+        <result property="ssbmmc" column="SSBMMC" jdbcType="VARCHAR"/>
44 45
     </resultMap>
45 46
 
46 47
     <!--查询单个-->
47 48
     <select id="queryById" resultMap="StaBudgetapprovalMap">
48
-        select b.*, d.YSJE
49
+        select b.*, d.YSJE,c.dept_name as SSBMMC
49 50
         from sta_BudgetApproval b
50 51
                  left join prj_AnnualBudgetDetail d on d.NYS = b.NYS and d.ID = b.FYLB
52
+        left join sys_dept_info c on b.SSBM = c.dept_id
51 53
         where b.ID = #{id}
52 54
     </select>
53 55
 
@@ -344,7 +346,9 @@
344 346
             ,SQSM = #{sqsm}
345 347
             ,BZJE = #{bzje}
346 348
             ,BHSJE = #{bhsje}
349
+          <if test="sfbz != null">
347 350
             ,SFBZ = #{sfbz}
351
+          </if>
348 352
             ,SF = #{sf}
349 353
         where ID = #{id}
350 354
     </update>

+ 2 - 4
src/main/resources/templates/annualbudget/list.html

@@ -175,8 +175,6 @@
175 175
         });
176 176
     });
177 177
 </script>
178
-
179
-
180 178
 <script th:src="@{/lib/jquery-3.4.1/jquery-3.4.1.min.js}" charset="utf-8"></script>
181 179
 <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
182 180
 <script th:src="@{/lib/coco-message/coco-message.js}" charset="utf-8"></script>
@@ -255,8 +253,8 @@
255 253
             // defaultToolbar: ['filter', 'print'],
256 254
             cols: [
257 255
                 [
258
-                    {type: "radio", fixed: 'left'},
259
-                    {type: 'numbers', align: 'center',title: '😊'},
256
+                    {type: "radio", fixed: 'left',title: '😊'},
257
+                    {type: 'numbers', align: 'center',title: '序号'},
260 258
                     {field: 'spzt', width: '7%', title: '审批状态'},
261 259
                     {field: 'xmmc', width: '20%', title: '项目名称'},
262 260
                     {field: 'rwsmc', width: '20%', title: '任务书名称'},

+ 274 - 0
src/main/resources/templates/stabudgetapproval/bmbg.html

@@ -0,0 +1,274 @@
1
+<!DOCTYPE html>
2
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
3
+<head>
4
+    <meta charset="UTF-8">
5
+    <title>项目转移</title>
6
+    <link rel="stylesheet" th:href="@{/lib/layui/css/layui.css}" media="all">
7
+    <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
8
+    <link rel="stylesheet" th:href="@{/lib/font-awesome-4.7.0/css/font-awesome.min.css}" media="all">
9
+    <style>
10
+        body {
11
+            display: flex;
12
+            justify-content: space-between;
13
+            align-items: center;
14
+            height: 100vh;
15
+            margin: 0;
16
+        }
17
+
18
+        .left-section,
19
+        .right-section {
20
+            width: 50%;
21
+            height: 100%;
22
+            border: 1.5px solid dimgrey;
23
+            position: relative; /* 添加这一行,使其成为定位参考 */
24
+        }
25
+        h2 {
26
+            text-align: center;
27
+            margin-top: 10%;
28
+            color: #0C0C0C;
29
+        }
30
+
31
+        .layui-form-item {
32
+            margin-bottom: 15px; /* 控制每个表单项之间的间距 */
33
+        }
34
+
35
+        .right-bottom-btn {
36
+            position: absolute;
37
+            bottom: 20px; /* 距离底部20px */
38
+            right: 20px; /* 距离右边20px */
39
+        }
40
+        /* 可根据需要自定义样式和布局 */
41
+
42
+        .left-section .layui-form{
43
+            margin-top: 10%;
44
+        }
45
+        .right-section .layui-form {
46
+            margin-top: 10%;
47
+        }
48
+    </style>
49
+</head>
50
+<body>
51
+<div class="left-section">
52
+    <!-- 左侧内容 -->
53
+    <h2>转移前</h2>
54
+
55
+    <div class="layui-form layuimini-form">
56
+        <div class="layui-form-item layui-inline" style="width: 100%">
57
+            <label class="layui-form-label required" style="width: 17%">项目名称</label>
58
+            <div class="layui-input-inline" style="width: 70%">
59
+                <input type="text" class="layui-input" th:value="${sta.xmmc}" disabled>
60
+            </div>
61
+        </div>
62
+        <div class="layui-form-item layui-inline" style="width: 100%">
63
+            <label class="layui-form-label" style="width: 17%">ERP编号</label>
64
+            <div class="layui-input-inline" style="width: 70%">
65
+                <input type="text"  class="layui-input" th:value="${sta.erpbh}" disabled>
66
+            </div>
67
+        </div>
68
+
69
+        <div class="layui-form-item layui-inline" style="width: 100%">
70
+            <label class="layui-form-label" style="width: 17%">所属部门</label>
71
+            <div class="layui-input-inline" style="width: 70%">
72
+                <input type="text"  class="layui-input" th:value="${sta.ssbmmc}" disabled>
73
+            </div>
74
+        </div>
75
+
76
+      <!--  <div class="layui-form-item layui-inline" style="width: 100%">
77
+            <label class="layui-form-label" style="width: 17%">电科院负责人</label>
78
+            <div class="layui-input-inline" style="width: 70%">
79
+                <input type="text"  class="layui-input" th:value="${project.dkyfzrxm}" disabled>
80
+            </div>
81
+        </div>
82
+        <div class="layui-form-item layui-inline" style="width: 100%">
83
+            <label class="layui-form-label" style="width: 17%">申请人</label>
84
+            <div class="layui-input-inline" style="width: 70%">
85
+                <input type="text" class="layui-input"  th:value="${project.cjrxm}" disabled>
86
+            </div>
87
+        </div>-->
88
+    </div>
89
+
90
+</div>
91
+
92
+<div class="right-section">
93
+    <!-- 右侧内容 -->
94
+    <h2>转移后</h2>
95
+    <div class="layui-form layuimini-form">
96
+        <div class="layui-form-item layui-inline" style="width: 100%">
97
+            <label class="layui-form-label required" style="width: 17%">项目名称</label>
98
+            <div class="layui-input-inline" style="width: 70%">
99
+                <input type="text" id="xmmc" name="xmmc" class="layui-input" th:value="${sta.xmmc}" disabled>
100
+                <input type="hidden" id="id" name="id" class="layui-input" th:value="${sta.id}">
101
+            </div>
102
+        </div>
103
+        <div class="layui-form-item layui-inline" style="width: 100%">
104
+            <label class="layui-form-label" style="width: 17%">ERP编号</label>
105
+            <div class="layui-input-inline" style="width: 70%">
106
+                <input type="text" id="erpbh" name="erpbh" class="layui-input" th:value="${sta.erpbh}" disabled>
107
+            </div>
108
+        </div>
109
+
110
+        <div class="layui-form-item layui-inline" style="width: 100%">
111
+            <label class="layui-form-label" style="width: 17%">所属部门<span style="color: red;">*</span></label>
112
+            <div class="layui-input-inline" style="width: 70%">
113
+                <input type="hidden" id="ssbm" name="ssbm" class="layui-input">
114
+                <!-- 设置一个下拉框 -->
115
+                <select name="ssbmmc" id="ssbmmc"  lay-search>
116
+                    <option value="">请选择</option>
117
+                    <option th:each="item:${dept}" th:text="${item.deptName}" th:value="${item.deptId}"></option>
118
+                </select>
119
+            </div>
120
+        </div>
121
+
122
+     <!--   <div class="layui-form-item layui-inline" style="width: 100%">
123
+            <label class="layui-form-label" style="width: 17%">电科院负责人<span style="color: red;">*</span></label>
124
+            <div class="layui-input-inline" style="width: 70%">
125
+                <input type="hidden" id="dkyfzr" name="dkyfzr" class="layui-input">
126
+                <input type="text" id = 'dkyfzrxm' name="dkyfzrxm" class="layui-input">
127
+            </div>
128
+        </div>
129
+        <div class="layui-form-item layui-inline" style="width: 100%">
130
+            <label class="layui-form-label" style="width: 17%">申请人<span style="color: red;">*</span></label>
131
+            <div class="layui-input-inline" style="width: 70%">
132
+                <input type="hidden" id="sqr" name="sqr" class="layui-input">
133
+                <input type="text" id = 'sqrxm' name="sqrxm" class="layui-input">
134
+
135
+            </div>
136
+        </div>-->
137
+    </div>
138
+
139
+    <!-- 右侧悬浮按钮 -->
140
+    <div class="right-bottom-btn">
141
+        <button class="layui-btn"  lay-filter="saveBtn">
142
+            <i class="layui-icon layui-icon-ok"></i>确定
143
+        </button>
144
+        <button class="layui-btn" lay-filter="cancleBtn">
145
+            <i class="layui-icon layui-icon-close"></i>取消
146
+        </button>
147
+    </div>
148
+
149
+</div>
150
+<script th:src="@{/lib/jquery-3.4.1/jquery-3.4.1.min.js}" charset="utf-8"></script>
151
+<script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
152
+<script th:src="@{/lib/coco-message/coco-message.js}" charset="utf-8"></script>
153
+<script th:src="@{/lib/xm-select-v1.2.2/xm-select.js}" charset="utf-8"></script>
154
+<script th:src="@{/js/lay-config.js}" charset="utf-8"></script>
155
+<script type="text/javascript" th:inline="javascript">
156
+    AjaxUtil.ctx = /*[[@{/}]]*/'';
157
+    var updateflag = 0;
158
+    var xmApproval = {};
159
+    // 初始化 LayUI
160
+    layui.use(['form','table','tableSelect'], function () {
161
+        var form = layui.form,
162
+            layer = layui.layer,
163
+            tableSelect = layui.tableSelect,
164
+            table = layui.table;
165
+        //获取创建人
166
+        tableSelect.render({
167
+            elem: '#sqrxm',
168
+            checkedKey: 'userid',
169
+            searchKey: 'name',
170
+            searchPlaceholder: '搜索申请人',
171
+            table:{
172
+                url:AjaxUtil.ctx+'prjContract/cjr',
173
+                cols:[
174
+                    [
175
+                        {type:'radio',title:'😊',width: '7%'},
176
+                        {type: 'numbers',title: '序号',align: 'center',width: '10%'},
177
+                        {field:'name',title: '姓名',align: 'center',width:'30%'},
178
+                        {field: 'deptName',title: '部门',align: 'left',width: '50%'}
179
+                    ]
180
+                ]
181
+            },
182
+            done: function (elem, data) {
183
+                var NEWJSON = [];
184
+                var NEWJSON1 = [];
185
+                layui.each(data.data, function (index, item) {
186
+                    NEWJSON.push(item.name);
187
+                    NEWJSON1.push(item.userId);
188
+                });
189
+                elem.val(NEWJSON.join(","));
190
+                $("#sqr").val(NEWJSON1.join(","));
191
+
192
+            }
193
+        });
194
+        // 获取电科院负责人
195
+        tableSelect.render({
196
+            elem: '#dkyfzrxm',
197
+            checkedKey: 'id',
198
+            searchKey: 'xm',
199
+            searchPlaceholder: '搜索电科院负责人',
200
+            table:{
201
+                url:AjaxUtil.ctx +'prjContract/dkyfzr',
202
+                cols: [
203
+                    [
204
+                        {type:'radio',title:'😊',width:'7%'},
205
+                        {type: 'numbers',title: '序号',align:'center',width: '10%'},
206
+                        {field: 'xm',title: '姓名',align: 'center',width: '30%'},
207
+                        {field: 'bmmc',title: '部门',align: 'left',width: '50%'}
208
+
209
+                    ]
210
+                ]
211
+            },
212
+            done: function (elem,data) {
213
+                var NEWJSON = [];
214
+                var NEWJSON1 = [];
215
+                layui.each(data.data, function (index, item) {
216
+                    NEWJSON.push(item.xm);
217
+                    NEWJSON1.push(item.id);
218
+                });
219
+                elem.val(NEWJSON.join(","));
220
+                $('#dkyfzr').val(NEWJSON1.join(","));
221
+
222
+            }
223
+        });
224
+
225
+        $("button[lay-filter='saveBtn']").click(function (data) {
226
+            // 提交表单元素
227
+            // 将表单元素提交至后台
228
+            // 获取表单的数据
229
+            // 创建一个集合
230
+            var formData = {
231
+                'id': document.getElementById('id').value
232
+                ,'xmmc': $('#xmmc').val()
233
+                ,'erpbh':$('#erpbh').val()
234
+                ,'dkyfzr':$('#dkyfzr').val()
235
+                ,'dkyfzrxm':$('#dkyfzrxm').val()
236
+                ,'ssbm':$('#ssbm').val()
237
+                ,'ssbmmc':$('#ssbmmc').val()
238
+                ,'sqr':$('#sqr').val()
239
+                ,'sqrxm':$('#sqrxm').val()
240
+            }
241
+            // 将对象转换为 JSON 字符串
242
+            AjaxUtil.post({
243
+                url: AjaxUtil.ctx + 'staBudgetapproval/bgbm',
244
+                contentType: "application/json",
245
+                data: JSON.stringify(formData),
246
+                success: function (res) {
247
+                    if (res.code === 0) {
248
+                        layer.msg(res.message,{icon: 1}, function (){
249
+                            setTimeout(function () {
250
+                                var index = parent.layer.getFrameIndex(window.name);
251
+                                parent.layer.close(index);
252
+                            },1000);
253
+
254
+                        });
255
+                        // 获取弹框 并关闭弹
256
+                    }else {
257
+                        layer.msg(res.message,{ icon:2 });
258
+                    }
259
+                },
260
+                error: function (error) {
261
+                    layer.msg("请求出错,请稍后重试!", { icon: 2 }); // 处理 Ajax 错误
262
+                }
263
+            });
264
+        });
265
+        // 监听取消按钮
266
+        $("button[lay-filter='cancleBtn']").click(function () {
267
+            var iframeIndex = parent.layer.getFrameIndex(window.name);
268
+            parent.layer.close(iframeIndex);
269
+        });
270
+    });
271
+
272
+</script>
273
+</body>
274
+</html>

+ 101 - 134
src/main/resources/templates/stafeemanage/list_allapply.html

@@ -7,33 +7,6 @@
7 7
     <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
8 8
     <link rel="stylesheet" th:href="@{/lib/font-awesome-4.7.0/css/font-awesome.min.css}"
9 9
           media="all">
10
-    <!--<style>
11
-        .layui-form-item {
12
-            margin-bottom: 10px; /* 调整每个表单项之间的间距 */
13
-        }
14
-
15
-        .layui-inline {
16
-            display: inline-block;
17
-            margin-bottom: 10px; /* 调整每行表单项之间的间距 */
18
-        }
19
-
20
-        .layui-form-label {
21
-            width: 70px;
22
-            text-align: right; /* 标签右对齐 */
23
-            margin-right: 10px; /* 调整标签和输入框之间的距离 */
24
-        }
25
-
26
-        .layui-input-inline {
27
-            width: 140px;
28
-            margin-right: 10px; /* 调整输入框之间的距离 */
29
-        }
30
-        /* 设置表格单元格的行高 */
31
-        #currentTableId td, #currentTableId th {
32
-            line-height: 120px; /* 根据需要调整此值 */
33
-        }
34
-
35
-    </style>-->
36
-
37 10
 </head>
38 11
 <body>
39 12
 <div class="layuimini-container">
@@ -85,13 +58,11 @@
85 58
                         <div class="layui-inline">
86 59
                             <label class="layui-form-label" style="width: 60px">费用类别</label>
87 60
                             <div class="layui-input-inline" style="width: 200px">
88
-                                <!--<input type="text" id="fylb" name="fylb" autocomplete="off" class="layui-input">-->
89 61
                                 <select name="fylb" id="fylb" lay-filter="status" lay-search>
90 62
                                     <option value="">全部</option>
91 63
                                     <option th:each="item:${fylb}" th:text="${item.fymc}"
92 64
                                             th:value="${item.fymc}"></option>
93 65
                                 </select>
94
-
95 66
                             </div>
96 67
                         </div>
97 68
                         <div class="layui-inline">
@@ -120,12 +91,6 @@
120 91
                             </div>
121 92
                         </div>
122 93
                         <br>
123
-<!--                        <div class="layui-inline">
124
-                            <label class="layui-form-label" style="width: 60px">所属部门</label>
125
-                            <div class="layui-input-inline" style="width: 200px">
126
-                                <input type="text" id="ssbmmc" name="ssbmmc" autocomplete="off" class="layui-input">
127
-                            </div>
128
-                        </div>-->
129 94
                         <div class="layui-inline">
130 95
                             <label class="layui-form-label" style="width: 60px">所属部门</label>
131 96
                             <div class="layui-input-inline" style="width: 200px;">
@@ -189,8 +154,30 @@
189 154
             </div>
190 155
         </fieldset>
191 156
 
157
+        <script type="text/html" id="toolbarDemo">
158
+            <div class="layui-btn-container" style="display: flex;">
159
+                <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="view">
160
+                    <i class="layui-icon layui-icon-file" style="font-size: 10px;"></i>查看
161
+                </button>
162
+                <button class="layui-btn layui-btn-sm data-add-btn" lay-event="tjrevokeApprove">
163
+                    <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>撤销审批
164
+                </button>
165
+                <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="spOption">
166
+                    <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>审核
167
+                </button>
168
+                <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="spList">
169
+                    <i class="layui-icon layui-icon-list" style="font-size: 10px;"></i>审批列表
170
+                </button>
171
+                <button class="layui-btn layui-btn-sm" lay-event="export" style="background-color: black">
172
+                    <i class="layui-icon layui-icon-export" style="font-size: 10px;"></i>导出列表
173
+                </button>
174
+                <button class="layui-btn layui-btn-sm layui-btn-checked" lay-event="xmzy" id="zy" style="display: none">
175
+                    <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>项目转移
176
+                </button>
177
+            </div>
178
+        </script>
192 179
         <input type="hidden" id="userId" name="userId" class="layui-input" th:value="${userId}">
193
-        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter" ></table>
180
+        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
194 181
     </div>
195 182
 </div>
196 183
 <script>
@@ -209,28 +196,6 @@
209 196
         });
210 197
     });
211 198
 </script>
212
-<script type="text/html" id="toolbarDemo">
213
-    <div class="layui-btn-container" style="display: flex;">
214
-        <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="view">
215
-            <i class="layui-icon layui-icon-file" style="font-size: 10px;"></i>查看
216
-        </button>
217
-        <button class="layui-btn layui-btn-sm data-add-btn" lay-event="tjrevokeApprove">
218
-            <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>撤销审批
219
-        </button>
220
-        <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="spOption">
221
-            <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>审核
222
-        </button>
223
-        <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="spList">
224
-            <i class="layui-icon layui-icon-list" style="font-size: 10px;"></i>审批列表
225
-        </button>
226
-        <button class="layui-btn layui-btn-sm" lay-event="export" style="background-color: black">
227
-            <i class="layui-icon layui-icon-export" style="font-size: 10px;"></i>导出列表
228
-        </button>
229
-        <button class="layui-btn layui-btn-sm layui-btn-checked" lay-event="xmzy" id="zy" style="display: none">
230
-            <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>项目转移
231
-        </button>
232
-    </div>
233
-</script>
234 199
 <script>
235 200
     // 当文档加载完成后执行以下操作
236 201
     document.addEventListener('DOMContentLoaded', function() {
@@ -355,8 +320,8 @@
355 320
                 url: AjaxUtil.ctx + 'basePerson/rylist',
356 321
                 cols: [
357 322
                     [
358
-                        {type: "checkbox", fixed: 'left',title: '😊'},
359
-                        {type: 'numbers', align: 'center',title: '序号'},
323
+                        {type: "checkbox", fixed: 'left', title: '😊'},
324
+                        {type: 'numbers', align: 'center', title: '序号'},
360 325
                         {field: 'xm', width: '15%', title: '姓名', align: 'left'},
361 326
                         {field: 'dwmc', title: '公司/单位', align: 'left'}
362 327
                     ]
@@ -376,17 +341,18 @@
376 341
         var getYear = document.getElementById('nf').value;
377 342
         var currTable = table.render({
378 343
             elem: '#currentTableId',
379
-            url: AjaxUtil.ctx + 'staBudgetapproval/list_allApply/?nf='+getYear,
344
+            url: AjaxUtil.ctx + 'staBudgetapproval/list_allApply/?nf=' + getYear,
380 345
             method: 'post',
381 346
             toolbar: '#toolbarDemo',
382 347
             // defaultToolbar: ['filter', 'print'],
383 348
             cols: [
384 349
                 [
385
-                    {type: "radio", fixed: true,title: '😊'},
386
-                    {type: 'numbers', fixed: true,title: '序号'},
350
+                    {type: "radio", title: '😊'},
351
+                    {type: 'numbers', title: '序号'},
387 352
                     {field: 'xmmc', width: '15%', title: '项目名称'},
388 353
                     {field: 'erpbh', width: '9%', title: 'ERP编号'},
389
-                    {field: 'sfbyj', width: '8%', title: '是否备用金', align: 'center', templet: function (d) {
354
+                    {
355
+                        field: 'sfbyj', width: '8%', title: '是否备用金', align: 'center', templet: function (d) {
390 356
                             if (1 == d.sfbyj) {
391 357
                                 return '<span class="layui-badge layui-bg-blue">是</span>';
392 358
                             } else {
@@ -427,15 +393,15 @@
427 393
                 if (res.data && Array.isArray(res.data)) {
428 394
                     for (let i = 0; i < res.data.length; i++) {
429 395
                         console.log(res.data[i]);
430
-                        if (res.data[i].sfth==1){
431
-                            const Index = i ;
396
+                        if (res.data[i].sfth == 1) {
397
+                            const Index = i;
432 398
                             $(`.layui-table tr[data-index="${Index}"]`).css('background-color', '#ADD8E6');
433 399
                         }
434 400
                     }
435 401
                 }
436 402
                 console.log(userId);
437
-                if(userId == 1 || userId == 42){/*
438
-                    $('#zy').css('display', 'block');*/
403
+                if (userId == 1 || userId == 42) {
404
+                    $('#zy').css('display', 'block');
439 405
                 }
440 406
             }
441 407
         });
@@ -524,7 +490,7 @@
524 490
                         maxmin: true,
525 491
                         shadeClose: true,
526 492
                         area: ['1020px', layerheight + 'px'],
527
-                        content: AjaxUtil.ctx + 'staBudgetapproval/forApplyUpdate/' + data[0].id+'?fylbmc='+data[0].fylbmc,
493
+                        content: AjaxUtil.ctx + 'staBudgetapproval/forApplyUpdate/' + data[0].id + '?fylbmc=' + data[0].fylbmc,
528 494
                         end: function (index) {
529 495
                             if (updateflag == 1)
530 496
                                 currTable.reload();
@@ -547,7 +513,7 @@
547 513
                 } else {
548 514
                     var title = '浏览费用申请';
549 515
                     var width = '1020px';
550
-                    var content = AjaxUtil.ctx + 'staBudgetapproval/forApplyView/' + data[0].id+'?fylbmc='+data[0].fylbmc;
516
+                    var content = AjaxUtil.ctx + 'staBudgetapproval/forApplyView/' + data[0].id + '?fylbmc=' + data[0].fylbmc;
551 517
                     if (data[0].sfbyj == 1) {
552 518
                         title = '浏览备用金申请';
553 519
                         if (data[0].fylbmc == null) {
@@ -825,7 +791,7 @@
825 791
                     Message.warning("请选择一条记录进行撤销!", 1500);
826 792
                 } else if (data[0].spzt == "审批结束") {
827 793
                     Message.warning("该费用申请已审批结束!", 1500);
828
-                }else if(data[0].spzt == "未提交"|| data[0].spzt == "未提交(返回)"){
794
+                } else if (data[0].spzt == "未提交" || data[0].spzt == "未提交(返回)") {
829 795
                     Message.warning("该费用申请还未提交审批!", 1500);
830 796
                 }
831 797
                     // else if (data[0].cjr != userId) {
@@ -865,43 +831,43 @@
865 831
                         });
866 832
                     });
867 833
                 }
868
-            }else if (obj.event === 'export'){
834
+            } else if (obj.event === 'export') {
869 835
 
870 836
                 var formData = form.val('search-form');
871 837
                 // 获取form 表单代码
872 838
                 console.log(formData);
873 839
                 var formDataString = JSON.stringify(formData);
874 840
                 AjaxUtil.post({
875
-                    url:AjaxUtil.ctx +'staBudgetapproval/getAll/'+formDataString,
841
+                    url: AjaxUtil.ctx + 'staBudgetapproval/getAll/' + formDataString,
876 842
                     contentType: "application/json",
877 843
                     timeout: 15000, //大批量导出时会出现超时问题
878
-                    success: function(res){
844
+                    success: function (res) {
879 845
                         console.log(res);
880
-                        table.exportFile('currentTableId',res.data,'xlsx');
846
+                        table.exportFile('currentTableId', res.data, 'xlsx');
881 847
                     },
882
-                    error:function (error) {
883
-                        Message.error(error,2000)
848
+                    error: function (error) {
849
+                        Message.error(error, 2000)
884 850
 
885 851
                     }
886 852
                 });
887 853
 
888 854
 
889
-            }else if (obj.event === 'xmzy'){
855
+            } else if (obj.event === 'xmzy') {
890 856
                 var project = table.cache['currentTableId'];//  绑定表格元素 cache 表示缓存的意思
891 857
                 // 判断缓存是否为空
892
-                if(project.length == 0){
858
+                if (project.length == 0) {
893 859
                     return;
894 860
                 }
895 861
                 // 获取table 中 缓存的数据
896
-                var checkStatus =  table.checkStatus('currentTableId')
897
-                    ,data = checkStatus.data;
898
-                if (data == null || data.length === 0){
899
-                    layer.msg('请选择要转移的项目',{icon: 3});
900
-                }else if (data.length > 1){
901
-                    layer.msg('请选择一条项目进项转移',{icon:3});
902
-                }else if (data[0].spzt != '审批结束'){
903
-                    layer.msg('"'+data[0].sqmc+'"未审批结束,不能转移',{icon:3});
904
-                }else {
862
+                var checkStatus = table.checkStatus('currentTableId')
863
+                    , data = checkStatus.data;
864
+                if (data == null || data.length === 0) {
865
+                    layer.msg('请选择要转移的项目', {icon: 3});
866
+                } else if (data.length > 1) {
867
+                    layer.msg('请选择一条项目进项转移', {icon: 3});
868
+                } else if (data[0].spzt != '审批结束') {
869
+                    layer.msg('"' + data[0].sqmc + '"未审批结束,不能转移', {icon: 3});
870
+                } else {
905 871
                     layer.open({
906 872
                         title: '项目转移',
907 873
                         type: 2,
@@ -909,7 +875,7 @@
909 875
                         maxmin: true,
910 876
                         shadeClose: true,
911 877
                         area: ['1090px', layerheight + 'px'],
912
-                        content: AjaxUtil.ctx + 'staBudgetapproval/updateSsbm/' + data[0].id,
878
+                        content: AjaxUtil.ctx + 'staBudgetapproval/updateSsbm?id=' + data[0].id,
913 879
                         success: function (layero, index) {
914 880
                         },
915 881
                         end: function (index) {
@@ -923,57 +889,58 @@
923 889
             }
924 890
         });
925 891
 
926
-        //双击
927
-        table.on('rowDouble(currentTableFilter)', function (obj) {
928
-            var data = obj.data;
929
-            var title = '浏览费用申请';
930
-            var width = '1020px';
931
-            var content = AjaxUtil.ctx + 'staBudgetapproval/forApplyView/' + data.id;
932
-            if (data.sfbyj == 1) {
933
-                title = '浏览备用金申请';
934
-                if (data.fylbmc == null) {
935
-                    width = layerwidth + 'px';
936
-                    content = AjaxUtil.ctx + 'staBudgetapproval/forImprestView/' + data.id;
937
-                }
938
-            }
939
-            layer.open({
940
-                title: title,
941
-                type: 2,
942
-                shade: 0.3,
943
-                maxmin: true,
944
-                shadeClose: true,
945
-                area: [width, layerheight + 'px'],
946
-                content: content,
947
-                end: function (index) {
948
-                    layer.close(index);
892
+            //双击
893
+            table.on('rowDouble(currentTableFilter)', function (obj) {
894
+                var data = obj.data;
895
+                var title = '浏览费用申请';
896
+                var width = '1020px';
897
+                var content = AjaxUtil.ctx + 'staBudgetapproval/forApplyView/' + data.id;
898
+                if (data.sfbyj == 1) {
899
+                    title = '浏览备用金申请';
900
+                    if (data.fylbmc == null) {
901
+                        width = layerwidth + 'px';
902
+                        content = AjaxUtil.ctx + 'staBudgetapproval/forImprestView/' + data.id;
903
+                    }
949 904
                 }
905
+                layer.open({
906
+                    title: title,
907
+                    type: 2,
908
+                    shade: 0.3,
909
+                    maxmin: true,
910
+                    shadeClose: true,
911
+                    area: [width, layerheight + 'px'],
912
+                    content: content,
913
+                    end: function (index) {
914
+                        layer.close(index);
915
+                    }
916
+                });
950 917
             });
951 918
         });
952
-    });
953 919
 
954
-    function setUpdateFlag() {
955
-        updateflag = 1;
956
-    }
957
-
958
-    function getXmApproval() {
959
-        return xmApproval;
960
-    }
961
-
962
-    function arrayToTree(data, firstPid) {
963
-        const result = [];
964
-        getChildren(data, result, firstPid)
965
-        return result;
966
-    }
967
-
968
-    function getChildren(data, result, parentId) {
969
-        for (const item of data) {
970
-            if (item.parentId === parentId) {
971
-                const newItem = {...item, children: []};
972
-                result.push(newItem);
973
-                getChildren(data, newItem.children, item.deptId);
920
+        function setUpdateFlag() {
921
+            updateflag = 1;
922
+        }
923
+
924
+        function getXmApproval() {
925
+            return xmApproval;
926
+        }
927
+
928
+        function arrayToTree(data, firstPid) {
929
+            const result = [];
930
+            getChildren(data, result, firstPid)
931
+            return result;
932
+        }
933
+
934
+        function getChildren(data, result, parentId) {
935
+            for (const item of data) {
936
+                if (item.parentId === parentId) {
937
+                    const newItem = {...item, children: []};
938
+                    result.push(newItem);
939
+                    getChildren(data, newItem.children, item.deptId);
940
+                }
974 941
             }
975 942
         }
976
-    }
943
+
977 944
 </script>
978 945
 </body>
979 946
 </html>

+ 765 - 0
src/main/resources/templates/stafeemanage/sta.html

@@ -0,0 +1,765 @@
1
+<!DOCTYPE html>
2
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
3
+<head>
4
+    <meta charset="UTF-8">
5
+    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
6
+    <title>Title</title>
7
+    <link rel="stylesheet" th:href="@{/lib/layui/css/layui.css}" media="all">
8
+    <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
9
+    <link rel="stylesheet" th:href="@{/lib/font-awesome-4.7.0/css/font-awesome.min.css}" media="all">
10
+
11
+</head>
12
+<body>
13
+<h1> 你好 世界</h1>
14
+<script type="text/html" id="toolbarDemo">
15
+    <div class="layui-btn-container" style="display: flex;">
16
+        <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="view">
17
+            <i class="layui-icon layui-icon-file" style="font-size: 10px;"></i>查看
18
+        </button>
19
+        <button class="layui-btn layui-btn-sm data-add-btn" lay-event="tjrevokeApprove">
20
+            <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>撤销审批
21
+        </button>
22
+        <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="spOption">
23
+            <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>审核
24
+        </button>
25
+        <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="spList">
26
+            <i class="layui-icon layui-icon-list" style="font-size: 10px;"></i>审批列表
27
+        </button>
28
+        <button class="layui-btn layui-btn-sm" lay-event="export" style="background-color: black">
29
+            <i class="layui-icon layui-icon-export" style="font-size: 10px;"></i>导出列表
30
+        </button>
31
+        <button class="layui-btn layui-btn-sm layui-btn-checked" lay-event="xmzy" id="zy" style="display: none">
32
+            <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>项目转移
33
+        </button>
34
+    </div>
35
+</script>
36
+<input type="hidden" id="userId" name="userId" class="layui-input" th:value="${userId}">
37
+<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
38
+
39
+<script th:src="@{/lib/jquery-3.4.1/jquery-3.4.1.min.js}" charset="utf-8"></script>
40
+<script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
41
+<script th:src="@{/lib/coco-message/coco-message.js}" charset="utf-8"></script>
42
+<script th:src="@{/js/lay-config.js}" charset="utf-8"></script>
43
+<script th:src="@{/lib/xm-select-v1.2.2/xm-select.js}" charset="utf-8"></script>
44
+<script th:inline="javascript" type="text/javascript">
45
+    var updateflag = 0;
46
+    var fyApproval = {};
47
+
48
+    layui.use(['form', 'table', 'tableSelect', 'laydate', 'layCascader'], function () {
49
+        var form = layui.form,
50
+            tableSelect = layui.tableSelect,
51
+            laydate = layui.laydate,
52
+            table = layui.table;
53
+        layCascader = layui.layCascader;
54
+        var userId = $("#userId").val();
55
+        var cascader;
56
+        var sqsj1 = '',
57
+            sqsj2 = '';
58
+        //申请时间
59
+        laydate.render({
60
+            elem: '#sqsj1',
61
+            done: function (value, date, endDate) {
62
+                sqsj1 = $("#sqsj1").val();
63
+                sqsj2 = $("#sqsj2").val();
64
+                if (sqsj1 != "" && sqsj2 != "") {
65
+                    if (sqsj1 > sqsj2) {
66
+                        Message.warning("起始时间不能晚于终止时间!", 1500);
67
+                        $("#sqsj1").val("");
68
+                    }
69
+                }
70
+            }
71
+        });
72
+        laydate.render({
73
+            elem: '#sqsj2',
74
+            done: function (value, date, endDate) {
75
+                sqsj1 = $("#sqsj1").val();
76
+                sqsj2 = $("#sqsj2").val();
77
+                if (sqsj1 != "" && sqsj2 != "") {
78
+                    if (sqsj1 > sqsj2) {
79
+                        Message.warning("终止时间不能早于开始时间!", 1500);
80
+                        $("#sqsj2").val("");
81
+                    }
82
+                }
83
+            }
84
+        });
85
+        var index2 = layer.load(0, {shade: 0.1});
86
+        AjaxUtil.get({
87
+            url: AjaxUtil.ctx + 'userinfo/listDeptForSelect',
88
+            success: function (res) {
89
+                layer.close(index2);
90
+                var datalist = [];
91
+                // 添加“全部”选项
92
+                datalist.push({
93
+                    value: '', // 空值
94
+                    label: '全部', // 显示文本
95
+                    children: [] // 需要子项以保持一致性
96
+                });
97
+
98
+                for (let item of res.data) {
99
+                    item.value = item.deptName;
100
+                    item.label = item.deptName;
101
+                    // 确保每个部门也有一个 children 属性
102
+                    item.children = [];
103
+                    datalist.push(item);
104
+                }
105
+
106
+                // 扁平数据转树
107
+                var options = arrayToTree(datalist, "50");
108
+                // var options = arrayToTree(datalist, "0");
109
+
110
+                // 初始化cascader实例
111
+                cascader = layCascader({
112
+                    elem: '#ssbmmc',
113
+                    clearable: true,
114
+                    showAllLevels: false, // 配置仅显示最后一级
115
+                    props: {
116
+                        checkStrictly: true, // 配置选择任意一级选项
117
+                    },
118
+                    options: options
119
+                });
120
+
121
+                // 监听cascader变化
122
+                cascader.changeEvent(function (value, node) {
123
+                    // 主动关闭面板
124
+                    cascader.close();
125
+                    $("#deptId").val(value);
126
+                });
127
+            },
128
+            error: function (error) {
129
+                layer.close(index2);
130
+                Message.error('获取部门信息失败!', 1000);
131
+            }
132
+        });
133
+
134
+        //电科院负责人
135
+        tableSelect.render({
136
+            elem: '#dkyfzrxm',
137
+            checkedKey: 'id',
138
+            searchKey: 'xm',
139
+            searchPlaceholder: '搜索姓名',
140
+            table: {
141
+                url: AjaxUtil.ctx + 'basePerson/rylist',
142
+                cols: [
143
+                    [
144
+                        {type: "checkbox", fixed: 'left',title: '😊'},
145
+                        {type: 'numbers', align: 'center',title: '序号'},
146
+                        {field: 'xm', width: '15%', title: '姓名', align: 'left'},
147
+                        {field: 'dwmc', title: '公司/单位', align: 'left'}
148
+                    ]
149
+                ]
150
+            },
151
+            done: function (elem, data) {
152
+                var NEWJSON = [];
153
+                var NEWJSON1 = [];
154
+                layui.each(data.data, function (index, item) {
155
+                    NEWJSON.push(item.xm);
156
+                    NEWJSON1.push(item.id);
157
+                })
158
+                elem.val(NEWJSON.join(","));
159
+                $("#dkyfzr").val(NEWJSON1.join(","));
160
+            }
161
+        });
162
+        var getYear = document.getElementById('nf').value;
163
+        var currTable = table.render({
164
+            elem: '#currentTableId',
165
+            url: AjaxUtil.ctx + 'staBudgetapproval/list_allApply/?nf='+getYear,
166
+            method: 'post',
167
+            toolbar: '#toolbarDemo',
168
+            // defaultToolbar: ['filter', 'print'],
169
+            cols: [
170
+                [
171
+                    {type: "radio", title: '😊'},
172
+                    {type: 'numbers',title: '序号'},
173
+                    {field: 'xmmc', width: '15%', title: '项目名称'},
174
+                    {field: 'erpbh', width: '9%', title: 'ERP编号'},
175
+                    {field: 'sfbyj', width: '8%', title: '是否备用金', align: 'center', templet: function (d) {
176
+                            if (1 == d.sfbyj) {
177
+                                return '<span class="layui-badge layui-bg-blue">是</span>';
178
+                            } else {
179
+                                return '<span class="layui-badge layui-bg-orange">否</span>';
180
+                            }
181
+                        }
182
+                    },
183
+                    {field: 'sqje', width: '7%', title: '申请金额(元)'},
184
+                    {field: 'bzje', width: '7%', title: '报账金额(元)'},
185
+                    {field: 'bhsje', width: '7%', title: '不含税金额(元)'},
186
+                    {field: 'fylbmc', width: '15%', title: '费用类别'},
187
+                    {field: 'xmlxmc', width: '10%', title: '项目类型'},
188
+                    {field: 'spzt', width: '9%', title: '审批状态'},
189
+                    {field: 'sqrxm', width: '5%', title: '申请人'},
190
+                    {field: 'bh', width: '8%', title: '科研费号'},
191
+                    {field: 'dkyfzrxm', width: '8%', title: '电科院负责人'},
192
+                    {field: 'ssbmmc', width: '8%', title: '所属部门'},
193
+                    {field: 'nf', width: '4%', title: '年份'},
194
+                    {field: 'sqsj', width: '8%', title: '申请时间', align: 'center'},
195
+                    {field: 'sqmc', width: '25%', title: '申请名称'}
196
+                ]
197
+            ],
198
+            autoSort: false,
199
+            limits: [10, 15, 20, 25, 50, 100],
200
+            limit: 10,
201
+            page: true,
202
+            skin: 'grid',
203
+            parseData: function (res) { //res 即为原始返回的数据
204
+                return {
205
+                    "code": res.code, //解析接口状态
206
+                    "msg": res.message, //解析提示文本
207
+                    "count": res.data.total, //解析数据长度
208
+                    "data": res.data.rows //解析数据列表
209
+                };
210
+            },
211
+            done: function (res, curr, count) { // done为数据渲染完的回调
212
+
213
+                if (res.data && Array.isArray(res.data)) {
214
+                    for (let i = 0; i < res.data.length; i++) {
215
+                        console.log(res.data[i]);
216
+                        if (res.data[i].sfth==1){
217
+                            const Index = i ;
218
+                            $(`.layui-table tr[data-index="${Index}"]`).css('background-color', '#ADD8E6');
219
+                        }
220
+                    }
221
+                }
222
+                console.log(userId);
223
+                if(userId == 1 || userId == 42){/*
224
+                    $('#zy').css('display', 'block');*/
225
+                }
226
+            }
227
+        });
228
+        // 监听搜索操作
229
+        form.on('submit(data-search-btn)', function (data) {
230
+            // 执行搜索重载
231
+            currTable.reload({
232
+                page: {
233
+                    curr: 1 // 页码从1开始
234
+                },
235
+                where: form.val("search-form")
236
+            });
237
+            return false;
238
+        });
239
+
240
+        // 监听重置操作
241
+        form.on('submit(data-reset-btn)', function (data) {
242
+            form.val("search-form", {
243
+                "bh": '',
244
+                "erpbh": '',
245
+                "xmlx": '',
246
+                "sfbyj": '',
247
+                "xmmc": '',
248
+                "ssbmmc": '',
249
+                "nf": '0',
250
+                "spzt": '',
251
+                "sfbz": '',
252
+                "dkyfzr": '',
253
+                "sqsj1": '',
254
+                "sqsj2": ''
255
+            });
256
+            cascader.reload();
257
+            // 执行搜索重载
258
+            currTable.reload({
259
+                page: {
260
+                    curr: 1
261
+                },
262
+                where: form.val("search-form")
263
+            });
264
+            return false;
265
+        });
266
+
267
+
268
+        // 监听工具栏事件
269
+        table.on('toolbar(currentTableFilter)', function (obj) {
270
+            if (obj.event === 'add') {  // 监听添加操作
271
+                layer.open({
272
+                    title: '新建费用申请',
273
+                    type: 2,
274
+                    shade: 0.3,
275
+                    maxmin: true,
276
+                    area: ['1020px', layerheight + 'px'],
277
+                    content: AjaxUtil.ctx + 'staBudgetapproval/forApplyAdd',
278
+                    end: function (index) {
279
+                        // 重载表格
280
+                        if (updateflag == 1)
281
+                            currTable.reload();
282
+                        updateflag = 0;
283
+                    }
284
+                });
285
+            } else if (obj.event == 'edit') {
286
+                var dataApproval = table.cache["currentTableId"];
287
+                if (dataApproval.length == 0)
288
+                    return;
289
+
290
+                var checkStatus = table.checkStatus('currentTableId')
291
+                    , data = checkStatus.data;
292
+                if (data == null || data.length === 0) {
293
+                    Message.warning("请选择要编辑的费用申请!", 1500);
294
+                } else if (data.length > 1) {
295
+                    Message.warning("请选择一条记录进行编辑!", 1500);
296
+                } else if (data[0].spzt == "作废") {
297
+                    Message.warning("该费用申请已作废!", 1500);
298
+                } else if (data[0].spzt == "审批结束") {
299
+                    Message.warning("该费用申请已审批结束,不能修改!", 1500);
300
+                } else if (data[0].spzt != null && data[0].spzt.indexOf("未提交") < 0) {
301
+                    Message.warning("该费用申请审批中,不能修改!", 1500);
302
+                    ;
303
+                } else if (data[0].sqr != userId) {
304
+                    Message.error("您不是该费用的申请人,不能修改!", 1500);
305
+                } else {
306
+                    layer.open({
307
+                        title: '编辑费用申请',
308
+                        type: 2,
309
+                        shade: 0.3,
310
+                        maxmin: true,
311
+                        shadeClose: true,
312
+                        area: ['1020px', layerheight + 'px'],
313
+                        content: AjaxUtil.ctx + 'staBudgetapproval/forApplyUpdate/' + data[0].id+'?fylbmc='+data[0].fylbmc,
314
+                        end: function (index) {
315
+                            if (updateflag == 1)
316
+                                currTable.reload();
317
+                            updateflag = 0;
318
+                        }
319
+                    });
320
+                    // layer.full(index);
321
+                }
322
+            } else if (obj.event == 'view') {
323
+                var dataApproval = table.cache["currentTableId"];
324
+                if (dataApproval.length == 0)
325
+                    return;
326
+
327
+                var checkStatus = table.checkStatus('currentTableId')
328
+                    , data = checkStatus.data;
329
+                if (data == null || data.length === 0) {
330
+                    Message.warning("请选择要查看的费用申请!", 1500);
331
+                } else if (data.length > 1) {
332
+                    Message.warning("请选择一条记录进行查看!", 1500);
333
+                } else {
334
+                    var title = '浏览费用申请';
335
+                    var width = '1020px';
336
+                    var content = AjaxUtil.ctx + 'staBudgetapproval/forApplyView/' + data[0].id+'?fylbmc='+data[0].fylbmc;
337
+                    if (data[0].sfbyj == 1) {
338
+                        title = '浏览备用金申请';
339
+                        if (data[0].fylbmc == null) {
340
+                            width = layerwidth + 'px';
341
+                            content = AjaxUtil.ctx + 'staBudgetapproval/forImprestView/' + data[0].id;
342
+                        }
343
+                    }
344
+                    layer.open({
345
+                        title: title,
346
+                        type: 2,
347
+                        shade: 0.3,
348
+                        maxmin: true,
349
+                        shadeClose: true,
350
+                        area: [width, layerheight + 'px'],
351
+                        content: content,
352
+                        end: function (index) {
353
+                            layer.close(index);
354
+                        }
355
+                    });
356
+                    // layer.full(index);
357
+                }
358
+            } else if (obj.event === 'delete') {  // 监听删除操作
359
+                var dataApproval = table.cache["currentTableId"];
360
+                if (dataApproval.length == 0)
361
+                    return;
362
+
363
+                var checkStatus = table.checkStatus('currentTableId')
364
+                    , data = checkStatus.data;
365
+                if (data == null || data.length === 0) {
366
+                    Message.warning("请选择要删除的费用申请!", 1500);
367
+                    return;
368
+                } else {
369
+                    for (let item of data) {
370
+                        if (item.sqr != userId) {
371
+                            Message.error("存在您不是申请人的费用,不能直接删除!", 2000);
372
+                            return;
373
+                        }
374
+                        if (item.spzt != "未提交") {
375
+                            if (item.spzt == "审批结束")
376
+                                Message.warning("存在已审批结束的费用申请,不能直接删除!", 2000);
377
+                            else if (data[0].spzt != null)
378
+                                Message.warning("存在审批中的费用申请,不能直接删除!", 2000);
379
+                            return;
380
+                        }
381
+                    }
382
+                }
383
+                layer.confirm('确定批量删除费用申请吗?', function (index) {
384
+                    layer.close(index);
385
+                    AjaxUtil.post({
386
+                        url: AjaxUtil.ctx + "staBudgetapproval/batchDelete",
387
+                        contentType: "application/json",
388
+                        data: JSON.stringify(data),
389
+                        success: function (res) {
390
+                            if (res.code === 0) {
391
+                                Message.success(1500, res.message, function () {
392
+                                    // 重载表格
393
+                                    currTable.reload();
394
+                                });
395
+                            } else {
396
+                                Message.error(res.message, 1000);
397
+                            }
398
+                        },
399
+                        error: function (error) {
400
+                        }
401
+                    });
402
+                });
403
+            } else if (obj.event === 'tjApprove') {
404
+                var projects = table.cache["currentTableId"];
405
+                if (projects.length == 0)
406
+                    return;
407
+
408
+                var checkStatus = table.checkStatus('currentTableId')
409
+                    , data = checkStatus.data;
410
+                if (data == null || data.length === 0) {
411
+                    Message.warning("请选择要提交审批的费用申请!", 2000);
412
+                } else if (data.length > 1) {
413
+                    Message.warning("请选择一条记录进行提交!", 1500);
414
+                } else if (data[0].spzt == "审批结束") {
415
+                    Message.warning("该费用申请已审批结束!", 1500);
416
+                } else if (data[0].spzt == "作废") {
417
+                    Message.warning("该费用申请已作废!", 1500);
418
+                } else if (data[0].spzt != null && data[0].spzt.indexOf("未提交") < 0) {
419
+                    Message.warning("该费用申请正在审批中……", 1500);
420
+                } else if (data[0].sqr != userId) {
421
+                    Message.error("您不是该费用的申请人!", 1500);
422
+                } else {
423
+                    xmApproval = {
424
+                        "xmid": data[0].id,
425
+                        "xm": data[0].sqmc,
426
+                        "zt": data[0].spzt,
427
+                        "sqje": data[0].sqje
428
+                    };
429
+                    if (data[0].spzt == null) {
430
+                        xmApproval.zt = "未提交";
431
+                        data[0].spzt = "未提交";
432
+                    }
433
+
434
+                    var content = AjaxUtil.ctx + 'staBudgetapproval/forApproveAdd';
435
+                    if (data[0].spzt != "未提交")
436
+                        content = AjaxUtil.ctx + 'staBudgetapproval/forApproveUpdate/' + data[0].id + '/' + data[0].sqje + '?spzt=' + data[0].spzt;
437
+
438
+                    var index = layer.open({
439
+                        title: '提交审批',
440
+                        type: 2,
441
+                        shade: 0.3,
442
+                        maxmin: true,
443
+                        shadeClose: true,
444
+                        area: ['1025px', layerheight + 'px'],
445
+                        content: content,
446
+                        end: function () {
447
+                            if (updateflag == 1)
448
+                                currTable.reload();
449
+                            updateflag = 0;
450
+                            layer.close(index);
451
+                        }
452
+                    });
453
+                }
454
+            } else if (obj.event === 'spOption') {
455
+                var projects = table.cache["currentTableId"];
456
+                if (projects.length == 0)
457
+                    return;
458
+                var checkStatus = table.checkStatus('currentTableId')
459
+                    , data = checkStatus.data;
460
+                if (data == null || data.length === 0) {
461
+                    Message.warning("请选择要审批的费用申请!", 2000);
462
+                } else if (data.length > 1) {
463
+                    Message.warning("请选择一条记录进行审批!", 1500);
464
+                } else if (data[0].spzt == null || data[0].spzt.indexOf("未提交") >= 0) {
465
+                    Message.warning("该费用申请尚未提交审批!", 1500);
466
+                } else if (data[0].spzt == "审批结束") {
467
+                    Message.warning("该费用申请已审批结束!", 2000);
468
+                } else if (data[0].spzt == "作废") {
469
+                    Message.warning("该费用申请已作废!", 1500);
470
+                } else {
471
+                    xmApproval = {
472
+                        "xmid": data[0].id,
473
+                        "xm": data[0].sqmc,
474
+                        "zt": data[0].spzt,
475
+                        "sqje": data[0].sqje
476
+                    };
477
+
478
+                    var content = AjaxUtil.ctx + 'staBudgetapproval/forApproveAdd';
479
+                    if (data[0].spzt != "未提交")
480
+                        content = AjaxUtil.ctx + 'staBudgetapproval/forApproveUpdate/' + data[0].id + '/' + data[0].sqje + '?spzt=' + data[0].spzt;
481
+
482
+                    layer.open({
483
+                        title: '审批意见',
484
+                        type: 2,
485
+                        shade: 0.3,
486
+                        maxmin: true,
487
+                        shadeClose: true,
488
+                        area: ['1025px', layerheight + 'px'],
489
+                        content: content,
490
+                        end: function (index) {
491
+                            if (updateflag == 1)
492
+                                currTable.reload();
493
+                            updateflag = 0;
494
+                        }
495
+                    });
496
+                }
497
+            } else if (obj.event === 'spList') {
498
+                var projects = table.cache["currentTableId"];
499
+                if (projects.length == 0)
500
+                    return;
501
+
502
+                var checkStatus = table.checkStatus('currentTableId')
503
+                    , data = checkStatus.data;
504
+                if (data == null || data.length === 0) {
505
+                    Message.warning("请选择要查看审批列表的费用申请!", 1500);
506
+                } else if (data.length > 1) {
507
+                    Message.warning("请选择一条记录进行查看!", 1500);
508
+                } else if (data[0].spzt == null || data[0].spzt == "未提交") {
509
+                    Message.warning("该备费用申请尚未提交审批!", 1500);
510
+                } else {
511
+                    xmApproval = {
512
+                        "xmid": data[0].id,
513
+                        "xm": data[0].sqmc,
514
+                        "zt": data[0].spzt,
515
+                        "sqje": data[0].sqje
516
+                    };
517
+
518
+                    var content = AjaxUtil.ctx + 'staBudgetapproval/forApproveList';
519
+                    if (data[0].sfbyj == 1)
520
+                        content = AjaxUtil.ctx + 'staBudgetapproval/forApproveList1';
521
+
522
+                    var index = layer.open({
523
+                        title: '审批列表',
524
+                        type: 2,
525
+                        shade: 0.3,
526
+                        maxmin: true,
527
+                        shadeClose: true,
528
+                        area: ['1300px', layerheight + 'px'],
529
+                        content: content,
530
+                        end: function () {
531
+                            layer.close(index);
532
+                        }
533
+                    });
534
+                }
535
+            } else if (obj.event === 'reimburse') {
536
+                var projects = table.cache["currentTableId"];
537
+                if (projects.length == 0)
538
+                    return;
539
+
540
+                var checkStatus = table.checkStatus('currentTableId')
541
+                    , data = checkStatus.data;
542
+                if (data == null || data.length === 0) {
543
+                    Message.warning("请选择要报账的费用申请!", 1500);
544
+                } else if (data.length > 1) {
545
+                    Message.warning("请选择一条记录进行报账!", 1500);
546
+                } else if (data[0].spzt == "作废") {
547
+                    Message.warning("该费用申请已作废!", 1500);
548
+                } else if (data[0].spzt.indexOf("未提交") >= 0) {
549
+                    Message.warning("该费用申请尚未提交审批!", 1500);
550
+                } else if (data[0].spzt != "审批结束") {
551
+                    Message.warning("该费用申请正在审批中……", 1500);
552
+                } else if (data[0].sfbz == 1) {
553
+                    Message.warning("该费用申请已报账", 1500);
554
+                } else {
555
+                    var index = layer.open({
556
+                        title: '新建报账',
557
+                        type: 2,
558
+                        shade: 0.3,
559
+                        maxmin: true,
560
+                        shadeClose: true,
561
+                        area: ['970px', '750px'],
562
+                        content: AjaxUtil.ctx + "staReimbursement/forAdd/" + data[0].id,
563
+                        end: function () {
564
+                            if (updateflag == 1)
565
+                                currTable.reload();
566
+                            updateflag = 0;
567
+                            layer.close(index);
568
+                        }
569
+                    });
570
+                }
571
+            } else if (obj.event === 'nullify') {  // 监听作废操作
572
+                var projects = table.cache["currentTableId"];
573
+                if (projects.length == 0)
574
+                    return;
575
+
576
+                var checkStatus = table.checkStatus('currentTableId')
577
+                    , data = checkStatus.data;
578
+                if (data == null || data.length === 0)
579
+                    Message.warning("请选择要作废的费用申请!", 1000);
580
+                else {
581
+                    layer.confirm('确定批量作废费用申请吗?', function (index) {
582
+                        layer.close(index);
583
+                        AjaxUtil.post({
584
+                            url: AjaxUtil.ctx + "staBudgetapproval/batchNullify",
585
+                            contentType: "application/json",
586
+                            data: JSON.stringify(data),
587
+                            success: function (res) {
588
+                                if (res.code === 0) {
589
+                                    Message.success(1500, res.message, function () {
590
+                                        // 重载表格
591
+                                        currTable.reload();
592
+                                    });
593
+                                } else {
594
+                                    Message.error(res.message, 1000);
595
+                                }
596
+                            },
597
+                            error: function (error) {
598
+                            }
599
+                        });
600
+                    });
601
+                }
602
+            } else if (obj.event === 'tjrevokeApprove') {
603
+                var projects = table.cache["currentTableId"];
604
+                if (projects.length == 0)
605
+                    return;
606
+                var checkStatus = table.checkStatus('currentTableId')
607
+                    , data = checkStatus.data;
608
+                if (data == null || data.length === 0) {
609
+                    Message.warning("请选择要撤销的费用申请!", 1500);
610
+                } else if (data.length > 1) {
611
+                    Message.warning("请选择一条记录进行撤销!", 1500);
612
+                } else if (data[0].spzt == "审批结束") {
613
+                    Message.warning("该费用申请已审批结束!", 1500);
614
+                }else if(data[0].spzt == "未提交"|| data[0].spzt == "未提交(返回)"){
615
+                    Message.warning("该费用申请还未提交审批!", 1500);
616
+                }
617
+                    // else if (data[0].cjr != userId) {
618
+                // Message.error("您不是该任务书的创建人!", 1500);}
619
+                else {
620
+                    xmApproval = {
621
+                        "xmid": data[0].id,
622
+                        "xm": data[0].zwmc,
623
+                        "zt": "未提交"
624
+                    };
625
+                    if (data[0].spzt == null) {
626
+                        xmApproval.zt = "未提交";
627
+                        data[0].spzt = "未提交";
628
+                    }
629
+                    var project = {
630
+                        "id": xmApproval.xmid,
631
+                        "spzt": data[0].spzt
632
+                    }
633
+                    layer.confirm('确定撤销费用申请吗?', function (index) {
634
+                        layer.close(index);
635
+                        AjaxUtil.post({
636
+                            url: AjaxUtil.ctx + "staBudgetapproval/TJrevokeApprove",
637
+                            contentType: "application/json",
638
+                            data: JSON.stringify(project),
639
+                            success: function (res) {
640
+                                if (res.code === 0) {
641
+                                    Message.success(1500, res.message, function () {
642
+                                        // 重载表格
643
+                                        currTable.reload();
644
+                                    });
645
+                                } else {
646
+                                    Message.error(res.message, 1000);
647
+                                }
648
+                            },
649
+                            error: function (error) {
650
+                            }
651
+                        });
652
+                    });
653
+                }
654
+            }else if (obj.event === 'export'){
655
+
656
+                var formData = form.val('search-form');
657
+                // 获取form 表单代码
658
+                console.log(formData);
659
+                var formDataString = JSON.stringify(formData);
660
+                AjaxUtil.post({
661
+                    url:AjaxUtil.ctx +'staBudgetapproval/getAll/'+formDataString,
662
+                    contentType: "application/json",
663
+                    timeout: 15000, //大批量导出时会出现超时问题
664
+                    success: function(res){
665
+                        console.log(res);
666
+                        table.exportFile('currentTableId',res.data,'xlsx');
667
+                    },
668
+                    error:function (error) {
669
+                        Message.error(error,2000)
670
+
671
+                    }
672
+                });
673
+
674
+
675
+            }else if (obj.event === 'xmzy'){
676
+                var project = table.cache['currentTableId'];//  绑定表格元素 cache 表示缓存的意思
677
+                // 判断缓存是否为空
678
+                if(project.length == 0){
679
+                    return;
680
+                }
681
+                // 获取table 中 缓存的数据
682
+                var checkStatus =  table.checkStatus('currentTableId')
683
+                    ,data = checkStatus.data;
684
+                if (data == null || data.length === 0){
685
+                    layer.msg('请选择要转移的项目',{icon: 3});
686
+                }else if (data.length > 1){
687
+                    layer.msg('请选择一条项目进项转移',{icon:3});
688
+                }else if (data[0].spzt != '审批结束'){
689
+                    layer.msg('"'+data[0].sqmc+'"未审批结束,不能转移',{icon:3});
690
+                }else {
691
+                    layer.open({
692
+                        title: '项目转移',
693
+                        type: 2,
694
+                        shade: 0.3,
695
+                        maxmin: true,
696
+                        shadeClose: true,
697
+                        area: ['1090px', layerheight + 'px'],
698
+                        content: AjaxUtil.ctx + 'staBudgetapproval/updateSsbm/' + data[0].id,
699
+                        success: function (layero, index) {
700
+                        },
701
+                        end: function (index) {
702
+                            // 刷新表格
703
+                            if (updateflag == 1)
704
+                                currTable.reload();
705
+                            updateflag = 0;
706
+                        }
707
+                    });
708
+                }
709
+            }
710
+        });
711
+
712
+        //双击
713
+        table.on('rowDouble(currentTableFilter)', function (obj) {
714
+            var data = obj.data;
715
+            var title = '浏览费用申请';
716
+            var width = '1020px';
717
+            var content = AjaxUtil.ctx + 'staBudgetapproval/forApplyView/' + data.id;
718
+            if (data.sfbyj == 1) {
719
+                title = '浏览备用金申请';
720
+                if (data.fylbmc == null) {
721
+                    width = layerwidth + 'px';
722
+                    content = AjaxUtil.ctx + 'staBudgetapproval/forImprestView/' + data.id;
723
+                }
724
+            }
725
+            layer.open({
726
+                title: title,
727
+                type: 2,
728
+                shade: 0.3,
729
+                maxmin: true,
730
+                shadeClose: true,
731
+                area: [width, layerheight + 'px'],
732
+                content: content,
733
+                end: function (index) {
734
+                    layer.close(index);
735
+                }
736
+            });
737
+        });
738
+    });
739
+
740
+    function setUpdateFlag() {
741
+        updateflag = 1;
742
+    }
743
+
744
+    function getXmApproval() {
745
+        return xmApproval;
746
+    }
747
+
748
+    function arrayToTree(data, firstPid) {
749
+        const result = [];
750
+        getChildren(data, result, firstPid)
751
+        return result;
752
+    }
753
+
754
+    function getChildren(data, result, parentId) {
755
+        for (const item of data) {
756
+            if (item.parentId === parentId) {
757
+                const newItem = {...item, children: []};
758
+                result.push(newItem);
759
+                getChildren(data, newItem.children, item.deptId);
760
+            }
761
+        }
762
+    }
763
+</script>
764
+</body>
765
+</html>