瀏覽代碼

修复线上调差及计量审批流程bug

ellisran 6 月之前
父節點
當前提交
1306d0dccd
共有 3 個文件被更改,包括 43 次插入10 次删除
  1. 0 1
      app/view/material/file.ejs
  2. 1 1
      app/view/wap/shenpi_stage.ejs
  3. 42 8
      db_script/material_audit_order.js

+ 0 - 1
app/view/material/file.ejs

@@ -122,7 +122,6 @@
 </div>
 <script>
   const auditors = JSON.parse('<%- JSON.stringify(auditors) %>');
-  const curAuditor = JSON.parse('<%- JSON.stringify(ctx.material.curAuditor) %>');
   const materialStatus = parseInt('<%- ctx.material.status %>');
   const materialUid = parseInt('<%- ctx.material.user_id %>');
   const auditConst = JSON.parse('<%- JSON.stringify(auditConst) %>');

+ 1 - 1
app/view/wap/shenpi_stage.ejs

@@ -202,7 +202,7 @@
                         <input type="radio" id="customRadioInline1" name="checkType" class="custom-control-input" value="<%- auditConst.status.checkNo %>" <% if (audit.order === 1 || audit.aid === stage.auditors[0].aid) { %>checked<% } %>>
                         <label class="custom-control-label" for="customRadioInline1">退回原报 <%- stage.user.name %></label>
                     </div>
-                    <% if (stage.curAuditors[0].audit_order > 1) { %>
+                    <% if (stage.curAuditors && stage.curAuditors[0] && stage.curAuditors[0].audit_order > 1) { %>
                         <div class="custom-control custom-radio custom-control-inline">
                             <input class="custom-control-input" type="radio" name="checkType" id="customRadioInline2" value="<%- auditConst.status.checkNoPre %>" checked>
                             <label class="custom-control-label" for="customRadioInline2">退回上一审批人

+ 42 - 8
db_script/material_audit_order.js

@@ -1,5 +1,37 @@
 const BaseUtil = require('./baseUtils');
 const querySql = BaseUtil.querySql;
+const sp_status = {
+    sqspr: 1, // 授权审批人
+    gdspl: 2, // 固定审批流
+    gdzs: 3, // 固定终审
+};
+// 审批类型
+const sp_type = {
+    advance: 1,
+    ledger: 2,
+    revise: 3,
+    stage: 4,
+    change: 5,
+    material: 6,
+};
+const updateShenpiAudit = async function(tender, type) {
+    const shenpiData = await querySql('Select * From zh_shenpi_audit where tid = ? AND sp_type = ? AND sp_status = ? ORDER BY id', [tender.id, type, sp_status.gdspl]);
+    if (shenpiData.length === 0) return;
+
+    for (const [i, spd] of shenpiData.entries()) {
+        if (spd.audit_order > 0) continue;
+        await querySql('UPDATE zh_shenpi_audit SET audit_order = ? WHERE id = ?', [i+1, spd.id]);
+    }
+};
+
+const updateShenpi = async function(tender) {
+    // updateShenpiAudit(tender, sp_type.advance);
+    // updateShenpiAudit(tender, sp_type.ledger);
+    // updateShenpiAudit(tender, sp_type.revise);
+    // updateShenpiAudit(tender, sp_type.stage);
+    // updateShenpiAudit(tender, sp_type.change);
+    await updateShenpiAudit(tender, sp_type.material);
+};
 const errorStageTimes = [];
 const updateMaterialTimes = async function(material, times) {
     const auditData = await querySql('SELECT * FROM zh_material_audit WHERE mid = ? AND times = ? ORDER BY `order`', [material.id, times]);
@@ -38,10 +70,11 @@ const doCompleteTest = async function(id) {
         const tender = await querySql('Select * From zh_tender where id > ?', [id]);
         for (const t of tender) {
             console.log(`Update Tender ${t.name}(${t.id}):`);
-            const materials = await querySql('Select * From zh_material where tid = ?', [t.id]);
-            for (const s of materials) {
-                await updateMaterial(s);
-            }
+            await updateShenpi(t);
+            // const materials = await querySql('Select * From zh_material where tid = ?', [t.id]);
+            // for (const s of materials) {
+            //     await updateMaterial(s);
+            // }
         }
     } catch (err) {
         console.log(err);
@@ -58,10 +91,11 @@ const doComplete = async function() {
         const tenders = await querySql('Select * From zh_tender');
         for (const t of tenders) {
             console.log(`Update Tender ${t.name}(${t.id}):`);
-            const materials = await querySql('Select * From zh_material where tid = ?', [t.id]);
-            for (const s of materials) {
-                await updateMaterial(s);
-            }
+            await updateShenpi(t);
+            // const materials = await querySql('Select * From zh_material where tid = ?', [t.id]);
+            // for (const s of materials) {
+            //     await updateMaterial(s);
+            // }
         }
     } catch (err) {
         console.log(err);