Przeglądaj źródła

资料归集,授权相关

MaiXinRong 11 miesięcy temu
rodzic
commit
bad2fcc656

+ 27 - 18
app/public/js/filing_template.js

@@ -311,39 +311,47 @@ $(document).ready(function() {
                 if (col.field !== 'is_fixed') return;
                 const tree = self.checkTree;
                 const node = tree.nodes[info.row];
-                if (node.level <= 1) {
+                if (node.level <= 1 && node.is_fixed) {
                     toastr.warning('顶层节点不可取消固定');
                     SpreadJsObj.reLoadRowsData(info.sheet, [info.row]);
                     return;
                 }
 
+                const row = [];
                 if (!node.is_fixed) {
-                    node.is_fixed = true;
-                    const row = [tree.nodes.indexOf(node)];
-                    const parents = tree.getAllParents(node);
-                    for (const p of parents) {
-                        if (p.is_fixed) continue;
+                    const relas = [];
+                    if (node.level > 1) {
+                        const parents = tree.getAllParents(node);
+                        for (const p of parents) {
+                            relas.push(...p.children);
+                            if (p.level === 1) relas.push(p);
+                        }
+                    } else {
+                        relas.push(node);
+                    }
+                    for (const p of relas) {
                         p.is_fixed = true;
                         row.push(tree.nodes.indexOf(p));
                     }
-                    SpreadJsObj.reLoadRowsData(info.sheet, row);
                 } else {
-                    node.is_fixed = false;
-                    const row = [tree.nodes.indexOf(node)];
-                    const posterity = tree.getPosterity(node);
+                    const parent = tree.getParent(node);
+                    const posterity = tree.getPosterity(parent);
                     for (const p of posterity) {
-                        if (!p.is_fixed) continue;
                         p.is_fixed = false;
                         row.push(tree.nodes.indexOf(p));
                     }
-                    SpreadJsObj.reLoadRowsData(info.sheet, row);
                 }
+                SpreadJsObj.reLoadRowsData(info.sheet, row);
             });
             $(`#${setting.modal}-ok`).click(function() {
-                const data = self.getMultiUpdateData();
-                filingObj.batchUpdateFiling(data, function() {
-                    self.modal.modal('hide');
-                });
+                try {
+                    const data = self.getMultiUpdateData();
+                    filingObj.batchUpdateFiling(data, function() {
+                        self.modal.modal('hide');
+                    });
+                } catch(err) {
+                    toastr.error(err.stack ? '保存配置数据错误' : err);
+                }
             });
         }
         getMultiUpdateData() {
@@ -353,8 +361,9 @@ $(document).ready(function() {
                 let filing_type = node.source_filing_type;
                 if (!node.is_fixed) {
                     const parents = this.checkTree.getAllParents(node);
-                    const index = parents.lastIndexOf(x => { return x.is_fixed; });
-                    filing_type = parents[index].source_filing_type;
+                    const fixedParent = _.findLast(parents, function(x) { return x.is_fixed; });
+                    if (!fixedParent) throw `【${node.name}】查询不到固定信息`;
+                    filing_type = fixedParent.source_filing_type;
                 }
                 data.push({ id: node.id, is_fixed: node.is_fixed, filing_type });
             }

+ 47 - 12
app/service/filing.js

@@ -43,15 +43,34 @@ module.exports = app => {
         }
 
         analysisFilingType(filing) {
-            const curFilingType = filing.filter(f => {
-                return f.tree_level === 1;
-            });
-            curFilingType.sort((x, y) => {
-                return x.tree_order - y.tree_order;
-            });
-            return curFilingType.map(f => {
-                return { value: f.filing_type, name: f.name }
+            const copy = JSON.parse(JSON.stringify(filing));
+            const curFilingType = copy.filter(f => {
+                return f.is_fixed;
             });
+            const checkChildren = function (parent) {
+                parent.children = curFilingType.filter(x => { return x.tree_pid === parent.id; });
+                if (parent.children.length > 1) parent.children.sort((x, y) => { return x.tree_order - y.tree_order; });
+                for (const c of parent.children) {
+                    checkChildren(c);
+                }
+            };
+            const topFiling = curFilingType.filter(x => { return x.tree_level === 1; });
+            topFiling.sort((x, y) => { return x.tree_order - y.tree_order; });
+            for (const tp of topFiling) {
+                checkChildren(tp);
+            }
+            const result = [];
+            const getFilingType = function(arr, prefix = '') {
+                for (const a of arr) {
+                    if (a.children.length) {
+                        getFilingType(a.children, prefix ? prefix + '/' + a.name : a.name);
+                    } else {
+                        result.push({ value: a.filing_type, name: a.name, parentsName: prefix });
+                    }
+                }
+            };
+            getFilingType(topFiling);
+            return result;
         }
 
         async getFilingType(spid) {
@@ -73,7 +92,7 @@ module.exports = app => {
                 const parent = f.tree_pid !== rootId ? templateFiling.find(x => { return x.id === f.tree_pid; }) : null;
                 const newData = {
                     id: f.newId, tree_pid : parent ? parent.newId : rootId, tree_level: f.tree_level, tree_order: f.tree_order,
-                    spid, add_user_id: this.ctx.session.sessionUser.accountId, is_fixed: f.tree_level === 1,
+                    spid, add_user_id: this.ctx.session.sessionUser.accountId, is_fixed: f.is_fixed,
                     filing_type: f.filing_type, name: f.name,
                 };
                 insertData.push(newData);
@@ -85,11 +104,27 @@ module.exports = app => {
             }
         }
 
+        _filterValidFiling(filing, filingType) {
+            const validFiling = filing.filter(x => { return filingType.indexOf(x.filing_type) > -1;});
+            const checkParent = function(child) {
+                let parent = validFiling.find(x => { return x.id === child.tree_pid; });
+                if (!parent) {
+                    parent = filing.find(x => { return x.id === child.tree_pid; });
+                    validFiling.push(parent);
+                }
+                if (parent.tree_level > 1) checkParent(parent);
+            };
+            for (const vf of validFiling) {
+                if (vf.tree_level > 1 && vf.is_fixed) checkParent(vf);
+            }
+            return validFiling;
+        }
+
         async getValidFiling(spid, filingType) {
-            const condition = { spid, is_deleted: 0 };
-            if (filingType !== 'all') condition.filing_type = filingType;
             if (!filingType || filingType.length === 0) return [];
-            return await this.getAllDataByCondition({ where: condition });
+            const result = await this.getAllDataByCondition({ where: { spid, is_deleted: 0 } });
+            if (filingType === 'all') return result;
+            return this._filterValidFiling(result, filingType);
         }
 
         async getPosterityData(id){

+ 2 - 2
app/service/rpt_gather_memory.js

@@ -1594,8 +1594,8 @@ module.exports = app => {
         async _gatherStageYjcl(tender, stage) {
             const data = await this.ctx.service.stageYjcl.getStageData(stage);
             for (const d of data) {
-                d.end_qty = this.ctx.helper.add(d.pre_qty, qty);
-                d.end_tp = this.ctx.helper.add(d.pre_tp, tp);
+                d.end_qty = this.ctx.helper.add(d.pre_qty, d.qty);
+                d.end_tp = this.ctx.helper.add(d.pre_tp, d.tp);
             }
             this.resultStageJgcl.push(...data);
         }

+ 2 - 2
app/service/sub_project.js

@@ -407,9 +407,9 @@ module.exports = app => {
             if (!template) throw '选择的文件类别不存在';
 
             const templateFiling = await this.ctx.service.filingTemplate.getAllDataByCondition({
-                where: { temp_id: template.id, tree_level: 1 },
+                where: { temp_id: template.id, is_fixed: 1 },
             });
-            const filing_type = templateFiling.map(x => { return x.filing_type; }).join(','), file_permission = '1,2';
+            const filing_type = this.ctx.service.filing.analysisFilingType(templateFiling).map(x => { return x.value; }).join(','), file_permission = '1,2';
             for (const u of users) {
                 const nm = orgMember.find(x => { return u.id === x.uid; });
                 if (nm) {

+ 2 - 2
app/view/file/file_modal.ejs

@@ -11,7 +11,7 @@
                         <div class="d-flex justify-content-center bg-graye">
                             <div class="p-2 vertical-middle"><input class="mr-1" type="checkbox" id="filing-select-all">文档类别</div>
                         </div>
-                        <div class="modal-height-400">
+                        <div class="modal-height-400 scroll-y">
                             <div class="category">
                                 <ul style="list-style: none">
                                     <% for (const ft of filingTypes) { %>
@@ -19,7 +19,7 @@
                                         <div class="form-check">
                                             <input class="form-check-input" name="cbft" type="checkbox" value="<%- ft.value %>" id="ftCheck<%- ft.value %>">
                                             <label class="form-check-label" for="ftCheck<%- ft.value %>"></label>
-                                            <span name="ftName" ftid="<%- ft.value %>"><%- ft.name %></span>
+                                            <span name="ftName" ftid="<%- ft.value %>" title="<%- ft.parentsName %>"><%- ft.name %></span>
                                         </div>
                                     </li>
                                     <% } %>