|
@@ -184,6 +184,16 @@ $(document).ready(() => {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ batchAdd: function(num) {
|
|
|
+ postData(window.location.pathname + '/save', {type: 'batchadd', num}, function (result) {
|
|
|
+ if (result) {
|
|
|
+ changeList = _.concat(changeList, result);
|
|
|
+ SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
|
|
|
+ changeSpreadObj.makeSjsFooter();
|
|
|
+ changeSpreadObj.resetXmjSpread();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
del: function () {
|
|
|
const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
|
|
|
const index = changeList.indexOf(select);
|
|
@@ -478,6 +488,33 @@ $(document).ready(() => {
|
|
|
SpreadJsObj.addDeleteBind(changeSpread, changeSpreadObj.deletePress);
|
|
|
changeSpreadSheet.getCell(-1, 10).foreColor('#dc3545');
|
|
|
|
|
|
+ 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: '#change-spread',
|
|
@@ -500,6 +537,25 @@ $(document).ready(() => {
|
|
|
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',
|