浏览代码

1. 招标预算脚本
2. 填剩余量相关

MaiXinRong 1 年之前
父节点
当前提交
7394f16214
共有 3 个文件被更改,包括 150 次插入1 次删除
  1. 48 0
      app/public/js/stage.js
  2. 89 0
      db_script/budget_zb.js
  3. 13 1
      publish.md

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

@@ -1560,6 +1560,54 @@ $(document).ready(() => {
             return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
         },
         items: {
+            'remainCur': {
+                name: '填剩余量',
+                disabled: function (key, opt) {
+                    const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
+                    return readOnly || !node || node.lock;
+                },
+                callback: function (key, opt) {
+                    const sheet = spSpread.getActiveSheet();
+                    const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
+
+                    const updateStage = [];
+                    const posterity = stageTree.getPosterity(node);
+                    for (const p of posterity) {
+                        if (p.children && p.children.length > 0) continue;
+                        if (!p.b_code) continue;
+                        const posRange = stagePos.ledgerPos[itemsPre + p.id] || [];
+                        if (posRange.length > 0) continue;
+
+                        if (!p.is_tp) {
+                            const qty = ZhCalc.sub(p.quantity, p.pre_contract_qty);
+                            const differ = ZhCalc.sub(p.quantity, p.end_contract_qty);
+                            if (differ) updateStage.push({ lid: p.id, contract_qty: qty, contract_expr: '' });
+                        } else {
+                            const tp = ZhCalc.sub(p.total_price, p.pre_contract_tp);
+                            const differ = ZhCalc.sub(p.quantity, p.end_contract_qty);
+                            if (differ) updateStage.push({ lid: p.id, contract_tp: tp });
+                        }
+                    }
+
+                    if (updateStage.length > 0) {
+                        if (updateStage.length > 1000) {
+                            toastr.warning('提交的数据太大,仅提交1000条数据');
+                            updateStage.length = 1000;
+                        }
+                        postData(window.location.pathname + '/update', {bills: { stage: updateStage }}, function (result) {
+                            const nodes = stageTree.loadPostStageData(result);
+                            stageTreeSpreadObj.refreshTreeNodes(slSpread.getActiveSheet(), nodes);
+                            if (detail) {
+                                detail.loadStageLedgerUpdateData(result, nodes);
+                            } else {
+                                stageIm.loadUpdateLedgerData(result, nodes);
+                            }
+                            stageTreeSpreadObj.loadExprToInput(sheet);
+                        });
+                    }
+                },
+            },
+            zjjlSpr: '----',
             'locateZjjl': {
                 name: '定位至中间计量',
                 icon: 'fa-sign-in',

+ 89 - 0
db_script/budget_zb.js

@@ -0,0 +1,89 @@
+
+const BaseUtil = require('./baseUtils');
+const querySql = BaseUtil.querySql;
+const uuid = require('node-uuid');
+
+const getInsertSql = function (tableName, data) {
+    const column = [], query = [], value = [];
+    for (const prop in data) {
+        column.push(prop);
+        query.push('?');
+        value.push(data[prop]);
+    }
+    return [`INSERT INTO ${tableName} (${column.map(c => { return '`' + c + '`'}).join(',')}) VALUES (${query.join(',')})`, value]
+};
+
+const initBudgetZb = async function(budget) {
+    let budgetStd = await querySql('SELECT * From zh_budget_std where id = ?', [budget.std_id]);
+    budgetStd = budgetStd[0];
+    if (!budgetStd) {
+        console.log(`【Error】Budget-${budget.name}(${budget.id}): 未定义概预算标准`);
+        return;
+    }
+    if (!budgetStd.zb_template_id) {
+        console.log(`【Error】概预算标准-${budgetStd.name}: 招标预算模板未定义`);
+        return;
+    }
+
+    const template = await querySql('SELECT * FROM zh_bills_template WHERE list_id = ?', [budgetStd.zb_template_id]);
+    for (const tmp of template) {
+        const initB = {
+            id: uuid.v4(),
+            bid: budget.id,
+            tree_id: tmp.template_id,
+            tree_pid: tmp.pid,
+            level: tmp.level,
+            order: tmp.order,
+            full_path: tmp.full_path,
+            is_leaf: tmp.is_leaf,
+            code: tmp.code,
+            name: tmp.name,
+            unit: tmp.unit,
+            node_type: tmp.node_type,
+        };
+        const [initSql, initSqlParam] = getInsertSql('zh_budget_zb', initB);
+        await querySql(initSql, initSqlParam);
+    }
+};
+
+const checkBudgetZb = async function(budget) {
+    const data = await querySql('SELECT * From zh_budget_zb where bid = ?', [budget.id]);
+    if (data.length > 0) {
+        console.log(`Exit Budget ${budget.name}(${budget.id}):`);
+        return;
+    }
+
+    await initBudgetZb(budget);
+    console.log(`Done Budget ${budget.name}(${budget.id}):`);
+};
+
+const doComplete = async function() {
+    try {
+        const budget = await querySql('Select * From zh_budget');
+        for (const b of budget) {
+            console.log(`Update Budget ${b.name}(${b.id}):`);
+            await checkBudgetZb(b);
+        }
+    } catch (err) {
+        console.log(err);
+    }
+    BaseUtil.closePool();
+};
+const doCompleteTest = async function(tid) {
+    try {
+        const budget = await querySql('Select * From zh_budget where id = ?', [tid]);
+        for (const b of budget) {
+            console.log(`Update Budget ${b.name}(${b.id}):`);
+            await checkBudgetZb(b);
+        }
+    } catch (err) {
+        console.log(err);
+    }
+    BaseUtil.closePool();
+};
+const tenderId = process.argv[3];
+if (tenderId) {
+    doCompleteTest(tenderId);
+} else {
+    doComplete()
+}

+ 13 - 1
publish.md

@@ -10,8 +10,20 @@
 ##特殊操作
 如果没有特殊说明,则在第默认操作的第3步前,执行相关脚本,如果有特殊要求,需特别说明
 
+### V3.5.35
+#### uat
+```shell
+$ cd db_script
+$ node budget_zb uat
+```
+#### prod
+```shell
+$ cd db_script
+$ node budget_zb default
+```
+
 ### V3.5.35.0945
-2023-8-23 ~ 2023-9-22(uat) ~ prod
+2023-8-23 ~ 2023-9-22(uat) ~ 2023-9-23(prod)
 
 ### V3.5.34.0841
 2023-7-28 ~ 2023-8-21(uat) ~ 2023-8-22prod