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

变更添加清单页增加批量录入功能

ellisran 2 hete
szülő
commit
47c24da263

+ 638 - 0
app/public/js/change_revise.js

@@ -5492,6 +5492,644 @@ $(document).ready(() => {
                 }
             });
         });
+
+
+        const batchPosSpreadObj = {
+            clearBpSheet: function (sheet) {
+                sheet.zh_data = [];
+                sheet.deleteRows(0, sheet.getRowCount() - 3);
+                SpreadJsObj.resetTopAndSelect(sheet);
+            },
+            clearSpSheet: function (sheet) {
+                sheet.zh_data = [];
+                sheet.deleteRows(0, sheet.getRowCount());
+                SpreadJsObj.resetTopAndSelect(sheet);
+                for (const bp of bpObj.bpData) {
+                    bp.add = false;
+                    bpObj.bpSheet.zh_data[bpObj.bpData.indexOf(bp)].add = false;
+                }
+                SpreadJsObj.reLoadSheetData(bpObj.bpSheet);
+            },
+            bpClipboardPasted: function (e, info) {
+                if (info.sheet.getColumnCount() > info.sheet.zh_setting.cols.length) {
+                    info.sheet.setColumnCount(info.sheet.zh_setting.cols.length);
+                }
+                const node = SpreadJsObj.getSelectObject(billsSheet);
+                const data = [];
+                const rows = [];
+                const updateData = [], insertData = [];
+                const sortData = info.sheet.zh_data || [];
+                const hint = {
+                    expr: {type: 'warning', msg: '粘贴了表达式非法,已过滤'},
+                };
+                let bHint = false;
+                for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
+                    let bPaste = true;
+                    const curRow = info.cellRange.row + iRow;
+                    const posData = curRow >= sortData.length ? {} : sortData[curRow];
+                    for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
+                        const curCol = info.cellRange.col + iCol;
+                        const colSetting = info.sheet.zh_setting.cols[curCol];
+                        if (!colSetting) continue;
+                        let validText = colSetting.wordWrap ? info.sheet.getText(curRow, curCol) : trimInvalidChar(info.sheet.getText(curRow, curCol));
+                        if (colSetting.field === 'camount') {
+                            bPaste = true;
+                            const exprQuantity = {
+                                expr: '',
+                                quantity: 0,
+                            };
+                            const [valid, msg] = billsTreeSpreadObj._checkExpr(validText, exprQuantity);
+                            if (!valid) {
+                                toastMessageUniq(hint.expr);
+                                bPaste = false;
+                                continue;
+                            }
+                            if (isNaN(exprQuantity.quantity)) {
+                                toastMessageUniq(hint.expr);
+                                bPaste = false;
+                                continue;
+                            }
+                            validText = parseFloat(exprQuantity.quantity);
+                            posData.camount = ZhCalc.round(validText, findDecimal(node.unit)) || 0;
+                            posData.camount_expr = exprQuantity.expr;
+                            continue;
+                        }
+                        posData[colSetting.field] = validText;
+                    }
+                    if (bPaste && posData.name) {
+                        posData.id = curRow;
+                        delete posData.waitingLoading;
+                        if (curRow >= sortData.length) {
+                            bpObj.bpData.push(posData);
+                            insertData.push(posData);
+                        } else {
+                            // 更改bpObj.bpData同行数据用posData替换
+                            bpObj.bpData[curRow] = posData;
+                            updateData.push(posData);
+                        }
+                        data.push(posData);
+                        rows.push(curRow);
+                    }
+                }
+                if (data.length > 0) {
+                    for (const [i,d] of data.entries()) {
+                        const pos = _.find(bpObj.posData, { name: d.name });
+                        const bpPoss = _.filter(bpObj.bpData, { name: d.name });
+                        const spPos = _.find(bpObj.spData, { name: d.name });
+                        if (pos && bpPoss.length > 0) {
+                            // 其它bpPoss add为false
+                            for (const b of bpPoss) {
+                                b.add = false;
+                            }
+                            const cInfo = _.find(changeList, { gcl_id: pos.lid, mx_id: pos.id });
+                            if (cInfo) {
+                                continue;
+                            }
+                            bpObj.bpData[rows[i]].add = true;
+                            if (spPos) {
+                                spPos.id = d.id;
+                                spPos.camount = d.camount;
+                                spPos.camount_expr = d.camount_expr;
+                            } else {
+                                bpObj.spData.push({
+                                    id: d.id,
+                                    gcl_id: pos.lid,
+                                    mx_id: pos.id,
+                                    name: d.name,
+                                    camount: d.camount || 0,
+                                    camount_expr: d.camount_expr || '',
+                                    is_valuation: 1,
+                                });
+                            }
+                        }
+                    }
+                }
+                SpreadJsObj.loadSheetData(bpObj.bpSheet, SpreadJsObj.DataType.Data, bpObj.bpData);
+                SpreadJsObj.loadSheetData(bpObj.spSheet, SpreadJsObj.DataType.Data, bpObj.spData);
+            },
+            bpEditStarting: function (e, info) {
+                const sel = info.sheet.getSelections();
+                if (!sel || !sel[0]) return;
+                const col = info.sheet.zh_setting.cols[sel[0].col];
+                const node = SpreadJsObj.getSelectObject(info.sheet);
+                if (!node || node.id === undefined) return;
+                if (col.field === 'camount') {
+                    if (node.camount_expr && node.camount_expr !== '') {
+                        info.sheet.getCell(info.row, info.col).text(node.camount_expr);
+                    }
+                }
+            },
+            bpEditEnded: function (e, info) {
+                if (!info.sheet.zh_setting) {
+                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                    return;
+                }
+                const posData = info.sheet.zh_data ? info.sheet.zh_data[info.row] : null;
+                const node = SpreadJsObj.getSelectObject(billsSheet);
+                const col = info.sheet.zh_setting.cols[info.col];
+                if (!posData || posData.id === undefined || !col) {
+                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                    return;
+                }
+                if (col.field === 'camount') {
+                    let validText = info.editingText ? trimInvalidChar(info.editingText) : '';
+                    const orgValue = validText && validText !== ''
+                        ? (_.toNumber(validText) ? posData.camount : posData.camount_expr)
+                        : (posData.camount_expr && posData.camount_expr !== '' ? posData.camount_expr : posData.camount);
+                    if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
+                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        return;
+                    }
+                    const exprQuantity = {
+                        expr: '',
+                        quantity: 0,
+                    };
+                    const [valid, msg] = billsTreeSpreadObj._checkExpr(validText, exprQuantity);
+                    if (!valid) {
+                        toastr.error(msg);
+                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        return;
+                    }
+                    if (isNaN(exprQuantity.quantity)) {
+                        toastr.error('不能输入其它非数字类型字符');
+                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        return;
+                    }
+                    validText = parseFloat(exprQuantity.quantity);
+                    posData[col.field] = ZhCalc.round(validText, findDecimal(node.unit)) || 0;
+                    posData.camount_expr = exprQuantity.expr;
+                    const spPos = _.find(bpObj.spData, { id: posData.id });
+                    if (spPos) {
+                        spPos.camount = posData.camount;
+                        spPos.camount_expr = posData.camount_expr;
+                        const spRow = _.findIndex(bpObj.spSheet.zh_data, { id: posData.id });
+                        if (spRow >= 0) {
+                            bpObj.spSheet.zh_data[spRow].camount = posData.camount;
+                            bpObj.spSheet.zh_data[spRow].camount_expr = posData.camount_expr;
+                            SpreadJsObj.reLoadRowData(bpObj.spSheet, spRow);
+                        }
+                    }
+                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                }
+            },
+            spClipboardPasted: function (e, info) {
+                if (info.sheet.getColumnCount() > info.sheet.zh_setting.cols.length) {
+                    info.sheet.setColumnCount(info.sheet.zh_setting.cols.length);
+                }
+                const node = SpreadJsObj.getSelectObject(billsSheet);
+                const data = [];
+                const rows = [];
+                const sortData = info.sheet.zh_data || [];
+                const hint = {
+                    expr: {type: 'warning', msg: '粘贴了表达式非法,已过滤'},
+                };
+                let bHint = false;
+                for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
+                    let bPaste = true;
+                    const curRow = info.cellRange.row + iRow;
+                    const posData = sortData[curRow];
+                    if (!posData || posData.id === undefined) continue;
+                    for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
+                        const curCol = info.cellRange.col + iCol;
+                        const colSetting = info.sheet.zh_setting.cols[curCol];
+                        if (!colSetting) continue;
+                        let validText = colSetting.wordWrap ? info.sheet.getText(curRow, curCol) : trimInvalidChar(info.sheet.getText(curRow, curCol));
+                        if (colSetting.field === 'camount') {
+                            bPaste = true;
+                            const exprQuantity = {
+                                expr: '',
+                                quantity: 0,
+                            };
+                            const [valid, msg] = billsTreeSpreadObj._checkExpr(validText, exprQuantity);
+                            if (!valid) {
+                                toastMessageUniq(hint.expr);
+                                bPaste = false;
+                                continue;
+                            }
+                            if (isNaN(exprQuantity.quantity)) {
+                                toastMessageUniq(hint.expr);
+                                bPaste = false;
+                                continue;
+                            }
+                            validText = parseFloat(exprQuantity.quantity);
+                            posData.camount = ZhCalc.round(validText, findDecimal(node.unit)) || 0;
+                            posData.camount_expr = exprQuantity.expr;
+                            continue;
+                        }
+                    }
+                    if (bPaste) {
+                        delete posData.waitingLoading;
+                        bpObj.spData[curRow] = posData;
+                        data.push(posData);
+                    }
+                }
+                if (data.length > 0) {
+                    for (const [i,d] of data.entries()) {
+                        const bpPos = _.find(bpObj.bpData, { id: d.id });
+                        if (bpPos) {
+                            bpPos.camount = d.camount;
+                            bpPos.camount_expr = d.camount_expr;
+                            const bpRow = _.findIndex(bpObj.bpSheet.zh_data, { id: d.id });
+                            if (bpRow >= 0) {
+                                bpObj.bpSheet.zh_data[bpRow].camount = d.camount;
+                                bpObj.bpSheet.zh_data[bpRow].camount_expr = d.camount_expr;
+                                SpreadJsObj.reLoadRowData(bpObj.bpSheet, bpRow);
+                            }
+                        }
+                    }
+                }
+                SpreadJsObj.loadSheetData(bpObj.spSheet, SpreadJsObj.DataType.Data, bpObj.spData);
+            },
+            spEditStarting: function (e, info) {
+                const sel = info.sheet.getSelections();
+                if (!sel || !sel[0]) return;
+                const col = info.sheet.zh_setting.cols[sel[0].col];
+                const node = SpreadJsObj.getSelectObject(info.sheet);
+                if (!node || node.id === undefined) return;
+                if (col.field === 'camount') {
+                    if (node.camount_expr && node.camount_expr !== '') {
+                        info.sheet.getCell(info.row, info.col).text(node.camount_expr);
+                    }
+                }
+            },
+            spEditEnded: function (e, info) {
+                if (!info.sheet.zh_setting) {
+                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                    return;
+                }
+                const posData = info.sheet.zh_data ? info.sheet.zh_data[info.row] : null;
+                const node = SpreadJsObj.getSelectObject(billsSheet);
+                const col = info.sheet.zh_setting.cols[info.col];
+                if (!posData || posData.id === undefined || !col) {
+                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                    return;
+                }
+                if (col.field === 'camount') {
+                    let validText = info.editingText ? trimInvalidChar(info.editingText) : '';
+                    const orgValue = validText && validText !== ''
+                        ? (_.toNumber(validText) ? posData.camount : posData.camount_expr)
+                        : (posData.camount_expr && posData.camount_expr !== '' ? posData.camount_expr : posData.camount);
+                    if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
+                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        return;
+                    }
+                    const exprQuantity = {
+                        expr: '',
+                        quantity: 0,
+                    };
+                    const [valid, msg] = billsTreeSpreadObj._checkExpr(validText, exprQuantity);
+                    if (!valid) {
+                        toastr.error(msg);
+                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        return;
+                    }
+                    if (isNaN(exprQuantity.quantity)) {
+                        toastr.error('不能输入其它非数字类型字符');
+                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        return;
+                    }
+                    validText = parseFloat(exprQuantity.quantity);
+                    posData[col.field] = ZhCalc.round(validText, findDecimal(node.unit)) || 0;
+                    posData.camount_expr = exprQuantity.expr;
+                    const bpPos = _.find(bpObj.bpData, { id: posData.id });
+                    if (bpPos) {
+                        bpPos.camount = posData.camount;
+                        bpPos.camount_expr = posData.camount_expr;
+                        const bpRow = _.findIndex(bpObj.bpSheet.zh_data, { id: posData.id });
+                        if (bpRow >= 0) {
+                            bpObj.bpSheet.zh_data[bpRow].camount = posData.camount;
+                            bpObj.bpSheet.zh_data[bpRow].camount_expr = posData.camount_expr;
+                            SpreadJsObj.reLoadRowData(bpObj.bpSheet, bpRow);
+                        }
+                    }
+                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                }
+            },
+            spButtonClicked: function (e, info) {
+                if (!info.sheet.zh_setting) return;
+
+                const col = info.sheet.zh_setting.cols[info.col];
+                if (col.field !== 'is_valuation') return;
+
+                const node = SpreadJsObj.getSelectObject(info.sheet);
+                node.is_valuation = !node.is_valuation ? 1 : 0;
+                SpreadJsObj.reLoadSheetData(bpObj.spSheet);
+            },
+            deleteBp: function () {
+                if (bpObj.bpData.length === 0) return;
+                if (bpObj.bpSheet.getSelections().length === 0) return;
+                const selections = bpObj.bpSheet.getSelections();
+                const sel = selections ? selections[0] : bpObj.bpSheet.getSelections()[0];
+                const row = sel && sel.row !== undefined ? sel.row : -1;
+                if (row === -1 || sel.row + sel.rowCount > bpObj.bpData.length) {
+                    return false;
+                }
+                const delList = [];
+                for (let r = 0; r < sel.rowCount; r++) {
+                    const select = bpObj.bpData[row + r];
+                    delList.push(select);
+                }
+                _.pullAll(bpObj.bpData, delList);
+                bpObj.bpSheet.deleteRows(row, sel.rowCount);
+                // SpreadJsObj.loadSheetData(bpObj.bpSheet, SpreadJsObj.DataType.Data, bpObj.bpData);
+                SpreadJsObj.resetTopAndSelect(bpObj.bpSheet);
+            },
+            deleteSp: function () {
+                if (bpObj.spData.length === 0) return;
+                if (bpObj.spSheet.getSelections().length === 0) return;
+                const selections = bpObj.spSheet.getSelections();
+                const sel = selections ? selections[0] : bpObj.spSheet.getSelections()[0];
+                const row = sel && sel.row !== undefined ? sel.row : -1;
+                if (row === -1 || sel.row + sel.rowCount > bpObj.spData.length) {
+                    return false;
+                }
+                const delList = [];
+                for (let r = 0; r < sel.rowCount; r++) {
+                    const select = bpObj.spData[row + r];
+                    const bpSelect = _.filter(bpObj.bpData, { name: select.name });
+                    for (const b of bpSelect) {
+                        b.add = false;
+                    }
+                    delList.push(select);
+                }
+                _.pullAll(bpObj.spData, delList);
+                bpObj.spSheet.deleteRows(row, sel.rowCount);
+                SpreadJsObj.resetTopAndSelect(bpObj.spSheet);
+                SpreadJsObj.reLoadSheetData(bpObj.bpSheet);
+            },
+        };
+
+
+        $('#batch-pos').on('show.bs.modal', function (e) {
+            makeBatchPosSjsHtml();
+        });
+        let bp = false;
+        let bpObj = {
+            setting: null,
+            opSheet: null,
+            bpSheet: null,
+            spSheet: null,
+            posData: [],
+            spData: [],
+            bpData: [],
+        };
+
+        function makeBatchPosSjsHtml() {
+            if (!bp) {
+                initBatchPos();
+                bp = true;
+            }
+            const node = SpreadJsObj.getSelectObject(billsSheet);
+            if (node) {
+                const posData = pos.getLedgerPos(node.id) || [];
+                bpObj.posData = posData;
+                $('#batch-ledger-name').text(node.b_code);
+                SpreadJsObj.loadSheetData(bpObj.opSheet, SpreadJsObj.DataType.Data, posData);
+            } else {
+                bpObj.posData = [];
+                $('#batch-ledger-name').text('');
+                SpreadJsObj.loadSheetData(bpObj.opSheet, SpreadJsObj.DataType.Data, []);
+            }
+            bpObj.bpData = [];
+            bpObj.spData = [];
+            SpreadJsObj.loadSheetData(bpObj.bpSheet, SpreadJsObj.DataType.Data, []);
+            SpreadJsObj.loadSheetData(bpObj.spSheet, SpreadJsObj.DataType.Data, []);
+            // if (datas.length === 0) {
+            //     $('#show-project-0').show();
+            // } else {
+            //     $('#show-project-0').hide();
+            // }
+        }
+
+        const initBatchPos = function () {
+            const opSpread = SpreadJsObj.createNewSpread($('#origin-pos-spread')[0]);
+            bpObj.opSheet = opSpread.getActiveSheet();
+            const opSpreadSetting = {
+                emptyRows: 0,
+                headRows: 2,
+                headRowHeight: [25, 25],
+                defaultRowHeight: 21,
+                headerFont: '12px 微软雅黑',
+                font: '12px 微软雅黑',
+                headColWidth: [],
+                readOnly: true,
+                // selectedBackColor: '#fffacd',
+            };
+            opSpreadSetting.cols = posSpreadSetting.cols;
+            SpreadJsObj.initSheet(bpObj.opSheet, opSpreadSetting);
+            const bpSpread = SpreadJsObj.createNewSpread($('#batch-pos-spread')[0]);
+            bpObj.bpSheet = bpSpread.getActiveSheet();
+            const bpSpreadSetting = {
+                cols: [
+                    {
+                        title: '计量单元',
+                        field: 'name',
+                        hAlign: 0,
+                        width: 200,
+                        formatter: '@',
+                        readOnly: true,
+                    },
+                    {
+                        title: '申请变更数量',
+                        field: 'camount',
+                        hAlign: 2,
+                        width: 120,
+                        // readOnly: true,
+                    },
+                ],
+                emptyRows: 3,
+                headRows: 1,
+                headRowHeight: [32],
+                defaultRowHeight: 21,
+                headerFont: '12px 微软雅黑',
+                font: '12px 微软雅黑',
+                headColWidth: []
+                // selectedBackColor: '#fffacd',
+            };
+            bpSpreadSetting.getColor = function (sheet, data, row, col, defaultColor) {
+                if (data && data.add) {
+                    return '#c3e6cb';
+                }
+                return defaultColor;
+            };
+            SpreadJsObj.initSheet(bpObj.bpSheet, bpSpreadSetting);
+            bpSpread.bind(spreadNS.Events.EditStarting, batchPosSpreadObj.bpEditStarting);
+            bpSpread.bind(spreadNS.Events.EditEnded, batchPosSpreadObj.bpEditEnded);
+            bpSpread.bind(spreadNS.Events.ClipboardPasted, batchPosSpreadObj.bpClipboardPasted);
+
+            const spSpread = SpreadJsObj.createNewSpread($('#save-pos-spread')[0]);
+            bpObj.spSheet = spSpread.getActiveSheet();
+            const spSpreadSetting = {
+                cols: [
+                    {
+                        title: '计量单元',
+                        field: 'name',
+                        hAlign: 0,
+                        width: 200,
+                        formatter: '@',
+                        readOnly: true,
+                    },
+                    {
+                        title: '申请变更数量',
+                        field: 'camount',
+                        hAlign: 2,
+                        width: 120,
+                        // readOnly: true,
+                    },
+                    {
+                        title: '计价',
+                        field: 'is_valuation',
+                        hAlign: 1,
+                        width: 40,
+                        formatter: '@',
+                        cellType: 'checkbox',
+                        readOnly: true,
+                    },
+                ],
+                emptyRows: 0,
+                headRows: 1,
+                headRowHeight: [32],
+                defaultRowHeight: 21,
+                headerFont: '12px 微软雅黑',
+                font: '12px 微软雅黑',
+                headColWidth: []
+            };
+            SpreadJsObj.initSheet(bpObj.spSheet, spSpreadSetting);
+            spSpread.bind(spreadNS.Events.ButtonClicked, batchPosSpreadObj.spButtonClicked);
+            spSpread.bind(spreadNS.Events.EditStarting, batchPosSpreadObj.spEditStarting);
+            spSpread.bind(spreadNS.Events.EditEnded, batchPosSpreadObj.spEditEnded);
+            spSpread.bind(spreadNS.Events.ClipboardPasted, batchPosSpreadObj.spClipboardPasted);
+
+            // 右键删除已选粘贴
+            const bpContextMenuOptions = {
+                selector: '#batch-pos-spread',
+                build: function ($trigger, e) {
+                    const target = SpreadJsObj.safeRightClickSelection($trigger, e, bpSpread);
+                    return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
+                },
+                items: {
+                    delete: {
+                        name: '删除',
+                        icon: 'fa-remove',
+                        callback: function (key, opt) {
+                            batchPosSpreadObj.deleteBp();
+                        },
+                        disabled: function (key, opt) {
+                            const selection = bpObj.bpSheet.getSelections();
+                            const sel = selection ? selection[0] : bpObj.bpSheet.getSelections()[0];
+                            const row = sel && sel.row !== undefined ? sel.row : -1;
+                            if (row === -1 || sel.row + sel.rowCount > bpObj.bpData.length) {
+                                return true;
+                            }
+                            return false;
+                        }
+                    },
+                }
+            };
+            $.contextMenu(bpContextMenuOptions);
+
+            // 右键删除已选录入
+            const spContextMenuOptions = {
+                selector: '#save-pos-spread',
+                build: function ($trigger, e) {
+                    const target = SpreadJsObj.safeRightClickSelection($trigger, e, spSpread);
+                    return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
+                },
+                items: {
+                    delete: {
+                        name: '删除',
+                        icon: 'fa-remove',
+                        callback: function (key, opt) {
+                            batchPosSpreadObj.deleteSp();
+                        },
+                        disabled: function (key, opt) {
+                            const selection = bpObj.spSheet.getSelections();
+                            const sel = selection ? selection[0] : bpObj.spSheet.getSelections()[0];
+                            const row = sel && sel.row !== undefined ? sel.row : -1;
+                            if (row === -1 || sel.row + sel.rowCount > bpObj.spData.length) {
+                                return true;
+                            }
+                            return false;
+                        }
+                    },
+                }
+            };
+            $.contextMenu(spContextMenuOptions);
+
+            $('#batch-pos').bind('shown.bs.modal', function () {
+                if (opSpread) opSpread.refresh();
+                if (bpSpread) bpSpread.refresh();
+                if (spSpread) spSpread.refresh();
+            });
+
+            $('#clear-bp-btn').click(function () {
+                bpObj.bpData = [];
+                batchPosSpreadObj.clearBpSheet(bpObj.bpSheet);
+            });
+
+            $('#clear-op-btn').click(function () {
+                bpObj.spData = [];
+                batchPosSpreadObj.clearSpSheet(bpObj.spSheet);
+            });
+
+            $('#add-changelist-btn').click(function () {
+                if (bpObj.spData.length === 0) {
+                    toastr.warning('录入区计量单元为空');
+                    return;
+                }
+                const datas = [];
+                makeGclGatherData();
+                for (const posData of bpObj.spData) {
+                    const gclInfo = _.find(gclGatherData, function (item) {
+                        return item.leafXmjs && _.find(item.leafXmjs, {gcl_id: posData.gcl_id, mx_id: posData.mx_id });
+                    });
+                    const xmjInfo = _.find(gclInfo.leafXmjs, { mx_id: posData.mx_id });
+                    const oldCInfo = _.find(oldChangeList, { gcl_id: posData.gcl_id, mx_id: posData.mx_id });
+                    if (gclInfo && xmjInfo) {
+                        const data = {
+                            lid: xmjInfo.gcl_id,
+                            code: gclInfo.b_code,
+                            name: gclInfo.name || '',
+                            unit: gclInfo.unit || '',
+                            unit_price: gclInfo.unit_price,
+                            oamount: xmjInfo.quantity,
+                            oamount2: oldCInfo ? oldCInfo.oamount2 : xmjInfo.quantity,
+                            bwmx: xmjInfo.bwmx || xmjInfo.jldy || '',
+                            xmj_code: xmjInfo.code || '',
+                            xmj_jldy: xmjInfo.jldy || '',
+                            xmj_dwgc: xmjInfo.dwgc || '',
+                            xmj_fbgc: xmjInfo.fbgc || '',
+                            xmj_fxgc: xmjInfo.fxgc || '',
+                            gcl_id: xmjInfo.gcl_id,
+                            mx_id: xmjInfo.mx_id || '',
+                            is_valuation: posData.is_valuation,
+                            camount: posData.camount,
+                            camount_expr: posData.camount_expr,
+                            spamount: posData.camount,
+                        }
+                        if (oldCInfo) {
+                            data.detail = oldCInfo.detail;
+                            data.delimit = oldCInfo.delimit;
+                        }
+                        datas.push(data);
+                    }
+                }
+                if (datas.length > 0) {
+                    console.log(datas);
+                    postData('/tender/' + window.location.pathname.split('/')[2] + '/change/' + window.location.pathname.split('/')[4] + '/information/save', { type:'paste', insertData: datas, updateData: [] }, function (result) {
+                        changeList = result;
+                        const billsNode = SpreadJsObj.getSelectObject(billsSheet);
+                        billsTreeSpreadObj.reCalcCamount(billsNode);
+                        const loadResult = { update: [billsNode] };
+                        const refreshNode = billsTree.loadPostData(loadResult);
+                        billsTreeSpreadObj.refreshTree(billsSheet, refreshNode);
+                        posSpreadObj.loadCurPosData();
+                        $('#batch-pos').modal('hide');
+                    });
+                }
+                return;
+            });
+        };
     }
 });
 function findDecimal(unit) {

+ 7 - 0
app/view/change/revise.ejs

@@ -86,6 +86,13 @@
                                     </div>
                                 </div>
                             </li>
+                            <li class="nav-item">
+                                <div class="d-inline-block">
+                                    <% if (!readOnly) { %>
+                                    <a href="javascript:void(0);"  data-toggle="modal" data-target="#batch-pos" class="btn btn-sm btn-primary ml-3">批量录入</a>
+                                    <% } %>
+                                </div>
+                            </li>
                         </ul>
                     </div>
                     <div class="sp-wrap" id="pos-spread">

+ 46 - 0
app/view/change/revise_modal.ejs

@@ -126,6 +126,52 @@
     </div>
 </div>
 <% } %>
