Browse Source

资料费表格新建保存限制禁止重复申请

梁世豪 3 days ago
parent
commit
5122ddd12c

+ 2 - 0
src/main/java/com/liang/controller/PrjContractController.java

@@ -207,7 +207,9 @@ public class PrjContractController extends BaseController {
207 207
     public String forUpdate(Model model, @PathVariable Integer id) {
208 208
         //当前项目
209 209
         PrjContract contract = prjContractService.queryById(id);
210
+        String userPostName = getSysUserInfo().getUserPostName();
210 211
         model.addAttribute("contract", contract);
212
+        model.addAttribute("userPostName",userPostName);
211 213
 
212 214
         return "prjcontract/update";
213 215
     }

+ 19 - 0
src/main/java/com/liang/controller/StaBudgetapprovalController.java

@@ -64,6 +64,8 @@ public class StaBudgetapprovalController extends BaseController {
64 64
     private  SysUserPostService sysUserPostService;
65 65
     @Resource
66 66
     private  SysDeptInfoService sysDeptInfoService;
67
+    @Resource
68
+    private StaSourceFeeService staSourceFeeService;
67 69
 
68 70
 
69 71
     /**
@@ -271,6 +273,13 @@ public class StaBudgetapprovalController extends BaseController {
271 273
     @RequestMapping(value = "/forAdd", method = RequestMethod.GET)
272 274
     public String forAdd(Model model) {
273 275
         SysUserInfo userInfo = getSysUserInfo();
276
+        String deptName = userInfo.getDeptName();
277
+        //获取该部门下已申请的书籍
278
+        List<StaSourceFee> TsmcList = staSourceFeeService.searchSourceTsmcByDeptName(deptName);
279
+        List list = new ArrayList();
280
+        for (int i = 0; i < TsmcList.size(); i++) {
281
+            list.add(TsmcList.get(i).getTsmc());
282
+        }
274 283
         String fileUrl = "http://" + webfileip + ":" + webfileport + "/template/";
275 284
         model.addAttribute("ClfTemplate", fileUrl + "差旅费模版.xlsx");
276 285
         model.addAttribute("HyfTemplate", fileUrl + "会议费模版.xlsx");
@@ -286,6 +295,7 @@ public class StaBudgetapprovalController extends BaseController {
286 295
         model.addAttribute("WwTemplate", fileUrl + "外委研究支出费模版.xlsx");
287 296
         model.addAttribute("WxTemplate", fileUrl + "外协测试试验与加工费模版.xlsx");
288 297
         model.addAttribute("userInfo", userInfo);
298
+        model.addAttribute("tsmclist",list);
289 299
         return "stabudgetapproval/add";
290 300
     }
291 301
 
@@ -665,6 +675,15 @@ public class StaBudgetapprovalController extends BaseController {
665 675
         if (kmFyInfo.getBzje() == null)
666 676
             kmFyInfo.setBzje(0.0);
667 677
         model.addAttribute("kmFyInfo", kmFyInfo);
678
+        String deptName = getSysUserInfo().getDeptName();
679
+        //获取该部门下已申请的书籍
680
+        List<StaSourceFee> TsmcList = staSourceFeeService.searchSourceTsmcByDeptName(deptName);
681
+        List list = new ArrayList();
682
+        for (int i = 0; i < TsmcList.size(); i++) {
683
+            list.add(TsmcList.get(i).getTsmc());
684
+        }
685
+        model.addAttribute("userInfo",getSysUserInfo());
686
+        model.addAttribute("tsmclist",list);
668 687
         return "stabudgetapproval/update_apply";
669 688
     }
670 689
 

+ 2 - 0
src/main/java/com/liang/dao/StaSourceFeeDao.java

@@ -114,4 +114,6 @@ public interface StaSourceFeeDao {
114 114
      * @return
115 115
      */
116 116
     List<HashMap<String, Object>> searchSourceCost(Map map);
117
+
118
+    List<StaSourceFee> searchSourceTsmcByDeptName(String deptName);
117 119
 }

+ 1 - 0
src/main/java/com/liang/service/StaSourceFeeService.java

@@ -99,4 +99,5 @@ public interface StaSourceFeeService {
99 99
      */
100 100
     List<HashMap<String, Object>> searchSourceCost(Map map);
101 101
 
102
+    List<StaSourceFee> searchSourceTsmcByDeptName(String deptName);
102 103
 }

+ 5 - 0
src/main/java/com/liang/service/impl/StaSourceFeeServiceImpl.java

@@ -103,6 +103,11 @@ public class StaSourceFeeServiceImpl implements StaSourceFeeService {
103 103
         return this.staSourceFeeDao.searchSourceCost(map);
104 104
     }
105 105
 
106
+    @Override
107
+    public List<StaSourceFee> searchSourceTsmcByDeptName(String deptName) {
108
+        return this.staSourceFeeDao.searchSourceTsmcByDeptName(deptName);
109
+    }
110
+
106 111
 
107 112
     @Override
108 113
     public List<StaSourceFee> queryByKyfh(String kyfh) {

+ 15 - 1
src/main/resources/mapper/StaSourceFeeDao.xml

@@ -215,7 +215,8 @@
215 215
     </select>
216 216
 
217 217
     <!-- 项目报表 资料费查询 -->
218
-    <select id="searchSourceCost" resultType="HashMap">SELECT
218
+    <select id="searchSourceCost" resultType="HashMap">
219
+    SELECT
219 220
         sta_SourceFee.ID,
220 221
         sys_dept_info.dept_name AS BM,
221 222
         sta_BudgetApproval.XMMC,
@@ -282,4 +283,17 @@
282 283
         </if>
283 284
     </select>
284 285
 
286
+    <select id="searchSourceTsmcByDeptName" resultType="com.liang.entity.StaSourceFee">
287
+        SELECT
288
+            sta_SourceFee.TSMC
289
+        FROM
290
+            sta_SourceFee
291
+                LEFT JOIN
292
+            sta_BudgetApproval ON sta_SourceFee.ZB = sta_BudgetApproval.ID
293
+                INNER JOIN
294
+            sys_dept_info ON sta_BudgetApproval.SSBM = sys_dept_info.dept_id
295
+        where
296
+            sys_dept_info.dept_name = #{deptName}
297
+    </select>
298
+
285 299
 </mapper>

+ 30 - 7
src/main/resources/templates/stabudgetapproval/add.html

@@ -734,6 +734,8 @@
734 734
         var ssbm = $("#ssbm").val();
735 735
         var ssbmmc = $("#ssbmmc").val();
736 736
         var kmXmzys = 0;
737
+        var tsmclist = [[${tsmclist}]]
738
+        var userInfo = [[${userInfo}]]
737 739
 
738 740
         //年度预算
739 741
         form.on('select(Annualbudget)', function (data) {
@@ -2895,10 +2897,18 @@
2895 2897
                     if (updateflag == 1) {
2896 2898
                         updateflag = 0;
2897 2899
                         //刷新表格
2898
-                        // dataInformation.push(information);
2899
-                        // tabIndirect.reload();
2900 2900
                         var oldData = table.cache["currentTableId_Zlf"];
2901
-                        oldData.push(information);
2901
+                        var oldDataTsmcList = new Array();
2902
+                        for (let i = 0; i < oldData.length; i++) {
2903
+                           oldDataTsmcList.push(oldData[i].tsmc)
2904
+                        }
2905
+                        if (tsmclist.includes(information.tsmc)){
2906
+                            layer.alert(userInfo.deptName+'在资料费中已申请过:'+information.tsmc)
2907
+                        }else if (oldDataTsmcList.includes(information.tsmc)){
2908
+                            layer.alert('表中已存在资料:'+information.tsmc)
2909
+                        }else {
2910
+                            oldData.push(information);
2911
+                        }
2902 2912
                         table.reload('currentTableId_Zlf', {
2903 2913
                             data: oldData
2904 2914
                         });
@@ -2909,6 +2919,10 @@
2909 2919
         // 监听编辑按钮(资料费)
2910 2920
         $("button[lay-filter='subEditzlf']").click(function () {
2911 2921
             var oldData = table.cache["currentTableId_Zlf"];
2922
+            var oldDataTsmcList = new Array();
2923
+            for (let i = 0; i < oldData.length; i++) {
2924
+                oldDataTsmcList.push(oldData[i].tsmc)
2925
+            }
2912 2926
             if (oldData.length == 0)
2913 2927
                 return;
2914 2928
 
@@ -2937,15 +2951,24 @@
2937 2951
                     area: [layerwidth + 'px', layerheight + 'px'],
2938 2952
                     content: AjaxUtil.ctx + 'staSourceFee/forUpdate',
2939 2953
                     end: function (index) {
2940
-
2941 2954
                         if (updateflag == 1) {
2942 2955
                             updateflag = 0;
2943
-
2944 2956
                             for (var i = 0; i < oldData.length; i++) {
2945 2957
                                 var item = oldData[i];
2946 2958
                                 if (item.LAY_CHECKED) {//条件:选中
2947
-                                    oldData[i] = information;
2948
-                                    break;
2959
+                                    for (let i = 0; i < oldDataTsmcList.length; i++) {
2960
+                                        if (oldDataTsmcList[i] === item.tsmc) {
2961
+                                            oldDataTsmcList.splice(i, 1); // 删除当前项
2962
+                                        }
2963
+                                    }
2964
+                                    if (tsmclist.includes(information.tsmc)){
2965
+                                        layer.alert(userInfo.deptName+'在资料费中已申请过:'+information.tsmc)
2966
+                                    }else if (oldDataTsmcList.includes(information.tsmc)){
2967
+                                        layer.alert('表中已存在资料:'+information.tsmc)
2968
+                                    }else {
2969
+                                        oldData[i] = information;
2970
+                                        break;
2971
+                                    }
2949 2972
                                 }
2950 2973
                             }
2951 2974
                             //刷新表格

+ 43 - 16
src/main/resources/templates/stabudgetapproval/update_apply.html

@@ -577,6 +577,8 @@
577 577
         var kmXmzys = [[${kmFyInfo.xmzys}]];
578 578
         console.log(kmXmzys)
579 579
         var xgqsqje = [[${budgetapproval.sqje}]];
580
+        var tsmclist = [[${tsmclist}]];
581
+        var userInfo = [[${userInfo}]];
580 582
         if ($("#fylbmc").val().indexOf("设备使用费") > -1) {
581 583
             flag = '_Dev';
582 584
             document.getElementById('sbsyfDiv').style.display = 'block';
@@ -2077,15 +2079,12 @@
2077 2079
             cols: [
2078 2080
                 [
2079 2081
                     {type: "checkbox", align: 'center'},
2080
-                    {type: 'numbers', align: 'center'},
2081
-                    {field: 'fysq', title: '费用申请', width: '15%'},
2082
-                    {field: 'kyfh', title: '科研费号', width: '15%'},
2083
-                    {field: 'bzfy', title: '报账费用', width: '15%'},
2084
-                    {field: 'tsmc', title: '图书名称', width: '15%'},
2085
-                    {field: 'cbs', title: '出版社', width: '20%'},
2086
-                    {field: 'sl', title: '数量', width: '10%'},
2087
-                    {field: 'zj', title: '总价', width: '10%'},
2088
-                    {field: 'lyr',title: '领用人',width: '10%'},
2082
+                    {type: 'numbers', align: 'center',width: '6%'},
2083
+                    {field: 'tsmc', title: '图书名称', width: '25%'},
2084
+                    {field: 'cbs', title: '出版社', width: '25%'},
2085
+                    {field: 'sl', title: '数量', width: '11%'},
2086
+                    {field: 'zj', title: '总价', width: '11%'},
2087
+                    {field: 'lyr',title: '领用人',width: '15%'},
2089 2088
                 ]
2090 2089
             ],
2091 2090
             autoSort: false,
@@ -2110,11 +2109,18 @@
2110 2109
                 end: function (index) {
2111 2110
                     if (updateflag == 1) {
2112 2111
                         updateflag = 0;
2113
-                        //刷新表格
2114
-                        // dataInformation.push(information);
2115
-                        // tabIndirect.reload();
2116 2112
                         var oldData = table.cache["currentTableId_Zlf"];
2117
-                        oldData.push(information);
2113
+                        var oldDataTsmcList = new Array();
2114
+                        for (let i = 0; i < oldData.length; i++) {
2115
+                            oldDataTsmcList.push(oldData[i].tsmc)
2116
+                        }
2117
+                        if (tsmclist.includes(information.tsmc)){
2118
+                            layer.alert(userInfo.deptName+'在资料费中已申请过:'+information.tsmc)
2119
+                        }else if (oldDataTsmcList.includes(information.tsmc)){
2120
+                            layer.alert('表中已存在资料:'+information.tsmc)
2121
+                        }else {
2122
+                            oldData.push(information);
2123
+                        }
2118 2124
                         table.reload('currentTableId_Zlf', {
2119 2125
                             data: oldData
2120 2126
                         });
@@ -2127,7 +2133,10 @@
2127 2133
             var oldData = table.cache["currentTableId_Zlf"];
2128 2134
             if (oldData.length == 0)
2129 2135
                 return;
2130
-
2136
+            var oldDataTsmcList = new Array();
2137
+            for (let i = 0; i < oldData.length; i++) {
2138
+                oldDataTsmcList.push(oldData[i].tsmc)
2139
+            }
2131 2140
             var checkStatus = table.checkStatus('currentTableId_Zlf')
2132 2141
                 , data = checkStatus.data;
2133 2142
             if (data == null || data.length === 0) {
@@ -2161,8 +2170,26 @@
2161 2170
                             for (var i = 0; i < oldData.length; i++) {
2162 2171
                                 var item = oldData[i];
2163 2172
                                 if (item.LAY_CHECKED) {//条件:选中
2164
-                                    oldData[i] = information;
2165
-                                    break;
2173
+                                    for (let i = 0; i < oldDataTsmcList.length; i++) {
2174
+                                        if (oldDataTsmcList[i] === item.tsmc) {
2175
+                                            oldDataTsmcList.splice(i, 1); // 删除当前项
2176
+                                        }
2177
+                                    }
2178
+                                    console.log(tsmclist)
2179
+                                    for (let i = 0; i < tsmclist.length; i++) {
2180
+                                        if (tsmclist[i] === item.tsmc) {
2181
+                                            tsmclist.splice(i, 1); // 删除当前项
2182
+                                        }
2183
+                                    }
2184
+                                    console.log(tsmclist)
2185
+                                    if (tsmclist.includes(information.tsmc)){
2186
+                                        layer.alert(userInfo.deptName+'在资料费中已申请过:'+information.tsmc)
2187
+                                    }else if (oldDataTsmcList.includes(information.tsmc)){
2188
+                                        layer.alert('表中已存在资料:'+information.tsmc)
2189
+                                    }else {
2190
+                                        oldData[i] = information;
2191
+                                        break;
2192
+                                    }
2166 2193
                                 }
2167 2194
                             }
2168 2195
                             //刷新表格