浏览代码

工程量清单模式,计量台账,可删除本期新增的部位明细

MaiXinRong 6 年之前
父节点
当前提交
2e8b87f52a
共有 4 个文件被更改,包括 239 次插入145 次删除
  1. 68 5
      app/public/js/stage.js
  2. 18 7
      app/public/js/zh_calc.js
  3. 1 1
      app/service/pos.js
  4. 152 132
      app/service/stage_pos.js

+ 68 - 5
app/public/js/stage.js

@@ -889,7 +889,6 @@ $(document).ready(() => {
                 if (checkTzMeasureType() && !posData) {
                     toast('台账模式不可新增部位明细数据', 'error');
                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
-                    info.cancel = true;
                     return ;
                 }
                 // 不同节点下,部位明细检查输入
@@ -911,9 +910,9 @@ $(document).ready(() => {
                 // 生成提交数据
                 const data = {};
                 if (col.field === 'name') {
-                    if (info.editingText === '' && pos) {
+                    if ((!info.editingText || info.editingText === '') && posData) {
                         toast('部位名称不可为空', 'error', 'exclamation-circle');
-                        info.cancel = true;
+                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
                         return;
                     } else if (!posData) {
                         if (info.editingText !== '') {
@@ -921,6 +920,7 @@ $(document).ready(() => {
                             const order = (!sortData || sortData.length === 0) ? 1 : Math.max(sortData[sortData.length - 1].porder + 1, sortData.length + 1);
                             data.updateData = {name: info.editingText, lid: node.id, tid: tender.id, porder: order};
                         } else {
+                            SpreadJsObj.reLoadRowData(info.sheet, info.row);
                             return;
                         }
                     } else {
@@ -1087,8 +1087,27 @@ $(document).ready(() => {
                 }
             }
         },
-        leaveCell: function (e, info) {
-            console.log(1);
+        deletePos: function (sheet) {
+            const sels = sheet.getSelections();
+            const sel = sels ? sels[0] : null;
+            if (sheet.zh_data && sel) {
+                const data = {updateType: 'delete', updateData: []};
+                for (let iRow = 0; iRow < sel.rowCount; iRow++) {
+                    const posData = sheet.zh_data[sel.row + iRow];
+                    if (posData) {
+                        data.updateData.push(posData.id);
+                    }
+                }
+                if (data.updateData.length > 0) {
+                    postData(window.location.pathname + '/update', {pos: data}, function (result) {
+                        stagePos.removeDatas(result.pos.pos);
+                        const refreshData = stageTree.loadPostStageData(result.ledger);
+                        stageTreeSpreadObj.refreshTreeNodes(slSpread.getActiveSheet(), refreshData);
+                        stagePosSpreadObj.loadCurPosData();
+                        needCheckDetail();
+                    });
+                }
+            }
         },
     };
     // 加载上下窗口resizer
@@ -1117,6 +1136,50 @@ $(document).ready(() => {
     spSpread.bind(spreadNS.Events.ClipboardPasted, stagePosSpreadObj.clipboardPasted);
     spSpread.bind(spreadNS.Events.EditStarting, stagePosSpreadObj.editStarting);
     SpreadJsObj.addDeleteBind(spSpread, stagePosSpreadObj.deletePress);
+    if (!checkTzMeasureType()) {
+        $.contextMenu({
+            selector: '#stage-pos',
+            build: function ($trigger, e) {
+                const target = SpreadJsObj.safeRightClickSelection($trigger, e, spSpread);
+                return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
+            },
+            items: {
+                'del': {
+                    name: '删除',
+                    icon: 'fa-remove',
+                    disabled: function (key, opt) {
+                        const sheet = spSpread.getActiveSheet();
+                        if (sheet.zh_data && !readOnly) {
+                            const selection = sheet.getSelections();
+                            if (selection && selection[0]) {
+                                let valid = sheet.zh_data.length < selection[0].row + selection[0].rowCount;
+                                for (let iRow = 0; iRow < selection[0].rowCount; iRow++) {
+                                    const posData = sheet.zh_data[selection[0].row + iRow];
+                                    if (posData) {
+                                        if (posData.add_stage_order < stage.order || ZhCalc.isNonZero(posData.gather_qty) || ZhCalc.isNonZero(posData.end_gather_qty)) {
+                                            valid = true;
+                                            break;
+                                        }
+                                    } else {
+                                        valid = true;
+                                        break;
+                                    }
+                                }
+                                return valid;
+                            } else {
+                                return true;
+                            }
+                        } else {
+                            return true;
+                        }
+                    },
+                    callback: function (key, opt) {
+                        stagePosSpreadObj.deletePos(spSpread.getActiveSheet());
+                    }
+                }
+            }
+        })
+    }
 
     $('#row-view').on('show.bs.modal', function () {
         const html = [], customDisplay = customColDisplay();

+ 18 - 7
app/public/js/zh_calc.js

@@ -7,7 +7,7 @@
  * @version
  */
 ;const zhBaseCalc = (function () {
-    const mulPrecision = 12, divPrecision = 12;
+    const zeroPrecision = 12, mulPrecision = 12, divPrecision = 12;
 
     function digitLength (num) {
         // 兼容科学计数
@@ -49,7 +49,17 @@
         return this.round(num1 / num2, divPrecision);
     }
 
-    return { digitLength: digitLength, powLength: powLength, round: round, add: add, sub: sub, mul: mul, div: div }
+    function isNonZero(num) {
+        return num && round(num, zeroPrecision) !== 0;
+    }
+
+    return {
+        digitLength: digitLength,
+        powLength: powLength,
+        round: round,
+        add: add, sub: sub, mul: mul, div: div,
+        isNonZero: isNonZero,
+    }
 })();
 
 /**
@@ -76,7 +86,7 @@ const ZhCalc = (function () {
      */
     function sub(num1, num2) {
         return zhBaseCalc.sub(num1 ? num1 : 0, num2 ? num2 : 0);
-    };
+    }
     /**
      * 乘法 num1 * num2
      * @param num1
@@ -86,7 +96,7 @@ const ZhCalc = (function () {
     function mul(num1, num2, digit = 6) {
         //return Decimal.mul(num1 ? num1 : 0, num2 ? num2 : 0).toDecimalPlaces(digit).toNumber();
         return (num1 && num2) ? (Decimal.mul(num1, num2).toDecimalPlaces(digit).toNumber()) : 0;
-    };
+    }
     /**
      * 除法 num1 / num2
      * @param num1 - 被除数
@@ -100,7 +110,7 @@ const ZhCalc = (function () {
         } else {
             return null;
         }
-    };
+    }
     /**
      * 四舍五入
      * @param {Number} value - 舍入的数字
@@ -109,6 +119,7 @@ const ZhCalc = (function () {
      */
     function round(value, decimal) {
         return value ? new Decimal(value).toDecimalPlaces(decimal).toNumber() : null;
-    };
-    return {add, sub, mul, div, round}
+    }
+
+    return {add, sub, mul, div, round, isNonZero: zhBaseCalc.isNonZero}
 })();

+ 1 - 1
app/service/pos.js

@@ -23,7 +23,7 @@ module.exports = app => {
         }
 
         async getPosData(condition) {
-            const sql = 'SELECT p.id, p.tid, p.lid, p.name, p.quantity, p.drawing_code, p.sgfh_qty, p.sjcl_qty, p.qtcl_qty, p.porder, s.order As add_stage_order ' +
+            const sql = 'SELECT p.id, p.tid, p.lid, p.name, p.quantity, p.drawing_code, p.sgfh_qty, p.sjcl_qty, p.qtcl_qty, p.porder, p.add_stage, p.add_times, p.add_user, s.order As add_stage_order ' +
                 '  FROM ' + this.tableName + ' p ' +
                 '  LEFT JOIN ' + this.ctx.service.stage.tableName + ' s' +
                 '  ON add_stage = s.id'

+ 152 - 132
app/service/stage_pos.js

@@ -96,64 +96,71 @@ module.exports = app => {
          * @returns {Promise<{}>}
          * @private
          */
-        async _addStagePosData(transaction, data) {
+        async _addStagePosData(data) {
             let bills , precision;
             const  result = {pos: [], ledger: []};
             const datas = data instanceof Array ? data : [data], calcBills = [], calcStageBills = [];
 
-            for (const d of datas) {
-                if (d.sgfh_qty !== undefined || d.sjcl_qty !== undefined || d.qtcl_qty !== undefined) {
-                    if (!bills || bills.id !== data.lid) {
-                        bills = await this.ctx.service.ledger.getDataById(d.lid);
-                        precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, bills.unit);
+            const transaction = await this.db.beginTransaction();
+            try {
+                for (const d of datas) {
+                    if (d.sgfh_qty !== undefined || d.sjcl_qty !== undefined || d.qtcl_qty !== undefined) {
+                        if (!bills || bills.id !== data.lid) {
+                            bills = await this.ctx.service.ledger.getDataById(d.lid);
+                            precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, bills.unit);
+                        }
                     }
-                }
-                // 在主表pos中新增数据
-                const p = {
-                    id: this.uuid.v4(), tid: this.ctx.tender.id, lid: d.lid, name: d.name, porder: d.porder,
-                    add_stage: this.ctx.stage.id,
-                    add_times: this.ctx.stage.curTimes,
-                    add_user: this.ctx.session.sessionUser.accountId,
-                };
-                if (d.sgfh_qty) p.sgfh_qty = this.round(d.sgfh_qty, precision.value);
-                if (d.sjcl_qty) p.sjcl_qty = this.round(d.sjcl_qty, precision.value);
-                if (d.qtcl_qty) p.qtcl_qty = this.round(d.qtcl_qty, precision.value);
-                p.quantity = this.ctx.helper.sum([p.sgfh_qty, p.sjcl_qty, p.qtcl_qty]);
-                const addRst = await transaction.insert(this.ctx.service.pos.tableName, p);
-                result.pos.push(p.id);
-                // 如果存在复核数据,更新计算主表清单
-                if (p.sgfh_qty || p.sjcl_qty || p.qtcl_qty) {
-                    calcBills.push(p.lid);
-                    result.ledger.push(p.lid);
-                }
-                // 如果存在本期计算数据,更新计算清单本期计量数据
-                if (d.contract_qty || d.qc_qty || d.postil) {
-                    const ps = {
-                        pid: d.id,
-                        lid: d.lid,
-                        tid: this.ctx.tender.id,
-                        sid: this.ctx.stage.id,
-                        said: this.ctx.session.sessionUser.accountId,
-                        times: this.ctx.stage.curTimes,
-                        order: this.ctx.stage.curOrder,
+                    // 在主表pos中新增数据
+                    const p = {
+                        id: this.uuid.v4(), tid: this.ctx.tender.id, lid: d.lid, name: d.name, porder: d.porder,
+                        add_stage: this.ctx.stage.id,
+                        add_times: this.ctx.stage.curTimes,
+                        add_user: this.ctx.session.sessionUser.accountId,
                     };
-                    if (d.contract_qty) ps.contract_qty = this.round(d.contract_qty, precision.value);
-                    if (d.qc_qty) ps.qc_qty = this.round(d.qc_qty, precision.value);
-                    if (d.postil) ps.postil = d.postil;
-                    await transaction.insert(ps);
-                    if (d.contract_qty || d.qc_qty) {
-                        calcStageBills.push(ps.lid);
+                    if (d.sgfh_qty) p.sgfh_qty = this.round(d.sgfh_qty, precision.value);
+                    if (d.sjcl_qty) p.sjcl_qty = this.round(d.sjcl_qty, precision.value);
+                    if (d.qtcl_qty) p.qtcl_qty = this.round(d.qtcl_qty, precision.value);
+                    p.quantity = this.ctx.helper.sum([p.sgfh_qty, p.sjcl_qty, p.qtcl_qty]);
+                    const addRst = await transaction.insert(this.ctx.service.pos.tableName, p);
+                    result.pos.push(p.id);
+                    // 如果存在复核数据,更新计算主表清单
+                    if (p.sgfh_qty || p.sjcl_qty || p.qtcl_qty) {
+                        calcBills.push(p.lid);
+                        result.ledger.push(p.lid);
+                    }
+                    // 如果存在本期计算数据,更新计算清单本期计量数据
+                    if (d.contract_qty || d.qc_qty || d.postil) {
+                        const ps = {
+                            pid: d.id,
+                            lid: d.lid,
+                            tid: this.ctx.tender.id,
+                            sid: this.ctx.stage.id,
+                            said: this.ctx.session.sessionUser.accountId,
+                            times: this.ctx.stage.curTimes,
+                            order: this.ctx.stage.curOrder,
+                        };
+                        if (d.contract_qty) ps.contract_qty = this.round(d.contract_qty, precision.value);
+                        if (d.qc_qty) ps.qc_qty = this.round(d.qc_qty, precision.value);
+                        if (d.postil) ps.postil = d.postil;
+                        await transaction.insert(ps);
+                        if (d.contract_qty || d.qc_qty) {
+                            calcStageBills.push(ps.lid);
+                        }
+                        result.stageUpdate = true;
                     }
-                    result.stageUpdate = true;
                 }
+                for (const lid of calcBills) {
+                    await this.ctx.service.ledger.calc(this.ctx.tender.id, lid, transaction);
+                }
+                for (const lid of calcStageBills) {
+                    await this.ctx.service.stageBills.calc(ctx.tender.id, ctx.stage.id, lid, transaction);
+                }
+                await transaction.commit();
+                return result;
+            } catch(err) {
+                await transaction.rollback();
+                throw err;
             }
-            for (const lid of calcBills) {
-                await this.ctx.service.ledger.calc(this.ctx.tender.id, lid, transaction);
-            }
-            for (const lid of calcStageBills) {
-                await this.ctx.service.stageBills.calc(ctx.tender.id, ctx.stage.id, lid, transaction);
-            }
-            return result;
         }
 
         /**
@@ -164,65 +171,73 @@ module.exports = app => {
          * @returns {Promise<{ledger: Array, pos: Array}>}
          * @private
          */
-        async _updateStagePosData(transaction, data) {
+        async _updateStagePosData(data) {
             let bills, precision;
             const result = {ledger: [], pos: [], stageUpdate: true}, ledgerCalc = [];
             const datas = data instanceof Array ? data : [data];
             const orgPos = await this.ctx.service.pos.getPosDataByIds(this._.map(datas, 'pid'));
             const orgStagePos = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, {pid: this._.map(datas, 'pid')});
-            for (const d of datas) {
-                if (d.sgfh_qty || d.qtcl_qty || d.sjcl_qty || d.contract_qty || d.qc_qty) {
-                    if (!bills || bills.id !== data.lid) {
-                        bills = await this.ctx.service.ledger.getDataById(d.lid);
-                        precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, bills.unit);
+
+            const transaction = await this.db.beginTransaction();
+            try {
+                for (const d of datas) {
+                    if (d.sgfh_qty || d.qtcl_qty || d.sjcl_qty || d.contract_qty || d.qc_qty) {
+                        if (!bills || bills.id !== data.lid) {
+                            bills = await this.ctx.service.ledger.getDataById(d.lid);
+                            precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, bills.unit);
+                        }
                     }
-                }
-                if (d.name !== undefined || d.sgfh_qty !== undefined || d.qtcl_qty !== undefined || d.sjcl_qty !== undefined) {
-                    const p = {id: d.pid};
-                    if (d.name !== undefined) p.name = d.name;
-                    if (d.sgfh_qty !== undefined || d.qtcl_qty !== undefined || d.sjcl_qty !== undefined) {
-                        const op = this._.find(orgPos, {id: d.pid});
-                        p.sgfh_qty = d.sgfh_qty !== undefined ? d.sgfh_qty : op.sgfh_qty;
-                        p.sjcl_qty = d.sjcl_qty !== undefined ? d.sjcl_qty : op.sjcl_qty;
-                        p.qtcl_qty = d.qtcl_qty !== undefined ? d.qtcl_qty : op.qtcl_qty;
-                        p.quantity = this.ctx.helper.sum([p.sgfh_qty, p.sjcl_qty, p.qtcl_qty]);
-                        if (ledgerCalc.indexOf(op.lid) === -1) {
-                            ledgerCalc.push(op.lid);
+                    if (d.name !== undefined || d.sgfh_qty !== undefined || d.qtcl_qty !== undefined || d.sjcl_qty !== undefined) {
+                        const p = {id: d.pid};
+                        if (d.name !== undefined) p.name = d.name;
+                        if (d.sgfh_qty !== undefined || d.qtcl_qty !== undefined || d.sjcl_qty !== undefined) {
+                            const op = this._.find(orgPos, {id: d.pid});
+                            p.sgfh_qty = d.sgfh_qty !== undefined ? d.sgfh_qty : op.sgfh_qty;
+                            p.sjcl_qty = d.sjcl_qty !== undefined ? d.sjcl_qty : op.sjcl_qty;
+                            p.qtcl_qty = d.qtcl_qty !== undefined ? d.qtcl_qty : op.qtcl_qty;
+                            p.quantity = this.ctx.helper.sum([p.sgfh_qty, p.sjcl_qty, p.qtcl_qty]);
+                            if (ledgerCalc.indexOf(op.lid) === -1) {
+                                ledgerCalc.push(op.lid);
+                            }
                         }
+                        await transaction.update(this.ctx.service.pos.tableName, p);
                     }
-                    await transaction.update(this.ctx.service.pos.tableName, p);
-                }
 
-                if (d.contract_qty !== undefined || d.qc_qty !== undefined || d.postil !== undefined) {
-                    const sp = {pid: d.pid, lid: d.lid, contract_qty: d.contract_qty, qc_qty: d.qc_qty, postil: d.postil};
-                    const osp = this._.find(orgStagePos, function (p) { return p.pid === d.pid; });
-                    if (precision) {
-                        this.ctx.helper.checkFieldPrecision(sp, this.qtyFields, precision.value);
+                    if (d.contract_qty !== undefined || d.qc_qty !== undefined || d.postil !== undefined) {
+                        const sp = {pid: d.pid, lid: d.lid, contract_qty: d.contract_qty, qc_qty: d.qc_qty, postil: d.postil};
+                        const osp = this._.find(orgStagePos, function (p) { return p.pid === d.pid; });
+                        if (precision) {
+                            this.ctx.helper.checkFieldPrecision(sp, this.qtyFields, precision.value);
+                        }
+                        if (osp && osp.times === this.ctx.stage.curTimes && osp.order === this.ctx.stage.curOrder) {
+                            await transaction.update(this.tableName, d, {where: {id: osp.id}});
+                        } else {
+                            sp.tid = this.ctx.tender.id;
+                            sp.sid = this.ctx.stage.id;
+                            sp.said = this.ctx.session.sessionUser.accountId;
+                            sp.times = this.ctx.stage.curTimes;
+                            sp.order = this.ctx.stage.curOrder;
+                            await transaction.insert(this.tableName, sp);
+                        }
                     }
-                    if (osp && osp.times === this.ctx.stage.curTimes && osp.order === this.ctx.stage.curOrder) {
-                        await transaction.update(this.tableName, d, {where: {id: osp.id}});
-                    } else {
-                        sp.tid = this.ctx.tender.id;
-                        sp.sid = this.ctx.stage.id;
-                        sp.said = this.ctx.session.sessionUser.accountId;
-                        sp.times = this.ctx.stage.curTimes;
-                        sp.order = this.ctx.stage.curOrder;
-                        await transaction.insert(this.tableName, sp);
+                    result.pos.push(d.pid);
+                    if ((d.sgfh_qty !== undefined || d.qtcl_qty !== undefined || d.sjcl_qty !== undefined ||
+                            d.contract_qty === undefined || d.qc_qty === undefined) && (result.ledger.indexOf(d.lid) === -1)) {
+                        result.ledger.push(d.lid);
                     }
                 }
-                result.pos.push(d.pid);
-                if ((d.sgfh_qty !== undefined || d.qtcl_qty !== undefined || d.sjcl_qty !== undefined ||
-                        d.contract_qty === undefined || d.qc_qty === undefined) && (result.ledger.indexOf(d.lid) === -1)) {
-                    result.ledger.push(d.lid);
+                for (const lid of ledgerCalc) {
+                    await this.ctx.service.ledger.calc(this.ctx.tender.id, lid, transaction);
                 }
+                for (const lid of result.ledger) {
+                    await this.ctx.service.stageBills.calc(this.ctx.tender.id, this.ctx.stage.id, lid, transaction);
+                }
+                await transaction.commit();
+                return result;
+            } catch (err) {
+                await transaction.rollback();
+                throw err;
             }
-            for (const lid of ledgerCalc) {
-                await this.ctx.service.ledger.calc(this.ctx.tender.id, lid, transaction);
-            }
-            for (const lid of result.ledger) {
-                await this.ctx.service.stageBills.calc(this.ctx.tender.id, this.ctx.stage.id, lid, transaction);
-            }
-            return result;
         }
 
         /**
@@ -233,9 +248,9 @@ module.exports = app => {
          * @returns {Promise<{}>}
          * @private
          */
-        async _deleteStagePosData(transaction, data) {
-            const result = {};
+        async _deleteStagePosData(data) {
             const pos = await this.ctx.service.pos.getPosData({tid: this.ctx.tender.id, id: data});
+            const result = { pos: data, isDeletePos: true};
             if (pos instanceof Array) {
                 for (const p of pos) {
                     if (p.add_stage !== this.ctx.stage.id || p.add_times !== this.ctx.stage.curTimes || p.add_user !== this.ctx.session.sessionUser.accountId) {
@@ -246,20 +261,28 @@ module.exports = app => {
                 throw '您无权删除该数据';
             }
             const ledgerIds = this._.map(pos, 'lid');
-            // 删除部位明细
-            await transaction.delete(this.ctx.service.pos.tableName, {tid: this.ctx.tender.id, id: data});
-            for (const lid of ledgerIds) {
-                await this.ctx.service.ledger.calc(tid, lid, transaction);
-            }
-            // 删除部位明细计量数据
-            await transaction.delete(this.tableName, {tid: this.ctx.tender.id, lid: data});
-            for (const lid of ledgerIds) {
-                await this.ctx.service.stageBills.calc(this.ctx.tender.id, this.ctx.stage.id, lid, transaction);
+
+            const transaction = await this.db.beginTransaction();
+            try {
+                // 删除部位明细
+                await transaction.delete(this.ctx.service.pos.tableName, {tid: this.ctx.tender.id, id: data});
+                for (const lid of ledgerIds) {
+                    await this.ctx.service.ledger.calc(this.ctx.tender.id, lid, transaction);
+                }
+                // 删除部位明细计量数据
+                await transaction.delete(this.tableName, {tid: this.ctx.tender.id, lid: data});
+                for (const lid of ledgerIds) {
+                    await this.ctx.service.stageBills.calc(this.ctx.tender.id, this.ctx.stage.id, lid, transaction);
+                }
+                await transaction.commit();
+                // 获取需要更新的数据
+                result.ledger = ledgerIds;
+                result.stageUpdate = true;
+                return result;
+            } catch (err) {
+                await transaction.rollback();
+                throw err;
             }
-            // 获取需要更新的数据
-            result.ledger = ledgerIds;
-            result.stageUpdate = true;
-            return result;
         }
 
         /**
@@ -269,28 +292,21 @@ module.exports = app => {
          * @returns {Promise<{ledger: {}, pos: {}}>}
          */
         async updateStageData(data) {
+            if ((data.updateType === 'add' || data.upateType === 'delete') && this.ctx.tender.measure_type === measureType.tz) {
+                throw '台账模式下,不可在计量中新增或删除部位明细,如需操作,请进行台账修订';
+            }
             let refreshData;
-            const transaction = await this.db.beginTransaction();
-            try {
-                if ((data.updateType === 'add' || data.upateType === 'delete') && this.ctx.tender.measure_type === measureType.tz) {
-                    throw '台账模式下,不可在计量中新增或删除部位明细,如需操作,请进行台账修订';
-                }
-                if (data.updateType === 'add') {
-                    refreshData = await this._addStagePosData(transaction, data.updateData);
-                } else if (data.updateType === 'update') {
-                    refreshData = await this._updateStagePosData(transaction, data.updateData);
-                } else if (data.updateType === 'delete') {
-                    if (!data.updateData || data.updateData.length === 0) {
-                        throw '提交数据错误';
-                    }
-                    refreshData = await this._deleteStagePosData(transaction, data.updateData);
-                } else {
+            if (data.updateType === 'add') {
+                refreshData = await this._addStagePosData(data.updateData);
+            } else if (data.updateType === 'update') {
+                refreshData = await this._updateStagePosData(data.updateData);
+            } else if (data.updateType === 'delete') {
+                if (!data.updateData || data.updateData.length === 0) {
                     throw '提交数据错误';
                 }
-                await transaction.commit();
-            } catch (err) {
-                await transaction.rollback();
-                throw err;
+                refreshData = await this._deleteStagePosData(data.updateData);
+            } else {
+                throw '提交数据错误';
             }
 
             try {
@@ -301,10 +317,14 @@ module.exports = app => {
                         result.ledger.curStageData = await this.ctx.service.stageBills.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, refreshData.ledger);
                     }
                 }
-                if (refreshData.pos && refreshData.pos.length > 0) {
-                    result.pos.pos = await this.ctx.service.pos.getPosData({id: refreshData.pos});
-                    if (refreshData.stageUpdate) {
-                        result.pos.curStageData = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, {pid: refreshData.pos});
+                if (refreshData.pos) {
+                    if (refreshData.isDeletePos) {
+                        result.pos.pos = refreshData.pos;
+                    } else if (refreshData.pos.length > 0) {
+                        result.pos.pos = await this.ctx.service.pos.getPosData({id: refreshData.pos});
+                        if (refreshData.stageUpdate) {
+                            result.pos.curStageData = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, {pid: refreshData.pos});
+                        }
                     }
                 }
                 return result;