Kaynağa Gözat

过滤标段相关

MaiXinRong 4 ay önce
ebeveyn
işleme
db44b8ce67

+ 1 - 1
app/controller/budget_controller.js

@@ -88,7 +88,7 @@ module.exports = app => {
                 };
                 const tenderList = await ctx.service.tender.getList4Select('stage');
                 renderData.tenderList = tenderList.filter(x => {
-                    return !x.filter_budger;
+                    return !x.filter_budget;
                 });
                 renderData.tenderList = renderData.tenderList.map(y => {
                     return { id: y.id, name: y.name, lastStageOrder: y.lastStage.order, lastStageStatus: auditConst.stage.statusString[y.lastStage.status], category: y.category };

+ 11 - 0
app/controller/tender_controller.js

@@ -344,6 +344,17 @@ module.exports = app => {
             }
         }
 
+        async batchUpdate(ctx) {
+            try {
+                const data = JSON.parse(ctx.request.body.data);
+                const result = await ctx.service.tender.batchUpdate(data);
+                ctx.body = { err: 0, msg: '', data: result };
+            } catch(err) {
+                ctx.log(err);
+                ctx.ajaxErrorBody(err, '保存失败');
+            }
+        }
+
         /**
          * 删除标段(Ajax)
          *

+ 56 - 1
app/public/js/setting_manage.js

@@ -123,6 +123,44 @@ function getTenderTreeHtml4User () {
     }
 }
 
+function recursiveGetFilterTenderNodeHtml (node, arr) {
+    const html = [];
+    html.push(`<tr ${node.id ? 'tid="'+ node.id +'"' : ''}>`);
+    // 名称
+    html.push('<td class="in-' + node.level + '">');
+    if (node.cid) {
+        html.push('<i class="fa fa-folder-o"></i> ', node.name);
+    } else {
+        html.push('<span class="text-muted mr-2">');
+        html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
+        html.push('</span>', node.name);
+    }
+    html.push('</td>');
+    html.push('<td class="text-center">');
+    if (!node.cid) {
+        html.push(`<input data-tid="${node.id}" data-type="filter_budget" type="checkbox" ${node.filter_budget ? 'checked' : ''}>`);
+    }
+    html.push('</td>');
+    html.push('<td class="text-center">');
+    if (!node.cid) {
+        html.push(`<input data-tid="${node.id}" data-type="filter_fund" type="checkbox" ${node.filter_fund ? 'checked' : ''}>`);
+    }
+    html.push('</td>');
+    html.push('</tr>');
+    if (node.children) {
+        for (const c of node.children) {
+            html.push(recursiveGetFilterTenderNodeHtml(c, node.children));
+        }
+    }
+    return html.join('');
+}
+function getFilterTenderTreeHtml() {
+    const html = [];
+    for (const t of tenderTree4User) {
+        html.push(recursiveGetFilterTenderNodeHtml(t, tenderTree4User));
+    }
+    $('#filter-tender-list').html(html.join(''));
+}
 
 $(document).ready(() => {
     autoFlashHeight();
@@ -500,6 +538,7 @@ $(document).ready(() => {
     });
     sortCategory4User();
     initTenderTree4User();
+    getFilterTenderTreeHtml();
     $('#set-other-tender-user-a').click(function () {
         if(!cur_tenderid) {
             toastr.warning('未选中标段无法设置');
@@ -719,7 +758,23 @@ $(document).ready(() => {
             }
         });
     })
-})
+
+    $('#filter-tender-ok').click(function() {
+        const updateData = [];
+        const tr = $('tr[tid]', '#filter-tender');
+        for (const t of tr) {
+            const data = { id: t.getAttribute('tid')};
+            const checkes = $('input', t);
+            for (const c of checkes) {
+                data[c.getAttribute('data-type')] = c.checked ? 1 : 0;
+            }
+            updateData.push(data);
+        }
+        postData(`/sp/${spid}/list/batchUpdate`, updateData, function() {
+            window.location.reload();
+        });
+    });
+});
 
 const tenderListSpec = (function(){
     function getTenderTreeHeaderHtml() {

+ 1 - 0
app/router.js

@@ -275,6 +275,7 @@ module.exports = app => {
     app.post('/sp/:id/list/add', sessionAuth, subProjectCheck, 'tenderController.addTender');
     app.post('/sp/:id/list/update', sessionAuth, subProjectCheck, 'tenderController.updateTender');
     app.post('/sp/:id/list/del', sessionAuth, subProjectCheck, 'tenderController.deleteTender');
+    app.post('/sp/:id/list/batchUpdate', sessionAuth, subProjectCheck, 'tenderController.batchUpdate');
     app.get('/sp/:id/list/refreshCache', sessionAuth, subProjectCheck, 'tenderController.refreshCache');
 
     // **标段合同管理 todo 接入项目内部

+ 16 - 1
app/service/tender.js

@@ -104,7 +104,7 @@ module.exports = app => {
                 sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, this.ctx.subProject.id];
             } else if (getAll === 1 || (permission !== null && permission.tender !== undefined && permission.tender.indexOf('2') !== -1)) {
                 // 具有查看所有标段权限的用户查阅标段
-                sql = 'SELECT t.`id`, t.`project_id`, t.`name`, t.`status`, t.`category`, t.`ledger_times`, t.`ledger_status`, t.`measure_type`, t.`user_id`, t.`create_time`, t.`total_price`, t.`deal_tp`, t.`spid`,' +
+                sql = 'SELECT t.`id`, t.`project_id`, t.`name`, t.`status`, t.`category`, t.`ledger_times`, t.`ledger_status`, t.`measure_type`, t.`user_id`, t.`create_time`, t.`total_price`, t.`deal_tp`, t.`spid`, t.filter_budget, t.filter_fund,' +
                     '    pa.`name` As `user_name`, pa.`role` As `user_role`, pa.`company` As `user_company` ' +
                     '  FROM ?? As t ' +
                     '  Left Join ?? As pa ' +
@@ -360,6 +360,21 @@ module.exports = app => {
             }
         }
 
+        async batchUpdate (data) {
+            const validFields = ['filter_budget', 'filter_fund'];
+            const updateData = [];
+            for (const d of data) {
+                const ud = { id: d.id };
+                for (const prop in d) {
+                    if (validFields.indexOf(prop) < 0) continue;
+                    ud[prop] = d[prop];
+                }
+                updateData.push(d);
+            }
+            await this.db.updateRows(this.tableName, updateData);
+            return updateData;
+        }
+
         /**
          * 假删除
          *

+ 1 - 0
app/view/sp_setting/manage.ejs

@@ -8,6 +8,7 @@
                 </div>
                 <div class="d-inline-block" id="show-level"></div>
                 <div class="d-inline-block"><button class="btn btn-sm btn-primary" data-toggle="modal" data-target="#select-tender">关联标段</button></div>
+                <div class="d-inline-block"><button class="btn btn-sm btn-primary" data-toggle="modal" data-target="#filter-tender">过滤标段</button></div>
             </div>
         </div>
     </div>

+ 25 - 0
app/view/sp_setting/manage_modal.ejs

@@ -28,6 +28,31 @@
         </div>
     </div>
 </div>
+<div class="modal fade" id="filter-tender" data-backdrop="static">
+    <div class="modal-dialog modal-lg" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">过滤标段</h5>
+            </div>
+            <div class="modal-body">
+                <div class="modal-height-500 scroll-y" id="tender-list">
+                    <table class="table table-sm table-bordered table-hover">
+                        <thead class="text-center">
+                        <tr><th rowspan="2" width="80%">标段名称</th><th colspan="2" width="20%">过滤</th></tr>
+                        <tr><th>动态投资</th><th>资金监管</th></tr>
+                        </thead>
+                        <tbody id="filter-tender-list">
+                        </tbody>
+                    </table>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">关闭</button>
+                <button type="button" class="btn btn-sm btn-primary" id="filter-tender-ok">确认</button>
+            </div>
+        </div>
+    </div>
+</div>
 <!--设置其他流程-->
 <div class="modal fade" id="batch2" data-backdrop="static">
     <div class="modal-dialog" role="document">