@truenewx/tnxvue3 2.6.0 → 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 +5 -4
- package/src/element-plus/dialog/Dialog.vue +6 -6
- package/src/element-plus/fss-upload/FssUpload.vue +11 -7
- package/src/element-plus/input-number/InputNumber.vue +150 -150
- package/src/element-plus/query-table/QueryTable.vue +9 -9
- package/src/element-plus/select/Select.vue +4 -4
- package/src/element-plus/upload/Upload.vue +21 -17
- package/src/tnxvue-cli.js +1 -1
- package/src/tnxvue-router.js +11 -11
- package/src/tnxvue-validator.js +2 -2
- package/src/tnxvue.js +27 -25
- package/sample/App.vue +0 -19
- package/sample/main.js +0 -11
- package/sample/pages/index.vue +0 -79
- package/sample/pages/info.vue +0 -28
- package/sample/tnx.js +0 -31
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truenewx/tnxvue3",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"description": "互联网技术解决方案:Vue3扩展支持",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
|
-
"main": "
|
|
9
|
+
"main": "src/tnxvue.js",
|
|
10
10
|
"keywords": [
|
|
11
11
|
"truenewx",
|
|
12
12
|
"tnxvue3",
|
|
@@ -30,8 +30,9 @@
|
|
|
30
30
|
"vue-router": "4.1.6"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@babel/core": "7.
|
|
34
|
-
"@babel/eslint-parser": "7.
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
75
|
-
let append = this.$slots.append();
|
|
76
|
-
if (append
|
|
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><空></span>
|
|
29
29
|
</template>
|
|
30
|
-
<template #append v-if="records
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
package/src/tnxvue-router.js
CHANGED
|
@@ -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
|
|
62
|
+
export default function(VueRouter, menu, fnImportPage) {
|
|
63
63
|
let items;
|
|
64
64
|
if (Array.isArray(menu)) {
|
|
65
65
|
items = [];
|
|
66
|
-
menu.forEach(function
|
|
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
|
|
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
|
|
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
|
|
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
|
|
130
|
-
if (!router.prev
|
|
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
|
|
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
|
|
152
|
+
router.replaceState = function(path) {
|
|
153
153
|
let success = NetUtil.replaceState('#' + path);
|
|
154
154
|
if (!success) {
|
|
155
155
|
this.replace(path);
|
package/src/tnxvue-validator.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
|
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
|
|
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
|
|
189
|
-
getMeta.call(tnxvue.app.rpc, url, function
|
|
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
|
|
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
|
|
215
|
+
startCache: function(router, model, intervalMillis, ignoredFields) {
|
|
214
216
|
if (localStorage && intervalMillis && intervalMillis > 1000) { // 缓存间隔必须超过1秒
|
|
215
|
-
let path = this._readCache(router, undefined, function
|
|
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
|
|
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
|
|
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
|
|
262
|
+
saveCache: function(router, model) {
|
|
261
263
|
let intervalId;
|
|
262
264
|
let ignoredFields;
|
|
263
|
-
let path = this._readCache(router, undefined, function
|
|
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
|
|
270
|
-
return this._readCache(router, path, function
|
|
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
|
|
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
|
|
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
|
|
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
|
|
327
|
+
_expandRefFields: function(model) {
|
|
326
328
|
let expanded = false;
|
|
327
329
|
Object.keys(model).forEach(key => {
|
|
328
330
|
let value = model[key];
|
package/sample/App.vue
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div id="app">
|
|
3
|
-
<page-index/>
|
|
4
|
-
</div>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script>
|
|
8
|
-
import index from './pages/index.vue';
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
name: 'App',
|
|
12
|
-
components: {
|
|
13
|
-
'page-index': index,
|
|
14
|
-
},
|
|
15
|
-
data() {
|
|
16
|
-
return {}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
</script>
|
package/sample/main.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import '../../core/tnxcore.css';
|
|
2
|
-
import 'bootstrap/dist/css/bootstrap-reboot.min.css';
|
|
3
|
-
import 'bootstrap/dist/css/bootstrap-grid.min.css';
|
|
4
|
-
import 'bootstrap/dist/css/bootstrap-utilities.min.css';
|
|
5
|
-
import '../src/tnxvue.css';
|
|
6
|
-
import 'element-plus/dist/index.css';
|
|
7
|
-
import '../src/element-plus/tnxel.css';
|
|
8
|
-
import tnx from './tnx';
|
|
9
|
-
import App from './App.vue';
|
|
10
|
-
|
|
11
|
-
tnx.createVueInstance(App).mount('#app');
|
package/sample/pages/index.vue
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="container-xl mx-auto flex-h-center">
|
|
3
|
-
<div class="text-center">
|
|
4
|
-
<h1>{{ title }}</h1>
|
|
5
|
-
<p>首页</p>
|
|
6
|
-
<el-space wrap>
|
|
7
|
-
<el-button @click="showAlert">Alert</el-button>
|
|
8
|
-
<el-button @click="showSuccess">Success</el-button>
|
|
9
|
-
<el-button @click="showError">Error</el-button>
|
|
10
|
-
<el-button @click="showConfirm">Confirm</el-button>
|
|
11
|
-
<el-button @click="showToast">Toast</el-button>
|
|
12
|
-
<el-button @click="showLoading">Loading</el-button>
|
|
13
|
-
<el-button @click="showOpen">Open</el-button>
|
|
14
|
-
</el-space>
|
|
15
|
-
<div class="mt-5">
|
|
16
|
-
<tnxel-fss-upload type="UserHeadImage" v-model="storageUrl"/>
|
|
17
|
-
</div>
|
|
18
|
-
</div>
|
|
19
|
-
</div>
|
|
20
|
-
</template>
|
|
21
|
-
|
|
22
|
-
<script>
|
|
23
|
-
import {app, tnx} from '../tnx.js';
|
|
24
|
-
import info from './info.vue';
|
|
25
|
-
|
|
26
|
-
export default {
|
|
27
|
-
components: {
|
|
28
|
-
'tnxel-fss-upload': tnx.components.FssUpload,
|
|
29
|
-
},
|
|
30
|
-
data() {
|
|
31
|
-
return {
|
|
32
|
-
title: process.env.VUE_APP_TITLE,
|
|
33
|
-
storageUrl: null,
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
created() {
|
|
37
|
-
app.rpc.loadConfig(process.env.VUE_APP_API_BASE_URL);
|
|
38
|
-
},
|
|
39
|
-
methods: {
|
|
40
|
-
showAlert() {
|
|
41
|
-
tnx.alert('Hello World', function() {
|
|
42
|
-
console.info('Alerted');
|
|
43
|
-
});
|
|
44
|
-
},
|
|
45
|
-
showSuccess() {
|
|
46
|
-
tnx.success('提交成功,请等待组织管理员为你分配角色,获得组织角色后方可使用组织功能。', function() {
|
|
47
|
-
console.info('Successed');
|
|
48
|
-
});
|
|
49
|
-
},
|
|
50
|
-
showError() {
|
|
51
|
-
tnx.error('Hello World', function() {
|
|
52
|
-
console.info('Errored');
|
|
53
|
-
});
|
|
54
|
-
},
|
|
55
|
-
showConfirm() {
|
|
56
|
-
tnx.confirm('Hello World', function(yes) {
|
|
57
|
-
console.info(yes);
|
|
58
|
-
});
|
|
59
|
-
},
|
|
60
|
-
showToast() {
|
|
61
|
-
tnx.toast('操作成功', 200000, function() {
|
|
62
|
-
console.info('Toast closed.');
|
|
63
|
-
});
|
|
64
|
-
},
|
|
65
|
-
showLoading() {
|
|
66
|
-
tnx.showLoading('加载中');
|
|
67
|
-
setTimeout(function() {
|
|
68
|
-
tnx.closeLoading();
|
|
69
|
-
}, 2000);
|
|
70
|
-
},
|
|
71
|
-
showOpen() {
|
|
72
|
-
tnx.open(info, {
|
|
73
|
-
param: '- from params',
|
|
74
|
-
opener: this,
|
|
75
|
-
});
|
|
76
|
-
},
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
</script>
|
package/sample/pages/info.vue
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<p>Component: Hello World {{ param }}</p>
|
|
4
|
-
</div>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script>
|
|
8
|
-
export default {
|
|
9
|
-
props: ['param', 'opener'],
|
|
10
|
-
data() {
|
|
11
|
-
return {
|
|
12
|
-
abc: 'abc',
|
|
13
|
-
};
|
|
14
|
-
},
|
|
15
|
-
methods: {
|
|
16
|
-
dialog() {
|
|
17
|
-
return {
|
|
18
|
-
title: '组件',
|
|
19
|
-
type: 'confirm',
|
|
20
|
-
click: this.toSubmit
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
toSubmit(yes, close) {
|
|
24
|
-
console.info(this.abc + ': ' + yes);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
</script>
|
package/sample/tnx.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// tnx.js
|
|
2
|
-
import tnxel from '../src/element-plus/tnxel';
|
|
3
|
-
|
|
4
|
-
export const tnx = tnxel;
|
|
5
|
-
export const util = tnx.util;
|
|
6
|
-
export const app = tnx.app;
|
|
7
|
-
|
|
8
|
-
app.rpc.toLogin = function (loginFormUrl, originalUrl) {
|
|
9
|
-
if (loginFormUrl) {
|
|
10
|
-
let alertable = originalUrl !== undefined;
|
|
11
|
-
const username = process.env.VUE_APP_LOGIN_USERNAME;
|
|
12
|
-
const password = process.env.VUE_APP_LOGIN_PASSWORD;
|
|
13
|
-
if (username && password) { // 将默认用户名密码插入到参数清单头部,以免被其它参数中的#影响而被忽略
|
|
14
|
-
const index = loginFormUrl.indexOf('?') + 1;
|
|
15
|
-
loginFormUrl = loginFormUrl.substr(0, index) + 'username=' + username + '&password='
|
|
16
|
-
+ password + '&' + loginFormUrl.substr(index);
|
|
17
|
-
alertable = false;
|
|
18
|
-
}
|
|
19
|
-
if (alertable) {
|
|
20
|
-
tnx.alert('尚未登录或登录会话已过期,需重新登录', function () {
|
|
21
|
-
window.location.href = loginFormUrl;
|
|
22
|
-
});
|
|
23
|
-
} else {
|
|
24
|
-
window.location.href = loginFormUrl;
|
|
25
|
-
}
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export default tnx;
|