Ver código fonte

填剩余量

MaiXinRong 3 anos atrás
pai
commit
4b4c796910
1 arquivos alterados com 74 adições e 0 exclusões
  1. 74 0
      app/public/js/stage.js

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

@@ -2211,6 +2211,80 @@ $(document).ready(() => {
                     $('#calc-by-ratio').modal('show');
                 }
             },
+            'remainCur': {
+                name: '填剩余量(选中行)',
+                disabled: function (key, opt) {
+                    const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
+                    return readOnly || node.lock;
+                },
+                callback: function (key, opt) {
+                    const sheet = spSpread.getActiveSheet();
+                    const sels = sheet.getSelections();
+                    if (!sels || !sels[0]) return;
+
+                    const data = { updateType: 'update', updateData: [] };
+                    for (let iRow = 0; iRow < sels[0].rowCount; iRow++) {
+                        const curRow = iRow + sels[0].row;
+                        const curPos = SpreadJsObj.getRowObject(sheet, curRow);
+                        if (!curPos) continue;
+
+                        const qty = ZhCalc.sub(curPos.quantity, curPos.pre_contract_qty);
+                        const differ = ZhCalc.sub(curPos.quantity, curPos.end_contract_qty);
+                        if (differ) data.updateData.push({ pid: curPos.id, lid: curPos.lid, contract_qty: qty });
+                    }
+                    if (data.updateData.length > 0) {
+                        postData(window.location.pathname + '/update', {pos: data}, function (result) {
+                            if (result.pos) {
+                                stagePos.updateDatas(result.pos.pos);
+                                stagePos.loadCurStageData(result.pos.curStageData);
+                            }
+                            const nodes = stageTree.loadPostStageData(result.ledger);
+                            stageTreeSpreadObj.refreshTreeNodes(slSpread.getActiveSheet(), nodes);
+                            stagePosSpreadObj.loadCurPosData();
+                            if (detail) {
+                                detail.loadStagePosUpdateData(result, nodes);
+                            } else {
+                                stageIm.loadUpdatePosData(result, nodes);
+                            }
+                        });
+                    }
+                },
+            },
+            'remainAll': {
+                name: '填剩余量(全部行)',
+                disabled: function (key, opt) {
+                    const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
+                    return readOnly || node.lock;
+                },
+                callback: function (key, opt) {
+                    const sheet = spSpread.getActiveSheet();
+                    if (!sheet.zh_data || sheet.zh_data.length === 0) return;
+
+                    const data = { updateType: 'update', updateData: [] };
+                    for (const curPos of sheet.zh_data) {
+                        const qty = ZhCalc.sub(curPos.quantity, curPos.pre_contract_qty);
+                        const differ = ZhCalc.sub(curPos.quantity, curPos.end_contract_qty);
+                        if (differ) data.updateData.push({ pid: curPos.id, lid: curPos.lid, contract_qty: qty });
+                    }
+                    if (data.updateData.length > 0) {
+                        postData(window.location.pathname + '/update', {pos: data}, function (result) {
+                            if (result.pos) {
+                                stagePos.updateDatas(result.pos.pos);
+                                stagePos.loadCurStageData(result.pos.curStageData);
+                            }
+                            const nodes = stageTree.loadPostStageData(result.ledger);
+                            stageTreeSpreadObj.refreshTreeNodes(slSpread.getActiveSheet(), nodes);
+                            stagePosSpreadObj.loadCurPosData();
+                            if (detail) {
+                                detail.loadStagePosUpdateData(result, nodes);
+                            } else {
+                                stageIm.loadUpdatePosData(result, nodes);
+                            }
+                        });
+                    }
+
+                },
+            },
             'shoufangdan': {
                 name: '生成收方单',
                 visible: function(key, opt) {