@truenewx/tnxvue3 3.4.0 → 3.4.2
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/package.json +23 -42
- 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/{aj-captcha → element-plus/aj-captcha}/Verify/VerifySlide.vue +9 -9
- package/src/element-plus/aj-captcha/api/index.js +11 -0
- package/src/{aj-captcha → element-plus/aj-captcha}/utils/ase.js +1 -1
- 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 +11 -7
- 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 +105 -94
- 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/tdesign/desktop/tnxtdd.ts +16 -0
- package/src/tdesign/foundation/validator.ts +367 -0
- package/src/tdesign/mobile/tnxtdm.ts +16 -0
- package/src/tdesign/tnxtd.ts +20 -0
- package/src/{tnxvue-router.js → tnxvue-router.ts} +66 -48
- package/src/tnxvue.ts +248 -0
- package/src/types.d.ts +7 -0
- package/tsconfig.json +21 -0
- package/index.html +0 -12
- package/src/aj-captcha/api/index.js +0 -19
- package/src/tnxvue-validator.js +0 -365
- package/src/tnxvue.js +0 -439
- /package/src/{aj-captcha → element-plus/aj-captcha}/Verify/VerifyPoints.vue +0 -0
- /package/src/{aj-captcha → element-plus/aj-captcha}/Verify.vue +0 -0
- /package/src/{aj-captcha → element-plus/aj-captcha}/utils/util.js +0 -0
|
@@ -101,11 +101,9 @@
|
|
|
101
101
|
:size="size"
|
|
102
102
|
@command="onDropdownCommand"
|
|
103
103
|
v-else-if="selector === 'dropdown'">
|
|
104
|
-
<el-button style="width: 100%" :type="theme">
|
|
105
|
-
<
|
|
106
|
-
|
|
107
|
-
<tnxel-icon value="ArrowDown"/>
|
|
108
|
-
</div>
|
|
104
|
+
<el-button style="max-width: 100%" :type="theme" :title="currentText">
|
|
105
|
+
<span class="flex-1 overflow-ellipsis me-2">{{ currentText }}</span>
|
|
106
|
+
<tnxel-icon value="ArrowDown"/>
|
|
109
107
|
</el-button>
|
|
110
108
|
<template #dropdown v-if="items && items.length">
|
|
111
109
|
<el-dropdown-menu>
|
|
@@ -273,7 +271,7 @@ export default {
|
|
|
273
271
|
if (util.object.isNotEmpty(newValue) || util.object.isNotEmpty(oldValue)) {
|
|
274
272
|
let vm = this;
|
|
275
273
|
// 确保变更事件在值变更应用后再触发
|
|
276
|
-
this.$nextTick(
|
|
274
|
+
this.$nextTick(() => {
|
|
277
275
|
vm.triggerChange(newValue);
|
|
278
276
|
});
|
|
279
277
|
}
|
|
@@ -414,7 +412,7 @@ export default {
|
|
|
414
412
|
if (this.isMulti()) {
|
|
415
413
|
let index = this.model.indexOf(value);
|
|
416
414
|
if (index >= 0) {
|
|
417
|
-
this.model = this.model.filter(
|
|
415
|
+
this.model = this.model.filter((e, i) => {
|
|
418
416
|
return i !== index;
|
|
419
417
|
});
|
|
420
418
|
} else {
|
|
@@ -542,4 +540,10 @@ export default {
|
|
|
542
540
|
color: var(--el-color-primary);
|
|
543
541
|
font-weight: 600;
|
|
544
542
|
}
|
|
543
|
+
|
|
544
|
+
.tnxel-dropdown .el-button > span {
|
|
545
|
+
max-width: 100%;
|
|
546
|
+
display: flex;
|
|
547
|
+
align-items: center;
|
|
548
|
+
}
|
|
545
549
|
</style>
|
|
@@ -34,10 +34,9 @@ export default {
|
|
|
34
34
|
},
|
|
35
35
|
mounted() {
|
|
36
36
|
this.topOffset = $('#' + this.id).offset().top - $(this.container).offset().top - 16;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
vm.navTo(index);
|
|
37
|
+
$('#' + this.id + ' .el-step').each((index, step) => {
|
|
38
|
+
$(step).click(() => {
|
|
39
|
+
this.navTo(index);
|
|
41
40
|
});
|
|
42
41
|
});
|
|
43
42
|
},
|
|
@@ -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
|
+
}
|
|
@@ -7,6 +7,7 @@ import ElementPlus_zh_CN from 'element-plus/es/locale/lang/zh-cn';
|
|
|
7
7
|
import tnxbs from '@truenewx/tnxcore/src/tnxbs'; // 二次封装组件中使用了Bootstrap的基础样式
|
|
8
8
|
import tnxvue from '../tnxvue.js';
|
|
9
9
|
|
|
10
|
+
import CaptchaVerify from './aj-captcha/Verify.vue';
|
|
10
11
|
import Avatar from './avatar/Avatar.vue';
|
|
11
12
|
import Alert from './alert/Alert.vue';
|
|
12
13
|
import Button from './button/Button.vue';
|
|
@@ -53,8 +54,10 @@ export const build = tnxvue.build;
|
|
|
53
54
|
|
|
54
55
|
export default build('tnxel', () => {
|
|
55
56
|
const components = Object.assign({}, tnxvue.components, {
|
|
56
|
-
|
|
57
|
+
CaptchaVerify, // 只使用了ElementPlus的图标
|
|
58
|
+
|
|
57
59
|
Alert,
|
|
60
|
+
Avatar,
|
|
58
61
|
Button,
|
|
59
62
|
CheckIcon,
|
|
60
63
|
CloseErrorButton,
|
|
@@ -142,22 +145,24 @@ export default build('tnxel', () => {
|
|
|
142
145
|
window.tnx.dialogInstances.push(dialog);
|
|
143
146
|
return dialog;
|
|
144
147
|
},
|
|
145
|
-
closeDialog(all
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
break;
|
|
148
|
+
closeDialog(all) {
|
|
149
|
+
return new Promise((resolve) => {
|
|
150
|
+
if (window.tnx.dialogInstances.length) {
|
|
151
|
+
let dialog = window.tnx.dialogInstances.pop();
|
|
152
|
+
let promises = [];
|
|
153
|
+
while (dialog) {
|
|
154
|
+
promises.push(dialog.close());
|
|
155
|
+
if (all) {
|
|
156
|
+
dialog = window.tnx.dialogInstances.pop();
|
|
157
|
+
} else {
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
158
160
|
}
|
|
161
|
+
Promise.all(promises).then(resolve);
|
|
162
|
+
} else {
|
|
163
|
+
resolve();
|
|
159
164
|
}
|
|
160
|
-
}
|
|
165
|
+
});
|
|
161
166
|
},
|
|
162
167
|
drawerInstances: [], // 抽屉堆栈
|
|
163
168
|
drawer(content, title, buttons, options, contentProps) {
|
|
@@ -202,29 +207,31 @@ export default build('tnxel', () => {
|
|
|
202
207
|
window.tnx.drawerInstances.push(drawer);
|
|
203
208
|
return drawer;
|
|
204
209
|
},
|
|
205
|
-
closeDrawer(all
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
break;
|
|
210
|
+
closeDrawer(all) {
|
|
211
|
+
return new Promise((resolve) => {
|
|
212
|
+
if (window.tnx.drawerInstances.length) {
|
|
213
|
+
let drawer = window.tnx.drawerInstances.pop();
|
|
214
|
+
let promises = [];
|
|
215
|
+
while (drawer) {
|
|
216
|
+
promises.push(drawer.close());
|
|
217
|
+
if (all) {
|
|
218
|
+
drawer = window.tnx.drawerInstances.pop();
|
|
219
|
+
} else {
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
218
222
|
}
|
|
223
|
+
Promise.all(promises).then(resolve);
|
|
224
|
+
} else {
|
|
225
|
+
resolve();
|
|
219
226
|
}
|
|
220
|
-
}
|
|
227
|
+
});
|
|
221
228
|
},
|
|
222
229
|
_closeMessage() {
|
|
223
230
|
ElMessage.closeAll();
|
|
224
231
|
this.closeLoading();
|
|
225
232
|
},
|
|
226
233
|
_handleZIndex(selector) {
|
|
227
|
-
setTimeout(
|
|
234
|
+
setTimeout(() => {
|
|
228
235
|
const topZIndex = window.tnx.util.dom.minTopZIndex(2);
|
|
229
236
|
if (selector.endsWith(':last')) {
|
|
230
237
|
selector = selector.substring(0, selector.length - ':last'.length);
|
|
@@ -243,11 +250,9 @@ export default build('tnxel', () => {
|
|
|
243
250
|
}
|
|
244
251
|
});
|
|
245
252
|
},
|
|
246
|
-
alert(message, title,
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
options = callback;
|
|
250
|
-
callback = title;
|
|
253
|
+
alert(message, title, options) {
|
|
254
|
+
if (typeof title === 'object') {
|
|
255
|
+
options = title;
|
|
251
256
|
title = '提示';
|
|
252
257
|
}
|
|
253
258
|
options = Object.assign({
|
|
@@ -255,46 +260,45 @@ export default build('tnxel', () => {
|
|
|
255
260
|
type: 'warning',
|
|
256
261
|
confirmButtonText: '确定',
|
|
257
262
|
}, options);
|
|
258
|
-
this.
|
|
259
|
-
ElMessageBox.alert(message, title || '提示', options)
|
|
263
|
+
this._closeMessage();
|
|
264
|
+
const promise = ElMessageBox.alert(message, title || '提示', options);
|
|
260
265
|
this._handleZIndex('.el-message-box__wrapper:last');
|
|
261
266
|
this.app.eventBus.emit('tnx.alert', options);
|
|
267
|
+
return promise;
|
|
262
268
|
},
|
|
263
|
-
success(message,
|
|
264
|
-
this.closeLoading();
|
|
269
|
+
success(message, options) {
|
|
265
270
|
options = Object.assign({
|
|
266
271
|
dangerouslyUseHTMLString: true,
|
|
267
272
|
}, options, {
|
|
268
273
|
type: 'success',
|
|
269
274
|
confirmButtonText: '确定',
|
|
270
275
|
});
|
|
271
|
-
this.
|
|
272
|
-
ElMessageBox.alert(message, '成功', options)
|
|
276
|
+
this._closeMessage();
|
|
277
|
+
const promise = ElMessageBox.alert(message, '成功', options);
|
|
273
278
|
this._handleZIndex('.el-message-box__wrapper:last');
|
|
274
279
|
this.app.eventBus.emit('tnx.success', options);
|
|
280
|
+
return promise;
|
|
275
281
|
},
|
|
276
|
-
error(message,
|
|
277
|
-
this.closeLoading();
|
|
282
|
+
error(message, options) {
|
|
278
283
|
options = Object.assign({
|
|
279
284
|
dangerouslyUseHTMLString: true,
|
|
280
285
|
}, options, {
|
|
281
286
|
type: 'error',
|
|
282
287
|
confirmButtonText: '确定',
|
|
283
288
|
});
|
|
284
|
-
this.
|
|
285
|
-
ElMessageBox.alert(message, '错误', options)
|
|
289
|
+
this._closeMessage();
|
|
290
|
+
const promise = ElMessageBox.alert(message, '错误', options);
|
|
286
291
|
this._handleZIndex('.el-message-box__wrapper:last');
|
|
287
292
|
this.app.eventBus.emit('tnx.error', options);
|
|
288
293
|
// 打印TypeError对象,便于调试
|
|
289
294
|
if (typeof message === 'object' && message.name === 'TypeError') {
|
|
290
295
|
console.error(message);
|
|
291
296
|
}
|
|
297
|
+
return promise;
|
|
292
298
|
},
|
|
293
|
-
confirm(message, title
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
options = callback;
|
|
297
|
-
callback = title;
|
|
299
|
+
confirm(message, title = '确认', options) {
|
|
300
|
+
if (typeof title === 'object') {
|
|
301
|
+
options = title;
|
|
298
302
|
title = '确认';
|
|
299
303
|
}
|
|
300
304
|
options = Object.assign({
|
|
@@ -315,29 +319,20 @@ export default build('tnxel', () => {
|
|
|
315
319
|
options.confirmButtonText = options.cancelButtonText;
|
|
316
320
|
options.cancelButtonText = buttonText;
|
|
317
321
|
}
|
|
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);
|
|
322
|
+
|
|
323
|
+
this._closeMessage();
|
|
324
|
+
return new Promise(resolve => {
|
|
325
|
+
ElMessageBox.confirm(message, title, options).then(() => {
|
|
326
|
+
resolve(true);
|
|
327
|
+
}).catch(() => {
|
|
328
|
+
resolve(false);
|
|
329
|
+
});
|
|
330
|
+
this._handleZIndex('.el-message-box__wrapper:last');
|
|
331
|
+
this.app.eventBus.emit('tnx.confirm', options);
|
|
332
|
+
})
|
|
333
|
+
|
|
333
334
|
},
|
|
334
|
-
toast(message, timeout,
|
|
335
|
-
this.closeLoading();
|
|
336
|
-
if (typeof timeout === 'function') {
|
|
337
|
-
options = callback;
|
|
338
|
-
callback = timeout;
|
|
339
|
-
timeout = undefined;
|
|
340
|
-
}
|
|
335
|
+
toast(message, timeout, options) {
|
|
341
336
|
options = Object.assign({
|
|
342
337
|
type: 'success', // 默认为成功主题,可更改为其它主题
|
|
343
338
|
offset: this.util.dom.getDocHeight() * 0.4,
|
|
@@ -348,46 +343,62 @@ export default build('tnxel', () => {
|
|
|
348
343
|
message: message,
|
|
349
344
|
duration: timeout || 1500,
|
|
350
345
|
customClass: 'tnxel-toast',
|
|
351
|
-
onClose: callback,
|
|
352
346
|
});
|
|
347
|
+
|
|
353
348
|
this._closeMessage();
|
|
354
|
-
ElMessage(options);
|
|
349
|
+
const messageInstance = ElMessage(options);
|
|
355
350
|
this._handleZIndex('.el-message:last');
|
|
356
351
|
this.app.eventBus.emit('tnx.toast', options);
|
|
352
|
+
|
|
353
|
+
// 创建一个Promise,在消息关闭时resolve
|
|
354
|
+
return new Promise((resolve) => {
|
|
355
|
+
const originalOnClose = options.onClose;
|
|
356
|
+
options.onClose = () => {
|
|
357
|
+
if (originalOnClose) {
|
|
358
|
+
originalOnClose();
|
|
359
|
+
}
|
|
360
|
+
resolve();
|
|
361
|
+
};
|
|
362
|
+
// 如果消息实例有close方法,重新设置onClose
|
|
363
|
+
if (messageInstance && messageInstance.close) {
|
|
364
|
+
const originalClose = messageInstance.close;
|
|
365
|
+
messageInstance.close = () => {
|
|
366
|
+
originalClose.call(messageInstance);
|
|
367
|
+
options.onClose();
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
});
|
|
357
371
|
},
|
|
358
|
-
showLoading(message,
|
|
372
|
+
showLoading(message, options) {
|
|
359
373
|
if (typeof message !== 'string') {
|
|
360
|
-
options =
|
|
361
|
-
callback = message;
|
|
374
|
+
options = message;
|
|
362
375
|
message = undefined;
|
|
363
376
|
}
|
|
364
|
-
if (typeof callback !== 'function') {
|
|
365
|
-
options = callback;
|
|
366
|
-
callback = undefined;
|
|
367
|
-
}
|
|
368
377
|
options = Object.assign({
|
|
369
378
|
dangerouslyUseHTMLString: true,
|
|
370
379
|
}, options, {
|
|
371
380
|
text: message,
|
|
372
381
|
});
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
382
|
+
return new Promise((resolve, reject) => {
|
|
383
|
+
window.tnx._closeMessage();
|
|
384
|
+
try {
|
|
385
|
+
window.tnx.loadingInstance = ElLoading.service(options);
|
|
386
|
+
this._handleZIndex('.el-loading-mask');
|
|
387
|
+
window.tnx.app.eventBus.emit('tnx.showLoading', options);
|
|
379
388
|
let vm = window.tnx.loadingInstance.vm;
|
|
380
389
|
if (vm) {
|
|
381
|
-
|
|
390
|
+
window.tnx.nextTickTimeout(vm, () => {
|
|
391
|
+
resolve(window.tnx.loadingInstance);
|
|
392
|
+
}, 500);
|
|
382
393
|
} else {
|
|
383
|
-
|
|
394
|
+
resolve(window.tnx.loadingInstance);
|
|
384
395
|
}
|
|
396
|
+
} catch (e) {
|
|
397
|
+
window.tnx.loadingInstance = null;
|
|
398
|
+
console.error(e);
|
|
399
|
+
reject(e);
|
|
385
400
|
}
|
|
386
|
-
}
|
|
387
|
-
window.tnx.loadingInstance = null;
|
|
388
|
-
console.error(e);
|
|
389
|
-
}
|
|
390
|
-
return window.tnx.loadingInstance;
|
|
401
|
+
});
|
|
391
402
|
},
|
|
392
403
|
closeLoading() {
|
|
393
404
|
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
|
+
}
|