|  | @@ -273,14 +273,26 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      };
 | 
	
		
			
				|  |  |      if (!readOnly) {
 | 
	
		
			
				|  |  | +        changeSpreadObj.add = function () {
 | 
	
		
			
				|  |  | +            changeSpreadSheet.addRows(changeSpreadSheet.getRowCount() - 1, 1);
 | 
	
		
			
				|  |  | +            changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
 | 
	
		
			
				|  |  | +            // changeSpreadSheet.setSelection(changeList.length - 1, 0, 1, 1);
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +        changeSpreadObj.batchAdd = function (num) {
 | 
	
		
			
				|  |  | +            changeSpreadSheet.addRows(changeSpreadSheet.getRowCount() - 1, parseInt(num));
 | 
	
		
			
				|  |  | +            changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  |          changeSpreadObj.del = function (sheet) {
 | 
	
		
			
				|  |  |              const selection = sheet.getSelections();
 | 
	
		
			
				|  |  |              const row = selection[0].row, count = selection[0].rowCount;
 | 
	
		
			
				|  |  |              const sortData = sheet.zh_data;
 | 
	
		
			
				|  |  |              const ids = [];
 | 
	
		
			
				|  |  | +            let emptyRowNum = 0;
 | 
	
		
			
				|  |  |              for (let iRow = 0; iRow < count; iRow++) {
 | 
	
		
			
				|  |  |                  if (sortData[iRow + row]) {
 | 
	
		
			
				|  |  |                      ids.push(sortData[iRow + row].id);
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    emptyRowNum++;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              if (ids.length > 0) {
 | 
	
	
		
			
				|  | @@ -289,6 +301,9 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                      SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
 | 
	
		
			
				|  |  |                      changeSpreadObj.makeSjsFooter();
 | 
	
		
			
				|  |  |                  });
 | 
	
		
			
				|  |  | +            } else if (emptyRowNum > 0) {
 | 
	
		
			
				|  |  | +                changeSpreadSheet.deleteRows(changeList.length, emptyRowNum);
 | 
	
		
			
				|  |  | +                changeSpreadSheet.setSelection(changeList.length - 1, 0, 1, 1);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  |          changeSpreadObj.editEnded = function (e, info) {
 | 
	
	
		
			
				|  | @@ -479,6 +494,33 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |          changeSpread.bind(spreadNS.Events.ValueChanged, changeSpreadObj.valueChanged);
 | 
	
		
			
				|  |  |          SpreadJsObj.addDeleteBind(changeSpread, changeSpreadObj.deletePress);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        let batchInsertObj;
 | 
	
		
			
				|  |  | +        $.contextMenu.types.batchInsert = function (item, opt, root) {
 | 
	
		
			
				|  |  | +            const self = this;
 | 
	
		
			
				|  |  | +            if ($.isFunction(item.icon)) {
 | 
	
		
			
				|  |  | +                item._icon = item.icon.call(this, this, $t, key, item);
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                if (typeof(item.icon) === 'string' && item.icon.substring(0, 3) === 'fa-') {
 | 
	
		
			
				|  |  | +                    // to enable font awesome
 | 
	
		
			
				|  |  | +                    item._icon = root.classNames.icon + ' ' + root.classNames.icon + '--fa fa ' + item.icon;
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    item._icon = root.classNames.icon + ' ' + root.classNames.icon + '-' + item.icon;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            this.addClass(item._icon);
 | 
	
		
			
				|  |  | +            const $obj = $('<div>' + item.name + '<input class="text-right ml-1 mr-1" type="tel" max="100" min="1" value="' + item.value + '" style="width: 30px; height: 18px; padding-right: 4px;">行</div>')
 | 
	
		
			
				|  |  | +                .appendTo(this);
 | 
	
		
			
				|  |  | +            const $input = $obj.find('input');
 | 
	
		
			
				|  |  | +            const event = () => {
 | 
	
		
			
				|  |  | +                if (self.hasClass('context-menu-disabled')) return;
 | 
	
		
			
				|  |  | +                item.batchInsert($input[0], root);
 | 
	
		
			
				|  |  | +            };
 | 
	
		
			
				|  |  | +            $obj.on('click', event).keypress(function (e) {if (e.keyCode === 13) { event(); }});
 | 
	
		
			
				|  |  | +            $input.click((e) => {e.stopPropagation();})
 | 
	
		
			
				|  |  | +                .keyup((e) => {if (e.keyCode === 13) item.batchInsert($input[0], root);})
 | 
	
		
			
				|  |  | +                .on('input', function () {this.value = this.value.replace(/[^\d]/g, '');});
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          // 右键菜单
 | 
	
		
			
				|  |  |          $.contextMenu({
 | 
	
		
			
				|  |  |              selector: '#apply-spread',
 | 
	
	
		
			
				|  | @@ -505,6 +547,32 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  },
 | 
	
		
			
				|  |  |                  sprDel: '------------',
 | 
	
		
			
				|  |  | +                'createAdd': {
 | 
	
		
			
				|  |  | +                    name: '添加行',
 | 
	
		
			
				|  |  | +                    icon: 'fa-sign-in',
 | 
	
		
			
				|  |  | +                    callback: function (key, opt) {
 | 
	
		
			
				|  |  | +                        changeSpreadObj.add(changeSpreadSheet);
 | 
	
		
			
				|  |  | +                    },
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +                'batchInsert': {
 | 
	
		
			
				|  |  | +                    name: '批量添加行',
 | 
	
		
			
				|  |  | +                    type: 'batchInsert',
 | 
	
		
			
				|  |  | +                    value: '2',
 | 
	
		
			
				|  |  | +                    icon: 'fa-sign-in',
 | 
	
		
			
				|  |  | +                    batchInsert: function (obj, root) {
 | 
	
		
			
				|  |  | +                        if (_.toNumber(obj.value) > _.toNumber(obj.max)) {
 | 
	
		
			
				|  |  | +                            obj.value = obj.max;
 | 
	
		
			
				|  |  | +                            toastr.warning('批量添加不可多于' + obj.max);
 | 
	
		
			
				|  |  | +                        } else if(_.toNumber(obj.value) < _.toNumber(obj.min)) {
 | 
	
		
			
				|  |  | +                            obj.value = obj.min;
 | 
	
		
			
				|  |  | +                            toastr.warning('批量添加不可少于' + obj.min);
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +                            // treeOperationObj.addNode(ledgerSpread.getActiveSheet(), parseInt(obj.value));
 | 
	
		
			
				|  |  | +                            changeSpreadObj.batchAdd(obj.value);
 | 
	
		
			
				|  |  | +                            root.$menu.trigger('contextmenu:hide');
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    },
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  |                  'delete': {
 | 
	
		
			
				|  |  |                      name: '删除',
 | 
	
		
			
				|  |  |                      icon: 'fa-remove',
 | 
	
	
		
			
				|  | @@ -515,7 +583,8 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                          // const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
 | 
	
		
			
				|  |  |                          if (changeSpreadSheet.zh_data) {
 | 
	
		
			
				|  |  |                              const selection = changeSpreadSheet.getSelections();
 | 
	
		
			
				|  |  | -                            return changeSpreadSheet.zh_data.length < selection[0].row + selection[0].rowCount;
 | 
	
		
			
				|  |  | +                            // return changeSpreadSheet.zh_data.length < selection[0].row + selection[0].rowCount;
 | 
	
		
			
				|  |  | +                            return changeSpreadSheet.getRowCount() - 1 < selection[0].row + selection[0].rowCount;
 | 
	
		
			
				|  |  |                          } else {
 | 
	
		
			
				|  |  |                              return true;
 | 
	
		
			
				|  |  |                          }
 |