Forráskód Böngészése

Merge branch 'master' of http://192.168.1.41:3000/maixinrong/Calculation

TonyKang 5 éve
szülő
commit
e8c9c8e9e1

+ 3 - 3
app/lib/rpt_data_analysis.js

@@ -163,7 +163,7 @@ const gatherGcl = {
     },
     _loadGatherInfo: function (gcl, data) {
         for (const prop in data) {
-            if (/^t_[0-9]*_(id|name)$/.test(prop)) {
+            if (/^t_[0-9]+_(id|name)$/.test(prop)) {
                 gcl[prop] = data[prop];
             }
         }
@@ -188,7 +188,7 @@ const gatherGcl = {
         }
         const gatherOther = fields.indexOf('chapter') >= 0;
         const gclBills = [], other = {name: '未计入清单章节项', chapter: '10000'};
-        this._loadGatherInfo(other, gatherData[0]);
+        if (tableName.indexOf('mem_gather_') >= 0) this._loadGatherInfo(other, gatherData[0]);
 
         for (const b of gatherData) {
             const child = ctx.helper._.find(gatherData, {ledger_pid: b.ledger_id});
@@ -1339,7 +1339,7 @@ const stageSelectConverse = {
     },
     _commonConverse: function (helper, data, stages) {
         const result = [];
-        const reg = new RegExp('^t_[0-9]+_');
+        const reg = new RegExp('^s_[0-9]+_');
         for (const s of stages) {
             const curReg = new RegExp('^s_' + s + '_');
             for (const [i, d] of data.entries()) {

+ 22 - 1
app/public/js/change_approval.js

@@ -85,6 +85,7 @@ $(document).ready(() => {
                 $('input[name="w_code"]').val($.trim($('#w_code').val()));
 
                 $('#success-approval').find('textarea').val(sdesc.replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' '));
+                if ($('#warning-text').length) $('#warning-text').remove()
                 $('#success-approval').submit();
             }
         } else {
@@ -95,7 +96,10 @@ $(document).ready(() => {
             }
             const type = $('#fail-approval').find('input[name="status"]:checked').val();
             if (type === undefined) {
-                toastr.error('请选择退回类型!');
+                // toastr.error('请选择退回类型!');
+                if (!$('#warning-text').length) {
+                    $('#change-back-content').prepend('<p id="warning-text" style="color: red; margin: 0;">请选择退回流程</p>');
+                }
                 returnflag = false;
             }
             if(returnflag) {
@@ -143,3 +147,20 @@ const postDataWithAsync = function (url, data, successCallback, errorCallBack, s
         }
     });
 };
+
+function auditCheck(i) {
+    console.log('111111111')
+    const inlineRadio1 = $('#change-back:checked').val()
+    const inlineRadio2 = $('#chagne-backnew:checked').val()
+    const opinion = $('textarea[name="sdesc"]').eq(i).val().replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ');
+    $('textarea[name="sdesc"]').eq(i).val(opinion);
+    if (!inlineRadio1 && !inlineRadio2) {
+        if (!$('#warning-text').length) {
+            $('#reject-process').prepend('<p id="warning-text" style="color: red; margin: 0;">请选择退回流程</p>');
+        }
+        return false;
+    } else {
+        if ($('#warning-text').length) $('#warning-text').remove()
+        return true;
+    }
+}

+ 11 - 2
app/public/js/material_audit.js

@@ -163,8 +163,17 @@ function checkAuditorFrom () {
 }
 // texterea换行
 function auditCheck(i) {
-    console.log('11111111111')
+    const inlineRadio1 = $('#inlineRadio1:checked').val()
+    const inlineRadio2 = $('#inlineRadio2:checked').val()
     const opinion = $('textarea[name="opinion"]').eq(i).val().replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ');
     $('textarea[name="opinion"]').eq(i).val(opinion);
-    return true;
+    if (!inlineRadio1 && !inlineRadio2) {
+        if (!$('#warning-text').length) {
+            $('#reject-process').prepend('<p id="warning-text" style="color: red; margin: 0;">请选择退回流程</p>');
+        }
+        return false;
+    } else {
+        if ($('#warning-text').length) $('#warning-text').remove()
+        return true;
+    }
 }

+ 22 - 14
app/service/ledger.js

@@ -324,22 +324,20 @@ module.exports = app => {
             if (!bSameParent) {
                 throw '复制数据错误:仅可操作同层节点';
             }
-            const orgParentPath = copyNodes[0].full_path.replace(copyNodes[0].ledger_id, '');
 
-            const newIds = [];
+            const pasteBillsData = [], pastePosData = [];
             this.transaction = await this.db.beginTransaction();
             try {
                 // 选中节点的所有后兄弟节点,order+粘贴节点个数
                 await this._updateChildrenOrder(tenderId, selectData.ledger_pid, selectData.order + 1, copyNodes.length);
                 // 数据库创建新增节点数据
+                const leafBillsId = [];
+                let maxId = await this._getMaxLid(this.ctx.tender.id);
                 for (let iNode = 0; iNode < copyNodes.length; iNode++) {
                     const node = copyNodes[iNode];
                     let datas = await this.getDataByFullPath(paste.tid, node.full_path + '%');
                     datas = this._.sortBy(datas, 'level');
 
-                    const maxId = await this._getMaxLid(this.ctx.tender.id);
-
-                    const leafBillsId = [];
                     // 计算粘贴数据中需更新部分
                     datas.sort(function (x, y) {
                         return x.level - y.level;
@@ -372,7 +370,6 @@ module.exports = app => {
                         if (data.is_leaf) {
                             leafBillsId.push(idChange);
                         }
-                        newIds.push(data.id);
                     }
                     for (const data of datas) {
                         delete data.children;
@@ -384,13 +381,26 @@ module.exports = app => {
                         } else {
                             data.full_path = newParentPath + '' + data.ledger_id;
                         }
+                        pasteBillsData.push(data)
                     }
-                    const newData = await this.transaction.insert(this.tableName, datas);
-                    for (const id of leafBillsId) {
-                        await this.ctx.service.pos.copyBillsPosData(id.org, id.new, this.transaction);
+                    maxId = maxId + datas.length;
+                }
+                const newData = await this.transaction.insert(this.tableName, pasteBillsData);
+                this._cacheMaxLid(tenderId, maxId);
+
+                for (const id of leafBillsId) {
+                    const posData = await this.ctx.service.pos.getAllDataByCondition({ where: { tid: paste.tid, lid: id.org } });
+                    if (posData.length > 0) {
+                        for (const pd of posData) {
+                            pd.id = this.uuid.v4();
+                            pd.lid = id.new;
+                            pd.tid = this.ctx.tender.id;
+                            pd.in_time = new Date();
+                            pastePosData.push(pd);
+                        }
                     }
-                    this._cacheMaxLid(tenderId, maxId + datas.length);
                 }
+                await this.transaction.insert(this.ctx.service.pos.tableName, pastePosData);
                 await this.transaction.commit();
             } catch (err) {
                 await this.transaction.rollback();
@@ -402,12 +412,10 @@ module.exports = app => {
             for (let i = 1; i <= copyNodes.length; i++) {
                 order.push(selectData.order + i);
             }
-            const createData = await this.getDataByIds(newIds);
             const updateData = await this.getNextsData(selectData.tender_id, selectData.ledger_pid, selectData.order + copyNodes.length);
-            const posData = await this.ctx.service.pos.getPosData({ lid: newIds });
             return {
-                ledger: { create: createData, update: updateData },
-                pos: posData,
+                ledger: { create: pasteBillsData, update: updateData },
+                pos: pastePosData,
             };
         }
 

+ 14 - 9
app/service/pos.js

@@ -454,17 +454,22 @@ module.exports = app => {
          * @param transaction - 复制整块事务
          * @returns {Promise<void>}
          */
-        async copyBillsPosData(orgLid, newLid, transaction) {
-            const posData = await this.getAllDataByCondition({ where: { lid: orgLid } });
-            if (posData.length > 0) {
-                for (const pd of posData) {
-                    pd.id = this.uuid.v4();
-                    pd.lid = newLid;
-                    pd.tid = this.ctx.tender.id;
-                    pd.in_time = new Date();
+        async copyBillsPosData(lid, transaction) {
+            const lidArr = lid instanceof Array ? lid : [lid];
+            const pasteData = [];
+            for (const id of lidArr) {
+                const posData = await this.getAllDataByCondition({ where: { lid: id.org } });
+                if (posData.length > 0) {
+                    for (const pd of posData) {
+                        pd.id = this.uuid.v4();
+                        pd.lid = id.new;
+                        pd.tid = this.ctx.tender.id;
+                        pd.in_time = new Date();
+                        pasteData.push(pd);
+                    }
                 }
-                await transaction.insert(this.tableName, posData);
             }
+            await transaction.insert(this.tableName, pasteData);
         }
 
         /**

+ 5 - 3
app/view/change/info_modal.ejs

@@ -704,14 +704,16 @@
                                                         <textarea class="form-control form-control-sm" name="sdesc">不同意</textarea>
                                                         <input type="hidden" name="audit_id" value="<%= a.id %>">
                                                     </div>
-                                                    <div class="alert alert-warning">
+                                                    <div id="change-back-content"class="alert alert-warning">
                                                         <div class="form-check form-check-inline">
-                                                            <input class="form-check-input" type="radio" name="status" id="change-back" value="5" <% if (a.usite === 1) { %>checked<% } %>>
+                                                            <input class="form-check-input" type="radio" name="status" id="change-back" value="5">
+                                                            <!-- <input class="form-check-input" type="radio" name="status" id="change-back" value="5" <% if (a.usite === 1) { %>checked<% } %>> -->
                                                             <label class="form-check-label" for="change-back">退回原报 <%= auditList3[0].name %></label>
                                                         </div>
                                                         <% if (a.usite !== 1) { %>
                                                             <div class="form-check form-check-inline">
-                                                                <input class="form-check-input" type="radio" name="status" id="chagne-backnew" value="6" <% if (a.usite !== 1) { %>checked<% } %>>
+                                                                <input class="form-check-input" type="radio" name="status" id="chagne-backnew" value="6">
+                                                                <!-- <input class="form-check-input" type="radio" name="status" id="chagne-backnew" value="6" <% if (a.usite !== 1) { %>checked<% } %>> -->
                                                                 <label class="form-check-label" for="chagne-backnew">退回上一审批人 <%= auditList2[a.usite-1].name %></label>
                                                                 <input type="hidden" name="audit_last_id" value="<%= auditList2[a.usite-1].id %>">
                                                             </div>

+ 6 - 3
app/view/material/audit_modal.ejs

@@ -327,15 +327,18 @@
                                         <label>审批意见<b class="text-danger">*</b></label>
                                         <textarea class="form-control form-control-sm" name="opinion">不同意</textarea>
                                     </div>
-                                    <div class="alert alert-warning">
+                                    <div id="reject-process" class="alert alert-warning">
+
                                         <div class="form-check form-check-inline">
-                                            <input class="form-check-input" type="radio" name="checkType" id="inlineRadio1" value="<%- auditConst.status.checkNo %>" <% if (auditors[iA].order === 1 || auditors[iA].aid === auditors[0].aid) { %>checked<% } %>>
+                                            <!-- <input class="form-check-input" type="radio" name="checkType" id="inlineRadio1" value="<%- auditConst.status.checkNo %>" <% if (auditors[iA].order === 1 || auditors[iA].aid === auditors[0].aid) { %>checked<% } %>> -->
+                                            <input class="form-check-input" type="radio" name="checkType" id="inlineRadio1" value="<%- auditConst.status.checkNo %>">
                                             <label class="form-check-label" for="inlineRadio1">退回原报 <%- ctx.material.user.name %></label>
                                         </div>
                                         <% if (auditors[iA].order > 1 && auditors[iA].aid !== auditors[0].aid) { %>
                                             <% const auditorIndex = ctx.material.auditors.findIndex(function (item) { return item.aid === auditors[iA].aid }) %>
                                             <div class="form-check form-check-inline">
-                                                <input class="form-check-input" type="radio" name="checkType" id="inlineRadio2" value="<%- auditConst.status.checkNoPre %>" checked>
+                                                <!-- <input class="form-check-input" type="radio" name="checkType" id="inlineRadio2" value="<%- auditConst.status.checkNoPre %>" checked> -->
+                                                <input class="form-check-input" type="radio" name="checkType" id="inlineRadio2" value="<%- auditConst.status.checkNoPre %>" >
                                                 <label class="form-check-label" for="inlineRadio2">退回上一审批人 <%- ctx.material.auditors[auditorIndex-1].name %></label>
                                             </div>
                                         <% } %>