Переглянути джерело

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

Tony Kang 1 рік тому
батько
коміт
e3c2f22f40

+ 2 - 2
app/middleware/http_header.js

@@ -8,7 +8,7 @@ module.exports = options => {
         ctx.set('X-Content-Type-Options', 'nosniff');
         // CT-638385 点击劫持相关
         // 禁止以iframe或者frame的形式嵌入 (deny/sameorign都可)
-        ctx.set('X-Frame-Options', 'deny');
+         ctx.set('X-Frame-Options', 'deny');
         // CT-638235
         // 避免钓鱼欺骗 (启用XSS过滤器。如果检测到攻击,浏览器将不会清理页面,而是完全阻止页面的渲染)
         ctx.set('X-XSS-Protection', '1; mode=block');
@@ -16,7 +16,7 @@ module.exports = options => {
         ctx.set('strict-transport-security', 'max-age=31536000; includeSubDomains; preload');
         //
         const csp = [
-            'default-src', `'self' data: 'unsafe-inline' 'unsafe-eval' https://*.smartcost.com.cn https://*.aliyuncs.com https://*.qq.com/`,
+            'default-src', `'self' data: blob: 'unsafe-inline' 'unsafe-eval' https://*.smartcost.com.cn https://*.aliyuncs.com https://*.qq.com/ https://*.baidu.com/ http://*.baidu.com/`,
         ];
         ctx.set('Content-Security-Policy', csp.join(' '));
         // IE8以上版本用户,在下载时,不显示打开选项

+ 1 - 0
app/public/js/ledger.js

@@ -101,6 +101,7 @@ $(document).ready(function() {
     const ancGclSheet = ancGclSpread.getActiveSheet();
 
     const billsTag = $.billsTag({
+        relaTree: ledgerTree,
         selector: '#bills-tag',
         relaSpread: ledgerSpread,
         relaPosSpread: posSpread,

+ 4 - 4
app/public/js/ledger_gather.js

@@ -415,10 +415,10 @@ $(document).ready(() => {
     });
     $('[name=gather-anc-gcl]').change(function() {
         const checkOption = $('[name=gather-anc-gcl]:checked');
-        if (checkOption.length === 0) {
-            toastr.warning('请至少选择一个汇总条件');
-            return;
-        }
+        // if (checkOption.length === 0) {
+        //     toastr.warning('请至少选择一个汇总条件');
+        //     return;
+        // }
 
         const fields = [];
         for (const co of checkOption) {

+ 22 - 17
app/public/js/revise.js

@@ -103,21 +103,6 @@ $(document).ready(() => {
 
     const posSearch = $.posSearch({selector: '#pos-search', searchSpread: posSpread});
 
-    const billsTag = $.billsTag({
-        selector: '#bills-tag',
-        relaSpread: billsSpread,
-        updateUrl: window.location.pathname + '/tag',
-        afterModify: function (nodes) {
-            SpreadJsObj.repaintNodesRowHeader(billsSpread.getActiveSheet(), nodes);
-        },
-        afterLocated:  function () {
-            posSpreadObj.loadCurPosData();
-        },
-        afterShow: function () {
-            billsSpread.refresh();
-            if (posSpread) posSpread.refresh();
-        },
-    });
     const errorList = $.cs_errorList({
         tabSelector: '#error-list-tab',
         selector: '#error-list',
@@ -184,6 +169,23 @@ $(document).ready(() => {
     // 初始化 计量单元
     const pos = new PosData({ id: 'id', ledgerId: 'lid' });
 
+    const billsTag = $.billsTag({
+        relaTree: billsTree,
+        selector: '#bills-tag',
+        relaSpread: billsSpread,
+        updateUrl: window.location.pathname + '/tag',
+        afterModify: function (nodes) {
+            SpreadJsObj.repaintNodesRowHeader(billsSpread.getActiveSheet(), nodes);
+        },
+        afterLocated:  function () {
+            posSpreadObj.loadCurPosData();
+        },
+        afterShow: function () {
+            billsSpread.refresh();
+            if (posSpread) posSpread.refresh();
+        },
+    });
+
     // 清单 相关方法&绑定spreadjs事件
     const billsTreeSpreadObj = {
         loadExprToInput(sheet) {
@@ -2136,7 +2138,7 @@ $(document).ready(() => {
         billsTree.loadDatas(result.bills);
         treeCalc.calculateAll(billsTree);
         for (const t of result.tags) {
-            t.node = billsTree.datas.find(x => {return x.id === t.lid});
+            t.node = billsTree.nodes.find(x => {return x.id === t.lid});
         }
         billsTag.loadDatas(result.tags);
         SpreadJsObj.loadSheetData(billsSheet, SpreadJsObj.DataType.Tree, billsTree);
@@ -2148,6 +2150,9 @@ $(document).ready(() => {
         posSpreadObj.loadCurPosData();
         SpreadJsObj.resetTopAndSelect(posSheet);
 
+        for (const r of result.att) {
+            r.node = billsTree.datas.find(x => {return x.id === r.lid});
+        }
         reviseAtt = $.ledger_att({
             selector: '#fujian',
             key: 'id',
@@ -2159,7 +2164,7 @@ $(document).ready(() => {
             readOnly: false, // todo fileUploadPermission,
             locate: function (att) {
                 if (!att) return;
-                SpreadJsObj.locateTreeNode(billsSheet, att.node.tree_id, true);
+                SpreadJsObj.locateTreeNode(billsSheet, att.node.ledger_id, true);
                 billsTreeSpreadObj.loadRelaAtt();
                 posSpreadObj.loadCurPosData();
             }

+ 4 - 1
app/public/js/revise_history.js

@@ -170,6 +170,9 @@ $(document).ready(() => {
         posSpreadObj.loadCurPosData();
         SpreadJsObj.resetTopAndSelect(posSheet);
 
+        for (const r of result.att) {
+            r.node = billsTree.datas.find(x => {return x.id === r.lid});
+        }
         reviseAtt = $.ledger_att({
             selector: '#fujian',
             key: 'id',
@@ -181,7 +184,7 @@ $(document).ready(() => {
             readOnly: true, // todo fileUploadPermission,
             locate: function (att) {
                 if (!att) return;
-                SpreadJsObj.locateTreeNode(billsSheet, att.node.tree_id, true);
+                SpreadJsObj.locateTreeNode(billsSheet, att.node.ledger_id, true);
                 billsTreeSpreadObj.loadRelaAtt();
                 posSpreadObj.loadCurPosData();
             }

+ 1 - 0
app/public/js/settle_ledger.js

@@ -194,6 +194,7 @@ $(document).ready(() => {
     };
 
     const billsTag = $.billsTag({
+        relaTree: settleTree,
         selector: '#bills-tag',
         relaSpread: slSpread,
         updateUrl: window.location.pathname + '/tag',

+ 7 - 0
app/public/js/shares/cs_tools.js

@@ -777,6 +777,7 @@ const showSelectTab = function(select, spread, afterShow) {
         if (!setting.key) setting.key = 'id';
         if (!setting.treeId) setting.treeId = 'ledger_id';
         const obj = $(setting.selector);
+        const relaTree = setting.relaTree;
         const html = [], pageLength = 15;
         let billsTags = [], classIndexes = [], billsIndexes = {}, curShow = [];
         html.push('<div class="sjs-bar d-flex justify-content-between">');
@@ -869,6 +870,12 @@ const showSelectTab = function(select, spread, afterShow) {
             tagHtml.push(`<a class="mr-1" name="bills-tag-locate" href="javascript: void(0);" lid="${lid}" pos_id="${tag.pos_id}"><i class="fa fa-crosshairs"></i> 定位</a>`);
             if (tag.uid === userID && !setting.readOnly) tagHtml.push(`<a href="javascript: void(0);" name="bills-tag-edit" tag-id="${tag.id}"><i class="fa fa-edit"></i> 编辑</a>`);
             tagHtml.push('</div>');
+            if (tag.node && relaTree) {
+                const parents = relaTree.getAllParents(tag.node);
+                const parentName = [];
+                parents.forEach(p => { if (p.code && p.level > 1) parentName.push(p.name); });
+                if(parentName.length > 0) tagHtml.push(`<div>所属部位:${parentName.join('/')}</div>`);
+            }
             tagHtml.push('<div class="card-body p-2">', '<p class="card-text">', tag.comment, '</p>', '</div>');
             tagHtml.push('</div>');
             return tagHtml.join('');

+ 1 - 0
app/public/js/sr_detail.js

@@ -327,6 +327,7 @@ $(document).ready(() => {
     SpreadJsObj.initSheet(spSpread.getActiveSheet(), posSpreadSetting);
 
     const billsTag = $.billsTag({
+        relaTree: stageTree,
         selector: '#bills-tag',
         relaSpread: slSpread,
         updateUrl: window.location.pathname + '/tag',

+ 1 - 0
app/public/js/stage.js

@@ -844,6 +844,7 @@ $(document).ready(() => {
     SpreadJsObj.initSheet(spSpread.getActiveSheet(), posSpreadSetting);
 
     const billsTag = $.billsTag({
+        relaTree: stageTree,
         selector: '#bills-tag',
         relaSpread: slSpread,
         updateUrl: window.location.pathname + '/tag',

+ 23 - 4
app/service/stage_audit_ass.js

@@ -43,13 +43,30 @@ module.exports = app => {
         async getAuditStageAss(ass_user_id) {
             // 找出待上报或待审批的协同字段
             const accountStageAssData = await this.getAllDataByCondition({ where: { ass_user_id } });
+            const lastStageList = [];
+            const tidList = this._.map(accountStageAssData, 'tid');
+            for (const t of tidList) {
+                const s = await this.ctx.service.stage.getLastestStage(t);
+                lastStageList.push(s);
+            }
+            const accountStageAssDatas = [];
+            for (const as of accountStageAssData) {
+                const s = this._.find(lastStageList, { tid: as.tid });
+                if (s.id === as.sid) {
+                    const asaIndex = accountStageAssDatas.findIndex(x => { return x.sid === as.sid; });
+                    if (asaIndex === -1 || (asaIndex >= 0 && as.times > accountStageAssDatas[asaIndex].times)) {
+                        if (asaIndex >= 0 && as.times > accountStageAssDatas[asaIndex].times) accountStageAssDatas.splice(asaIndex, 1);
+                        accountStageAssDatas.push(as);
+                    }
+                }
+            }
             const result = [];
             const accountAssData = await this.ctx.service.auditAss.getAllDataByCondition({ where: { ass_user_id } });
-            for (const as of accountStageAssData) {
+            for (const as of accountStageAssDatas) {
                 const index = accountAssData.findIndex(x => { return x.tid === as.tid && x.user_id === as.user_id; });
                 if (index >= 0) {
                     accountAssData.splice(index, 1);
-                    if (as.confirm === 0) result.push(as);
+                    result.push(as);
                 }
             }
             result.push(...accountAssData);
@@ -58,11 +75,13 @@ module.exports = app => {
             if (result.length > 0) {
                 for (const r of result) {
                     const t = await this.ctx.service.tender.getDataById(r.tid);
-                    const s = r.sid ? await this.ctx.service.stage.getDataById(r.sid) : await this.ctx.service.stage.getLastestStage(r.tid);
+                    const s = this._.find(lastStageList, { tid: r.tid }) || await this.ctx.service.stage.getLastestStage(r.tid);
+                    // const s = r.sid && r.sid === lasts.id ? lasts : await this.ctx.service.stage.getDataById(r.sid);
                     if (s) {
                         r.tender_name = t.name;
                         r.sstatus = s.status;
                         r.sorder = s.order;
+                        if (r.sid && r.sid === s.id && r.times && r.times === s.times && r.confirm === 1) continue;
                         if (s && s.status === auditConst.stage.status.checkNo && s.user_id === r.user_id) {
                             const lastAudit = await this.ctx.service.stageAudit.getLastestAuditor(s.id, s.times - 1, auditConst.stage.status.checkNo);
                             r.begin_time = lastAudit ? lastAudit.end_time : s.in_time;
@@ -77,7 +96,7 @@ module.exports = app => {
                     }
                 }
             }
-            return result2;
+            return this._.orderBy(result2, ['begin_time'], ['desc']);
         }
 
         async getUserAssist(stage, user_id) {

+ 1 - 1
app/view/dashboard/index.ejs

@@ -48,7 +48,7 @@
                                     <% if (auditRevise.length !== 0) { %>
                                     <option value="4">台账修订(<%- auditRevise.length %>)</option>
                                     <% } %>
-                                    <% if (auditStages.length !== 0) { %>
+                                    <% if (auditStages.length !== 0 || auditStageAss.length !== 0) { %>
                                     <option value="2">计量审批(<%- (auditStages.length + auditStageAss.length) %>)</option>
                                     <% } %>
                                     <% if (auditChanges.length !== 0) { %>

+ 7 - 1
config/web.js

@@ -263,8 +263,10 @@ const JsFiles = {
                     '/public/js/decimal.min.js',
                     '/public/js/math.min.js',
                     '/public/js/component/menu.js',
+                    '/public/js/axios/axios.min.js', '/public/js/js-xlsx/jszip.min.js', '/public/js/file-saver/FileSaver.min.js',
                 ],
                 mergeFiles: [
+                    '/public/js/shares/ali_oss.js',
                     '/public/js/sub_menu.js',
                     '/public/js/div_resizer.js',
                     '/public/js/spreadjs_rela/spreadjs_zh.js',
@@ -302,8 +304,12 @@ const JsFiles = {
                 mergeFile: 'revise_price',
             },
             history: {
-                files: ['/public/js/spreadjs/sheets/v11/gc.spread.sheets.all.11.2.2.min.js', '/public/js/decimal.min.js', '/public/js/component/menu.js'],
+                files: [
+                    '/public/js/spreadjs/sheets/v11/gc.spread.sheets.all.11.2.2.min.js', '/public/js/decimal.min.js', '/public/js/component/menu.js',
+                    '/public/js/axios/axios.min.js', '/public/js/js-xlsx/jszip.min.js', '/public/js/file-saver/FileSaver.min.js',
+                ],
                 mergeFiles: [
+                    '/public/js/shares/ali_oss.js',
                     '/public/js/sub_menu.js',
                     '/public/js/div_resizer.js',
                     '/public/js/spreadjs_rela/spreadjs_zh.js',