Skip to content

Commit 3c29c79

Browse files
author
hikki
committed
v3.2
1 parent 698af7e commit 3c29c79

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

resources/assets/component.js

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,16 +1144,23 @@ window.ComponentSortable = class {
11441144
};
11451145

11461146
window.ComponentCascadeLine = class {
1147-
constructor(name, select, url, movable = true) {
1147+
constructor(name, select, url, options) {
11481148
if (!Array.isArray(select)) {
11491149
console.error('CascadeLine param select must be array!');
11501150
return;
11511151
}
11521152
this.name = name;
1153-
this.movable = movable;
1153+
this.OPTIONS = Object.assign({
1154+
movable : true,
1155+
exchange:true,
1156+
insert:true,
1157+
update:true,
1158+
delete:true
1159+
}, options);
11541160
this.DOM = document.getElementById(name);
11551161
this.URL = url;
1156-
this.make().makeSelect(select).makeHeader();
1162+
this.make().makeSelect(select);
1163+
if(this.OPTIONS.insert)this.makeHeader();
11571164

11581165
let search = document.querySelector(`#${this.name} .dot-search`);
11591166
search.addEventListener('input', () => {
@@ -1162,6 +1169,7 @@ window.ComponentCascadeLine = class {
11621169
}, 700);
11631170
});
11641171

1172+
if(!this.OPTIONS.movable)return;
11651173
for (let D of this.DOM.querySelectorAll('i.right')) {
11661174
this.nodeMigrate(D);
11671175
}
@@ -1237,7 +1245,6 @@ window.ComponentCascadeLine = class {
12371245
this.CONTENT_DOM.append(stackDom);
12381246
}
12391247
this.STACKS = this.CONTENT_DOM.childNodes;
1240-
return this;
12411248
}
12421249

12431250
insertLabelDom(data, index, stack) {
@@ -1252,25 +1259,25 @@ window.ComponentCascadeLine = class {
12521259
div.addEventListener("contextmenu", (e) => {
12531260
e.preventDefault();
12541261
if(e.target instanceof HTMLElement) e.target.click();
1255-
_component.contextmenu(e, [
1256-
{
1257-
title: '新增', func: () => {
1258-
this.nodeInsert(div, data, stack);
1259-
}
1260-
},
1261-
{
1262-
title: '修改', func: () => {
1263-
this.nodeUpdate(div, data);
1264-
}
1265-
},
1266-
{
1267-
title: '删除', func: () => {
1268-
this.nodeDelete(div, data, stack);
1269-
}
1262+
let settings = [];
1263+
if(this.OPTIONS.insert) settings.push({
1264+
title: '新增', func: () => {
1265+
this.nodeInsert(div, data, stack);
1266+
}
1267+
});
1268+
if(this.OPTIONS.update) settings.push({
1269+
title: '修改', func: () => {
1270+
this.nodeUpdate(div, data);
12701271
}
1271-
]);
1272+
});
1273+
if(this.OPTIONS.delete) settings.push({
1274+
title: '删除', func: () => {
1275+
this.nodeDelete(div, data, stack);
1276+
}
1277+
});
1278+
_component.contextmenu(e, settings);
12721279
});
1273-
if (this.movable) div.insertAdjacentHTML('afterbegin', `<i class="right">${_component.move}</i>`);
1280+
if (this.OPTIONS.movable) div.insertAdjacentHTML('afterbegin', `<i class="right">${_component.move}</i>`);
12741281
return div;
12751282
}
12761283

0 commit comments

Comments
 (0)