@truenewx/tnxvue3 3.4.0 → 3.4.1
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/eslint.config.cjs +58 -0
- package/index.html +12 -12
- package/package.json +16 -40
- package/src/aj-captcha/Verify/VerifySlide.vue +9 -9
- package/src/aj-captcha/api/index.js +2 -10
- package/src/aj-captcha/utils/ase.js +1 -1
- package/src/bootstrap-vue/alert/Alert.vue +79 -79
- package/src/bootstrap-vue/button/Button.vue +40 -40
- package/src/bootstrap-vue/enum-select/EnumSelect.vue +4 -5
- package/src/bootstrap-vue/form/Form.vue +320 -320
- package/src/bootstrap-vue/form/FormGroup.vue +73 -73
- package/src/bootstrap-vue/loading-icon/LoadingIcon.vue +46 -46
- package/src/bootstrap-vue/paged/Paged.vue +119 -119
- package/src/bootstrap-vue/progress/Progress.vue +58 -58
- package/src/bootstrap-vue/query-table/QueryTable.vue +84 -84
- package/src/bootstrap-vue/region-cascader/RegionCascader.vue +119 -119
- package/src/bootstrap-vue/select/Select.vue +375 -375
- package/src/bootstrap-vue/submit-form/SubmitForm.vue +180 -176
- package/src/bootstrap-vue/tags-input/TagsInput.vue +64 -64
- package/src/bootstrap-vue/tnxbsv.css +107 -107
- package/src/bootstrap-vue/tnxbsv.js +109 -92
- package/src/bootstrap-vue/upload/Upload.vue +173 -173
- package/src/element-plus/avatar/Avatar.vue +8 -9
- package/src/element-plus/button/Button.vue +2 -2
- package/src/element-plus/curd/Curd.vue +20 -23
- package/src/element-plus/date-picker/DatePicker.vue +1 -1
- package/src/element-plus/detail-form/DetailForm.vue +1 -1
- package/src/element-plus/dialog/Dialog.vue +18 -20
- package/src/element-plus/drawer/Drawer.vue +10 -9
- package/src/element-plus/edit-table/EditTable.vue +3 -3
- package/src/element-plus/enum-select/EnumSelect.vue +3 -3
- package/src/element-plus/enum-view/EnumView.vue +41 -41
- package/src/element-plus/fetch-cascader/FetchCascader.vue +3 -4
- package/src/element-plus/fetch-select/FetchSelect.vue +10 -11
- package/src/element-plus/fetch-tags/FetchTags.vue +4 -5
- package/src/element-plus/fss-upload/FssUpload.vue +18 -18
- package/src/element-plus/fss-view/FssView.vue +1 -1
- package/src/element-plus/icon/Icon.vue +6 -0
- package/src/element-plus/input-dropdown/InputDropdown.vue +74 -74
- package/src/element-plus/query-form/QueryForm.vue +1 -1
- package/src/element-plus/query-table/QueryTable.vue +22 -26
- package/src/element-plus/region-cascader/RegionCascader.vue +4 -5
- package/src/element-plus/select/Select.vue +2 -2
- package/src/element-plus/steps-nav/StepsNav.vue +3 -4
- package/src/element-plus/submit-form/SubmitForm.vue +36 -39
- package/src/element-plus/tabs/Tabs.vue +1 -1
- package/src/element-plus/tnxel.css +22 -0
- package/src/element-plus/tnxel.js +101 -93
- package/src/element-plus/toolbar/ToolBarItem.js +15 -15
- package/src/element-plus/toolbar/Toolbar.vue +56 -56
- package/src/element-plus/transfer/Transfer.vue +8 -9
- package/src/element-plus/upload/Upload.vue +24 -24
- package/src/tnxvue-router.js +4 -4
- package/src/tnxvue-validator.js +8 -2
- package/src/tnxvue.js +13 -26
|
@@ -100,11 +100,10 @@ export default {
|
|
|
100
100
|
mounted() {
|
|
101
101
|
this.initRules();
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
let container = $(vm.container);
|
|
103
|
+
this.$nextTick(() => {
|
|
104
|
+
let container = $(this.container);
|
|
106
105
|
if (container.length) {
|
|
107
|
-
|
|
106
|
+
this.topOffset = $('#' + this.id).offset().top - container.offset().top - 16;
|
|
108
107
|
}
|
|
109
108
|
});
|
|
110
109
|
},
|
|
@@ -112,18 +111,17 @@ export default {
|
|
|
112
111
|
initRules() {
|
|
113
112
|
if (this.rules) {
|
|
114
113
|
if (typeof this.rules === 'string') {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
vm.rulesLoaded(meta.$rules);
|
|
114
|
+
window.tnx.app.rpc.getMeta(this.rules, this.rulesApp).then(meta => {
|
|
115
|
+
if (this.rulesLoaded) {
|
|
116
|
+
this.rulesLoaded(meta.$rules);
|
|
119
117
|
} else {
|
|
120
|
-
|
|
118
|
+
this.$emit('rules-loaded', meta.$rules);
|
|
121
119
|
}
|
|
122
|
-
|
|
120
|
+
this.validationRules = meta.$rules;
|
|
123
121
|
delete meta.$rules;
|
|
124
122
|
this.$emit('meta', meta);
|
|
125
|
-
|
|
126
|
-
}
|
|
123
|
+
this.fieldNames = Object.keys(meta);
|
|
124
|
+
});
|
|
127
125
|
} else {
|
|
128
126
|
this.validationRules = {};
|
|
129
127
|
Object.keys(this.rules).forEach(fieldName => {
|
|
@@ -166,28 +164,29 @@ export default {
|
|
|
166
164
|
this.$refs.form.scrollToField(fieldName);
|
|
167
165
|
}
|
|
168
166
|
},
|
|
169
|
-
validate(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
}).catch(function (errors) {
|
|
176
|
-
if (_this.errorFocus && errorFocus !== false) {
|
|
177
|
-
_this.$nextTick(function () {
|
|
178
|
-
_this.focusError.call(_this, errors);
|
|
167
|
+
validate() {
|
|
168
|
+
return new Promise((resolve) => {
|
|
169
|
+
if (this.$refs.form) {
|
|
170
|
+
this.$refs.form.validate((valid) => {
|
|
171
|
+
resolve(valid);
|
|
179
172
|
});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
173
|
+
} else if (this.rules) {
|
|
174
|
+
const validator = new AsyncValidator(this.rules);
|
|
175
|
+
validator.validate(this.model).then(() => {
|
|
176
|
+
resolve(true);
|
|
177
|
+
}).catch(() => {
|
|
178
|
+
resolve(false);
|
|
179
|
+
});
|
|
180
|
+
} else {
|
|
181
|
+
resolve(true);
|
|
183
182
|
}
|
|
184
183
|
});
|
|
185
184
|
},
|
|
186
185
|
validateField(props, callback, errorFocus) {
|
|
187
186
|
let _this = this;
|
|
188
|
-
this.$refs.form.validateField(props,
|
|
187
|
+
this.$refs.form.validateField(props, (errorMessage) => {
|
|
189
188
|
if (errorMessage && _this.errorFocus && errorFocus !== false) {
|
|
190
|
-
_this.$nextTick(
|
|
189
|
+
_this.$nextTick(() => {
|
|
191
190
|
_this.focusError.call(_this);
|
|
192
191
|
});
|
|
193
192
|
}
|
|
@@ -200,17 +199,16 @@ export default {
|
|
|
200
199
|
this.$refs.form.clearValidate(props);
|
|
201
200
|
},
|
|
202
201
|
toSubmit(callback, disabled) {
|
|
203
|
-
|
|
204
|
-
this.validate(function (success) {
|
|
202
|
+
this.validate().then(success => {
|
|
205
203
|
if (success) {
|
|
206
204
|
if (typeof callback !== 'function') {
|
|
207
|
-
callback =
|
|
205
|
+
callback = this.submit;
|
|
208
206
|
}
|
|
209
207
|
if (typeof callback === 'function') {
|
|
210
208
|
if (disabled !== false) {
|
|
211
|
-
|
|
209
|
+
this.disable();
|
|
212
210
|
}
|
|
213
|
-
callback(
|
|
211
|
+
callback(this);
|
|
214
212
|
}
|
|
215
213
|
}
|
|
216
214
|
});
|
|
@@ -229,12 +227,14 @@ export default {
|
|
|
229
227
|
},
|
|
230
228
|
/**
|
|
231
229
|
* 执行所有的校验规则,以自定义方式处理错误
|
|
232
|
-
* @param callback 校验后的回调函数,首个参数为错误消息字符串数组,没有错误时为null
|
|
233
230
|
* @param fieldLabels 字段标签,可以是一个函数,也可以是一个对象,用于自定义错误消息中的字段标签
|
|
231
|
+
* @returns Promise<string[]|null> 错误消息字符串数组,没有错误时为null
|
|
234
232
|
*/
|
|
235
|
-
validateRules(
|
|
233
|
+
validateRules(fieldLabels) {
|
|
236
234
|
let validator = new AsyncValidator(this.validationRules);
|
|
237
|
-
validator.validate(this.model
|
|
235
|
+
return validator.validate(this.model).then(() => {
|
|
236
|
+
return null;
|
|
237
|
+
}).catch((errors) => {
|
|
238
238
|
let messages = [];
|
|
239
239
|
if (errors) {
|
|
240
240
|
for (let error of errors) {
|
|
@@ -248,10 +248,7 @@ export default {
|
|
|
248
248
|
messages.push(fieldLabel + error.message);
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
-
|
|
252
|
-
messages = null;
|
|
253
|
-
}
|
|
254
|
-
callback(messages);
|
|
251
|
+
return messages.length === 0 ? null : messages;
|
|
255
252
|
});
|
|
256
253
|
}
|
|
257
254
|
}
|
|
@@ -882,3 +882,25 @@ i svg {
|
|
|
882
882
|
word-break: break-all;
|
|
883
883
|
overflow-wrap: break-word;
|
|
884
884
|
}
|
|
885
|
+
|
|
886
|
+
.link {
|
|
887
|
+
color: var(--el-color-primary);
|
|
888
|
+
text-decoration: none;
|
|
889
|
+
cursor: pointer;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
.link:hover {
|
|
893
|
+
color: var(--el-color-primary-light-5);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
.is-disabled .link {
|
|
897
|
+
color: var(--el-color-primary-light-5);
|
|
898
|
+
cursor: not-allowed;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
.el-input-group__append div.el-select .el-select__wrapper,
|
|
902
|
+
.el-input-group__append div.el-select:hover .el-select__wrapper,
|
|
903
|
+
.el-input-group__prepend div.el-select .el-select__wrapper,
|
|
904
|
+
.el-input-group__prepend div.el-select:hover .el-select__wrapper {
|
|
905
|
+
background-color: var(--el-color-white);
|
|
906
|
+
}
|
|
@@ -142,22 +142,24 @@ export default build('tnxel', () => {
|
|
|
142
142
|
window.tnx.dialogInstances.push(dialog);
|
|
143
143
|
return dialog;
|
|
144
144
|
},
|
|
145
|
-
closeDialog(all
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
break;
|
|
145
|
+
closeDialog(all) {
|
|
146
|
+
return new Promise((resolve) => {
|
|
147
|
+
if (window.tnx.dialogInstances.length) {
|
|
148
|
+
let dialog = window.tnx.dialogInstances.pop();
|
|
149
|
+
let promises = [];
|
|
150
|
+
while (dialog) {
|
|
151
|
+
promises.push(dialog.close());
|
|
152
|
+
if (all) {
|
|
153
|
+
dialog = window.tnx.dialogInstances.pop();
|
|
154
|
+
} else {
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
158
157
|
}
|
|
158
|
+
Promise.all(promises).then(resolve);
|
|
159
|
+
} else {
|
|
160
|
+
resolve();
|
|
159
161
|
}
|
|
160
|
-
}
|
|
162
|
+
});
|
|
161
163
|
},
|
|
162
164
|
drawerInstances: [], // 抽屉堆栈
|
|
163
165
|
drawer(content, title, buttons, options, contentProps) {
|
|
@@ -202,29 +204,31 @@ export default build('tnxel', () => {
|
|
|
202
204
|
window.tnx.drawerInstances.push(drawer);
|
|
203
205
|
return drawer;
|
|
204
206
|
},
|
|
205
|
-
closeDrawer(all
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
break;
|
|
207
|
+
closeDrawer(all) {
|
|
208
|
+
return new Promise((resolve) => {
|
|
209
|
+
if (window.tnx.drawerInstances.length) {
|
|
210
|
+
let drawer = window.tnx.drawerInstances.pop();
|
|
211
|
+
let promises = [];
|
|
212
|
+
while (drawer) {
|
|
213
|
+
promises.push(drawer.close());
|
|
214
|
+
if (all) {
|
|
215
|
+
drawer = window.tnx.drawerInstances.pop();
|
|
216
|
+
} else {
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
218
219
|
}
|
|
220
|
+
Promise.all(promises).then(resolve);
|
|
221
|
+
} else {
|
|
222
|
+
resolve();
|
|
219
223
|
}
|
|
220
|
-
}
|
|
224
|
+
});
|
|
221
225
|
},
|
|
222
226
|
_closeMessage() {
|
|
223
227
|
ElMessage.closeAll();
|
|
224
228
|
this.closeLoading();
|
|
225
229
|
},
|
|
226
230
|
_handleZIndex(selector) {
|
|
227
|
-
setTimeout(
|
|
231
|
+
setTimeout(() => {
|
|
228
232
|
const topZIndex = window.tnx.util.dom.minTopZIndex(2);
|
|
229
233
|
if (selector.endsWith(':last')) {
|
|
230
234
|
selector = selector.substring(0, selector.length - ':last'.length);
|
|
@@ -243,11 +247,9 @@ export default build('tnxel', () => {
|
|
|
243
247
|
}
|
|
244
248
|
});
|
|
245
249
|
},
|
|
246
|
-
alert(message, title,
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
options = callback;
|
|
250
|
-
callback = title;
|
|
250
|
+
alert(message, title, options) {
|
|
251
|
+
if (typeof title === 'object') {
|
|
252
|
+
options = title;
|
|
251
253
|
title = '提示';
|
|
252
254
|
}
|
|
253
255
|
options = Object.assign({
|
|
@@ -255,46 +257,45 @@ export default build('tnxel', () => {
|
|
|
255
257
|
type: 'warning',
|
|
256
258
|
confirmButtonText: '确定',
|
|
257
259
|
}, options);
|
|
258
|
-
this.
|
|
259
|
-
ElMessageBox.alert(message, title || '提示', options)
|
|
260
|
+
this._closeMessage();
|
|
261
|
+
const promise = ElMessageBox.alert(message, title || '提示', options);
|
|
260
262
|
this._handleZIndex('.el-message-box__wrapper:last');
|
|
261
263
|
this.app.eventBus.emit('tnx.alert', options);
|
|
264
|
+
return promise;
|
|
262
265
|
},
|
|
263
|
-
success(message,
|
|
264
|
-
this.closeLoading();
|
|
266
|
+
success(message, options) {
|
|
265
267
|
options = Object.assign({
|
|
266
268
|
dangerouslyUseHTMLString: true,
|
|
267
269
|
}, options, {
|
|
268
270
|
type: 'success',
|
|
269
271
|
confirmButtonText: '确定',
|
|
270
272
|
});
|
|
271
|
-
this.
|
|
272
|
-
ElMessageBox.alert(message, '成功', options)
|
|
273
|
+
this._closeMessage();
|
|
274
|
+
const promise = ElMessageBox.alert(message, '成功', options);
|
|
273
275
|
this._handleZIndex('.el-message-box__wrapper:last');
|
|
274
276
|
this.app.eventBus.emit('tnx.success', options);
|
|
277
|
+
return promise;
|
|
275
278
|
},
|
|
276
|
-
error(message,
|
|
277
|
-
this.closeLoading();
|
|
279
|
+
error(message, options) {
|
|
278
280
|
options = Object.assign({
|
|
279
281
|
dangerouslyUseHTMLString: true,
|
|
280
282
|
}, options, {
|
|
281
283
|
type: 'error',
|
|
282
284
|
confirmButtonText: '确定',
|
|
283
285
|
});
|
|
284
|
-
this.
|
|
285
|
-
ElMessageBox.alert(message, '错误', options)
|
|
286
|
+
this._closeMessage();
|
|
287
|
+
const promise = ElMessageBox.alert(message, '错误', options);
|
|
286
288
|
this._handleZIndex('.el-message-box__wrapper:last');
|
|
287
289
|
this.app.eventBus.emit('tnx.error', options);
|
|
288
290
|
// 打印TypeError对象,便于调试
|
|
289
291
|
if (typeof message === 'object' && message.name === 'TypeError') {
|
|
290
292
|
console.error(message);
|
|
291
293
|
}
|
|
294
|
+
return promise;
|
|
292
295
|
},
|
|
293
|
-
confirm(message, title
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
options = callback;
|
|
297
|
-
callback = title;
|
|
296
|
+
confirm(message, title = '确认', options) {
|
|
297
|
+
if (typeof title === 'object') {
|
|
298
|
+
options = title;
|
|
298
299
|
title = '确认';
|
|
299
300
|
}
|
|
300
301
|
options = Object.assign({
|
|
@@ -315,29 +316,20 @@ export default build('tnxel', () => {
|
|
|
315
316
|
options.confirmButtonText = options.cancelButtonText;
|
|
316
317
|
options.cancelButtonText = buttonText;
|
|
317
318
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
ElMessageBox.confirm(message, title, options);
|
|
331
|
-
this._handleZIndex('.el-message-box__wrapper:last');
|
|
332
|
-
this.app.eventBus.emit('tnx.confirm', options);
|
|
319
|
+
|
|
320
|
+
this._closeMessage();
|
|
321
|
+
return new Promise(resolve => {
|
|
322
|
+
ElMessageBox.confirm(message, title, options).then(() => {
|
|
323
|
+
resolve(true);
|
|
324
|
+
}).catch(() => {
|
|
325
|
+
resolve(false);
|
|
326
|
+
});
|
|
327
|
+
this._handleZIndex('.el-message-box__wrapper:last');
|
|
328
|
+
this.app.eventBus.emit('tnx.confirm', options);
|
|
329
|
+
})
|
|
330
|
+
|
|
333
331
|
},
|
|
334
|
-
toast(message, timeout,
|
|
335
|
-
this.closeLoading();
|
|
336
|
-
if (typeof timeout === 'function') {
|
|
337
|
-
options = callback;
|
|
338
|
-
callback = timeout;
|
|
339
|
-
timeout = undefined;
|
|
340
|
-
}
|
|
332
|
+
toast(message, timeout, options) {
|
|
341
333
|
options = Object.assign({
|
|
342
334
|
type: 'success', // 默认为成功主题,可更改为其它主题
|
|
343
335
|
offset: this.util.dom.getDocHeight() * 0.4,
|
|
@@ -348,46 +340,62 @@ export default build('tnxel', () => {
|
|
|
348
340
|
message: message,
|
|
349
341
|
duration: timeout || 1500,
|
|
350
342
|
customClass: 'tnxel-toast',
|
|
351
|
-
onClose: callback,
|
|
352
343
|
});
|
|
344
|
+
|
|
353
345
|
this._closeMessage();
|
|
354
|
-
ElMessage(options);
|
|
346
|
+
const messageInstance = ElMessage(options);
|
|
355
347
|
this._handleZIndex('.el-message:last');
|
|
356
348
|
this.app.eventBus.emit('tnx.toast', options);
|
|
349
|
+
|
|
350
|
+
// 创建一个Promise,在消息关闭时resolve
|
|
351
|
+
return new Promise((resolve) => {
|
|
352
|
+
const originalOnClose = options.onClose;
|
|
353
|
+
options.onClose = () => {
|
|
354
|
+
if (originalOnClose) {
|
|
355
|
+
originalOnClose();
|
|
356
|
+
}
|
|
357
|
+
resolve();
|
|
358
|
+
};
|
|
359
|
+
// 如果消息实例有close方法,重新设置onClose
|
|
360
|
+
if (messageInstance && messageInstance.close) {
|
|
361
|
+
const originalClose = messageInstance.close;
|
|
362
|
+
messageInstance.close = () => {
|
|
363
|
+
originalClose.call(messageInstance);
|
|
364
|
+
options.onClose();
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
});
|
|
357
368
|
},
|
|
358
|
-
showLoading(message,
|
|
369
|
+
showLoading(message, options) {
|
|
359
370
|
if (typeof message !== 'string') {
|
|
360
|
-
options =
|
|
361
|
-
callback = message;
|
|
371
|
+
options = message;
|
|
362
372
|
message = undefined;
|
|
363
373
|
}
|
|
364
|
-
if (typeof callback !== 'function') {
|
|
365
|
-
options = callback;
|
|
366
|
-
callback = undefined;
|
|
367
|
-
}
|
|
368
374
|
options = Object.assign({
|
|
369
375
|
dangerouslyUseHTMLString: true,
|
|
370
376
|
}, options, {
|
|
371
377
|
text: message,
|
|
372
378
|
});
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
+
return new Promise((resolve, reject) => {
|
|
380
|
+
window.tnx._closeMessage();
|
|
381
|
+
try {
|
|
382
|
+
window.tnx.loadingInstance = ElLoading.service(options);
|
|
383
|
+
this._handleZIndex('.el-loading-mask');
|
|
384
|
+
window.tnx.app.eventBus.emit('tnx.showLoading', options);
|
|
379
385
|
let vm = window.tnx.loadingInstance.vm;
|
|
380
386
|
if (vm) {
|
|
381
|
-
|
|
387
|
+
window.tnx.nextTickTimeout(vm, () => {
|
|
388
|
+
resolve(window.tnx.loadingInstance);
|
|
389
|
+
}, 500);
|
|
382
390
|
} else {
|
|
383
|
-
|
|
391
|
+
resolve(window.tnx.loadingInstance);
|
|
384
392
|
}
|
|
393
|
+
} catch (e) {
|
|
394
|
+
window.tnx.loadingInstance = null;
|
|
395
|
+
console.error(e);
|
|
396
|
+
reject(e);
|
|
385
397
|
}
|
|
386
|
-
}
|
|
387
|
-
window.tnx.loadingInstance = null;
|
|
388
|
-
console.error(e);
|
|
389
|
-
}
|
|
390
|
-
return window.tnx.loadingInstance;
|
|
398
|
+
});
|
|
391
399
|
},
|
|
392
400
|
closeLoading() {
|
|
393
401
|
if (window.tnx.loadingInstance) { // 确保绝对的单例
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 工具栏项
|
|
3
|
-
*/
|
|
4
|
-
export default class ToolBarItem {
|
|
5
|
-
|
|
6
|
-
icon = '';
|
|
7
|
-
caption = '';
|
|
8
|
-
disabled = false;
|
|
9
|
-
click = null;
|
|
10
|
-
|
|
11
|
-
static from(object) {
|
|
12
|
-
return Object.assign(new ToolBarItem(), object);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 工具栏项
|
|
3
|
+
*/
|
|
4
|
+
export default class ToolBarItem {
|
|
5
|
+
|
|
6
|
+
icon = '';
|
|
7
|
+
caption = '';
|
|
8
|
+
disabled = false;
|
|
9
|
+
click = null;
|
|
10
|
+
|
|
11
|
+
static from(object) {
|
|
12
|
+
return Object.assign(new ToolBarItem(), object);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="tnxel-toolbar">
|
|
3
|
-
<div class="flex-v-center">
|
|
4
|
-
<template v-for="(item, index) of leftItems" :key="index">
|
|
5
|
-
<el-divider direction="vertical" v-if="item === '|'"/>
|
|
6
|
-
<ToolBarItem
|
|
7
|
-
:item="Item.from(item)"
|
|
8
|
-
:size="size"
|
|
9
|
-
v-else-if="typeof item ==='object'"/>
|
|
10
|
-
</template>
|
|
11
|
-
</div>
|
|
12
|
-
<div class="flex-v-center">
|
|
13
|
-
<ToolBarItem v-for="(item, index) of rightItems" :key="index"
|
|
14
|
-
:item="Item.from(item)"
|
|
15
|
-
:size="size"/>
|
|
16
|
-
</div>
|
|
17
|
-
</div>
|
|
18
|
-
</template>
|
|
19
|
-
|
|
20
|
-
<script>
|
|
21
|
-
import ToolBarItem from './ToolBarItem.vue';
|
|
22
|
-
import Item from './ToolBarItem.js';
|
|
23
|
-
|
|
24
|
-
export default {
|
|
25
|
-
name: 'TnxelToolbar',
|
|
26
|
-
components: {ToolBarItem},
|
|
27
|
-
props: {
|
|
28
|
-
leftItems: Array,
|
|
29
|
-
rightItems: Array,
|
|
30
|
-
size: {
|
|
31
|
-
type: String,
|
|
32
|
-
validator: value => {
|
|
33
|
-
return ['small', 'default', 'large'].includes(value);
|
|
34
|
-
},
|
|
35
|
-
default: 'default',
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
data() {
|
|
39
|
-
return {
|
|
40
|
-
Item,
|
|
41
|
-
model: {},
|
|
42
|
-
};
|
|
43
|
-
},
|
|
44
|
-
methods: {}
|
|
45
|
-
}
|
|
46
|
-
</script>
|
|
47
|
-
|
|
48
|
-
<style>
|
|
49
|
-
.tnxel-toolbar {
|
|
50
|
-
height: 32px;
|
|
51
|
-
padding: 0 8px;
|
|
52
|
-
display: flex;
|
|
53
|
-
align-items: center;
|
|
54
|
-
justify-content: space-between;
|
|
55
|
-
}
|
|
56
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="tnxel-toolbar">
|
|
3
|
+
<div class="flex-v-center">
|
|
4
|
+
<template v-for="(item, index) of leftItems" :key="index">
|
|
5
|
+
<el-divider direction="vertical" v-if="item === '|'"/>
|
|
6
|
+
<ToolBarItem
|
|
7
|
+
:item="Item.from(item)"
|
|
8
|
+
:size="size"
|
|
9
|
+
v-else-if="typeof item ==='object'"/>
|
|
10
|
+
</template>
|
|
11
|
+
</div>
|
|
12
|
+
<div class="flex-v-center">
|
|
13
|
+
<ToolBarItem v-for="(item, index) of rightItems" :key="index"
|
|
14
|
+
:item="Item.from(item)"
|
|
15
|
+
:size="size"/>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
import ToolBarItem from './ToolBarItem.vue';
|
|
22
|
+
import Item from './ToolBarItem.js';
|
|
23
|
+
|
|
24
|
+
export default {
|
|
25
|
+
name: 'TnxelToolbar',
|
|
26
|
+
components: {ToolBarItem},
|
|
27
|
+
props: {
|
|
28
|
+
leftItems: Array,
|
|
29
|
+
rightItems: Array,
|
|
30
|
+
size: {
|
|
31
|
+
type: String,
|
|
32
|
+
validator: value => {
|
|
33
|
+
return ['small', 'default', 'large'].includes(value);
|
|
34
|
+
},
|
|
35
|
+
default: 'default',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
data() {
|
|
39
|
+
return {
|
|
40
|
+
Item,
|
|
41
|
+
model: {},
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
methods: {}
|
|
45
|
+
}
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<style>
|
|
49
|
+
.tnxel-toolbar {
|
|
50
|
+
height: 32px;
|
|
51
|
+
padding: 0 8px;
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
justify-content: space-between;
|
|
55
|
+
}
|
|
56
|
+
</style>
|
|
@@ -59,23 +59,22 @@ export default {
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
created() {
|
|
62
|
-
let vm = this;
|
|
63
62
|
let params;
|
|
64
63
|
if (typeof this.params === 'function') {
|
|
65
64
|
params = this.params();
|
|
66
65
|
} else {
|
|
67
66
|
params = this.params;
|
|
68
67
|
}
|
|
69
|
-
window.tnx.app.rpc.get(this.url, params
|
|
70
|
-
|
|
68
|
+
window.tnx.app.rpc.get(this.url, params).then((list) => {
|
|
69
|
+
this.selectable = [];
|
|
71
70
|
list.forEach(item => {
|
|
72
|
-
if (
|
|
73
|
-
|
|
71
|
+
if (this.formatter) {
|
|
72
|
+
this.formatter(item);
|
|
74
73
|
}
|
|
75
|
-
|
|
76
|
-
key: item[
|
|
77
|
-
label: item[
|
|
78
|
-
index: item[
|
|
74
|
+
this.selectable.push({
|
|
75
|
+
key: item[this.keyName],
|
|
76
|
+
label: item[this.labelName],
|
|
77
|
+
index: item[this.indexName],
|
|
79
78
|
});
|
|
80
79
|
});
|
|
81
80
|
});
|