|
@@ -770,6 +770,7 @@ $(document).ready(() => {
|
|
|
SpreadJsObj.addCutEvents(billsSpread, billsTreeSpreadObj.cut);
|
|
|
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 {
|
|
@@ -784,7 +785,11 @@ $(document).ready(() => {
|
|
|
const $obj = $('<div>' + item.name + '<input class="text-right ml-1 mr-1" type="tel" max="20" min="1" value="' + item.value + '" style="width: 30px; height: 18px; padding-right: 4px;">行</div>')
|
|
|
.appendTo(this);
|
|
|
const $input = $obj.find('input');
|
|
|
- const event = () => { item.batchInsert($input[0], root); };
|
|
|
+
|
|
|
+ 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);})
|
|
@@ -868,6 +873,17 @@ $(document).ready(() => {
|
|
|
root.$menu.trigger('contextmenu:hide');
|
|
|
}
|
|
|
},
|
|
|
+ disabled: function (key, opt) {
|
|
|
+ const sheet = billsSheet;
|
|
|
+ const selection = sheet.getSelections();
|
|
|
+ const sel = selection ? selection[0] : sheet.getSelections()[0];
|
|
|
+ const row = sel ? sel.row : -1;
|
|
|
+ const tree = sheet.zh_tree;
|
|
|
+ if (!tree) return true;
|
|
|
+ const first = sheet.zh_tree.nodes[row];
|
|
|
+ const valid = !sheet.zh_setting.readOnly;
|
|
|
+ return !(valid && first && first.level > 1);
|
|
|
+ }
|
|
|
},
|
|
|
'batchInsertBillsPos': {
|
|
|
name: '批量插入清单-计量单元',
|