|  | @@ -11,6 +11,23 @@
 | 
	
		
			
				|  |  |  const ckBillsSpread = window.location.pathname + '-billsSelect';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  $(document).ready(() => {
 | 
	
		
			
				|  |  | +    toastr.options = {
 | 
	
		
			
				|  |  | +        "closeButton": false,
 | 
	
		
			
				|  |  | +        "debug": false,
 | 
	
		
			
				|  |  | +        "newestOnTop": false,
 | 
	
		
			
				|  |  | +        "progressBar": false,
 | 
	
		
			
				|  |  | +        "positionClass": "toast-top-center",
 | 
	
		
			
				|  |  | +        "preventDuplicates": false,
 | 
	
		
			
				|  |  | +        "onclick": null,
 | 
	
		
			
				|  |  | +        "showDuration": "300",
 | 
	
		
			
				|  |  | +        "hideDuration": "1000",
 | 
	
		
			
				|  |  | +        "timeOut": "5000",
 | 
	
		
			
				|  |  | +        "extendedTimeOut": "1000",
 | 
	
		
			
				|  |  | +        "showEasing": "swing",
 | 
	
		
			
				|  |  | +        "hideEasing": "linear",
 | 
	
		
			
				|  |  | +        "showMethod": "fadeIn",
 | 
	
		
			
				|  |  | +        "hideMethod": "fadeOut"
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  |      autoFlashHeight();
 | 
	
		
			
				|  |  |      // 初始化spread
 | 
	
		
			
				|  |  |      const billsSpread = SpreadJsObj.createNewSpread($('#bills-spread')[0]);
 | 
	
	
		
			
				|  | @@ -55,7 +72,7 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |      treeSetting.calcFun = function (node) {
 | 
	
		
			
				|  |  |          node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
 | 
	
		
			
				|  |  |      };
 | 
	
		
			
				|  |  | -    const billsTree = createNewPathTree('ledger', treeSetting);
 | 
	
		
			
				|  |  | +    const billsTree = createNewPathTree('revise', treeSetting);
 | 
	
		
			
				|  |  |      billsTree.loadDatas(billsData);
 | 
	
		
			
				|  |  |      treeCalc.calculateAll(billsTree);
 | 
	
		
			
				|  |  |      // 加载至spread
 | 
	
	
		
			
				|  | @@ -78,7 +95,7 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                      const rNode = sheet.zh_tree.nodes[sel.row + r];
 | 
	
		
			
				|  |  |                      if (rNode.level > node.level) continue;
 | 
	
		
			
				|  |  |                      if ((rNode.level < node.level) || (rNode.level === node.level && rNode.pid !== node.pid)) {
 | 
	
		
			
				|  |  | -                        toast('请选择同一清单下的节点,进行该操作');
 | 
	
		
			
				|  |  | +                        toastr.warning('请选择同一清单下的节点,进行该操作');
 | 
	
		
			
				|  |  |                          return;
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      count += 1;
 | 
	
	
		
			
				|  | @@ -145,8 +162,11 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                  const tree = sheet.zh_tree;
 | 
	
		
			
				|  |  |                  // 处理删除
 | 
	
		
			
				|  |  |                  if (data.delete) {
 | 
	
		
			
				|  |  | +                    data.delete.sort(function (a, b) {
 | 
	
		
			
				|  |  | +                        return b.deleteIndex - a.deleteIndex;
 | 
	
		
			
				|  |  | +                    });
 | 
	
		
			
				|  |  |                      for (const d of data.delete) {
 | 
	
		
			
				|  |  | -                        sheet.deleteRows(tree.nodes.indexOf(d), 1);
 | 
	
		
			
				|  |  | +                        sheet.deleteRows(d.deleteIndex, 1);
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  // 处理新增
 | 
	
	
		
			
				|  | @@ -203,6 +223,45 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |              const [tree, node, count] = this.getDefaultSelectInfo(sheet);
 | 
	
		
			
				|  |  |              if (!tree || !node || !count) return;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +            if (type === 'delete') {
 | 
	
		
			
				|  |  | +                const parent = tree.getParent(node);
 | 
	
		
			
				|  |  | +                const children = parent ? parent.children : tree.children;
 | 
	
		
			
				|  |  | +                const index = children.indexOf(node);
 | 
	
		
			
				|  |  | +                for (let i = 0; i < count; i++) {
 | 
	
		
			
				|  |  | +                    const child = children[i+index];
 | 
	
		
			
				|  |  | +                    if (tree.checkNodeUsed(child, pos)) {
 | 
	
		
			
				|  |  | +                        toastr.warning('选中的清单已计量,不可删除');
 | 
	
		
			
				|  |  | +                        return;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            } else if (type === 'up-level') {
 | 
	
		
			
				|  |  | +                const parent = tree.getParent(node);
 | 
	
		
			
				|  |  | +                const children = parent ? parent.children : tree.children;
 | 
	
		
			
				|  |  | +                const index = children.indexOf(node);
 | 
	
		
			
				|  |  | +                for (let i = index; i < children.length; i++) {
 | 
	
		
			
				|  |  | +                    const child = children[index];
 | 
	
		
			
				|  |  | +                    if (tree.checkNodeUsed(child, pos)) {
 | 
	
		
			
				|  |  | +                        if (i >= index + count) {
 | 
	
		
			
				|  |  | +                            toastr.warning('其后清单已计量,选中的清单不可升级');
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +                            toastr.warning('选中的清单已计量,不可升级');
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        return;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            } else if (type === 'down-level') {
 | 
	
		
			
				|  |  | +                const parent = tree.getParent(node);
 | 
	
		
			
				|  |  | +                const children = parent ? parent.children : tree.children;
 | 
	
		
			
				|  |  | +                const index = children.indexOf(node);
 | 
	
		
			
				|  |  | +                for (let i = 0; i < count; i++) {
 | 
	
		
			
				|  |  | +                    const child = children[i+index];
 | 
	
		
			
				|  |  | +                    if (tree.checkNodeUsed(child, pos)) {
 | 
	
		
			
				|  |  | +                        toastr.warning('选中的清单已计量,不可降级');
 | 
	
		
			
				|  |  | +                        return;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              postData(window.location.pathname + '/update', {
 | 
	
		
			
				|  |  |                  postType: type,
 | 
	
		
			
				|  |  |                  postData: {
 | 
	
	
		
			
				|  | @@ -215,13 +274,18 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                  if (type === 'delete') {
 | 
	
		
			
				|  |  |                      const sel = sheet.getSelections()[0];
 | 
	
		
			
				|  |  |                      if (sel) {
 | 
	
		
			
				|  |  | -                        sheet.setSelection(tree.nodes.indexOf(node), sel.col, 1, sel.colCount);
 | 
	
		
			
				|  |  | +                        sheet.setSelection(sel.row, sel.col, 1, sel.colCount);
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                } else if (['up-move', 'down-move', 'up-level', 'down-level'].indexOf(type) > -1) {
 | 
	
		
			
				|  |  | +                } else if (['up-move', 'down-move'].indexOf(type) > -1) {
 | 
	
		
			
				|  |  |                      const sel = sheet.getSelections()[0];
 | 
	
		
			
				|  |  |                      if (sel) {
 | 
	
		
			
				|  |  |                          sheet.setSelection(tree.nodes.indexOf(node), sel.col, sel.rowCount, sel.colCount);
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | +                } else if (type === 'add') {
 | 
	
		
			
				|  |  | +                    const sel = sheet.getSelections()[0];
 | 
	
		
			
				|  |  | +                    if (sel) {
 | 
	
		
			
				|  |  | +                        sheet.setSelection(tree.nodes.indexOf(refreshData.create[0]), sel.col, sel.rowCount, sel.colCount);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  self.refreshOperationValid(sheet);
 | 
	
		
			
				|  |  |              });
 | 
	
	
		
			
				|  | @@ -247,14 +311,14 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                      return;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  // 台账模式,检查部位明细相关
 | 
	
		
			
				|  |  | -                if (checkTzMeasureType()) {
 | 
	
		
			
				|  |  | +                if (isTz) {
 | 
	
		
			
				|  |  |                      if (col.field === 'sgfh_qty' || col.field === 'sgfh_tp' ||
 | 
	
		
			
				|  |  |                          col.field === 'sjcl_qty' || col.field === 'sjcl_tp' ||
 | 
	
		
			
				|  |  |                          col.field === 'qtcl_qty' || col.field === 'qtcl_tp') {
 | 
	
		
			
				|  |  |                          if (!node.children || node.children.length ===0) {
 | 
	
		
			
				|  |  |                              const lPos = pos.getLedgerPos(node.id);
 | 
	
		
			
				|  |  |                              if (lPos && lPos.length > 0) {
 | 
	
		
			
				|  |  | -                                toast('清单含有部位明细,不可修改施工图复核数量', 'error');
 | 
	
		
			
				|  |  | +                                toastr.error('清单含有部位明细,不可修改施工图复核数量');
 | 
	
		
			
				|  |  |                                  SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
		
			
				|  |  |                                  return;
 | 
	
		
			
				|  |  |                              }
 | 
	
	
		
			
				|  | @@ -263,7 +327,7 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                      if (col.field === 'b_code' && (info.editingText === '' || !info.editingText)) {
 | 
	
		
			
				|  |  |                          const lPos = pos.getLedgerPos(node.id);
 | 
	
		
			
				|  |  |                          if (lPos && lPos.length > 0) {
 | 
	
		
			
				|  |  | -                            toast('清单含有部位明细,请先删除部位明细,再删除清单编号', 'error');
 | 
	
		
			
				|  |  | +                            toastr.error('清单含有部位明细,请先删除部位明细,再删除清单编号');
 | 
	
		
			
				|  |  |                              SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
		
			
				|  |  |                              return;
 | 
	
		
			
				|  |  |                          }
 | 
	
	
		
			
				|  | @@ -282,6 +346,123 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                  });
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          },
 | 
	
		
			
				|  |  | +        clipboardPasting: function (e, info) {
 | 
	
		
			
				|  |  | +            if (info.sheet.zh_setting) {
 | 
	
		
			
				|  |  | +                const range = info.cellRange;
 | 
	
		
			
				|  |  | +                for (let iRow = range.row; iRow < range.row + range.rowCount; iRow++) {
 | 
	
		
			
				|  |  | +                    const node = info.sheet.zh_tree.nodes[iRow];
 | 
	
		
			
				|  |  | +                    if (info.sheet.zh_tree.checkNodeUsed(node, pos)) {
 | 
	
		
			
				|  |  | +                        toastr.warning('"' + node.code + node.b_code + ' ' + node.name +'"已计量,请勿修改');
 | 
	
		
			
				|  |  | +                        info.cancel = true;
 | 
	
		
			
				|  |  | +                        return;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +        clipboardPasted: function (e, info) {
 | 
	
		
			
				|  |  | +            const tree = info.sheet.zh_tree;
 | 
	
		
			
				|  |  | +            if (!tree) { return; }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            const sortData = info.sheet.zh_tree.nodes;
 | 
	
		
			
				|  |  | +            const datas = [], filterNodes = [];
 | 
	
		
			
				|  |  | +            let bHint = false, bPaste;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            for (let iRow = 0; iRow < info.cellRange.rowCount; iRow ++) {
 | 
	
		
			
				|  |  | +                bPaste = false;
 | 
	
		
			
				|  |  | +                const curRow = info.cellRange.row + iRow;
 | 
	
		
			
				|  |  | +                const node = sortData[curRow];
 | 
	
		
			
				|  |  | +                if (node) {
 | 
	
		
			
				|  |  | +                    const data = info.sheet.zh_tree.getNodeKeyData(node);
 | 
	
		
			
				|  |  | +                    for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
 | 
	
		
			
				|  |  | +                        const curCol = info.cellRange.col + iCol;
 | 
	
		
			
				|  |  | +                        const colSetting = info.sheet.zh_setting.cols[curCol];
 | 
	
		
			
				|  |  | +                        const value = info.sheet.getText(curRow, curCol).replace('\n', '');
 | 
	
		
			
				|  |  | +                        const lPos = pos.getLedgerPos(node.id);
 | 
	
		
			
				|  |  | +                        if (lPos && lPos.length > 0) {
 | 
	
		
			
				|  |  | +                            if (value === '' && colSetting.field === 'b_code') {
 | 
	
		
			
				|  |  | +                                if (!bHint) {
 | 
	
		
			
				|  |  | +                                    toastr.warning('清单含有部位明细,请先删除部位明细,再删除清单编号');
 | 
	
		
			
				|  |  | +                                    bHint = true;
 | 
	
		
			
				|  |  | +                                }
 | 
	
		
			
				|  |  | +                                continue;
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                            if (colSetting.field === 'sgfh_qty' || colSetting.field === 'sgfh_tp' ||
 | 
	
		
			
				|  |  | +                                colSetting.field === 'sjcl_qty' || colSetting.field === 'sjcl_tp' ||
 | 
	
		
			
				|  |  | +                                colSetting.field === 'qtcl_qty' || colSetting.field === 'qtcl_tp') {
 | 
	
		
			
				|  |  | +                                if (!bHint) {
 | 
	
		
			
				|  |  | +                                    toastr.warning('清单含有部位明细,数量金额根据部位明细汇总计算所得,不可编辑');
 | 
	
		
			
				|  |  | +                                    bHint = true;
 | 
	
		
			
				|  |  | +                                }
 | 
	
		
			
				|  |  | +                                continue;
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        data[colSetting.field] = value;
 | 
	
		
			
				|  |  | +                        bPaste = true;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if (bPaste) {
 | 
	
		
			
				|  |  | +                        datas.push(data);
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        filterNodes.push(node);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (datas.length > 0) {
 | 
	
		
			
				|  |  | +                postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
 | 
	
		
			
				|  |  | +                    const refreshNode = tree.loadPostData(result);
 | 
	
		
			
				|  |  | +                    if (refreshNode.update) {
 | 
	
		
			
				|  |  | +                        refreshNode.update = refreshNode.update.concat(filterNodes);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    billsTreeSpreadObj.refreshTree(info.sheet, refreshNode);
 | 
	
		
			
				|  |  | +                }, function () {
 | 
	
		
			
				|  |  | +                    SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 | 
	
		
			
				|  |  | +                });
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +        deletePress: function (sheet) {
 | 
	
		
			
				|  |  | +            if (!sheet.zh_setting) return;
 | 
	
		
			
				|  |  | +            const sel = sheet.getSelections()[0], datas = [];
 | 
	
		
			
				|  |  | +            for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
 | 
	
		
			
				|  |  | +                const node = sheet.zh_tree.nodes[iRow];
 | 
	
		
			
				|  |  | +                if (sheet.zh_tree.checkNodeUsed(node, pos)) {
 | 
	
		
			
				|  |  | +                    toastr.warning('"' + node.code + node.b_code + ' ' + node.name +'"已计量,请勿修改');
 | 
	
		
			
				|  |  | +                    return;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                const data = sheet.zh_tree.getNodeKeyData(node);
 | 
	
		
			
				|  |  | +                for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
 | 
	
		
			
				|  |  | +                    const col = sheet.zh_setting.cols[iCol];
 | 
	
		
			
				|  |  | +                    data[col.field] = null;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                datas.push(data);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (datas.length > 0) {
 | 
	
		
			
				|  |  | +                postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
 | 
	
		
			
				|  |  | +                    const refreshNode = sheet.zh_tree.loadPostData(result);
 | 
	
		
			
				|  |  | +                    billsTreeSpreadObj.refreshTree(sheet, refreshNode);
 | 
	
		
			
				|  |  | +                });
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +        pasteBlock: function (spread, copyInfo) {
 | 
	
		
			
				|  |  | +            const self = this;
 | 
	
		
			
				|  |  | +            const sheet = spread.getActiveSheet();
 | 
	
		
			
				|  |  | +            const [tree, node] = this.getDefaultSelectInfo(spread.getActiveSheet());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            postData(window.location.pathname + '/update', {
 | 
	
		
			
				|  |  | +                postType: 'paste-block',
 | 
	
		
			
				|  |  | +                postData: {
 | 
	
		
			
				|  |  | +                    id: tree.getNodeKey(node),
 | 
	
		
			
				|  |  | +                    tid: copyInfo.tid,
 | 
	
		
			
				|  |  | +                    block: copyInfo.block,
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }, function (data) {
 | 
	
		
			
				|  |  | +                pos.updateDatas(data.pos);
 | 
	
		
			
				|  |  | +                const result = tree.loadPostData(data.ledger);
 | 
	
		
			
				|  |  | +                self.refreshTree(sheet, result);
 | 
	
		
			
				|  |  | +                self.refreshOperationValid(sheet);
 | 
	
		
			
				|  |  | +                removeLocalCache(copyBlockTag);
 | 
	
		
			
				|  |  | +            }, null, true);
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  |          topRowChanged: function (e, info) {
 | 
	
		
			
				|  |  |              SpreadJsObj.saveTopAndSelect(info.sheet, ckBillsSpread);
 | 
	
		
			
				|  |  |          },
 | 
	
	
		
			
				|  | @@ -294,6 +475,10 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |          $('a[name="base-opr"]').click(function () {
 | 
	
		
			
				|  |  |              billsTreeSpreadObj.baseOpr(billsSheet, this.getAttribute('type'));
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  | +        billsSpread.bind(spreadNS.Events.EditEnded, billsTreeSpreadObj.editEnded);
 | 
	
		
			
				|  |  | +        billsSpread.bind(spreadNS.Events.ClipboardPasting, billsTreeSpreadObj.clipboardPasting);
 | 
	
		
			
				|  |  | +        billsSpread.bind(spreadNS.Events.ClipboardPasted, billsTreeSpreadObj.clipboardPasted);
 | 
	
		
			
				|  |  | +        SpreadJsObj.addDeleteBind(billsSpread, billsTreeSpreadObj.deletePress);
 | 
	
		
			
				|  |  |          let batchInsertObj;
 | 
	
		
			
				|  |  |          // 右键菜单
 | 
	
		
			
				|  |  |          $.contextMenu({
 | 
	
	
		
			
				|  | @@ -328,6 +513,12 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                          $('#batch').modal('show');
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  },
 | 
	
		
			
				|  |  | +                'debug': {
 | 
	
		
			
				|  |  | +                    name: 'debug',
 | 
	
		
			
				|  |  | +                    callback: function (key, opt) {
 | 
	
		
			
				|  |  | +                        console.log(SpreadJsObj.getSelectObject(billsSheet));
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -347,12 +538,275 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |              SpreadJsObj.resetFieldReadOnly(posSheet);
 | 
	
		
			
				|  |  |          },
 | 
	
		
			
				|  |  |          editStarting: function (e, info) {
 | 
	
		
			
				|  |  | -            posSpreadObj.ledgerTreeNode = SpreadJsObj.getSelectObject(billsSheet);
 | 
	
		
			
				|  |  | +            posSpreadObj.billsNode = SpreadJsObj.getSelectObject(billsSheet);
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +        /**
 | 
	
		
			
				|  |  | +         * 编辑单元格响应事件
 | 
	
		
			
				|  |  | +         * @param {Object} e
 | 
	
		
			
				|  |  | +         * @param {Object} info
 | 
	
		
			
				|  |  | +         */
 | 
	
		
			
				|  |  | +        editEnded: 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 col = info.sheet.zh_setting.cols[info.col];
 | 
	
		
			
				|  |  | +            const orgText = posData ? posData[col.field] : null;
 | 
	
		
			
				|  |  | +            const newText = info.sheet.getCell(info.row, info.col).text();
 | 
	
		
			
				|  |  | +            if (orgText === newText || ((!orgText || orgText === '') && (newText === ''))) return;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            const node = posSpreadObj.billsNode;
 | 
	
		
			
				|  |  | +            if (!node) {
 | 
	
		
			
				|  |  | +                toastr.error('数据错误,请选择台账节点后再试');
 | 
	
		
			
				|  |  | +                SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            } else if (newText && newText !== '' && node.children && node.children.length > 0) {
 | 
	
		
			
				|  |  | +                toastr.error('父节点不可插入部位明细');
 | 
	
		
			
				|  |  | +                SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            } else if (newText && newText !== '' && (!node.b_code || node.b_code === '')) {
 | 
	
		
			
				|  |  | +                toastr.error('项目节不可插入部位明细');
 | 
	
		
			
				|  |  | +                SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            const data = {postType: 'pos'};
 | 
	
		
			
				|  |  | +            if (col.field === 'name') {
 | 
	
		
			
				|  |  | +                if (newText === '' && posData) {
 | 
	
		
			
				|  |  | +                    toastr.error('部位名称不可为空', 'error');
 | 
	
		
			
				|  |  | +                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
		
			
				|  |  | +                    return;
 | 
	
		
			
				|  |  | +                } else if (!posData) {
 | 
	
		
			
				|  |  | +                    if (newText && newText !== '') {
 | 
	
		
			
				|  |  | +                        data.posPostType = 'add';
 | 
	
		
			
				|  |  | +                        const sortData = info.sheet.zh_data;
 | 
	
		
			
				|  |  | +                        const order = (!sortData || sortData.length === 0) ? 1 : Math.max(sortData[sortData.length - 1].porder + 1, sortData.length + 1);
 | 
	
		
			
				|  |  | +                        data.postData = { name: newText, lid: node.id, porder: order};
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        return;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    data.posPostType = 'update-pos';
 | 
	
		
			
				|  |  | +                    data.postData = {id: posData.id, name: newText};
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            } else if (!posData) {
 | 
	
		
			
				|  |  | +                toastr.warning('新增部位请先输入名称');
 | 
	
		
			
				|  |  | +                SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                data.posPostType = 'update';
 | 
	
		
			
				|  |  | +                data.postData = {id: posData.id};
 | 
	
		
			
				|  |  | +                data.postData[col.field] = col.type === 'Number' ? parseFloat(newText) : newText;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            postData(window.location.pathname + '/update', data, function (result) {
 | 
	
		
			
				|  |  | +                const updateRst = pos.updateDatas(result.pos);
 | 
	
		
			
				|  |  | +                // 刷新当前行, 不适用于新增(在非下一空白行新增)
 | 
	
		
			
				|  |  | +                if (updateRst.create.length > 0) {
 | 
	
		
			
				|  |  | +                    posSpreadObj.loadCurPosData();
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                const loadResult = billsTree.loadPostData(result.ledger);
 | 
	
		
			
				|  |  | +                billsTreeSpreadObj.refreshTree(billsSheet, loadResult);
 | 
	
		
			
				|  |  | +                billsTreeSpreadObj.refreshOperationValid(billsSheet);
 | 
	
		
			
				|  |  | +            }, function () {
 | 
	
		
			
				|  |  | +                SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +        /**
 | 
	
		
			
				|  |  | +         * 删除按钮响应事件
 | 
	
		
			
				|  |  | +         * @param sheet
 | 
	
		
			
				|  |  | +         */
 | 
	
		
			
				|  |  | +        deletePress: function (sheet) {
 | 
	
		
			
				|  |  | +            if (!sheet.zh_settting) return;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            const sortData = sheet.zh_data;
 | 
	
		
			
				|  |  | +            const datas = [], posSelects = [];
 | 
	
		
			
				|  |  | +            const sel = sheet.getSelections()[0];
 | 
	
		
			
				|  |  | +            for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
 | 
	
		
			
				|  |  | +                let bDel = false;
 | 
	
		
			
				|  |  | +                const node = sortData[iRow];
 | 
	
		
			
				|  |  | +                if (node) {
 | 
	
		
			
				|  |  | +                    const data = {id: node.id};
 | 
	
		
			
				|  |  | +                    for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
 | 
	
		
			
				|  |  | +                        const colSetting = sheet.zh_setting.cols[iCol];
 | 
	
		
			
				|  |  | +                        if (colSetting.field === 'name') {
 | 
	
		
			
				|  |  | +                            toastr.error('部位名称不能为空');
 | 
	
		
			
				|  |  | +                            return;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        const style = sheet.getStyle(iRow, iCol);
 | 
	
		
			
				|  |  | +                        if (!style.locked) {
 | 
	
		
			
				|  |  | +                            const colSetting = sheet.zh_setting.cols[iCol];
 | 
	
		
			
				|  |  | +                            data[colSetting.field] = null;
 | 
	
		
			
				|  |  | +                            bDel = true;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if (bDel) {
 | 
	
		
			
				|  |  | +                        datas.push(data);
 | 
	
		
			
				|  |  | +                        posSelects.push(node);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (datas.length > 0) {
 | 
	
		
			
				|  |  | +                postData(window.location.pathname + '/update', {postType: 'pos', posPostType: 'update', postData: datas}, function (result) {
 | 
	
		
			
				|  |  | +                    pos.updateDatas(result.pos);
 | 
	
		
			
				|  |  | +                    posSpreadObj.loadCurPosData();
 | 
	
		
			
				|  |  | +                    const loadResult = billsTree.loadPostData(result.ledger);
 | 
	
		
			
				|  |  | +                    billsTreeSpreadObj.refreshTree(billsSheet, loadResult);
 | 
	
		
			
				|  |  | +                    billsTreeSpreadObj.refreshOperationValid(billsSheet);
 | 
	
		
			
				|  |  | +                }, function () {
 | 
	
		
			
				|  |  | +                    posSpreadObj.loadCurPosData();
 | 
	
		
			
				|  |  | +                });
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +        /**
 | 
	
		
			
				|  |  | +         * 删除 部位明细
 | 
	
		
			
				|  |  | +         * @param sheet
 | 
	
		
			
				|  |  | +         */
 | 
	
		
			
				|  |  | +        deletePos: function (sheet) {
 | 
	
		
			
				|  |  | +            const selection = sheet.getSelections();
 | 
	
		
			
				|  |  | +            const data = {
 | 
	
		
			
				|  |  | +                postType: 'pos',
 | 
	
		
			
				|  |  | +                posPostType: 'delete',
 | 
	
		
			
				|  |  | +                postData: [],
 | 
	
		
			
				|  |  | +            };
 | 
	
		
			
				|  |  | +            const row = selection[0].row, count = selection[0].rowCount;
 | 
	
		
			
				|  |  | +            const sortData = sheet.zh_data;
 | 
	
		
			
				|  |  | +            for (let iRow = 0; iRow < count; iRow++) {
 | 
	
		
			
				|  |  | +                const posData = sortData[iRow + row];
 | 
	
		
			
				|  |  | +                if (posData) {
 | 
	
		
			
				|  |  | +                    if (posData.used) {
 | 
	
		
			
				|  |  | +                        toastr.error('"' + posData.name + '"已计量,请勿删除');
 | 
	
		
			
				|  |  | +                        return;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    data.postData.push(sortData[iRow + row].id);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            console.log(data);
 | 
	
		
			
				|  |  | +            if (data.postData.length > 0) {
 | 
	
		
			
				|  |  | +                postData(window.location.pathname + '/update', data, function (result) {
 | 
	
		
			
				|  |  | +                    pos.removeDatas(result.pos);
 | 
	
		
			
				|  |  | +                    sheet.deleteRows(row, count);
 | 
	
		
			
				|  |  | +                    const loadResult = billsTree.loadPostData(result.ledger);
 | 
	
		
			
				|  |  | +                    billsTreeSpreadObj.refreshTree(billsSheet, loadResult);
 | 
	
		
			
				|  |  | +                    billsTreeSpreadObj.refreshOperationValid(billsSheet);
 | 
	
		
			
				|  |  | +                });
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +        clipboardPasting: function (e, info) {
 | 
	
		
			
				|  |  | +            if (!info.sheet.zh_setting) {
 | 
	
		
			
				|  |  | +                info.cancel = true;
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            const range = info.cellRange;
 | 
	
		
			
				|  |  | +            for (let iRow = range.row; iRow < range.row + range.rowCount; iRow++) {
 | 
	
		
			
				|  |  | +                const posData = info.sheet.zh_data[iRow];
 | 
	
		
			
				|  |  | +                if (posData && posData.used) {
 | 
	
		
			
				|  |  | +                    toastr.warning('"' + pos.name +'"已计量,请勿修改');
 | 
	
		
			
				|  |  | +                    info.cancel = true;
 | 
	
		
			
				|  |  | +                    return;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +        /**
 | 
	
		
			
				|  |  | +         * 粘贴单元格响应事件
 | 
	
		
			
				|  |  | +         * @param e
 | 
	
		
			
				|  |  | +         * @param info
 | 
	
		
			
				|  |  | +         */
 | 
	
		
			
				|  |  | +        clipboardPasted: function (e, info) {
 | 
	
		
			
				|  |  | +            const node = SpreadJsObj.getSelectObject(billsSheet);
 | 
	
		
			
				|  |  | +            if (node.code && (node.code !== '')) {
 | 
	
		
			
				|  |  | +                toastr.error('项目节不可含有清单明细');
 | 
	
		
			
				|  |  | +                posSpreadObj.loadCurPosData();
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (node.children && (node.children.length > 0)) {
 | 
	
		
			
				|  |  | +                toastr.error('仅清单子项可以含有部位明细');
 | 
	
		
			
				|  |  | +                posSpreadObj.loadCurPosData();
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (!info.sheet.zh_setting) {
 | 
	
		
			
				|  |  | +                posSpreadObj.loadCurPosData();
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            const data = [];
 | 
	
		
			
				|  |  | +            const sortData = info.sheet.zh_data || [];
 | 
	
		
			
				|  |  | +            if (sortData.length === 0 || info.cellRange.row + info.cellRange.rowCount > sortData.length) {
 | 
	
		
			
				|  |  | +                if (info.cellRange.col !== 0) {
 | 
	
		
			
				|  |  | +                    toast('新增部位请先输入名称', 'warning');
 | 
	
		
			
				|  |  | +                    posSpreadObj.loadCurPosData();
 | 
	
		
			
				|  |  | +                    return;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            const lastOrder = sortData.length > 0 ? sortData[sortData.length - 1].porder + 1 : 1;
 | 
	
		
			
				|  |  | +            for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
 | 
	
		
			
				|  |  | +                const curRow = info.cellRange.row + iRow;
 | 
	
		
			
				|  |  | +                const posData = curRow >= sortData.length ? {lid: node.id, porder: lastOrder + curRow - sortData.length} : {id: sortData[curRow].id, lid: node.id};
 | 
	
		
			
				|  |  | +                for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
 | 
	
		
			
				|  |  | +                    const curCol = info.cellRange.col + iCol;
 | 
	
		
			
				|  |  | +                    const colSetting = info.sheet.zh_setting.cols[curCol];
 | 
	
		
			
				|  |  | +                    posData[colSetting.field] = info.sheet.getText(curRow, curCol);
 | 
	
		
			
				|  |  | +                    if (colSetting.type === 'Number') {
 | 
	
		
			
				|  |  | +                        posData[colSetting.field] = _.toNumber(posData[colSetting.field]);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                data.push(posData);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            postData(window.location.pathname + '/update', {postType: 'pos', posPostType: 'paste', postData: data}, function (result) {
 | 
	
		
			
				|  |  | +                pos.updateDatas(result.pos);
 | 
	
		
			
				|  |  | +                posSpreadObj.loadCurPosData();
 | 
	
		
			
				|  |  | +                const loadResult = billsTree.loadPostData(result.ledger);
 | 
	
		
			
				|  |  | +                billsTreeSpreadObj.refreshTree(billsSheet, loadResult);
 | 
	
		
			
				|  |  | +                posSpreadObj.loadCurPosData();
 | 
	
		
			
				|  |  | +                billsTreeSpreadObj.refreshOperationValid(billsSheet);
 | 
	
		
			
				|  |  | +            }, function () {
 | 
	
		
			
				|  |  | +                SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  |          },
 | 
	
		
			
				|  |  |      };
 | 
	
		
			
				|  |  |      posSpreadObj.loadCurPosData();
 | 
	
		
			
				|  |  |      SpreadJsObj.resetTopAndSelect(posSheet);
 | 
	
		
			
				|  |  | +    if (!readOnly) {
 | 
	
		
			
				|  |  | +        posSpread.bind(spreadNS.Events.EditStarting, posSpreadObj.editStarting);
 | 
	
		
			
				|  |  | +        posSpread.bind(spreadNS.Events.EditEnded, posSpreadObj.editEnded);
 | 
	
		
			
				|  |  | +        posSpread.bind(spreadNS.Events.ClipboardPasting, posSpreadObj.clipboardPasting);
 | 
	
		
			
				|  |  | +        posSpread.bind(spreadNS.Events.ClipboardPasted, posSpreadObj.clipboardPasted);
 | 
	
		
			
				|  |  | +        SpreadJsObj.addDeleteBind(posSpread, posSpreadObj.deletePress);
 | 
	
		
			
				|  |  | +        $.contextMenu({
 | 
	
		
			
				|  |  | +            selector: '#pos-spread',
 | 
	
		
			
				|  |  | +            build: function ($trigger, e) {
 | 
	
		
			
				|  |  | +                const target = SpreadJsObj.safeRightClickSelection($trigger, e, posSpread);
 | 
	
		
			
				|  |  | +                return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +            items: {
 | 
	
		
			
				|  |  | +                'delete': {
 | 
	
		
			
				|  |  | +                    name: '删除',
 | 
	
		
			
				|  |  | +                    icon: 'fa-remove',
 | 
	
		
			
				|  |  | +                    disabled: function (key, opt) {
 | 
	
		
			
				|  |  | +                        if (posSheet.zh_data) {
 | 
	
		
			
				|  |  | +                            const selection = posSheet.getSelections();
 | 
	
		
			
				|  |  | +                            return posSheet.zh_data.length < selection[0].row + selection[0].rowCount;
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +                            return true;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    },
 | 
	
		
			
				|  |  | +                    callback: function (key, opt) {
 | 
	
		
			
				|  |  | +                        posSpreadObj.deletePos(posSheet);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +                'debug': {
 | 
	
		
			
				|  |  | +                    name: 'debug',
 | 
	
		
			
				|  |  | +                    callback: function (key, opt) {
 | 
	
		
			
				|  |  | +                        console.log(SpreadJsObj.getSelectObject(posSheet));
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |      $.divResizer({
 | 
	
		
			
				|  |  |          select: '#revise-resize',
 | 
	
		
			
				|  |  |          callback: function () {
 | 
	
	
		
			
				|  | @@ -387,7 +841,7 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  if (stdType === 'bills') {
 | 
	
		
			
				|  |  |                      if (!(mainNode.b_code && mainNode.b_code !== '') && !mainTree.isLeafXmj(mainNode)) {
 | 
	
		
			
				|  |  | -                        toast('非最底层项目下,不应添加清单', 'warning');
 | 
	
		
			
				|  |  | +                        toastr.warning('非最底层项目下,不应添加清单');
 | 
	
		
			
				|  |  |                          return;
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
	
		
			
				|  | @@ -404,6 +858,9 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                  }, function (result) {
 | 
	
		
			
				|  |  |                      const refreshNode = mainTree.loadPostData(result);
 | 
	
		
			
				|  |  |                      billsTreeSpreadObj.refreshTree(mainSheet, refreshNode);
 | 
	
		
			
				|  |  | +                    if (sel && refreshNode.create[0]) {
 | 
	
		
			
				|  |  | +                        mainSheet.setSelection(mainTree.nodes.indexOf(refreshNode.create[0]), sel.col, sel.rowCount, sel.colCount);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |                      billsTreeSpreadObj.refreshOperationValid(mainSheet);
 | 
	
		
			
				|  |  |                  });
 | 
	
		
			
				|  |  |              });
 | 
	
	
		
			
				|  | @@ -450,7 +907,7 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                  if (!mainNode || !mainTree) { return; }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  if (mainNode.code && mainNode.code !== '' && !mainTree.isLeafXmj(mainNode)) {
 | 
	
		
			
				|  |  | -                    toast('非最底层项目下,不应添加清单', 'error');
 | 
	
		
			
				|  |  | +                    toastr.warning('非最底层项目下,不应添加清单');
 | 
	
		
			
				|  |  |                      return;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -467,6 +924,10 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                  }, function (result) {
 | 
	
		
			
				|  |  |                      const refreshData = mainTree.loadPostData(result);
 | 
	
		
			
				|  |  |                      billsTreeSpreadObj.refreshTree(mainSheet, refreshData);
 | 
	
		
			
				|  |  | +                    const sel = mainSheet.getSelections()[0];
 | 
	
		
			
				|  |  | +                    if (sel && refreshData.create[0]) {
 | 
	
		
			
				|  |  | +                        mainSheet.setSelection(mainTree.nodes.indexOf(refreshData.create[0]), sel.col, sel.rowCount, sel.colCount);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |                      billsTreeSpreadObj.refreshOperationValid(mainSheet);
 | 
	
		
			
				|  |  |                  });
 | 
	
		
			
				|  |  |              });
 |