@truenewx/tnxvue3 2.6.1 → 2.6.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truenewx/tnxvue3",
3
- "version": "2.6.1",
3
+ "version": "2.6.3",
4
4
  "description": "互联网技术解决方案:Vue3扩展支持",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -30,8 +30,9 @@
30
30
  "vue-router": "4.1.6"
31
31
  },
32
32
  "devDependencies": {
33
- "@babel/core": "7.21.8",
34
- "@babel/eslint-parser": "7.21.8",
33
+ "@babel/core": "7.22.5",
34
+ "@babel/eslint-parser": "7.22.5",
35
+ "@babel/preset-env": "7.22.5",
35
36
  "@vue/cli-plugin-babel": "5.0.8",
36
37
  "@vue/cli-plugin-eslint": "5.0.8",
37
38
  "@vue/cli-service": "5.0.8",
@@ -98,7 +98,7 @@ export default {
98
98
  this.visible = this.modelValue;
99
99
  if (newValue && !oldValue) { // 从隐藏到显示
100
100
  let vm = this;
101
- this.$nextTick(function () {
101
+ this.$nextTick(function() {
102
102
  vm.locate(true);
103
103
  });
104
104
  }
@@ -109,13 +109,13 @@ export default {
109
109
  },
110
110
  mounted() {
111
111
  let vm = this;
112
- this.$nextTick(function () {
112
+ this.$nextTick(function() {
113
113
  if (this.visible) {
114
114
  vm.locate(true);
115
115
  }
116
116
 
117
117
  if (vm.$refs.content && !vm.$refs.content.close) {
118
- vm.$refs.content.close = function () {
118
+ vm.$refs.content.close = function() {
119
119
  vm.close();
120
120
  }
121
121
  }
@@ -143,7 +143,7 @@ export default {
143
143
  $dialog = $container.next('.el-overlay').find('.el-dialog');
144
144
  }
145
145
  }
146
- if (!$dialog?.length) {
146
+ if (!$dialog || !$dialog.length) {
147
147
  $dialog = $('.el-dialog:last');
148
148
  }
149
149
  if ($dialog.length) {
@@ -179,9 +179,9 @@ export default {
179
179
  },
180
180
  close(callback) {
181
181
  const vm = this;
182
- this.beforeClose(function () {
182
+ this.beforeClose(function() {
183
183
  if (typeof callback === 'function') {
184
- vm.options.onClosed = util.function.around(vm.options.onClosed, function (onClosed) {
184
+ vm.options.onClosed = util.function.around(vm.options.onClosed, function(onClosed) {
185
185
  if (onClosed) {
186
186
  onClosed();
187
187
  }
@@ -87,7 +87,11 @@ export default {
87
87
  },
88
88
  computed: {
89
89
  uploadingFiles() {
90
- return this.$refs.upload?.files || [];
90
+ let files = null;
91
+ if (this.$refs.upload) {
92
+ files = this.$refs.upload.files;
93
+ }
94
+ return files || [];
91
95
  },
92
96
  },
93
97
  watch: {
@@ -130,7 +134,7 @@ export default {
130
134
  _initialize() {
131
135
  const vm = this;
132
136
  let fssConfig = vm.tnx.fss.getClientConfig();
133
- vm.tnx.app.rpc.ensureLogined(function () {
137
+ vm.tnx.app.rpc.ensureLogined(function() {
134
138
  let locationUrls;
135
139
  if (vm.modelValue) {
136
140
  locationUrls = Array.isArray(vm.modelValue) ? vm.modelValue : [vm.modelValue];
@@ -140,7 +144,7 @@ export default {
140
144
  if (locationUrls.length) {
141
145
  vm.tnx.app.rpc.get(fssConfig.contextUrl + '/metas', {
142
146
  locationUrls: locationUrls
143
- }, function (metas) {
147
+ }, function(metas) {
144
148
  let fileList = [];
145
149
  metas.forEach(meta => {
146
150
  if (meta) {
@@ -153,7 +157,7 @@ export default {
153
157
  }
154
158
  });
155
159
  vm.fileList = fileList;
156
- vm.$nextTick(function () {
160
+ vm.$nextTick(function() {
157
161
  vm._loadUploadOptions();
158
162
  });
159
163
  }, {
@@ -161,7 +165,7 @@ export default {
161
165
  });
162
166
  } else {
163
167
  vm.fileList = [];
164
- vm.$nextTick(function () {
168
+ vm.$nextTick(function() {
165
169
  vm._loadUploadOptions();
166
170
  });
167
171
  }
@@ -176,7 +180,7 @@ export default {
176
180
  // 上传限制为空才执行加载,避免多次重复加载
177
181
  if (Object.keys(this.uploadOptions).length === 0) {
178
182
  let vm = this;
179
- vm.tnx.fss.loadUploadOptions(this.type, function (uploadOptions) {
183
+ vm.tnx.fss.loadUploadOptions(this.type, function(uploadOptions) {
180
184
  if (vm.extension) {
181
185
  let extensions = Array.isArray(vm.extension) ? vm.extension : [vm.extension];
182
186
  let acceptedExtensions = [];
@@ -294,7 +298,7 @@ export default {
294
298
  if (typeof reject === 'function') {
295
299
  reject(file);
296
300
  } else {
297
- this.tnx.alert('文件"' + file.name + '"还未上传完毕,请稍候', function () {
301
+ this.tnx.alert('文件"' + file.name + '"还未上传完毕,请稍候', function() {
298
302
  if (reject && typeof reject.disable === 'function') {
299
303
  reject.disable(false);
300
304
  }
@@ -1,150 +1,150 @@
1
- <template>
2
- <div class="tnxel-input-number" :class="containerClassObject">
3
- <el-input-number ref="input" class="flex-grow-1" :class="{'rounded-end-0': suffix, 'text-start': !controls}"
4
- v-model="model"
5
- :min="min" :max="max"
6
- :controls="controls" controls-position="right"
7
- :placeholder="placeholderText" :disabled="disabled"
8
- :step="step || Math.pow(10, -this.scale)" step-strictly
9
- :precision="scale"
10
- :value-on-clear="null"
11
- :size="size"
12
- @change="onChange"
13
- @blur="$emit('blur', $event)"/>
14
- <div class="el-input-group__append" v-if="suffix">{{ suffix }}</div>
15
- </div>
16
- </template>
17
-
18
- <script>
19
- export default {
20
- name: 'TnxelInputNumber',
21
- props: {
22
- modelValue: [Number, String],
23
- span: Number,
24
- min: Number,
25
- max: Number,
26
- placeholder: {
27
- type: String,
28
- default: () => '请设置',
29
- },
30
- disabled: Boolean,
31
- append: String,
32
- controls: {
33
- type: Boolean,
34
- default: true,
35
- },
36
- step: Number,
37
- scale: {
38
- type: Number,
39
- default: 0,
40
- },
41
- required: Boolean,
42
- size: String,
43
- },
44
- emits: ['update:modelValue', 'blur'],
45
- data() {
46
- return {
47
- model: typeof this.modelValue === 'string' ? Number(this.modelValue) : this.modelValue,
48
- showRequiredError: false,
49
- }
50
- },
51
- computed: {
52
- placeholderText() {
53
- if (this.placeholder) {
54
- return this.placeholder;
55
- }
56
- let text = this.disabled ? '未' : '请';
57
- text += this.controls ? '设置' : '输入';
58
- return text;
59
- },
60
- containerClassObject() {
61
- let classObject = {
62
- 'is-error': this.showRequiredError,
63
- };
64
- if (this.span) {
65
- classObject['el-col'] = true;
66
- classObject['el-col-' + this.span] = true;
67
- }
68
- return classObject;
69
- },
70
- suffix() {
71
- if (this.append) {
72
- return this.append;
73
- }
74
- if (this.$slots?.append) {
75
- let append = this.$slots.append();
76
- if (append?.length) {
77
- return append[0].text;
78
- }
79
- }
80
- return null;
81
- }
82
- },
83
- watch: {
84
- model(value) {
85
- this.$emit('update:modelValue', value);
86
- },
87
- modelValue(value) {
88
- this.model = typeof value === 'string' ? Number(value) : value;
89
- }
90
- },
91
- methods: {
92
- validateRequired(focusError) {
93
- if (this.required) {
94
- this.showRequiredError = this.model === undefined || this.model === null || this.model === '';
95
- if (this.showRequiredError && focusError) {
96
- this.focus();
97
- }
98
- return !this.showRequiredError;
99
- }
100
- return true;
101
- },
102
- focus() {
103
- this.$refs.input.focus();
104
- },
105
- onChange() {
106
- this.validateRequired(false);
107
- },
108
- }
109
- }
110
- </script>
111
-
112
- <style>
113
- .tnxel-input-number {
114
- display: flex;
115
- }
116
-
117
- .tnxel-input-number .el-input-number {
118
- width: auto;
119
- line-height: 1;
120
- }
121
-
122
- .tnxel-input-number .el-input__inner {
123
- min-width: 50px;
124
- }
125
-
126
- .tnxel-input-number .el-input-number.text-start .el-input__inner {
127
- text-align: left;
128
- }
129
-
130
- .tnxel-input-number .el-input-number.is-controls-right .el-input__wrapper {
131
- padding-left: 8px;
132
- }
133
-
134
- .tnxel-input-number .el-input-number .el-input__wrapper .el-input__suffix {
135
- display: none;
136
- }
137
-
138
- .tnxel-input-number .el-input-number.rounded-end-0 .el-input__wrapper {
139
- border-top-right-radius: 0;
140
- border-bottom-right-radius: 0;
141
- }
142
-
143
- .tnxel-input-number .el-input-group__append {
144
- border: 1px solid var(--el-border-color);
145
- border-left: none;
146
- line-height: 1;
147
- border-top-right-radius: var(--el-input-border-radius, var(--el-border-radius-base));
148
- border-bottom-right-radius: var(--el-input-border-radius, var(--el-border-radius-base));
149
- }
150
- </style>
1
+ <template>
2
+ <div class="tnxel-input-number" :class="containerClassObject">
3
+ <el-input-number ref="input" class="flex-grow-1" :class="{'rounded-end-0': suffix, 'text-start': !controls}"
4
+ v-model="model"
5
+ :min="min" :max="max"
6
+ :controls="controls" controls-position="right"
7
+ :placeholder="placeholderText" :disabled="disabled"
8
+ :step="step || Math.pow(10, -this.scale)" step-strictly
9
+ :precision="scale"
10
+ :value-on-clear="null"
11
+ :size="size"
12
+ @change="onChange"
13
+ @blur="$emit('blur', $event)"/>
14
+ <div class="el-input-group__append" v-if="suffix">{{ suffix }}</div>
15
+ </div>
16
+ </template>
17
+
18
+ <script>
19
+ export default {
20
+ name: 'TnxelInputNumber',
21
+ props: {
22
+ modelValue: [Number, String],
23
+ span: Number,
24
+ min: Number,
25
+ max: Number,
26
+ placeholder: {
27
+ type: String,
28
+ default: () => '请设置',
29
+ },
30
+ disabled: Boolean,
31
+ append: String,
32
+ controls: {
33
+ type: Boolean,
34
+ default: true,
35
+ },
36
+ step: Number,
37
+ scale: {
38
+ type: Number,
39
+ default: 0,
40
+ },
41
+ required: Boolean,
42
+ size: String,
43
+ },
44
+ emits: ['update:modelValue', 'blur'],
45
+ data() {
46
+ return {
47
+ model: typeof this.modelValue === 'string' ? Number(this.modelValue) : this.modelValue,
48
+ showRequiredError: false,
49
+ }
50
+ },
51
+ computed: {
52
+ placeholderText() {
53
+ if (this.placeholder) {
54
+ return this.placeholder;
55
+ }
56
+ let text = this.disabled ? '未' : '请';
57
+ text += this.controls ? '设置' : '输入';
58
+ return text;
59
+ },
60
+ containerClassObject() {
61
+ let classObject = {
62
+ 'is-error': this.showRequiredError,
63
+ };
64
+ if (this.span) {
65
+ classObject['el-col'] = true;
66
+ classObject['el-col-' + this.span] = true;
67
+ }
68
+ return classObject;
69
+ },
70
+ suffix() {
71
+ if (this.append) {
72
+ return this.append;
73
+ }
74
+ if (this.$slots && this.$slots.append) {
75
+ let append = this.$slots.append();
76
+ if (append && append.length) {
77
+ return append[0].text;
78
+ }
79
+ }
80
+ return null;
81
+ }
82
+ },
83
+ watch: {
84
+ model(value) {
85
+ this.$emit('update:modelValue', value);
86
+ },
87
+ modelValue(value) {
88
+ this.model = typeof value === 'string' ? Number(value) : value;
89
+ }
90
+ },
91
+ methods: {
92
+ validateRequired(focusError) {
93
+ if (this.required) {
94
+ this.showRequiredError = this.model === undefined || this.model === null || this.model === '';
95
+ if (this.showRequiredError && focusError) {
96
+ this.focus();
97
+ }
98
+ return !this.showRequiredError;
99
+ }
100
+ return true;
101
+ },
102
+ focus() {
103
+ this.$refs.input.focus();
104
+ },
105
+ onChange() {
106
+ this.validateRequired(false);
107
+ },
108
+ }
109
+ }
110
+ </script>
111
+
112
+ <style>
113
+ .tnxel-input-number {
114
+ display: flex;
115
+ }
116
+
117
+ .tnxel-input-number .el-input-number {
118
+ width: auto;
119
+ line-height: 1;
120
+ }
121
+
122
+ .tnxel-input-number .el-input__inner {
123
+ min-width: 50px;
124
+ }
125
+
126
+ .tnxel-input-number .el-input-number.text-start .el-input__inner {
127
+ text-align: left;
128
+ }
129
+
130
+ .tnxel-input-number .el-input-number.is-controls-right .el-input__wrapper {
131
+ padding-left: 8px;
132
+ }
133
+
134
+ .tnxel-input-number .el-input-number .el-input__wrapper .el-input__suffix {
135
+ display: none;
136
+ }
137
+
138
+ .tnxel-input-number .el-input-number.rounded-end-0 .el-input__wrapper {
139
+ border-top-right-radius: 0;
140
+ border-bottom-right-radius: 0;
141
+ }
142
+
143
+ .tnxel-input-number .el-input-group__append {
144
+ border: 1px solid var(--el-border-color);
145
+ border-left: none;
146
+ line-height: 1;
147
+ border-top-right-radius: var(--el-input-border-radius, var(--el-border-radius-base));
148
+ border-bottom-right-radius: var(--el-input-border-radius, var(--el-border-radius-base));
149
+ }
150
+ </style>
@@ -27,7 +27,7 @@
27
27
  </template>
28
28
  <span v-else>&lt;空&gt;</span>
29
29
  </template>
30
- <template #append v-if="records?.length && paged && typeof paged.total !== 'number'">
30
+ <template #append v-if="records && records.length && paged && typeof paged.total !== 'number'">
31
31
  <tnxel-button class="py-0 px-1 mx-2 border-0" icon="Top" tooltip="回到顶部" plain
32
32
  @click="scrollToTop"/>
33
33
  <tnxel-icon class="text-secondary" value="Loading" :size="18" v-if="querying"/>
@@ -40,7 +40,7 @@
40
40
  </template>
41
41
  </el-table>
42
42
  <slot name="paged" :paged="paged" :show="showPaged" :query="query"
43
- v-if="params.pageSize > 0 && typeof paged?.total === 'number'">
43
+ v-if="params.pageSize > 0 && paged && typeof paged.total === 'number'">
44
44
  <tnxel-paged :value="paged" :change="onPagedChange" :align="pagedAlign" v-if="showPaged"/>
45
45
  </slot>
46
46
  </div>
@@ -135,7 +135,7 @@ export default {
135
135
  },
136
136
  tableMaxHeight() {
137
137
  if (this.fixedHeight && this.containerHeight) {
138
- return typeof this.paged?.total === 'number' ? (this.containerHeight - 40) : this.containerHeight;
138
+ return (this.paged && typeof this.paged.total === 'number') ? (this.containerHeight - 40) : this.containerHeight;
139
139
  }
140
140
  return undefined;
141
141
  },
@@ -180,7 +180,7 @@ export default {
180
180
  return undefined;
181
181
  },
182
182
  pageAllSelected() {
183
- if (this.records?.length) {
183
+ if (this.records && this.records.length) {
184
184
  let selected = null;
185
185
  for (let i = 0; i < this.records.length; i++) {
186
186
  if (selected === null) {
@@ -194,7 +194,7 @@ export default {
194
194
  return false;
195
195
  },
196
196
  allSelectedIndeterminate() {
197
- if (this.records?.length) {
197
+ if (this.records && this.records.length) {
198
198
  let firstSelected = this.pageSelectedIndexes[0] || false;
199
199
  if (this.records.length === 1) {
200
200
  return firstSelected;
@@ -261,7 +261,7 @@ export default {
261
261
  this.paged = null;
262
262
  }
263
263
  let vm = this;
264
- window.tnx.app.rpc.get(this.url, this.params, function (result) {
264
+ window.tnx.app.rpc.get(this.url, this.params, function(result) {
265
265
  vm.querying = false;
266
266
  if (Array.isArray(result)) {
267
267
  vm.records = vm.format(result);
@@ -309,7 +309,7 @@ export default {
309
309
  selectRow(row, column, cell) {
310
310
  if (this.selectable && this.records && column.getColumnIndex() > 0 && !cell.innerHTML.contains('</a>')) {
311
311
  let vm = this;
312
- let index = window.tnx.util.array.indexOf(this.records, function (element) {
312
+ let index = window.tnx.util.array.indexOf(this.records, function(element) {
313
313
  return row[vm.selectName] === element[vm.selectName];
314
314
  });
315
315
  if (index >= 0) {
@@ -319,7 +319,7 @@ export default {
319
319
  }
320
320
  },
321
321
  selectAll(selected) {
322
- if (this.records?.length) {
322
+ if (this.records && this.records.length) {
323
323
  for (let i = 0; i < this.records.length; i++) {
324
324
  this.pageSelectedIndexes[i] = selected;
325
325
  }
@@ -331,7 +331,7 @@ export default {
331
331
  for (let index = 0; index < this.pageSelectedIndexes.length; index++) {
332
332
  let selectedInPage = this.pageSelectedIndexes[index];
333
333
  let record = this.records[index];
334
- let fnEquals = function (element) {
334
+ let fnEquals = function(element) {
335
335
  return record[vm.selectName] === element[vm.selectName];
336
336
  };
337
337
  let selectedInAll = this.allSelectedRecords.contains(fnEquals);
@@ -136,7 +136,7 @@
136
136
  <script>
137
137
  import Icon from '../icon/Icon.vue';
138
138
 
139
- export const isMultiSelector = function (selector) {
139
+ export const isMultiSelector = function(selector) {
140
140
  return selector === 'checkbox' || selector === 'tags' || selector === 'texts';
141
141
  }
142
142
  export default {
@@ -218,7 +218,7 @@ export default {
218
218
  if (util.object.isNotEmpty(newValue) || util.object.isNotEmpty(oldValue)) {
219
219
  let vm = this;
220
220
  // 确保变更事件在值变更应用后再触发
221
- this.$nextTick(function () {
221
+ this.$nextTick(function() {
222
222
  vm.triggerChange(newValue);
223
223
  });
224
224
  }
@@ -288,7 +288,7 @@ export default {
288
288
  if (util.object.isNull(model)) {
289
289
  return null;
290
290
  }
291
- if (items?.length) {
291
+ if (items && items.length) {
292
292
  let item = this.getItem(model);
293
293
  if (item) {
294
294
  return item[this.valueName];
@@ -345,7 +345,7 @@ export default {
345
345
  if (this.isMulti()) {
346
346
  let index = this.model.indexOf(value);
347
347
  if (index >= 0) {
348
- this.model = this.model.filter(function (e, i) {
348
+ this.model = this.model.filter(function(e, i) {
349
349
  return i !== index;
350
350
  });
351
351
  } else {
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * 基于ElementPlus的扩展支持
4
4
  */
5
- import ElementPlus, {ElLoading, ElMessage, ElMessageBox} from 'element-plus';
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
8
  import tnxvue from '../tnxvue.js';
@@ -87,7 +87,6 @@ const dialogContainerClass = 'tnxel-dialog-container';
87
87
  const drawerContainerClass = 'tnxel-drawer-container';
88
88
 
89
89
  const tnxel = Object.assign({}, tnxbs, tnxvue, {
90
- libs: Object.assign({}, tnxbs.libs, tnxvue.libs, {ElementPlus}),
91
90
  components,
92
91
  _dialogs: [], // 对话框堆栈
93
92
  dialog(content, title, buttons, options, contentProps) {
@@ -119,7 +118,7 @@ const tnxel = Object.assign({}, tnxbs, tnxvue, {
119
118
  theme: options.theme,
120
119
  }).mount(containerSelector);
121
120
  dialogVm.options = Object.assign(dialogVm.options || {}, options);
122
- dialogVm.options.onClosed = this.util.function.around(dialogVm.options.onClosed, function (onClosed) {
121
+ dialogVm.options.onClosed = this.util.function.around(dialogVm.options.onClosed, function(onClosed) {
123
122
  let $container = $(containerSelector);
124
123
  $container.next('.el-overlay').remove();
125
124
  $container.remove();
@@ -176,7 +175,7 @@ const tnxel = Object.assign({}, tnxbs, tnxvue, {
176
175
  }).mount(containerSelector);
177
176
  drawerVm.id = drawerId;
178
177
  drawerVm.options = Object.assign(drawerVm.options || {}, options);
179
- drawerVm.options.onClosed = this.util.function.around(drawerVm.options.onClosed, function (onClosed) {
178
+ drawerVm.options.onClosed = this.util.function.around(drawerVm.options.onClosed, function(onClosed) {
180
179
  let $container = $(containerSelector);
181
180
  $container.next('.el-overlay').remove();
182
181
  $container.remove();
@@ -210,7 +209,7 @@ const tnxel = Object.assign({}, tnxbs, tnxvue, {
210
209
  },
211
210
  _handleZIndex(selector) {
212
211
  const util = this.util;
213
- setTimeout(function () {
212
+ setTimeout(function() {
214
213
  const topZIndex = util.dom.minTopZIndex(2);
215
214
  const element = $(selector);
216
215
  const zIndex = Number(element.css('zIndex'));
@@ -282,7 +281,7 @@ const tnxel = Object.assign({}, tnxbs, tnxvue, {
282
281
  options.cancelButtonText = buttonText;
283
282
  }
284
283
  if (typeof callback === 'function') {
285
- options.callback = function (action) {
284
+ options.callback = function(action) {
286
285
  let yes = undefined;
287
286
  if (action === 'confirm') {
288
287
  yes = options.reverse ? false : true;
@@ -374,14 +373,15 @@ const tnxel = Object.assign({}, tnxbs, tnxvue, {
374
373
  }
375
374
  });
376
375
 
377
- tnxel.install = tnxel.util.function.around(tnxel.install, function (install, vm) {
376
+ tnxel.install = tnxel.util.function.around(tnxel.install, function(install, vm) {
377
+ install.call(window.tnx, vm);
378
378
  vm.use(ElementPlus, {
379
379
  locale: ElementPlus_zh_CN,
380
380
  });
381
- install.call(window.tnx, vm);
381
+ this.libs.ElementPlus = ElementPlus;
382
382
  });
383
383
 
384
- tnxel.router.beforeLeave = tnxel.util.function.around(tnxel.router.beforeLeave, function (beforeLeave, router, from) {
384
+ tnxel.router.beforeLeave = tnxel.util.function.around(tnxel.router.beforeLeave, function(beforeLeave, router, from) {
385
385
  // 页面跳转前关闭当前页面中可能存在的所有消息框和对话框
386
386
  window.tnx._closeMessage();
387
387
  window.tnx.closeDialog(true);
@@ -389,19 +389,19 @@ tnxel.router.beforeLeave = tnxel.util.function.around(tnxel.router.beforeLeave,
389
389
  });
390
390
 
391
391
  tnxel.date = {
392
- formatDateTime: function (row, column, cellValue) {
392
+ formatDateTime: function(row, column, cellValue) {
393
393
  if (cellValue) {
394
394
  return new Date(cellValue).formatDateTime();
395
395
  }
396
396
  return undefined;
397
397
  },
398
- formatDate: function (row, column, cellValue) {
398
+ formatDate: function(row, column, cellValue) {
399
399
  if (cellValue) {
400
400
  return new Date(cellValue).formatDate();
401
401
  }
402
402
  return undefined;
403
403
  },
404
- formatTime: function (row, column, cellValue) {
404
+ formatTime: function(row, column, cellValue) {
405
405
  if (typeof cellValue === 'number') {
406
406
  cellValue = new Date(cellValue);
407
407
  }
@@ -413,7 +413,7 @@ tnxel.date = {
413
413
  }
414
414
  return undefined;
415
415
  },
416
- formatTimeMinute: function (row, column, cellValue) {
416
+ formatTimeMinute: function(row, column, cellValue) {
417
417
  if (typeof cellValue === 'number') {
418
418
  cellValue = new Date(cellValue);
419
419
  }
@@ -428,19 +428,19 @@ tnxel.date = {
428
428
  }
429
429
  return undefined;
430
430
  },
431
- formatDateMinute: function (row, column, cellValue) {
431
+ formatDateMinute: function(row, column, cellValue) {
432
432
  if (cellValue) {
433
433
  return new Date(cellValue).formatDateMinute();
434
434
  }
435
435
  return undefined;
436
436
  },
437
- formatDateMonth: function (row, column, cellValue) {
437
+ formatDateMonth: function(row, column, cellValue) {
438
438
  if (cellValue) {
439
439
  return new Date(cellValue).formatDateMonth();
440
440
  }
441
441
  return undefined;
442
442
  },
443
- formatPermanentableDate: function (row, column, cellValue) {
443
+ formatPermanentableDate: function(row, column, cellValue) {
444
444
  if (Array.isArray(cellValue)) {
445
445
  cellValue = cellValue[column];
446
446
  }
@@ -457,7 +457,7 @@ tnxel.date = {
457
457
  };
458
458
 
459
459
  tnxel.number = {
460
- formatPercent: function (row, column, cellValue) {
460
+ formatPercent: function(row, column, cellValue) {
461
461
  if (typeof cellValue !== 'number') {
462
462
  cellValue = parseFloat(cellValue);
463
463
  }
@@ -489,13 +489,13 @@ tnxel.boolean = {
489
489
  text: '无',
490
490
  }]
491
491
  },
492
- format: function (row, column, cellValue) {
492
+ format: function(row, column, cellValue) {
493
493
  if (typeof cellValue === 'boolean') {
494
494
  cellValue = cellValue.toText();
495
495
  }
496
496
  return cellValue;
497
497
  },
498
- formatHas: function (row, column, cellValue) {
498
+ formatHas: function(row, column, cellValue) {
499
499
  if (typeof cellValue === 'boolean') {
500
500
  cellValue = tnxel.boolean.items.getText('has', cellValue);
501
501
  }
@@ -506,7 +506,7 @@ tnxel.boolean = {
506
506
  tnxel.table = {}
507
507
 
508
508
  const rpc = tnxel.app.rpc;
509
- rpc.handleErrors = tnxel.util.function.around(rpc.handleErrors, function (handleErrors, errors, options) {
509
+ rpc.handleErrors = tnxel.util.function.around(rpc.handleErrors, function(handleErrors, errors, options) {
510
510
  if (options && options.form) {
511
511
  let forms;
512
512
  if (Array.isArray(options.form)) {
@@ -12,7 +12,7 @@
12
12
  :file-list="fileList"
13
13
  :show-file-list="true"
14
14
  :headers="uploadHeaders"
15
- :multiple="uploadOptions?.number !== 1"
15
+ :multiple="uploadOptions && uploadOptions.number !== 1"
16
16
  :accept="uploadAccept" :disabled="disabled" v-if="uploadOptions">
17
17
  <template #file="{file}">
18
18
  <div class="el-upload-list__panel" :data-file-id="getFileId(file)" :style="itemPanelStyle"
@@ -140,7 +140,7 @@ export default {
140
140
  fileIcon: {
141
141
  type: [String, Function],
142
142
  default() {
143
- return function (file) {
143
+ return function(file) {
144
144
  if (isImage(file)) {
145
145
  return 'Picture';
146
146
  }
@@ -170,11 +170,11 @@ export default {
170
170
  },
171
171
  computed: {
172
172
  fileNumExceed() {
173
- return this.uploadOptions?.number && this.files.length >= this.uploadOptions.number;
173
+ return this.uploadOptions && this.uploadOptions.number && this.files.length >= this.uploadOptions.number;
174
174
  },
175
175
  imageable() {
176
176
  let imageable = false;
177
- if (this.uploadOptions?.extensions) {
177
+ if (this.uploadOptions && this.uploadOptions.extensions) {
178
178
  for (let extension of this.uploadOptions.extensions) {
179
179
  if (this.tnx.util.file.isImage(extension)) {
180
180
  imageable = true;
@@ -223,7 +223,8 @@ export default {
223
223
  return content;
224
224
  },
225
225
  uploadAccept() {
226
- if (this.uploadOptions && !this.uploadOptions.extensionsRejected && this.uploadOptions.extensions?.length) {
226
+ if (this.uploadOptions && !this.uploadOptions.extensionsRejected && this.uploadOptions.extensions
227
+ && this.uploadOptions.extensions.length) {
227
228
  let accept = '';
228
229
  for (let extension of this.uploadOptions.extensions) {
229
230
  accept += ',.' + extension;
@@ -243,7 +244,10 @@ export default {
243
244
  width = width || uploadSize.width;
244
245
  height = height || uploadSize.height;
245
246
  }
246
- return {width, height};
247
+ return {
248
+ width,
249
+ height
250
+ };
247
251
  },
248
252
  itemPanelStyle() {
249
253
  let style = {
@@ -270,7 +274,7 @@ export default {
270
274
  this.init();
271
275
  },
272
276
  fileList() {
273
- if (this.uploadOptions?.number) {
277
+ if (this.uploadOptions && this.uploadOptions.number) {
274
278
  this.init();
275
279
  }
276
280
  }
@@ -280,7 +284,7 @@ export default {
280
284
  this.files = [].concat(this.fileList);
281
285
  let vm = this;
282
286
  // 需在vue渲染之后才可正常操作dom元素
283
- this.$nextTick(function () {
287
+ this.$nextTick(function() {
284
288
  // 初始化显示尺寸
285
289
  let width = vm.uploadSize.width;
286
290
  if (width) {
@@ -347,7 +351,7 @@ export default {
347
351
  }
348
352
  // 校验文件重复
349
353
  const vm = this;
350
- if (this.files.contains(function (f) {
354
+ if (this.files.contains(function(f) {
351
355
  const raw = f.raw ? f.raw : f;
352
356
  return file.uid !== raw.uid && vm.getFileId(file) === vm.getFileId(raw);
353
357
  })) {
@@ -417,7 +421,7 @@ export default {
417
421
 
418
422
  const vm = this;
419
423
  const rpc = this.tnx.app.rpc;
420
- return new Promise(function (resolve, reject) {
424
+ return new Promise(function(resolve, reject) {
421
425
  if (vm.validate(file)) {
422
426
  let $upload = $('#' + vm.id + ' .el-upload');
423
427
  if (vm.showFileList && vm.fileNumExceed) {
@@ -425,13 +429,13 @@ export default {
425
429
  }
426
430
 
427
431
  // 上传前需确保用户在fss应用中已登录
428
- rpc.ensureLogined(function () {
432
+ rpc.ensureLogined(function() {
429
433
  if (vm.beforeUpload) {
430
434
  let promise = vm.beforeUpload(file);
431
435
  if (promise instanceof Promise) {
432
- promise.then(function () {
436
+ promise.then(function() {
433
437
  resolve(file);
434
- }).catch(function () {
438
+ }).catch(function() {
435
439
  reject(file);
436
440
  });
437
441
  } else if (promise === false) {
@@ -447,7 +451,7 @@ export default {
447
451
  toLogin(loginFormUrl, originalUrl, originalMethod) {
448
452
  $upload.css('visibility', 'unset');
449
453
  // 从当前应用登录表单地址
450
- rpc.get('/authentication/login-url', function (loginUrl) {
454
+ rpc.get('/authentication/login-url', function(loginUrl) {
451
455
  if (loginUrl) {
452
456
  // 默认登录后跳转回当前页面
453
457
  loginUrl += loginUrl.contains('?') ? '&' : '?';
@@ -543,14 +547,14 @@ export default {
543
547
  }
544
548
  },
545
549
  removeFile(file) {
546
- this.files.remove(function (f) {
550
+ this.files.remove(function(f) {
547
551
  return file.uid === f.uid;
548
552
  });
549
553
  this.$refs.upload.handleRemove(file);
550
554
  if (!this.fileNumExceed) {
551
555
  this.handleErrors([]); // 移除一个文件后,此时如果有错误提示则一定为数量超限,需清空错误提示
552
556
  let container = $('#' + this.id);
553
- this.$nextTick(function () {
557
+ this.$nextTick(function() {
554
558
  // 去掉文件列表的样式,以免其占高度
555
559
  $('.el-upload-list', container).removeAttr('style');
556
560
  // 恢复添加框默认样式
@@ -575,7 +579,7 @@ export default {
575
579
  const image = new Image();
576
580
  image.src = url;
577
581
  const _this = this;
578
- image.onload = function () {
582
+ image.onload = function() {
579
583
  file.width = image.width;
580
584
  file.height = image.height;
581
585
  _this._doPreviewImage(file);
package/src/tnxvue-cli.js CHANGED
@@ -56,7 +56,7 @@ module.exports = {
56
56
  });
57
57
  }
58
58
  }
59
- if (patterns?.length) {
59
+ if (patterns && patterns.length) {
60
60
  pluginPatterns = pluginPatterns.concat(patterns);
61
61
  }
62
62
  config.plugins.push(new CopyWebpackPlugin({patterns: pluginPatterns}));
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 基于Vue的路由器构建函数
3
3
  */
4
- import {FunctionUtil, NetUtil} from '@truenewx/tnxcore/src/tnxcore-util';
4
+ import { FunctionUtil, NetUtil } from '@truenewx/tnxcore/src/tnxcore-util';
5
5
 
6
6
  function addRoute(routes, superiorPath, item, fnImportPage) {
7
7
  if (item && item.path) {
@@ -59,11 +59,11 @@ function getCurrentRoute(router) {
59
59
  return router.currentRoute._value;
60
60
  }
61
61
 
62
- export default function (VueRouter, menu, fnImportPage) {
62
+ export default function(VueRouter, menu, fnImportPage) {
63
63
  let items;
64
64
  if (Array.isArray(menu)) {
65
65
  items = [];
66
- menu.forEach(function (m) {
66
+ menu.forEach(function(m) {
67
67
  items = items.concat(m.items);
68
68
  });
69
69
  } else {
@@ -84,7 +84,7 @@ export default function (VueRouter, menu, fnImportPage) {
84
84
  // if (window.history && window.history.pushState) {
85
85
  // window.history.pushState(null, null, document.URL);
86
86
  // }
87
- window.addEventListener('popstate', function () {
87
+ window.addEventListener('popstate', function() {
88
88
  let $route = getCurrentRoute(router);
89
89
  if ($route) {
90
90
  $route.meta.historyFrom = router.history.state.forward;
@@ -93,7 +93,7 @@ export default function (VueRouter, menu, fnImportPage) {
93
93
 
94
94
  // 注册离开页面前事件处理支持
95
95
  router.$beforeLeaveHandlers = {};
96
- router.beforeLeave = function (handler) {
96
+ router.beforeLeave = function(handler) {
97
97
  if (typeof handler === 'function') {
98
98
  let $route = getCurrentRoute(router);
99
99
  let path = $route.path;
@@ -101,7 +101,7 @@ export default function (VueRouter, menu, fnImportPage) {
101
101
  }
102
102
  };
103
103
 
104
- router.beforeEach(function (to, from, next) {
104
+ router.beforeEach(function(to, from, next) {
105
105
  if (typeof window.tnx.router.beforeLeave === 'function') {
106
106
  window.tnx.router.beforeLeave(router, from);
107
107
  }
@@ -118,7 +118,7 @@ export default function (VueRouter, menu, fnImportPage) {
118
118
  }
119
119
  });
120
120
 
121
- router.afterEach(function (to, from) {
121
+ router.afterEach(function(to, from) {
122
122
  router.prev = from;
123
123
  // 前后hash相同,但全路径不同(意味着参数不同),则需要刷新页面,否则页面不会刷新
124
124
  if (to.href === from.href && to.fullPath !== from.fullPath) {
@@ -126,8 +126,8 @@ export default function (VueRouter, menu, fnImportPage) {
126
126
  }
127
127
  });
128
128
 
129
- router.back = FunctionUtil.around(router.back, function (back, path) {
130
- if (!router.prev?.href) { // 没有href,说明当前页面为刷新后进入的第一个页面,无法简单返回
129
+ router.back = FunctionUtil.around(router.back, function(back, path) {
130
+ if (!router.prev || !router.prev.href) { // 没有href,说明当前页面为刷新后进入的第一个页面,无法简单返回
131
131
  let $route = getCurrentRoute(router);
132
132
  if (!path) { // 未指定默认返回路径,则返回上一级页面
133
133
  path = $route.meta.superiorPath;
@@ -141,7 +141,7 @@ export default function (VueRouter, menu, fnImportPage) {
141
141
  back.call(router);
142
142
  });
143
143
 
144
- router.pushState = function (path) {
144
+ router.pushState = function(path) {
145
145
  let success = NetUtil.pushState('#' + path);
146
146
  if (!success) {
147
147
  this.push(path);
@@ -149,7 +149,7 @@ export default function (VueRouter, menu, fnImportPage) {
149
149
  return success;
150
150
  }
151
151
 
152
- router.replaceState = function (path) {
152
+ router.replaceState = function(path) {
153
153
  let success = NetUtil.replaceState('#' + path);
154
154
  if (!success) {
155
155
  this.replace(path);
@@ -317,7 +317,7 @@ function getRule(validationName, validationValue, fieldMeta) {
317
317
  if (rule) {
318
318
  rule.name = validationName;
319
319
  let metaType = 'text';
320
- if (fieldMeta?.type) {
320
+ if (fieldMeta && fieldMeta.type) {
321
321
  metaType = fieldMeta.type.toLowerCase();
322
322
  }
323
323
  rule.type = rule.type || getRuleType(metaType);
@@ -359,7 +359,7 @@ export default {
359
359
  validateRegExp: validator.validateRegExp,
360
360
  getRule,
361
361
  getRules,
362
- validate: function (rules, source, callback) {
362
+ validate: function(rules, source, callback) {
363
363
  return new AsyncValidator(rules).validate(source, callback);
364
364
  },
365
365
  }
package/src/tnxvue.js CHANGED
@@ -27,9 +27,6 @@ const components = {
27
27
  };
28
28
 
29
29
  const tnxvue = Object.assign({}, tnxcore, {
30
- libs: Object.assign({}, tnxcore.libs, {
31
- Vue: Vue
32
- }),
33
30
  components,
34
31
  router: {
35
32
  instance: null,
@@ -52,7 +49,7 @@ const tnxvue = Object.assign({}, tnxcore, {
52
49
  }
53
50
  vm.config.unwrapInjectedRef = true;
54
51
  window.tnx.app.eventBus = mitt();
55
- window.tnx.app.eventBus.once = function (name, handler) {
52
+ window.tnx.app.eventBus.once = function(name, handler) {
56
53
  this.all.set(name, [handler]);
57
54
  }
58
55
  return vm;
@@ -62,6 +59,7 @@ const tnxvue = Object.assign({}, tnxcore, {
62
59
  const component = this.components[key];
63
60
  vm.component(component.name, component);
64
61
  }
62
+ this.libs.Vue = Vue;
65
63
  },
66
64
  dialog(content, title, buttons, options, contentProps) {
67
65
  // 默认不实现,由UI框架扩展层实现
@@ -75,11 +73,13 @@ const tnxvue = Object.assign({}, tnxcore, {
75
73
  options = options || {};
76
74
 
77
75
  let mode = options.mode;
78
- if (component.methods?.dialog) {
79
- options = Object.assign({}, component.methods.dialog(props), options);
80
- } else if (component.methods?.drawer) {
81
- options = Object.assign({}, component.methods.drawer(props), options);
82
- mode = 'drawer';
76
+ if (component.methods) {
77
+ if (component.methods.dialog) {
78
+ options = Object.assign({}, component.methods.dialog(props), options);
79
+ } else if (component.methods.drawer) {
80
+ options = Object.assign({}, component.methods.drawer(props), options);
81
+ mode = 'drawer';
82
+ }
83
83
  }
84
84
 
85
85
  const title = component.title || options.title;
@@ -147,19 +147,19 @@ Object.assign(tnxvue.util, {
147
147
  * @param obj 对象
148
148
  * @returns {boolean} 是否组件实例
149
149
  */
150
- isComponent: function (obj) {
150
+ isComponent: function(obj) {
151
151
  return (typeof obj === 'object') && (typeof obj.render === 'function');
152
152
  }
153
153
  });
154
154
 
155
- tnxvue.app.isProduction = function () {
155
+ tnxvue.app.isProduction = function() {
156
156
  if (process && process.env && process.env.NODE_ENV !== 'production') {
157
157
  return false;
158
158
  }
159
159
  return true;
160
160
  };
161
161
 
162
- tnxvue.app.toDevUrl = function (url, portIndex, replacement) {
162
+ tnxvue.app.toDevUrl = function(url, portIndex, replacement) {
163
163
  if (!this.isProduction()) {
164
164
  let index = url.indexOf(':', url.indexOf('//'));
165
165
  if (index > 0) { // 必须带有端口号才可替换
@@ -185,8 +185,8 @@ tnxvue.app.toDevUrl = function (url, portIndex, replacement) {
185
185
 
186
186
  // 元数据到async-validator组件规则的转换处理
187
187
  tnxvue.app.validator = validator;
188
- tnxvue.app.rpc.getMeta = tnxvue.util.function.around(tnxvue.app.rpc.getMeta, function (getMeta, url, callback, app) {
189
- getMeta.call(tnxvue.app.rpc, url, function (meta) {
188
+ tnxvue.app.rpc.getMeta = tnxvue.util.function.around(tnxvue.app.rpc.getMeta, function(getMeta, url, callback, app) {
189
+ getMeta.call(tnxvue.app.rpc, url, function(meta) {
190
190
  if (meta) { // meta已被缓存,所以直接修改其内容,以便同步缓存
191
191
  meta.$rules = validator.getRules(meta);
192
192
  if (typeof callback === 'function') {
@@ -196,7 +196,7 @@ tnxvue.app.rpc.getMeta = tnxvue.util.function.around(tnxvue.app.rpc.getMeta, fun
196
196
  }, app);
197
197
  });
198
198
 
199
- tnxvue.app.page.init = tnxvue.util.function.around(tnxvue.app.page.init, function (init, page, container) {
199
+ tnxvue.app.page.init = tnxvue.util.function.around(tnxvue.app.page.init, function(init, page, container) {
200
200
  if (container.tagName === 'BODY') { // vue不推荐以body为挂载目标,故从body下获取第一个div作为容器
201
201
  for (let i = 0; i < container.children.length; i++) {
202
202
  const child = container.children[i];
@@ -210,22 +210,22 @@ tnxvue.app.page.init = tnxvue.util.function.around(tnxvue.app.page.init, functio
210
210
  });
211
211
 
212
212
  Object.assign(tnxvue.app.page, {
213
- startCache: function (router, model, intervalMillis, ignoredFields) {
213
+ startCache: function(router, model, intervalMillis, ignoredFields) {
214
214
  if (localStorage && intervalMillis && intervalMillis > 1000) { // 缓存间隔必须超过1秒
215
- let path = this._readCache(router, undefined, function (cache) {
215
+ let path = this._readCache(router, undefined, function(cache) {
216
216
  Object.assign(model, cache.model);
217
217
  });
218
218
 
219
219
  if (path) {
220
220
  let _this = this;
221
- let intervalId = setInterval(function () {
221
+ let intervalId = setInterval(function() {
222
222
  _this._storeCache(router, path, intervalId, model, ignoredFields);
223
223
  }, intervalMillis);
224
224
  }
225
225
  }
226
226
  return model;
227
227
  },
228
- _readCache: function (router, path, callback) {
228
+ _readCache: function(router, path, callback) {
229
229
  if (localStorage) {
230
230
  path = path || router.app.$route.path || '/';
231
231
  let cache = localStorage[path];
@@ -238,7 +238,7 @@ Object.assign(tnxvue.app.page, {
238
238
  return path;
239
239
  }
240
240
  },
241
- _storeCache: function (router, path, intervalId, model, ignoredFields) {
241
+ _storeCache: function(router, path, intervalId, model, ignoredFields) {
242
242
  if (path && intervalId) {
243
243
  let data = {};
244
244
  if (Array.isArray(ignoredFields) && ignoredFields.length) {
@@ -257,21 +257,21 @@ Object.assign(tnxvue.app.page, {
257
257
  });
258
258
  }
259
259
  },
260
- saveCache: function (router, model) {
260
+ saveCache: function(router, model) {
261
261
  let intervalId;
262
262
  let ignoredFields;
263
- let path = this._readCache(router, undefined, function (cache) {
263
+ let path = this._readCache(router, undefined, function(cache) {
264
264
  intervalId = cache.intervalId;
265
265
  ignoredFields = cache.ignored;
266
266
  });
267
267
  this._storeCache(router, path, intervalId, model, ignoredFields);
268
268
  },
269
- stopCache: function (router, path) {
270
- return this._readCache(router, path, function (cache) {
269
+ stopCache: function(router, path) {
270
+ return this._readCache(router, path, function(cache) {
271
271
  clearInterval(cache.intervalId);
272
272
  });
273
273
  },
274
- clearCache: function (router) {
274
+ clearCache: function(router) {
275
275
  let path = this.stopCache(router);
276
276
  if (path) {
277
277
  delete localStorage[path];
@@ -283,7 +283,7 @@ Object.assign(tnxvue.app.page, {
283
283
  * @param refs 页面中的组件引用集
284
284
  * @param validFieldNames 有效的字段名称集,如有指定则清除模型中的无效字段
285
285
  */
286
- toCommandModel: function (vm, model, validFieldNames) {
286
+ toCommandModel: function(vm, model, validFieldNames) {
287
287
  let result = {};
288
288
  if (model) {
289
289
  if (vm.$refs) {
@@ -315,14 +315,14 @@ Object.assign(tnxvue.app.page, {
315
315
  * 转换多层嵌入字段数据使其符合前端页面模型的基本要求
316
316
  * @param model 服务端视图模型
317
317
  */
318
- toPageModel: function (model) {
318
+ toPageModel: function(model) {
319
319
  let expanded = this._expandRefFields(model);
320
320
  while (expanded) {
321
321
  expanded = this._expandRefFields(model);
322
322
  }
323
323
  return model;
324
324
  },
325
- _expandRefFields: function (model) {
325
+ _expandRefFields: function(model) {
326
326
  let expanded = false;
327
327
  Object.keys(model).forEach(key => {
328
328
  let value = model[key];