Sfoglia il codice sorgente

概算控制,不允许多个概算控制关联同一个标段

MaiXinRong 3 anni fa
parent
commit
eca0e6e7d4

+ 20 - 0
app/controller/budget_controller.js

@@ -99,6 +99,26 @@ module.exports = app => {
             }
         }
 
+        async rela(ctx) {
+            try {
+                const id = parseInt(ctx.query.id);
+                const budgetList = await ctx.service.budget.getBudget(true);
+                const otherBudget = budgetList.filter(x => { return x.id !== id || !x.rela_tender });
+                const _ = ctx.helper._;
+                const otherRela = _.map(_.map(otherBudget, 'rela_tender').join(',').split(','), _.toInteger);
+                const tenderList = await ctx.service.tender.getList4Select('stage');
+                ctx.body = {
+                    err: 0,
+                    msg: '',
+                    data: tenderList.filter(x => { return otherRela.indexOf(x.id) === -1})
+                        .map(y => { return {id: y.id, name: y.name, lastStageOrder: y.lastStage.order, lastStageStatus: auditConst.stage.statusString[y.lastStage.status]}}),
+                };
+            } catch (err) {
+                ctx.log(err);
+                ctx.postError(err, '获取数据失败');
+            }
+        }
+
         async member(ctx) {
             try {
                 const data = JSON.parse(ctx.request.body.data);

+ 12 - 5
app/public/js/budget_list.js

@@ -78,11 +78,18 @@ $(document).ready(() => {
         }
     });
     $('#select-rela').on('show.bs.modal', () => {
-        $('[name=select-rela-check]').removeAttr('checked');
-        const rela = curBudget.rela_tender ? curBudget.rela_tender.split(',') : [];
-        for (const r of rela) {
-            $(`[tid=${r}]`).attr("checked", "checked");
-        }
+        $('#valid-rela-tender').html('');
+        postData(`/budget/rela?id=${curBudget.id}`, {}, tenders => {
+            const rela = curBudget.rela_tender ? curBudget.rela_tender.split(',') : [];
+            const html = [];
+            for (const t of tenders) {
+                html.push(`<tr><td class="text-center"><input type="checkbox" name="select-rela-check" tid="${t.id}"></td><td>${t.name}</td><td>第${t.lastStageOrder}期</td><td>${t.lastStageStatus}</td></tr>`);
+            }
+            $('#valid-rela-tender').html(html.join(''));
+            for (const r of rela) {
+                $(`[tid=${r}]`).attr("checked", "checked");
+            }
+        });
     });
 
     let timer = null;

+ 1 - 0
app/router.js

@@ -580,6 +580,7 @@ module.exports = app => {
     app.post('/budget/add', sessionAuth, projectManagerCheck, 'budgetController.add');
     app.post('/budget/del', sessionAuth, projectManagerCheck, 'budgetController.del');
     app.post('/budget/save', sessionAuth, 'budgetController.save');
+    app.post('/budget/rela', sessionAuth, 'budgetController.rela');
     app.post('/budget/member', sessionAuth, projectManagerCheck, 'budgetController.member');
     app.post('/budget/member-save', sessionAuth, projectManagerCheck, 'budgetController.memberSave');
     app.get('/budget/:id/compare', sessionAuth, budgetCheck, 'budgetController.compare');

+ 1 - 1
app/view/budget/list_modal.ejs

@@ -81,7 +81,7 @@
                 <h5>可选标段</h5>
                 <table class="table table-sm table-bordered">
                     <tr class="text-center"><th>选择</th><th>标段名称</th><th>期数</th><th>状态</th></tr>
-                    <tbody>
+                    <tbody id="valid-rela-tender">
                     <% for (const t of tenderList) { %>
                     <tr><td class="text-center"><input type="checkbox" name="select-rela-check" tid="<%- t.id %>"></td><td><%- t.name %></td><td>第<%- t.lastStage.order %>期</td><td><%- auditConst.stage.statusString[t.lastStage.status] %></td></tr>
                     <% } %>