efront 2.46.3 → 2.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/coms/crypt/encode62.js +38 -29
- package/coms/crypt/encode62_test.js +2 -1
- package/coms/zimoli/data.js +19 -9
- package/coms/zimoli/dispatch.js +13 -6
- package/coms/zimoli/encode62.js +3 -2
- package/coms/zimoli/input.js +0 -6
- package/coms/zimoli/input.less +6 -6
- package/coms/zimoli/model.js +42 -5
- package/coms/zimoli/popup.js +15 -10
- package/coms/zimoli/prompt.js +40 -0
- package/coms/zimoli/render.js +19 -9
- package/coms/zimoli/rootElements.js +1 -0
- package/coms/zimoli/search.js +15 -0
- package/coms/zimoli/select.js +26 -12
- package/coms/zimoli/selectList.js +68 -8
- package/coms/zimoli/selectList.less +15 -2
- package/coms/zimoli/selectListEdit.html +15 -0
- package/coms/zimoli/selectListEdit.js +68 -0
- package/coms/zimoli/selectListEdit.less +21 -0
- package/coms/zimoli/swap.less +1 -1
- package/coms/zimoli/table.html +6 -4
- package/coms/zimoli/table.js +59 -6
- package/coms/zimoli/table.less +3 -1
- package/coms/zimoli/textarea.less +0 -1
- package/coms/zimoli/zimoli.js +34 -6
- package/debug.log +2 -0
- package/package.json +1 -1
- package/public/efront.js +1 -1
|
@@ -6,6 +6,7 @@ var singleClick = function () {
|
|
|
6
6
|
node.activeNode = this;
|
|
7
7
|
if (node.value === this.value) return;
|
|
8
8
|
node.value = this.value;
|
|
9
|
+
node.name = this.name;
|
|
9
10
|
dispatch(node, "change");
|
|
10
11
|
};
|
|
11
12
|
var multipleClick = function () {
|
|
@@ -21,21 +22,27 @@ var multipleClick = function () {
|
|
|
21
22
|
}
|
|
22
23
|
dispatch(node, "change");
|
|
23
24
|
};
|
|
24
|
-
|
|
25
|
+
|
|
26
|
+
function main(children, multiple, addable) {
|
|
25
27
|
var list = div();
|
|
26
28
|
list.value = multiple ? [] : "";
|
|
27
29
|
var firstValue = false;
|
|
28
30
|
var clicker = multiple ? multipleClick : singleClick;
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
var
|
|
31
|
+
var itemMap = Object.create(null);
|
|
32
|
+
function createItem(option) {
|
|
33
|
+
var key = option.key || option.value;
|
|
34
|
+
if (key in itemMap) return itemMap[key];
|
|
35
|
+
var item = itemMap[option.value] = document.createElement('div');
|
|
36
|
+
|
|
37
|
+
item.setAttribute("item", '');
|
|
38
|
+
item.innerHTML = option.innerHTML || option.name;
|
|
39
|
+
item.name = option.name || option.innerHTML;
|
|
40
|
+
var icon = option.getAttribute ? option.getAttribute("icon") : option.icon;
|
|
34
41
|
if (icon) {
|
|
35
42
|
hasIcon = true;
|
|
36
43
|
css(item, { backgroundImage: `url('${icon}')` });
|
|
37
44
|
}
|
|
38
|
-
item.value =
|
|
45
|
+
item.value = key;
|
|
39
46
|
if (option.selected) {
|
|
40
47
|
iconed = icon;
|
|
41
48
|
if (multiple) {
|
|
@@ -54,10 +61,63 @@ function main(children, multiple) {
|
|
|
54
61
|
onclick(item, clicker);
|
|
55
62
|
}
|
|
56
63
|
return item;
|
|
57
|
-
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
var hasIcon = false, iconed = '';
|
|
67
|
+
appendChild(list, [].map.call(children, createItem));
|
|
68
|
+
if (addable) {
|
|
69
|
+
var adder = document.createElement("div");;
|
|
70
|
+
adder.innerHTML = "<a>添加</a><a>管理</a>";
|
|
71
|
+
button(adder.firstChild);
|
|
72
|
+
button(adder.children[1]);
|
|
73
|
+
on("click")(adder, async function (event) {
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
var target = getTargetIn(this, event.target, false);
|
|
76
|
+
switch (target) {
|
|
77
|
+
case this.children[0]:
|
|
78
|
+
var a = prompt("请输入", a => {
|
|
79
|
+
if (a in itemMap) {
|
|
80
|
+
alert(`选项 ${a} 已存在!`);
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
list.with = a;
|
|
85
|
+
on('remove')(a, function () {
|
|
86
|
+
list.with = null;
|
|
87
|
+
});
|
|
88
|
+
a = await a;
|
|
89
|
+
if (a in itemMap) return false;
|
|
90
|
+
cast(list.target, "add-option", a);
|
|
91
|
+
children.push({ name: a, key: a });
|
|
92
|
+
list.insertBefore(createItem({
|
|
93
|
+
name: a,
|
|
94
|
+
value: a,
|
|
95
|
+
}), adder);
|
|
96
|
+
break;
|
|
97
|
+
case this.children[1]:
|
|
98
|
+
var options = [].slice.call(list.children, 0, list.children.length - 1);
|
|
99
|
+
var edit = selectListEdit(options.slice(0));
|
|
100
|
+
|
|
101
|
+
list.with = edit;
|
|
102
|
+
on("remove")(edit, function () {
|
|
103
|
+
list.with = null;
|
|
104
|
+
remove([].slice.call(list.children, 0, list.children.length - 1));
|
|
105
|
+
children.splice(0, children.length);
|
|
106
|
+
children.push.apply(children, edit.$scope.options.map(o => ({ key: o.key || o.value, name: o.name || o.innerHTML })))
|
|
107
|
+
appendChild.before(adder, edit.$scope.options.map(createItem));
|
|
108
|
+
cast(list.target, 'set-options', edit.$scope.options);
|
|
109
|
+
});
|
|
110
|
+
popup(edit, [.5, .5]);
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
adder.setAttribute("adder", '');
|
|
115
|
+
list.appendChild(adder)
|
|
116
|
+
}
|
|
58
117
|
if (hasIcon) {
|
|
59
118
|
list.setAttribute('iconed', '');
|
|
60
119
|
}
|
|
61
120
|
list.icon = iconed;
|
|
121
|
+
on('mousedown')(list, e => e.preventDefault());
|
|
62
122
|
return list;
|
|
63
123
|
}
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
max-width: 100%;
|
|
3
3
|
background-color: #fff;
|
|
4
4
|
line-height: 30px;
|
|
5
|
-
box-shadow: 0 0 20px -6px rgba(0, 0, 0, .
|
|
5
|
+
box-shadow: 0 0 20px -6px rgba(0, 0, 0, .1);
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
border: 1px solid #0003;
|
|
6
8
|
|
|
7
|
-
>
|
|
9
|
+
>[item] {
|
|
8
10
|
cursor: default;
|
|
9
11
|
padding: 0 16px;
|
|
10
12
|
|
|
@@ -49,4 +51,15 @@
|
|
|
49
51
|
background-position-y: 50%;
|
|
50
52
|
background-position-x: 8px;
|
|
51
53
|
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
>[adder] {
|
|
57
|
+
padding: 0 16px;
|
|
58
|
+
text-align: right;
|
|
59
|
+
|
|
60
|
+
a {
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
vertical-align: top;
|
|
63
|
+
margin-left: 10px;
|
|
64
|
+
}
|
|
52
65
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<div head>管理选项</div>
|
|
2
|
+
<div body>
|
|
3
|
+
<div>
|
|
4
|
+
<input placeholder="搜索或添加" v-model="search" @keydown.enter="add()" /><a @click="add()"
|
|
5
|
+
-if="search&&!filtered.hasFullmatch">添加</a>
|
|
6
|
+
</div>
|
|
7
|
+
<div class="item" -repeat="o in (search?filtered:options)">
|
|
8
|
+
<span -html=o.name></span>
|
|
9
|
+
<a type="danger" @click="del(o)">删除</a>
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
<div foot>
|
|
13
|
+
<btn @click="save()">确定</btn>
|
|
14
|
+
<btn type="white" @click="remove()">取消</btn>
|
|
15
|
+
</div>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
function main(options) {
|
|
2
|
+
var page = view();
|
|
3
|
+
page.innerHTML = template;
|
|
4
|
+
on("submit")(page, e => e.preventDefault());
|
|
5
|
+
render(page, {
|
|
6
|
+
options, a: button, input, _search: '',
|
|
7
|
+
add() {
|
|
8
|
+
var a = this._search;
|
|
9
|
+
a = a.trim();
|
|
10
|
+
if (!a) return;
|
|
11
|
+
if (this.filtered.hasFullmatch) return;
|
|
12
|
+
options.push({ name: a, value: a });
|
|
13
|
+
this.research();
|
|
14
|
+
},
|
|
15
|
+
del(o) {
|
|
16
|
+
for (var cx = 0, dx = options.length; cx < dx; cx++) {
|
|
17
|
+
if (options[cx].value === o.value) {
|
|
18
|
+
var i = cx;
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (i >= 0) options.splice(i, 1);
|
|
23
|
+
console.log(i)
|
|
24
|
+
this.research();
|
|
25
|
+
},
|
|
26
|
+
get search() {
|
|
27
|
+
return this._search;
|
|
28
|
+
},
|
|
29
|
+
research() {
|
|
30
|
+
var v = this._search;
|
|
31
|
+
if (v) {
|
|
32
|
+
this.filtered = search(v, options);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
set search(v) {
|
|
36
|
+
this._search = v;
|
|
37
|
+
if (v) {
|
|
38
|
+
this.research();
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
btn: button,
|
|
42
|
+
remove() {
|
|
43
|
+
remove(page);
|
|
44
|
+
},
|
|
45
|
+
save() {
|
|
46
|
+
remove(page);
|
|
47
|
+
},
|
|
48
|
+
filtered: []
|
|
49
|
+
});
|
|
50
|
+
drag.on(page.firstChild, page);
|
|
51
|
+
on("append")(page, function () {
|
|
52
|
+
setTimeout(function () {
|
|
53
|
+
page.querySelector("input").focus();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
on("mousedown")(page, e => {
|
|
57
|
+
if (e.target !== page.querySelector("input")) {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
page.onback = function () {
|
|
62
|
+
if (page.$scope.search) {
|
|
63
|
+
page.$scope.search = '';
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
return page;
|
|
68
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
& {
|
|
2
|
+
position: absolute;
|
|
3
|
+
user-select: none;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
[body]>div {
|
|
7
|
+
padding: 6px 10px;
|
|
8
|
+
background: #fff;
|
|
9
|
+
|
|
10
|
+
>* {
|
|
11
|
+
line-height: 28px;
|
|
12
|
+
vertical-align: top;
|
|
13
|
+
margin-right: 20px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&.item {
|
|
17
|
+
&:nth-of-type(n+2) {
|
|
18
|
+
border-top: 1px solid #0003;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
package/coms/zimoli/swap.less
CHANGED
package/coms/zimoli/table.html
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
<thead>
|
|
2
2
|
<tr>
|
|
3
|
-
<td -repeat="f in fields
|
|
3
|
+
<td -repeat="f in fields track by f.id" :style="{width:f.width}"><i -if="f.icon"
|
|
4
|
+
-class="f.icon"></i></span><span -if="f.name" -html="f.name"></span>
|
|
4
5
|
</td>
|
|
5
6
|
</tr>
|
|
6
7
|
</thead>
|
|
7
8
|
<tbody -src="d in data">
|
|
8
9
|
<tr>
|
|
9
10
|
<td -repeat="f in fields">
|
|
10
|
-
<
|
|
11
|
-
<a on-click="o.do(d)" -if="f.options"
|
|
12
|
-
|
|
11
|
+
<model -if="f.key" :field=f :data=d readonly ></model>
|
|
12
|
+
<a on-click="o.do(d)" -if="!f.key&&f.options" _type="o.type instanceof Function?o.type(d):o.type"
|
|
13
|
+
-repeat="o in f.options">
|
|
14
|
+
<span -text="o.name instanceof Function?o.name(d):o.name"></span>
|
|
13
15
|
</a>
|
|
14
16
|
</td>
|
|
15
17
|
</tr>
|
package/coms/zimoli/table.js
CHANGED
|
@@ -91,11 +91,11 @@ var adaptTarget = function (event) {
|
|
|
91
91
|
}
|
|
92
92
|
if (target) target = getFirstSingleColCell(this, target.colend);
|
|
93
93
|
if (target) {
|
|
94
|
-
if (position.right >=
|
|
94
|
+
if (position.right >= getScreenPosition(this).right - 7) {
|
|
95
95
|
target = this;
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
-
css(
|
|
98
|
+
css(document.body, { 'cursor': 'col-resize' });
|
|
99
99
|
result = {
|
|
100
100
|
target,
|
|
101
101
|
restX: event.clientX - target.offsetWidth
|
|
@@ -106,18 +106,66 @@ var adaptTarget = function (event) {
|
|
|
106
106
|
}
|
|
107
107
|
if (!result) {
|
|
108
108
|
this.resizing = false;
|
|
109
|
-
css(
|
|
109
|
+
css(document.body, { 'cursor': '' });
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
112
|
var tdElementReg = /^t[hd]$/i;
|
|
113
113
|
var trElementReg = /^tr$/i;
|
|
114
|
+
var id = 0;
|
|
115
|
+
function enrichField(f) {
|
|
116
|
+
if (!f.id) f.id = ++id;
|
|
117
|
+
if (f.width) return;
|
|
118
|
+
var width;
|
|
119
|
+
if (f.size) {
|
|
120
|
+
width = f.size;
|
|
121
|
+
if (width < 40) width = width * 16;
|
|
122
|
+
}
|
|
123
|
+
else switch (f.type) {
|
|
124
|
+
case "text":
|
|
125
|
+
width = 30;
|
|
126
|
+
break;
|
|
127
|
+
case "input":
|
|
128
|
+
width = 200;
|
|
129
|
+
break;
|
|
130
|
+
case "date":
|
|
131
|
+
width = 180;
|
|
132
|
+
case "datetime":
|
|
133
|
+
width = 200;
|
|
134
|
+
break;
|
|
135
|
+
case "time":
|
|
136
|
+
width = 120;
|
|
137
|
+
break;
|
|
138
|
+
default:
|
|
139
|
+
if (f.options) {
|
|
140
|
+
width = f.options.map(o => o.name instanceof Function ? o.name() : o.name).join(" ").length * 20;
|
|
141
|
+
} else {
|
|
142
|
+
width = String(f.name || f.key).length * 16;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (width > 600) width = 600;
|
|
146
|
+
f.width = width + 60;
|
|
147
|
+
}
|
|
148
|
+
|
|
114
149
|
|
|
115
150
|
function table(elem) {
|
|
116
151
|
var tableElement = isElement(elem) ? elem : document.createElement("table");
|
|
117
152
|
var activeCols = [];
|
|
118
|
-
|
|
153
|
+
var adaptCursor = adaptTarget.bind(tableElement);
|
|
154
|
+
var off;
|
|
155
|
+
tableElement.init = function () {
|
|
156
|
+
off = on("mousemove")(window, adaptCursor);
|
|
157
|
+
};
|
|
158
|
+
tableElement.dispose = tableElement.destroy = function () {
|
|
159
|
+
off();
|
|
160
|
+
};
|
|
161
|
+
on("append")(tableElement, tableElement.init);
|
|
162
|
+
on("remove")(tableElement, tableElement.destroy);
|
|
163
|
+
if (isMounted(tableElement)) tableElement.init();
|
|
164
|
+
|
|
119
165
|
moveupon(tableElement, {
|
|
120
|
-
start() {
|
|
166
|
+
start(event) {
|
|
167
|
+
if (this.resizing) event.preventDefault();
|
|
168
|
+
},
|
|
121
169
|
move: resizeTarget,
|
|
122
170
|
});
|
|
123
171
|
onmousemove(tableElement, function (event) {
|
|
@@ -142,7 +190,7 @@ function table(elem) {
|
|
|
142
190
|
removeClass(td, "y-ing");
|
|
143
191
|
});
|
|
144
192
|
});
|
|
145
|
-
var table = tableElement
|
|
193
|
+
var table = tableElement;
|
|
146
194
|
var thead;
|
|
147
195
|
var cellMatchManager = function (element) {
|
|
148
196
|
if (!thead) [thead] = table.getElementsByTagName("thead");
|
|
@@ -162,10 +210,15 @@ function table(elem) {
|
|
|
162
210
|
care(table, function ([fields, data]) {
|
|
163
211
|
thead = null;
|
|
164
212
|
this.innerHTML = template;
|
|
213
|
+
fields.forEach(enrichField);
|
|
165
214
|
render(this, {
|
|
166
215
|
fields,
|
|
167
216
|
tbody: list,
|
|
168
217
|
data,
|
|
218
|
+
model,
|
|
219
|
+
setWidth(target, f) {
|
|
220
|
+
css(target, { width: f.width });
|
|
221
|
+
},
|
|
169
222
|
a: button,
|
|
170
223
|
}, this.$parentScopes.concat(this.$scope));
|
|
171
224
|
})
|
package/coms/zimoli/table.less
CHANGED
package/coms/zimoli/zimoli.js
CHANGED
|
@@ -249,11 +249,33 @@ function prepare(pgpath, ok) {
|
|
|
249
249
|
return _with_elements;
|
|
250
250
|
};
|
|
251
251
|
state.path = function (url) {
|
|
252
|
-
if (
|
|
252
|
+
if (/^\.+\//.test(url)) {
|
|
253
253
|
url = pgpath.replace(/[^\/]*$/, url);
|
|
254
254
|
}
|
|
255
|
+
if (isString(url) && /[\\\/\.]/.test(url)) {
|
|
256
|
+
url = url.replace(/^\.[\\\/]/, '');
|
|
257
|
+
var ps = url.split(/[\\\/]/);
|
|
258
|
+
var ds = [];
|
|
259
|
+
for (var p of ps) {
|
|
260
|
+
if (p === "..") {
|
|
261
|
+
ds.pop();
|
|
262
|
+
}
|
|
263
|
+
else if (p !== ".") {
|
|
264
|
+
ds.push(p);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
url = "/" + ds.join('/').replace(/^\//, '');
|
|
268
|
+
}
|
|
255
269
|
return url;
|
|
256
|
-
}
|
|
270
|
+
};
|
|
271
|
+
state.popup = function (a) {
|
|
272
|
+
a = state.path(a);
|
|
273
|
+
return popup.apply(this, [a].concat([].slice.call(arguments, 1)));
|
|
274
|
+
};
|
|
275
|
+
state.init = function (a) {
|
|
276
|
+
a = state.path(a);
|
|
277
|
+
return init.apply(this, [a].concat([].slice.call(arguments, 1)));
|
|
278
|
+
};
|
|
257
279
|
state.go = function (url, args, _history_name) {
|
|
258
280
|
// if (arguments.length === 1 && isFinite(url)) return window_history.go(url | 0);
|
|
259
281
|
var to = function (_url, args, _history_name) {
|
|
@@ -337,11 +359,17 @@ function prepare(pgpath, ok) {
|
|
|
337
359
|
}, state);
|
|
338
360
|
}
|
|
339
361
|
function create(pagepath, args, from, needroles) {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
362
|
+
if (typeof pagepath === 'string') {
|
|
363
|
+
var page_object = isObject(pagepath) ? pagepath : page_generators[getpgpath(pagepath)];
|
|
364
|
+
if (!page_object) {
|
|
365
|
+
throw new Error(`调用create前请确保prepare执行完毕:${pagepath}`);
|
|
366
|
+
}
|
|
367
|
+
var { pg, "with": _with_elements, state, onback: _pageback_listener, roles } = page_object;
|
|
368
|
+
}
|
|
369
|
+
else if (isFunction(pagepath)) {
|
|
370
|
+
var pg = pagepath;
|
|
371
|
+
var { with: _with_elements, state = {}, onback: _pageback_listener, roles } = pg;
|
|
343
372
|
}
|
|
344
|
-
var { pg, "with": _with_elements, state, onback: _pageback_listener, roles } = page_object;
|
|
345
373
|
if (!checkroles(user.roles, roles) || !checkroles(user.roles, needroles)) {
|
|
346
374
|
// 检查权限
|
|
347
375
|
if (!user.isLogin && user.loginPath) {
|
package/debug.log
ADDED