@truenewx/tnxvue3 2.6.1 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truenewx/tnxvue3",
3
- "version": "2.6.1",
3
+ "version": "2.6.2",
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 {
@@ -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
@@ -52,7 +52,7 @@ const tnxvue = Object.assign({}, tnxcore, {
52
52
  }
53
53
  vm.config.unwrapInjectedRef = true;
54
54
  window.tnx.app.eventBus = mitt();
55
- window.tnx.app.eventBus.once = function (name, handler) {
55
+ window.tnx.app.eventBus.once = function(name, handler) {
56
56
  this.all.set(name, [handler]);
57
57
  }
58
58
  return vm;
@@ -75,11 +75,13 @@ const tnxvue = Object.assign({}, tnxcore, {
75
75
  options = options || {};
76
76
 
77
77
  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';
78
+ if (component.methods) {
79
+ if (component.methods.dialog) {
80
+ options = Object.assign({}, component.methods.dialog(props), options);
81
+ } else if (component.methods.drawer) {
82
+ options = Object.assign({}, component.methods.drawer(props), options);
83
+ mode = 'drawer';
84
+ }
83
85
  }
84
86
 
85
87
  const title = component.title || options.title;
@@ -147,19 +149,19 @@ Object.assign(tnxvue.util, {
147
149
  * @param obj 对象
148
150
  * @returns {boolean} 是否组件实例
149
151
  */
150
- isComponent: function (obj) {
152
+ isComponent: function(obj) {
151
153
  return (typeof obj === 'object') && (typeof obj.render === 'function');
152
154
  }
153
155
  });
154
156
 
155
- tnxvue.app.isProduction = function () {
157
+ tnxvue.app.isProduction = function() {
156
158
  if (process && process.env && process.env.NODE_ENV !== 'production') {
157
159
  return false;
158
160
  }
159
161
  return true;
160
162
  };
161
163
 
162
- tnxvue.app.toDevUrl = function (url, portIndex, replacement) {
164
+ tnxvue.app.toDevUrl = function(url, portIndex, replacement) {
163
165
  if (!this.isProduction()) {
164
166
  let index = url.indexOf(':', url.indexOf('//'));
165
167
  if (index > 0) { // 必须带有端口号才可替换
@@ -185,8 +187,8 @@ tnxvue.app.toDevUrl = function (url, portIndex, replacement) {
185
187
 
186
188
  // 元数据到async-validator组件规则的转换处理
187
189
  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) {
190
+ tnxvue.app.rpc.getMeta = tnxvue.util.function.around(tnxvue.app.rpc.getMeta, function(getMeta, url, callback, app) {
191
+ getMeta.call(tnxvue.app.rpc, url, function(meta) {
190
192
  if (meta) { // meta已被缓存,所以直接修改其内容,以便同步缓存
191
193
  meta.$rules = validator.getRules(meta);
192
194
  if (typeof callback === 'function') {
@@ -196,7 +198,7 @@ tnxvue.app.rpc.getMeta = tnxvue.util.function.around(tnxvue.app.rpc.getMeta, fun
196
198
  }, app);
197
199
  });
198
200
 
199
- tnxvue.app.page.init = tnxvue.util.function.around(tnxvue.app.page.init, function (init, page, container) {
201
+ tnxvue.app.page.init = tnxvue.util.function.around(tnxvue.app.page.init, function(init, page, container) {
200
202
  if (container.tagName === 'BODY') { // vue不推荐以body为挂载目标,故从body下获取第一个div作为容器
201
203
  for (let i = 0; i < container.children.length; i++) {
202
204
  const child = container.children[i];
@@ -210,22 +212,22 @@ tnxvue.app.page.init = tnxvue.util.function.around(tnxvue.app.page.init, functio
210
212
  });
211
213
 
212
214
  Object.assign(tnxvue.app.page, {
213
- startCache: function (router, model, intervalMillis, ignoredFields) {
215
+ startCache: function(router, model, intervalMillis, ignoredFields) {
214
216
  if (localStorage && intervalMillis && intervalMillis > 1000) { // 缓存间隔必须超过1秒
215
- let path = this._readCache(router, undefined, function (cache) {
217
+ let path = this._readCache(router, undefined, function(cache) {
216
218
  Object.assign(model, cache.model);
217
219
  });
218
220
 
219
221
  if (path) {
220
222
  let _this = this;
221
- let intervalId = setInterval(function () {
223
+ let intervalId = setInterval(function() {
222
224
  _this._storeCache(router, path, intervalId, model, ignoredFields);
223
225
  }, intervalMillis);
224
226
  }
225
227
  }
226
228
  return model;
227
229
  },
228
- _readCache: function (router, path, callback) {
230
+ _readCache: function(router, path, callback) {
229
231
  if (localStorage) {
230
232
  path = path || router.app.$route.path || '/';
231
233
  let cache = localStorage[path];
@@ -238,7 +240,7 @@ Object.assign(tnxvue.app.page, {
238
240
  return path;
239
241
  }
240
242
  },
241
- _storeCache: function (router, path, intervalId, model, ignoredFields) {
243
+ _storeCache: function(router, path, intervalId, model, ignoredFields) {
242
244
  if (path && intervalId) {
243
245
  let data = {};
244
246
  if (Array.isArray(ignoredFields) && ignoredFields.length) {
@@ -257,21 +259,21 @@ Object.assign(tnxvue.app.page, {
257
259
  });
258
260
  }
259
261
  },
260
- saveCache: function (router, model) {
262
+ saveCache: function(router, model) {
261
263
  let intervalId;
262
264
  let ignoredFields;
263
- let path = this._readCache(router, undefined, function (cache) {
265
+ let path = this._readCache(router, undefined, function(cache) {
264
266
  intervalId = cache.intervalId;
265
267
  ignoredFields = cache.ignored;
266
268
  });
267
269
  this._storeCache(router, path, intervalId, model, ignoredFields);
268
270
  },
269
- stopCache: function (router, path) {
270
- return this._readCache(router, path, function (cache) {
271
+ stopCache: function(router, path) {
272
+ return this._readCache(router, path, function(cache) {
271
273
  clearInterval(cache.intervalId);
272
274
  });
273
275
  },
274
- clearCache: function (router) {
276
+ clearCache: function(router) {
275
277
  let path = this.stopCache(router);
276
278
  if (path) {
277
279
  delete localStorage[path];
@@ -283,7 +285,7 @@ Object.assign(tnxvue.app.page, {
283
285
  * @param refs 页面中的组件引用集
284
286
  * @param validFieldNames 有效的字段名称集,如有指定则清除模型中的无效字段
285
287
  */
286
- toCommandModel: function (vm, model, validFieldNames) {
288
+ toCommandModel: function(vm, model, validFieldNames) {
287
289
  let result = {};
288
290
  if (model) {
289
291
  if (vm.$refs) {
@@ -315,14 +317,14 @@ Object.assign(tnxvue.app.page, {
315
317
  * 转换多层嵌入字段数据使其符合前端页面模型的基本要求
316
318
  * @param model 服务端视图模型
317
319
  */
318
- toPageModel: function (model) {
320
+ toPageModel: function(model) {
319
321
  let expanded = this._expandRefFields(model);
320
322
  while (expanded) {
321
323
  expanded = this._expandRefFields(model);
322
324
  }
323
325
  return model;
324
326
  },
325
- _expandRefFields: function (model) {
327
+ _expandRefFields: function(model) {
326
328
  let expanded = false;
327
329
  Object.keys(model).forEach(key => {
328
330
  let value = model[key];