@truenewx/tnxvue3 2.6.3 → 2.6.5
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 +2 -3
- package/src/element-plus/tnxel.js +445 -440
- package/src/tnxvue.js +289 -290
- package/src/ant-design/tnxad-theme.css +0 -5
- package/src/ant-design/tnxad.css +0 -8
- package/src/ant-design/tnxad.js +0 -23
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import ElementPlus, { ElLoading, ElMessage, ElMessageBox } from 'element-plus';
|
|
6
6
|
import ElementPlus_zh_CN from 'element-plus/es/locale/lang/zh-cn';
|
|
7
7
|
import tnxbs from '@truenewx/tnxcore/src/tnxbs'; // 二次封装组件中使用了Bootstrap的基础样式
|
|
8
|
-
import tnxvue from '../tnxvue.js';
|
|
8
|
+
import tnxvue, { build } from '../tnxvue.js';
|
|
9
9
|
|
|
10
10
|
import Avatar from './avatar/Avatar.vue';
|
|
11
11
|
import Alert from './alert/Alert.vue';
|
|
@@ -44,485 +44,490 @@ import Upload from './upload/Upload.vue';
|
|
|
44
44
|
|
|
45
45
|
import './tnxel.css';
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
export { build };
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
Alert,
|
|
52
|
-
Button,
|
|
53
|
-
CheckIcon,
|
|
54
|
-
CloseErrorButton,
|
|
55
|
-
Curd,
|
|
56
|
-
DatePicker,
|
|
57
|
-
DateRange,
|
|
58
|
-
DateTimePicker,
|
|
59
|
-
DetailForm,
|
|
60
|
-
Dialog,
|
|
61
|
-
Drawer,
|
|
62
|
-
DropdownItem,
|
|
63
|
-
EnumSelect,
|
|
64
|
-
FetchCascader,
|
|
65
|
-
FetchSelect,
|
|
66
|
-
FetchTags,
|
|
67
|
-
FssUpload,
|
|
68
|
-
FssView,
|
|
69
|
-
Icon,
|
|
70
|
-
InputNumber,
|
|
71
|
-
Paged,
|
|
72
|
-
PermissionTree,
|
|
73
|
-
QueryForm,
|
|
74
|
-
QueryTable,
|
|
75
|
-
RegionCascader,
|
|
76
|
-
Select,
|
|
77
|
-
Slider,
|
|
78
|
-
StepsNav,
|
|
79
|
-
SubmitForm,
|
|
80
|
-
TabColumn,
|
|
81
|
-
Tabs,
|
|
82
|
-
Transfer,
|
|
83
|
-
Upload,
|
|
84
|
-
});
|
|
49
|
+
export default build('tnxel', () => {
|
|
50
|
+
const $ = tnxbs.libs.$;
|
|
85
51
|
|
|
86
|
-
const
|
|
87
|
-
|
|
52
|
+
const components = Object.assign({}, tnxvue.components, {
|
|
53
|
+
Avatar,
|
|
54
|
+
Alert,
|
|
55
|
+
Button,
|
|
56
|
+
CheckIcon,
|
|
57
|
+
CloseErrorButton,
|
|
58
|
+
Curd,
|
|
59
|
+
DatePicker,
|
|
60
|
+
DateRange,
|
|
61
|
+
DateTimePicker,
|
|
62
|
+
DetailForm,
|
|
63
|
+
Dialog,
|
|
64
|
+
Drawer,
|
|
65
|
+
DropdownItem,
|
|
66
|
+
EnumSelect,
|
|
67
|
+
FetchCascader,
|
|
68
|
+
FetchSelect,
|
|
69
|
+
FetchTags,
|
|
70
|
+
FssUpload,
|
|
71
|
+
FssView,
|
|
72
|
+
Icon,
|
|
73
|
+
InputNumber,
|
|
74
|
+
Paged,
|
|
75
|
+
PermissionTree,
|
|
76
|
+
QueryForm,
|
|
77
|
+
QueryTable,
|
|
78
|
+
RegionCascader,
|
|
79
|
+
Select,
|
|
80
|
+
Slider,
|
|
81
|
+
StepsNav,
|
|
82
|
+
SubmitForm,
|
|
83
|
+
TabColumn,
|
|
84
|
+
Tabs,
|
|
85
|
+
Transfer,
|
|
86
|
+
Upload,
|
|
87
|
+
});
|
|
88
88
|
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
_dialogs: [], // 对话框堆栈
|
|
92
|
-
dialog(content, title, buttons, options, contentProps) {
|
|
93
|
-
this._closeMessage();
|
|
89
|
+
const dialogContainerClass = 'tnxel-dialog-container';
|
|
90
|
+
const drawerContainerClass = 'tnxel-drawer-container';
|
|
94
91
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
content = null;
|
|
101
|
-
}
|
|
102
|
-
let componentDefinition = Object.assign({}, Dialog, componentOptions);
|
|
92
|
+
const tnxel = Object.assign({}, tnxbs, tnxvue, {
|
|
93
|
+
components,
|
|
94
|
+
_dialogs: [], // 对话框堆栈
|
|
95
|
+
dialog(content, title, buttons, options, contentProps) {
|
|
96
|
+
this._closeMessage();
|
|
103
97
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
options = options || {};
|
|
111
|
-
const dialogVm = window.tnx.createVueInstance(componentDefinition, null, {
|
|
112
|
-
modelValue: true,
|
|
113
|
-
container: containerSelector,
|
|
114
|
-
title: title,
|
|
115
|
-
content: content,
|
|
116
|
-
contentProps: contentProps,
|
|
117
|
-
buttons: buttons,
|
|
118
|
-
theme: options.theme,
|
|
119
|
-
}).mount(containerSelector);
|
|
120
|
-
dialogVm.options = Object.assign(dialogVm.options || {}, options);
|
|
121
|
-
dialogVm.options.onClosed = this.util.function.around(dialogVm.options.onClosed, function(onClosed) {
|
|
122
|
-
let $container = $(containerSelector);
|
|
123
|
-
$container.next('.el-overlay').remove();
|
|
124
|
-
$container.remove();
|
|
125
|
-
if (onClosed) {
|
|
126
|
-
onClosed.call(dialogVm);
|
|
98
|
+
let componentOptions = {};
|
|
99
|
+
if (this.util.isComponent(content)) {
|
|
100
|
+
componentOptions.components = {
|
|
101
|
+
'tnxel-dialog-content': content
|
|
102
|
+
};
|
|
103
|
+
content = null;
|
|
127
104
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
105
|
+
let componentDefinition = Object.assign({}, Dialog, componentOptions);
|
|
106
|
+
|
|
107
|
+
const dialogId = 'dialog-' + (new Date().getTime());
|
|
108
|
+
$('body').append('<div class="' + dialogContainerClass + '" id="' + dialogId + '"></div>');
|
|
109
|
+
if (!(buttons instanceof Array)) {
|
|
110
|
+
buttons = [];
|
|
111
|
+
}
|
|
112
|
+
const containerSelector = '.' + dialogContainerClass + '#' + dialogId;
|
|
113
|
+
options = options || {};
|
|
114
|
+
const dialogVm = window.tnx.createVueInstance(componentDefinition, null, {
|
|
115
|
+
modelValue: true,
|
|
116
|
+
container: containerSelector,
|
|
117
|
+
title: title,
|
|
118
|
+
content: content,
|
|
119
|
+
contentProps: contentProps,
|
|
120
|
+
buttons: buttons,
|
|
121
|
+
theme: options.theme,
|
|
122
|
+
}).mount(containerSelector);
|
|
123
|
+
dialogVm.options = Object.assign(dialogVm.options || {}, options);
|
|
124
|
+
dialogVm.options.onClosed = this.util.function.around(dialogVm.options.onClosed, function(onClosed) {
|
|
125
|
+
let $container = $(containerSelector);
|
|
126
|
+
$container.next('.el-overlay').remove();
|
|
127
|
+
$container.remove();
|
|
128
|
+
if (onClosed) {
|
|
129
|
+
onClosed.call(dialogVm);
|
|
145
130
|
}
|
|
131
|
+
});
|
|
132
|
+
this._dialogs.push(dialogVm);
|
|
133
|
+
return dialogVm;
|
|
134
|
+
},
|
|
135
|
+
closeDialog(all, callback) {
|
|
136
|
+
if (typeof all === 'function') {
|
|
137
|
+
callback = all;
|
|
138
|
+
all = false;
|
|
146
139
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
140
|
+
if (this._dialogs.length) {
|
|
141
|
+
let dialog = this._dialogs.pop();
|
|
142
|
+
while (dialog) {
|
|
143
|
+
dialog.close(callback);
|
|
144
|
+
if (all) {
|
|
145
|
+
dialog = this._dialogs.pop();
|
|
146
|
+
} else {
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
_drawers: [], // 抽屉堆栈
|
|
153
|
+
drawer(content, title, buttons, options, contentProps) {
|
|
154
|
+
this._closeMessage();
|
|
152
155
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
156
|
+
let componentOptions = {};
|
|
157
|
+
if (this.util.isComponent(content)) {
|
|
158
|
+
componentOptions.components = {
|
|
159
|
+
'tnxel-drawer-content': content
|
|
160
|
+
};
|
|
161
|
+
content = null;
|
|
162
|
+
}
|
|
163
|
+
let componentDefinition = Object.assign({}, Drawer, componentOptions);
|
|
161
164
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
const containerSelector = '.' + drawerContainerClass + '#' + drawerId;
|
|
168
|
-
options = options || {};
|
|
169
|
-
const drawerVm = window.tnx.createVueInstance(componentDefinition, null, {
|
|
170
|
-
content: content,
|
|
171
|
-
title: title,
|
|
172
|
-
contentProps: contentProps,
|
|
173
|
-
buttons: buttons,
|
|
174
|
-
theme: options.theme,
|
|
175
|
-
}).mount(containerSelector);
|
|
176
|
-
drawerVm.id = drawerId;
|
|
177
|
-
drawerVm.options = Object.assign(drawerVm.options || {}, options);
|
|
178
|
-
drawerVm.options.onClosed = this.util.function.around(drawerVm.options.onClosed, function(onClosed) {
|
|
179
|
-
let $container = $(containerSelector);
|
|
180
|
-
$container.next('.el-overlay').remove();
|
|
181
|
-
$container.remove();
|
|
182
|
-
if (onClosed) {
|
|
183
|
-
onClosed.call(drawerVm);
|
|
165
|
+
const drawerId = 'drawer-' + (new Date().getTime());
|
|
166
|
+
$('body').append('<div class="' + drawerContainerClass + '" id="' + drawerId + '"></div>');
|
|
167
|
+
if (!(buttons instanceof Array)) {
|
|
168
|
+
buttons = [];
|
|
184
169
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
170
|
+
const containerSelector = '.' + drawerContainerClass + '#' + drawerId;
|
|
171
|
+
options = options || {};
|
|
172
|
+
const drawerVm = window.tnx.createVueInstance(componentDefinition, null, {
|
|
173
|
+
content: content,
|
|
174
|
+
title: title,
|
|
175
|
+
contentProps: contentProps,
|
|
176
|
+
buttons: buttons,
|
|
177
|
+
theme: options.theme,
|
|
178
|
+
}).mount(containerSelector);
|
|
179
|
+
drawerVm.id = drawerId;
|
|
180
|
+
drawerVm.options = Object.assign(drawerVm.options || {}, options);
|
|
181
|
+
drawerVm.options.onClosed = this.util.function.around(drawerVm.options.onClosed, function(onClosed) {
|
|
182
|
+
let $container = $(containerSelector);
|
|
183
|
+
$container.next('.el-overlay').remove();
|
|
184
|
+
$container.remove();
|
|
185
|
+
if (onClosed) {
|
|
186
|
+
onClosed.call(drawerVm);
|
|
202
187
|
}
|
|
188
|
+
});
|
|
189
|
+
this._drawers.push(drawerVm);
|
|
190
|
+
return drawerVm;
|
|
191
|
+
},
|
|
192
|
+
closeDrawer(all, callback) {
|
|
193
|
+
if (typeof all === 'function') {
|
|
194
|
+
callback = all;
|
|
195
|
+
all = false;
|
|
203
196
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const topZIndex = util.dom.minTopZIndex(2);
|
|
214
|
-
const element = $(selector);
|
|
215
|
-
const zIndex = Number(element.css('zIndex'));
|
|
216
|
-
if (isNaN(zIndex) || topZIndex > zIndex) {
|
|
217
|
-
element.css('zIndex', topZIndex);
|
|
218
|
-
const modal = element.next();
|
|
219
|
-
if (modal.is('.v-modal')) {
|
|
220
|
-
modal.css('zIndex', topZIndex - 1);
|
|
197
|
+
if (this._drawers.length) {
|
|
198
|
+
let drawer = this._drawers.pop();
|
|
199
|
+
while (drawer) {
|
|
200
|
+
drawer.close(callback);
|
|
201
|
+
if (all) {
|
|
202
|
+
drawer = this._drawers.pop();
|
|
203
|
+
} else {
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
221
206
|
}
|
|
222
207
|
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
options = Object.assign({
|
|
241
|
-
dangerouslyUseHTMLString: true,
|
|
242
|
-
}, options, {
|
|
243
|
-
type: 'success',
|
|
244
|
-
confirmButtonText: '确定',
|
|
245
|
-
});
|
|
246
|
-
ElMessageBox.alert(message, '成功', options).then(callback);
|
|
247
|
-
this._handleZIndex('.el-message-box__wrapper:last');
|
|
248
|
-
},
|
|
249
|
-
error(message, callback, options) {
|
|
250
|
-
options = Object.assign({
|
|
251
|
-
dangerouslyUseHTMLString: true,
|
|
252
|
-
}, options, {
|
|
253
|
-
type: 'error',
|
|
254
|
-
confirmButtonText: '确定',
|
|
255
|
-
});
|
|
256
|
-
ElMessageBox.alert(message, '错误', options).then(callback);
|
|
257
|
-
this._handleZIndex('.el-message-box__wrapper:last');
|
|
258
|
-
},
|
|
259
|
-
confirm(message, title, callback, options) {
|
|
260
|
-
if (typeof title === 'function') {
|
|
261
|
-
options = callback;
|
|
262
|
-
callback = title;
|
|
263
|
-
title = '确认';
|
|
264
|
-
}
|
|
265
|
-
options = Object.assign({
|
|
266
|
-
type: 'question',
|
|
267
|
-
confirmButtonText: '确定',
|
|
268
|
-
cancelButtonText: '取消',
|
|
269
|
-
}, options, {
|
|
270
|
-
dangerouslyUseHTMLString: true,
|
|
271
|
-
distinguishCancelAndClose: true,
|
|
272
|
-
});
|
|
273
|
-
if (options.type === 'question') {
|
|
274
|
-
options.type = 'info';
|
|
275
|
-
options.icon = Icon.components.QuestionFilled;
|
|
276
|
-
}
|
|
277
|
-
if (options.reverse) {
|
|
278
|
-
options.customClass = 'reverse';
|
|
279
|
-
let buttonText = options.confirmButtonText;
|
|
280
|
-
options.confirmButtonText = options.cancelButtonText;
|
|
281
|
-
options.cancelButtonText = buttonText;
|
|
282
|
-
}
|
|
283
|
-
if (typeof callback === 'function') {
|
|
284
|
-
options.callback = function(action) {
|
|
285
|
-
let yes = undefined;
|
|
286
|
-
if (action === 'confirm') {
|
|
287
|
-
yes = options.reverse ? false : true;
|
|
288
|
-
} else if (action === 'cancel') {
|
|
289
|
-
yes = options.reverse ? true : false;
|
|
208
|
+
},
|
|
209
|
+
_closeMessage() {
|
|
210
|
+
ElMessage.closeAll();
|
|
211
|
+
this.closeLoading();
|
|
212
|
+
},
|
|
213
|
+
_handleZIndex(selector) {
|
|
214
|
+
const util = this.util;
|
|
215
|
+
setTimeout(function() {
|
|
216
|
+
const topZIndex = util.dom.minTopZIndex(2);
|
|
217
|
+
const element = $(selector);
|
|
218
|
+
const zIndex = Number(element.css('zIndex'));
|
|
219
|
+
if (isNaN(zIndex) || topZIndex > zIndex) {
|
|
220
|
+
element.css('zIndex', topZIndex);
|
|
221
|
+
const modal = element.next();
|
|
222
|
+
if (modal.is('.v-modal')) {
|
|
223
|
+
modal.css('zIndex', topZIndex - 1);
|
|
224
|
+
}
|
|
290
225
|
}
|
|
291
|
-
|
|
226
|
+
});
|
|
227
|
+
},
|
|
228
|
+
alert(message, title, callback, options) {
|
|
229
|
+
if (typeof title === 'function') {
|
|
230
|
+
options = callback;
|
|
231
|
+
callback = title;
|
|
232
|
+
title = '提示';
|
|
292
233
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
234
|
+
options = Object.assign({
|
|
235
|
+
dangerouslyUseHTMLString: true,
|
|
236
|
+
type: 'warning',
|
|
237
|
+
confirmButtonText: '确定',
|
|
238
|
+
}, options);
|
|
239
|
+
ElMessageBox.alert(message, title, options).then(callback);
|
|
240
|
+
this._handleZIndex('.el-message-box__wrapper:last');
|
|
241
|
+
},
|
|
242
|
+
success(message, callback, options) {
|
|
243
|
+
options = Object.assign({
|
|
244
|
+
dangerouslyUseHTMLString: true,
|
|
245
|
+
}, options, {
|
|
246
|
+
type: 'success',
|
|
247
|
+
confirmButtonText: '确定',
|
|
248
|
+
});
|
|
249
|
+
ElMessageBox.alert(message, '成功', options).then(callback);
|
|
250
|
+
this._handleZIndex('.el-message-box__wrapper:last');
|
|
251
|
+
},
|
|
252
|
+
error(message, callback, options) {
|
|
253
|
+
options = Object.assign({
|
|
254
|
+
dangerouslyUseHTMLString: true,
|
|
255
|
+
}, options, {
|
|
256
|
+
type: 'error',
|
|
257
|
+
confirmButtonText: '确定',
|
|
258
|
+
});
|
|
259
|
+
ElMessageBox.alert(message, '错误', options).then(callback);
|
|
260
|
+
this._handleZIndex('.el-message-box__wrapper:last');
|
|
261
|
+
},
|
|
262
|
+
confirm(message, title, callback, options) {
|
|
263
|
+
if (typeof title === 'function') {
|
|
264
|
+
options = callback;
|
|
265
|
+
callback = title;
|
|
266
|
+
title = '确认';
|
|
267
|
+
}
|
|
268
|
+
options = Object.assign({
|
|
269
|
+
type: 'question',
|
|
270
|
+
confirmButtonText: '确定',
|
|
271
|
+
cancelButtonText: '取消',
|
|
272
|
+
}, options, {
|
|
273
|
+
dangerouslyUseHTMLString: true,
|
|
274
|
+
distinguishCancelAndClose: true,
|
|
275
|
+
});
|
|
276
|
+
if (options.type === 'question') {
|
|
277
|
+
options.type = 'info';
|
|
278
|
+
options.icon = Icon.components.QuestionFilled;
|
|
279
|
+
}
|
|
280
|
+
if (options.reverse) {
|
|
281
|
+
options.customClass = 'reverse';
|
|
282
|
+
let buttonText = options.confirmButtonText;
|
|
283
|
+
options.confirmButtonText = options.cancelButtonText;
|
|
284
|
+
options.cancelButtonText = buttonText;
|
|
285
|
+
}
|
|
286
|
+
if (typeof callback === 'function') {
|
|
287
|
+
options.callback = function(action) {
|
|
288
|
+
let yes = undefined;
|
|
289
|
+
if (action === 'confirm') {
|
|
290
|
+
yes = options.reverse ? false : true;
|
|
291
|
+
} else if (action === 'cancel') {
|
|
292
|
+
yes = options.reverse ? true : false;
|
|
293
|
+
}
|
|
294
|
+
callback(yes);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
ElMessageBox.confirm(message, title, options);
|
|
298
|
+
this._handleZIndex('.el-message-box__wrapper:last');
|
|
299
|
+
},
|
|
300
|
+
toast(message, timeout, callback, options) {
|
|
301
|
+
if (typeof timeout === 'function') {
|
|
302
|
+
options = callback;
|
|
303
|
+
callback = timeout;
|
|
304
|
+
timeout = undefined;
|
|
305
|
+
}
|
|
306
|
+
options = Object.assign({
|
|
307
|
+
type: 'success', // 默认为成功主题,可更改为其它主题
|
|
308
|
+
offset: this.util.dom.getDocHeight() * 0.4,
|
|
309
|
+
dangerouslyUseHTMLString: true,
|
|
310
|
+
}, options, {
|
|
311
|
+
center: true, // 因为是竖向排列,所以必须居中
|
|
312
|
+
showClose: false,
|
|
313
|
+
message: message,
|
|
314
|
+
duration: timeout || 1500,
|
|
315
|
+
customClass: 'tnxel-toast',
|
|
316
|
+
onClose: callback,
|
|
317
|
+
});
|
|
318
|
+
this._closeMessage();
|
|
319
|
+
ElMessage(options);
|
|
320
|
+
this._handleZIndex('.el-message:last');
|
|
321
|
+
},
|
|
322
|
+
showLoading(message, options) {
|
|
323
|
+
if (typeof message !== 'string') {
|
|
324
|
+
options = message;
|
|
325
|
+
message = undefined;
|
|
326
|
+
}
|
|
327
|
+
options = Object.assign({
|
|
328
|
+
dangerouslyUseHTMLString: true,
|
|
329
|
+
}, options, {
|
|
330
|
+
text: message,
|
|
331
|
+
});
|
|
332
|
+
this._closeMessage();
|
|
333
|
+
window.tnx.loadingInstance = ElLoading.service(options);
|
|
334
|
+
this._handleZIndex('.el-loading-mask');
|
|
335
|
+
return window.tnx.loadingInstance;
|
|
336
|
+
},
|
|
337
|
+
closeLoading() {
|
|
338
|
+
if (window.tnx.loadingInstance) { // 确保绝对的单例
|
|
339
|
+
window.tnx.loadingInstance.close();
|
|
340
|
+
window.tnx.loadingInstance = undefined;
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
hideLoading() {
|
|
344
|
+
this.closeLoading();
|
|
345
|
+
},
|
|
346
|
+
validateUploaded(vm, reject) {
|
|
347
|
+
let result = true;
|
|
348
|
+
let formRef = null;
|
|
349
|
+
let refKeys = Object.keys(vm.$refs);
|
|
350
|
+
for (let refKey of refKeys) {
|
|
351
|
+
let refObj = vm.$refs[refKey];
|
|
352
|
+
if (Array.isArray(refObj)) {
|
|
353
|
+
for (let ref of refObj) {
|
|
354
|
+
if (typeof ref.validateUploaded === 'function') {
|
|
355
|
+
if (ref.validateUploaded(reject) === false) {
|
|
356
|
+
result = false;
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
} else if (refObj.$el.tagName === 'FORM' && typeof refObj.disable === 'function') {
|
|
362
|
+
formRef = refObj;
|
|
363
|
+
} else {
|
|
364
|
+
if (typeof refObj.validateUploaded === 'function') {
|
|
365
|
+
if (refObj.validateUploaded(reject) === false) {
|
|
353
366
|
result = false;
|
|
354
367
|
break;
|
|
355
368
|
}
|
|
356
369
|
}
|
|
357
370
|
}
|
|
358
|
-
} else if (refObj.$el.tagName === 'FORM' && typeof refObj.disable === 'function') {
|
|
359
|
-
formRef = refObj;
|
|
360
|
-
} else {
|
|
361
|
-
if (typeof refObj.validateUploaded === 'function') {
|
|
362
|
-
if (refObj.validateUploaded(reject) === false) {
|
|
363
|
-
result = false;
|
|
364
|
-
break;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
371
|
}
|
|
372
|
+
if (!result && formRef) {
|
|
373
|
+
formRef.disable(false);
|
|
374
|
+
}
|
|
375
|
+
return result;
|
|
368
376
|
}
|
|
369
|
-
|
|
370
|
-
formRef.disable(false);
|
|
371
|
-
}
|
|
372
|
-
return result;
|
|
373
|
-
}
|
|
374
|
-
});
|
|
377
|
+
});
|
|
375
378
|
|
|
376
|
-
tnxel.install = tnxel.util.function.around(tnxel.install, function(install, vm) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
379
|
+
tnxel.install = tnxel.util.function.around(tnxel.install, function(install, vm) {
|
|
380
|
+
install.call(window.tnx, vm);
|
|
381
|
+
let ElementComponent = ElementPlus;
|
|
382
|
+
if (window.tnx.libs && window.tnx.libs.ElementPlus) {
|
|
383
|
+
ElementComponent = window.tnx.libs.ElementPlus;
|
|
384
|
+
}
|
|
385
|
+
vm.use(ElementComponent, {
|
|
386
|
+
locale: ElementPlus_zh_CN,
|
|
387
|
+
});
|
|
388
|
+
window.tnx.libs = Object.assign({}, window.tnx.libs, {ElementPlus: ElementComponent});
|
|
380
389
|
});
|
|
381
|
-
this.libs.ElementPlus = ElementPlus;
|
|
382
|
-
});
|
|
383
390
|
|
|
384
|
-
tnxel.router.beforeLeave = tnxel.util.function.around(tnxel.router.beforeLeave, function(beforeLeave, router, from) {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
});
|
|
391
|
+
tnxel.router.beforeLeave = tnxel.util.function.around(tnxel.router.beforeLeave, function(beforeLeave, router, from) {
|
|
392
|
+
// 页面跳转前关闭当前页面中可能存在的所有消息框和对话框
|
|
393
|
+
window.tnx._closeMessage();
|
|
394
|
+
window.tnx.closeDialog(true);
|
|
395
|
+
beforeLeave.call(window.tnx.router, router, from);
|
|
396
|
+
});
|
|
390
397
|
|
|
391
|
-
tnxel.date = {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
}
|
|
396
|
-
return undefined;
|
|
397
|
-
},
|
|
398
|
-
formatDate: function(row, column, cellValue) {
|
|
399
|
-
if (cellValue) {
|
|
400
|
-
return new Date(cellValue).formatDate();
|
|
401
|
-
}
|
|
402
|
-
return undefined;
|
|
403
|
-
},
|
|
404
|
-
formatTime: function(row, column, cellValue) {
|
|
405
|
-
if (typeof cellValue === 'number') {
|
|
406
|
-
cellValue = new Date(cellValue);
|
|
407
|
-
}
|
|
408
|
-
if (cellValue instanceof Date) {
|
|
409
|
-
cellValue = cellValue.formatTime();
|
|
410
|
-
}
|
|
411
|
-
if (typeof cellValue === 'string') {
|
|
412
|
-
return cellValue;
|
|
413
|
-
}
|
|
414
|
-
return undefined;
|
|
415
|
-
},
|
|
416
|
-
formatTimeMinute: function(row, column, cellValue) {
|
|
417
|
-
if (typeof cellValue === 'number') {
|
|
418
|
-
cellValue = new Date(cellValue);
|
|
419
|
-
}
|
|
420
|
-
if (cellValue instanceof Date) {
|
|
421
|
-
cellValue = cellValue.formatTimeMinute();
|
|
422
|
-
}
|
|
423
|
-
if (typeof cellValue === 'string') {
|
|
424
|
-
let array = cellValue.split(':');
|
|
425
|
-
if (array.length > 1) {
|
|
426
|
-
return array[0] + ':' + array[1];
|
|
398
|
+
tnxel.date = {
|
|
399
|
+
formatDateTime: function(row, column, cellValue) {
|
|
400
|
+
if (cellValue) {
|
|
401
|
+
return new Date(cellValue).formatDateTime();
|
|
427
402
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
403
|
+
return undefined;
|
|
404
|
+
},
|
|
405
|
+
formatDate: function(row, column, cellValue) {
|
|
406
|
+
if (cellValue) {
|
|
407
|
+
return new Date(cellValue).formatDate();
|
|
408
|
+
}
|
|
409
|
+
return undefined;
|
|
410
|
+
},
|
|
411
|
+
formatTime: function(row, column, cellValue) {
|
|
412
|
+
if (typeof cellValue === 'number') {
|
|
413
|
+
cellValue = new Date(cellValue);
|
|
414
|
+
}
|
|
415
|
+
if (cellValue instanceof Date) {
|
|
416
|
+
cellValue = cellValue.formatTime();
|
|
417
|
+
}
|
|
418
|
+
if (typeof cellValue === 'string') {
|
|
419
|
+
return cellValue;
|
|
420
|
+
}
|
|
421
|
+
return undefined;
|
|
422
|
+
},
|
|
423
|
+
formatTimeMinute: function(row, column, cellValue) {
|
|
424
|
+
if (typeof cellValue === 'number') {
|
|
425
|
+
cellValue = new Date(cellValue);
|
|
426
|
+
}
|
|
427
|
+
if (cellValue instanceof Date) {
|
|
428
|
+
cellValue = cellValue.formatTimeMinute();
|
|
429
|
+
}
|
|
430
|
+
if (typeof cellValue === 'string') {
|
|
431
|
+
let array = cellValue.split(':');
|
|
432
|
+
if (array.length > 1) {
|
|
433
|
+
return array[0] + ':' + array[1];
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return undefined;
|
|
437
|
+
},
|
|
438
|
+
formatDateMinute: function(row, column, cellValue) {
|
|
439
|
+
if (cellValue) {
|
|
440
|
+
return new Date(cellValue).formatDateMinute();
|
|
441
|
+
}
|
|
442
|
+
return undefined;
|
|
443
|
+
},
|
|
444
|
+
formatDateMonth: function(row, column, cellValue) {
|
|
445
|
+
if (cellValue) {
|
|
446
|
+
return new Date(cellValue).formatDateMonth();
|
|
447
|
+
}
|
|
448
|
+
return undefined;
|
|
449
|
+
},
|
|
450
|
+
formatPermanentableDate: function(row, column, cellValue) {
|
|
451
|
+
if (Array.isArray(cellValue)) {
|
|
452
|
+
cellValue = cellValue[column];
|
|
453
|
+
}
|
|
454
|
+
return tnxvue.util.date.formatPermanentableDate(cellValue);
|
|
455
|
+
},
|
|
456
|
+
/**
|
|
457
|
+
* 将Java标准的日期格式转换为Day.js的日期格式
|
|
458
|
+
* @param format Java标准的日期格式
|
|
459
|
+
* @returns {String} Day.js的日期格式
|
|
460
|
+
*/
|
|
461
|
+
toDayJsDateFormat(format) {
|
|
462
|
+
return format.replaceAll('y', 'Y').replaceAll('d', 'D');
|
|
463
|
+
},
|
|
464
|
+
};
|
|
458
465
|
|
|
459
|
-
tnxel.number = {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
+
tnxel.number = {
|
|
467
|
+
formatPercent: function(row, column, cellValue) {
|
|
468
|
+
if (typeof cellValue !== 'number') {
|
|
469
|
+
cellValue = parseFloat(cellValue);
|
|
470
|
+
}
|
|
471
|
+
if (!isNaN(cellValue)) {
|
|
472
|
+
return cellValue.toPercent();
|
|
473
|
+
}
|
|
474
|
+
return undefined;
|
|
466
475
|
}
|
|
467
|
-
return undefined;
|
|
468
476
|
}
|
|
469
|
-
}
|
|
470
477
|
|
|
471
|
-
tnxel.boolean = {
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
478
|
+
tnxel.boolean = {
|
|
479
|
+
items: {
|
|
480
|
+
getText(type, value) {
|
|
481
|
+
let items = this[type];
|
|
482
|
+
if (Array.isArray(items)) {
|
|
483
|
+
for (let item of items) {
|
|
484
|
+
if (item.value === value) {
|
|
485
|
+
return item.text;
|
|
486
|
+
}
|
|
479
487
|
}
|
|
480
488
|
}
|
|
489
|
+
return undefined;
|
|
490
|
+
},
|
|
491
|
+
has: [{
|
|
492
|
+
value: true,
|
|
493
|
+
text: '有',
|
|
494
|
+
}, {
|
|
495
|
+
value: false,
|
|
496
|
+
text: '无',
|
|
497
|
+
}]
|
|
498
|
+
},
|
|
499
|
+
format: function(row, column, cellValue) {
|
|
500
|
+
if (typeof cellValue === 'boolean') {
|
|
501
|
+
cellValue = cellValue.toText();
|
|
481
502
|
}
|
|
482
|
-
return
|
|
503
|
+
return cellValue;
|
|
483
504
|
},
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
text: '无',
|
|
490
|
-
}]
|
|
491
|
-
},
|
|
492
|
-
format: function(row, column, cellValue) {
|
|
493
|
-
if (typeof cellValue === 'boolean') {
|
|
494
|
-
cellValue = cellValue.toText();
|
|
495
|
-
}
|
|
496
|
-
return cellValue;
|
|
497
|
-
},
|
|
498
|
-
formatHas: function(row, column, cellValue) {
|
|
499
|
-
if (typeof cellValue === 'boolean') {
|
|
500
|
-
cellValue = tnxel.boolean.items.getText('has', cellValue);
|
|
505
|
+
formatHas: function(row, column, cellValue) {
|
|
506
|
+
if (typeof cellValue === 'boolean') {
|
|
507
|
+
cellValue = tnxel.boolean.items.getText('has', cellValue);
|
|
508
|
+
}
|
|
509
|
+
return cellValue;
|
|
501
510
|
}
|
|
502
|
-
return cellValue;
|
|
503
511
|
}
|
|
504
|
-
}
|
|
505
512
|
|
|
506
|
-
tnxel.table = {}
|
|
513
|
+
tnxel.table = {}
|
|
507
514
|
|
|
508
|
-
const rpc = tnxel.app.rpc;
|
|
509
|
-
rpc.handleErrors = tnxel.util.function.around(rpc.handleErrors, function(handleErrors, errors, options) {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
}
|
|
517
|
-
forms.forEach(form => {
|
|
518
|
-
if (typeof form.disable === 'function') {
|
|
519
|
-
form.disable(false);
|
|
515
|
+
const rpc = tnxel.app.rpc;
|
|
516
|
+
rpc.handleErrors = tnxel.util.function.around(rpc.handleErrors, function(handleErrors, errors, options) {
|
|
517
|
+
if (options && options.form) {
|
|
518
|
+
let forms;
|
|
519
|
+
if (Array.isArray(options.form)) {
|
|
520
|
+
forms = options.form;
|
|
521
|
+
} else {
|
|
522
|
+
forms = [options.form];
|
|
520
523
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
+
forms.forEach(form => {
|
|
525
|
+
if (typeof form.disable === 'function') {
|
|
526
|
+
form.disable(false);
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
return handleErrors.call(rpc, errors, options);
|
|
531
|
+
});
|
|
532
|
+
return tnxel;
|
|
524
533
|
});
|
|
525
|
-
|
|
526
|
-
window.tnx = tnxel;
|
|
527
|
-
|
|
528
|
-
export default tnxel;
|