+<% if (!readOnly) { %>
+    <div class="modal fade" id="batch-pos" data-backdrop="static">
+        <div class="modal-dialog modal-lgx" role="document" >
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h5 class="modal-title">批量插入变更数量</h5>
+                </div>
+                <div class="modal-body">
+                    <div class="row">
+                        <div class="col-12">
+                            <div class="pl-2" style="line-height: 28px;"><b id="batch-ledger-name">403-1-b</b> 计量单元</div>
+                            <div class="modal-height-250" id="origin-pos-spread">
+                            </div>
+                        </div>
+                    </div>
+                    <div class="row">
+                        <div class="col-6">
+                            <div class="d-inline-block">
+                                <h5 class="pl-2" style="line-height: 28px;">粘贴区 </h5>
+                            </div>
+                            <div class="d-inline-block ml-3">
+                                <button class="btn btn-sm btn-outline-primary" id="clear-bp-btn">清空</button>
+                            </div>
+                            <div class="modal-height-300" id="batch-pos-spread">
+                            </div>
+                        </div>
+                        <div class="col-6">
+                            <div class="d-inline-block">
+                                <h5 class="pl-2" style="line-height: 28px;">录入区 </h5>
+                            </div>
+                            <div class="d-inline-block ml-3">
+                                <button class="btn btn-sm btn-outline-primary" id="clear-op-btn">清空</button>
+                            </div>
+                            <div class="modal-height-300" id="save-pos-spread">
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
+                    <button type="button" class="btn btn-sm btn-primary" id="add-changelist-btn">确定</button>
+                </div>
+            </div>
+        </div>
+    </div>
+<% } %>
 <% include ../shares/delete_hint_modal.ejs %>
 <% include ../shares/check_data_modal.ejs %>
 <% include ../shares/check_modal2.ejs %>