@truenewx/tnxvue3 2.6.4 → 2.6.6

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.
@@ -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,489 +44,488 @@ import Upload from './upload/Upload.vue';
44
44
 
45
45
  import './tnxel.css';
46
46
 
47
- const $ = tnxbs.libs.$;
47
+ export { build };
48
48
 
49
- const components = Object.assign({}, tnxvue.components, {
50
- Avatar,
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 dialogContainerClass = 'tnxel-dialog-container';
87
- const drawerContainerClass = 'tnxel-drawer-container';
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 tnxel = Object.assign({}, tnxbs, tnxvue, {
90
- components,
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
- let componentOptions = {};
96
- if (this.util.isComponent(content)) {
97
- componentOptions.components = {
98
- 'tnxel-dialog-content': content
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
- const dialogId = 'dialog-' + (new Date().getTime());
105
- $('body').append('<div class="' + dialogContainerClass + '" id="' + dialogId + '"></div>');
106
- if (!(buttons instanceof Array)) {
107
- buttons = [];
108
- }
109
- const containerSelector = '.' + dialogContainerClass + '#' + dialogId;
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);
127
- }
128
- });
129
- this._dialogs.push(dialogVm);
130
- return dialogVm;
131
- },
132
- closeDialog(all, callback) {
133
- if (typeof all === 'function') {
134
- callback = all;
135
- all = false;
136
- }
137
- if (this._dialogs.length) {
138
- let dialog = this._dialogs.pop();
139
- while (dialog) {
140
- dialog.close(callback);
141
- if (all) {
142
- dialog = this._dialogs.pop();
143
- } else {
144
- break;
98
+ let componentOptions = {};
99
+ if (this.util.isComponent(content)) {
100
+ componentOptions.components = {
101
+ 'tnxel-dialog-content': content
102
+ };
103
+ content = null;
104
+ }
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
- _drawers: [], // 抽屉堆栈
150
- drawer(content, title, buttons, options, contentProps) {
151
- this._closeMessage();
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
- let componentOptions = {};
154
- if (this.util.isComponent(content)) {
155
- componentOptions.components = {
156
- 'tnxel-drawer-content': content
157
- };
158
- content = null;
159
- }
160
- let componentDefinition = Object.assign({}, Drawer, componentOptions);
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
- const drawerId = 'drawer-' + (new Date().getTime());
163
- $('body').append('<div class="' + drawerContainerClass + '" id="' + drawerId + '"></div>');
164
- if (!(buttons instanceof Array)) {
165
- buttons = [];
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);
184
- }
185
- });
186
- this._drawers.push(drawerVm);
187
- return drawerVm;
188
- },
189
- closeDrawer(all, callback) {
190
- if (typeof all === 'function') {
191
- callback = all;
192
- all = false;
193
- }
194
- if (this._drawers.length) {
195
- let drawer = this._drawers.pop();
196
- while (drawer) {
197
- drawer.close(callback);
198
- if (all) {
199
- drawer = this._drawers.pop();
200
- } else {
201
- break;
165
+ const drawerId = 'drawer-' + (new Date().getTime());
166
+ $('body').append('<div class="' + drawerContainerClass + '" id="' + drawerId + '"></div>');
167
+ if (!(buttons instanceof Array)) {
168
+ buttons = [];
169
+ }
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
- _closeMessage() {
207
- ElMessage.closeAll();
208
- this.closeLoading();
209
- },
210
- _handleZIndex(selector) {
211
- const util = this.util;
212
- setTimeout(function() {
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
- alert(message, title, callback, options) {
226
- if (typeof title === 'function') {
227
- options = callback;
228
- callback = title;
229
- title = '提示';
230
- }
231
- options = Object.assign({
232
- dangerouslyUseHTMLString: true,
233
- type: 'warning',
234
- confirmButtonText: '确定',
235
- }, options);
236
- ElMessageBox.alert(message, title, options).then(callback);
237
- this._handleZIndex('.el-message-box__wrapper:last');
238
- },
239
- success(message, callback, options) {
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
- callback(yes);
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
- ElMessageBox.confirm(message, title, options);
295
- this._handleZIndex('.el-message-box__wrapper:last');
296
- },
297
- toast(message, timeout, callback, options) {
298
- if (typeof timeout === 'function') {
299
- options = callback;
300
- callback = timeout;
301
- timeout = undefined;
302
- }
303
- options = Object.assign({
304
- type: 'success', // 默认为成功主题,可更改为其它主题
305
- offset: this.util.dom.getDocHeight() * 0.4,
306
- dangerouslyUseHTMLString: true,
307
- }, options, {
308
- center: true, // 因为是竖向排列,所以必须居中
309
- showClose: false,
310
- message: message,
311
- duration: timeout || 1500,
312
- customClass: 'tnxel-toast',
313
- onClose: callback,
314
- });
315
- this._closeMessage();
316
- ElMessage(options);
317
- this._handleZIndex('.el-message:last');
318
- },
319
- showLoading(message, options) {
320
- if (typeof message !== 'string') {
321
- options = message;
322
- message = undefined;
323
- }
324
- options = Object.assign({
325
- dangerouslyUseHTMLString: true,
326
- }, options, {
327
- text: message,
328
- });
329
- this._closeMessage();
330
- window.tnx.loadingInstance = ElLoading.service(options);
331
- this._handleZIndex('.el-loading-mask');
332
- return window.tnx.loadingInstance;
333
- },
334
- closeLoading() {
335
- if (window.tnx.loadingInstance) { // 确保绝对的单例
336
- window.tnx.loadingInstance.close();
337
- window.tnx.loadingInstance = undefined;
338
- }
339
- },
340
- hideLoading() {
341
- this.closeLoading();
342
- },
343
- validateUploaded(vm, reject) {
344
- let result = true;
345
- let formRef = null;
346
- let refKeys = Object.keys(vm.$refs);
347
- for (let refKey of refKeys) {
348
- let refObj = vm.$refs[refKey];
349
- if (Array.isArray(refObj)) {
350
- for (let ref of refObj) {
351
- if (typeof ref.validateUploaded === 'function') {
352
- if (ref.validateUploaded(reject) === false) {
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
- if (!result && formRef) {
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
- install.call(window.tnx, vm);
378
- let ElementComponent = ElementPlus;
379
- if (window.tnx.libs && window.tnx.libs.ElementPlus) {
380
- ElementComponent = window.tnx.libs.ElementPlus;
381
- }
382
- vm.use(ElementComponent, {
383
- locale: ElementPlus_zh_CN,
379
+ tnxel.install = tnxel.util.function.around(tnxel.install, function(install, vm) {
380
+ install.call(tnxel, vm);
381
+ if (!tnxel.libs.ElementPlus) {
382
+ vm.use(ElementPlus, {
383
+ locale: ElementPlus_zh_CN,
384
+ });
385
+ tnxel.libs = Object.assign({}, tnxel.libs, {ElementPlus});
386
+ }
384
387
  });
385
- window.tnx.libs = Object.assign({}, window.tnx.libs, {ElementPlus: ElementComponent});
386
- });
387
388
 
388
- tnxel.router.beforeLeave = tnxel.util.function.around(tnxel.router.beforeLeave, function(beforeLeave, router, from) {
389
- // 页面跳转前关闭当前页面中可能存在的所有消息框和对话框
390
- window.tnx._closeMessage();
391
- window.tnx.closeDialog(true);
392
- beforeLeave.call(window.tnx.router, router, from);
393
- });
389
+ tnxel.router.beforeLeave = tnxel.util.function.around(tnxel.router.beforeLeave, function(beforeLeave, router, from) {
390
+ // 页面跳转前关闭当前页面中可能存在的所有消息框和对话框
391
+ window.tnx._closeMessage();
392
+ window.tnx.closeDialog(true);
393
+ beforeLeave.call(window.tnx.router, router, from);
394
+ });
394
395
 
395
- tnxel.date = {
396
- formatDateTime: function(row, column, cellValue) {
397
- if (cellValue) {
398
- return new Date(cellValue).formatDateTime();
399
- }
400
- return undefined;
401
- },
402
- formatDate: function(row, column, cellValue) {
403
- if (cellValue) {
404
- return new Date(cellValue).formatDate();
405
- }
406
- return undefined;
407
- },
408
- formatTime: function(row, column, cellValue) {
409
- if (typeof cellValue === 'number') {
410
- cellValue = new Date(cellValue);
411
- }
412
- if (cellValue instanceof Date) {
413
- cellValue = cellValue.formatTime();
414
- }
415
- if (typeof cellValue === 'string') {
416
- return cellValue;
417
- }
418
- return undefined;
419
- },
420
- formatTimeMinute: function(row, column, cellValue) {
421
- if (typeof cellValue === 'number') {
422
- cellValue = new Date(cellValue);
423
- }
424
- if (cellValue instanceof Date) {
425
- cellValue = cellValue.formatTimeMinute();
426
- }
427
- if (typeof cellValue === 'string') {
428
- let array = cellValue.split(':');
429
- if (array.length > 1) {
430
- return array[0] + ':' + array[1];
396
+ tnxel.date = {
397
+ formatDateTime: function(row, column, cellValue) {
398
+ if (cellValue) {
399
+ return new Date(cellValue).formatDateTime();
431
400
  }
432
- }
433
- return undefined;
434
- },
435
- formatDateMinute: function(row, column, cellValue) {
436
- if (cellValue) {
437
- return new Date(cellValue).formatDateMinute();
438
- }
439
- return undefined;
440
- },
441
- formatDateMonth: function(row, column, cellValue) {
442
- if (cellValue) {
443
- return new Date(cellValue).formatDateMonth();
444
- }
445
- return undefined;
446
- },
447
- formatPermanentableDate: function(row, column, cellValue) {
448
- if (Array.isArray(cellValue)) {
449
- cellValue = cellValue[column];
450
- }
451
- return tnxvue.util.date.formatPermanentableDate(cellValue);
452
- },
453
- /**
454
- * 将Java标准的日期格式转换为Day.js的日期格式
455
- * @param format Java标准的日期格式
456
- * @returns {String} Day.js的日期格式
457
- */
458
- toDayJsDateFormat(format) {
459
- return format.replaceAll('y', 'Y').replaceAll('d', 'D');
460
- },
461
- };
401
+ return undefined;
402
+ },
403
+ formatDate: function(row, column, cellValue) {
404
+ if (cellValue) {
405
+ return new Date(cellValue).formatDate();
406
+ }
407
+ return undefined;
408
+ },
409
+ formatTime: function(row, column, cellValue) {
410
+ if (typeof cellValue === 'number') {
411
+ cellValue = new Date(cellValue);
412
+ }
413
+ if (cellValue instanceof Date) {
414
+ cellValue = cellValue.formatTime();
415
+ }
416
+ if (typeof cellValue === 'string') {
417
+ return cellValue;
418
+ }
419
+ return undefined;
420
+ },
421
+ formatTimeMinute: function(row, column, cellValue) {
422
+ if (typeof cellValue === 'number') {
423
+ cellValue = new Date(cellValue);
424
+ }
425
+ if (cellValue instanceof Date) {
426
+ cellValue = cellValue.formatTimeMinute();
427
+ }
428
+ if (typeof cellValue === 'string') {
429
+ let array = cellValue.split(':');
430
+ if (array.length > 1) {
431
+ return array[0] + ':' + array[1];
432
+ }
433
+ }
434
+ return undefined;
435
+ },
436
+ formatDateMinute: function(row, column, cellValue) {
437
+ if (cellValue) {
438
+ return new Date(cellValue).formatDateMinute();
439
+ }
440
+ return undefined;
441
+ },
442
+ formatDateMonth: function(row, column, cellValue) {
443
+ if (cellValue) {
444
+ return new Date(cellValue).formatDateMonth();
445
+ }
446
+ return undefined;
447
+ },
448
+ formatPermanentableDate: function(row, column, cellValue) {
449
+ if (Array.isArray(cellValue)) {
450
+ cellValue = cellValue[column];
451
+ }
452
+ return tnxvue.util.date.formatPermanentableDate(cellValue);
453
+ },
454
+ /**
455
+ * 将Java标准的日期格式转换为Day.js的日期格式
456
+ * @param format Java标准的日期格式
457
+ * @returns {String} Day.js的日期格式
458
+ */
459
+ toDayJsDateFormat(format) {
460
+ return format.replaceAll('y', 'Y').replaceAll('d', 'D');
461
+ },
462
+ };
462
463
 
463
- tnxel.number = {
464
- formatPercent: function(row, column, cellValue) {
465
- if (typeof cellValue !== 'number') {
466
- cellValue = parseFloat(cellValue);
467
- }
468
- if (!isNaN(cellValue)) {
469
- return cellValue.toPercent();
464
+ tnxel.number = {
465
+ formatPercent: function(row, column, cellValue) {
466
+ if (typeof cellValue !== 'number') {
467
+ cellValue = parseFloat(cellValue);
468
+ }
469
+ if (!isNaN(cellValue)) {
470
+ return cellValue.toPercent();
471
+ }
472
+ return undefined;
470
473
  }
471
- return undefined;
472
474
  }
473
- }
474
475
 
475
- tnxel.boolean = {
476
- items: {
477
- getText(type, value) {
478
- let items = this[type];
479
- if (Array.isArray(items)) {
480
- for (let item of items) {
481
- if (item.value === value) {
482
- return item.text;
476
+ tnxel.boolean = {
477
+ items: {
478
+ getText(type, value) {
479
+ let items = this[type];
480
+ if (Array.isArray(items)) {
481
+ for (let item of items) {
482
+ if (item.value === value) {
483
+ return item.text;
484
+ }
483
485
  }
484
486
  }
487
+ return undefined;
488
+ },
489
+ has: [{
490
+ value: true,
491
+ text: '有',
492
+ }, {
493
+ value: false,
494
+ text: '无',
495
+ }]
496
+ },
497
+ format: function(row, column, cellValue) {
498
+ if (typeof cellValue === 'boolean') {
499
+ cellValue = cellValue.toText();
485
500
  }
486
- return undefined;
501
+ return cellValue;
487
502
  },
488
- has: [{
489
- value: true,
490
- text: '',
491
- }, {
492
- value: false,
493
- text: '无',
494
- }]
495
- },
496
- format: function(row, column, cellValue) {
497
- if (typeof cellValue === 'boolean') {
498
- cellValue = cellValue.toText();
499
- }
500
- return cellValue;
501
- },
502
- formatHas: function(row, column, cellValue) {
503
- if (typeof cellValue === 'boolean') {
504
- cellValue = tnxel.boolean.items.getText('has', cellValue);
503
+ formatHas: function(row, column, cellValue) {
504
+ if (typeof cellValue === 'boolean') {
505
+ cellValue = tnxel.boolean.items.getText('has', cellValue);
506
+ }
507
+ return cellValue;
505
508
  }
506
- return cellValue;
507
509
  }
508
- }
509
510
 
510
- tnxel.table = {}
511
+ tnxel.table = {}
511
512
 
512
- const rpc = tnxel.app.rpc;
513
- rpc.handleErrors = tnxel.util.function.around(rpc.handleErrors, function(handleErrors, errors, options) {
514
- if (options && options.form) {
515
- let forms;
516
- if (Array.isArray(options.form)) {
517
- forms = options.form;
518
- } else {
519
- forms = [options.form];
520
- }
521
- forms.forEach(form => {
522
- if (typeof form.disable === 'function') {
523
- form.disable(false);
513
+ const rpc = tnxel.app.rpc;
514
+ rpc.handleErrors = tnxel.util.function.around(rpc.handleErrors, function(handleErrors, errors, options) {
515
+ if (options && options.form) {
516
+ let forms;
517
+ if (Array.isArray(options.form)) {
518
+ forms = options.form;
519
+ } else {
520
+ forms = [options.form];
524
521
  }
525
- });
526
- }
527
- return handleErrors.call(rpc, errors, options);
522
+ forms.forEach(form => {
523
+ if (typeof form.disable === 'function') {
524
+ form.disable(false);
525
+ }
526
+ });
527
+ }
528
+ return handleErrors.call(rpc, errors, options);
529
+ });
530
+ return tnxel;
528
531
  });
529
-
530
- window.tnx = tnxel;
531
-
532
- export default tnxel;