vue2-client 1.6.27 → 1.6.28
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/CHANGELOG.md +4 -0
- package/package.json +17 -17
- package/src/base-client/components/common/XForm/XFormItem.vue +591 -592
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue2-client",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.28",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"serve": "vue-cli-service serve",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@amap/amap-jsapi-loader": "^1.0.1",
|
|
15
|
-
"@antv/g2plot": "^2.4.
|
|
15
|
+
"@antv/g2plot": "^2.4.29",
|
|
16
16
|
"lodash.get": "^4.4.2",
|
|
17
|
-
"js-base64": "^3.7.
|
|
18
|
-
"jsencrypt": "^3.2
|
|
17
|
+
"js-base64": "^3.7.5",
|
|
18
|
+
"jsencrypt": "^3.3.2",
|
|
19
19
|
"vue-json-viewer": "^2.2.22",
|
|
20
20
|
"xlsx": "0.18.5",
|
|
21
21
|
"file-saver": "^2.0.5",
|
|
@@ -25,37 +25,37 @@
|
|
|
25
25
|
"ant-design-vue": "^1.7.8",
|
|
26
26
|
"axios": "^0.27.2",
|
|
27
27
|
"clipboard": "^2.0.11",
|
|
28
|
-
"core-js": "^3.
|
|
29
|
-
"date-fns": "^2.
|
|
28
|
+
"core-js": "^3.30.1",
|
|
29
|
+
"date-fns": "^2.29.3",
|
|
30
30
|
"default-passive-events": "^2.0.0",
|
|
31
31
|
"enquire.js": "^2.1.6",
|
|
32
|
-
"highlight.js": "^
|
|
32
|
+
"highlight.js": "^11.7.0",
|
|
33
33
|
"js-cookie": "^2.2.1",
|
|
34
34
|
"mockjs": "^1.1.0",
|
|
35
35
|
"nprogress": "^0.2.0",
|
|
36
36
|
"viser-vue": "^2.4.8",
|
|
37
37
|
"vue": "2.6.14",
|
|
38
|
-
"vue-i18n": "^8.
|
|
39
|
-
"vue-router": "^3.5
|
|
38
|
+
"vue-i18n": "^8.28.2",
|
|
39
|
+
"vue-router": "^3.6.5",
|
|
40
40
|
"vuedraggable": "^2.24.3",
|
|
41
41
|
"vuex": "^3.6.2",
|
|
42
|
-
"vue-video-player": "5.0.2",
|
|
43
|
-
"videojs-contrib-hls": "5.
|
|
42
|
+
"vue-video-player": "^5.0.2",
|
|
43
|
+
"videojs-contrib-hls": "^5.15.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"script-loader": "^0.7.2",
|
|
47
|
-
"@ant-design/colors": "^
|
|
48
|
-
"@babel/core": "^7.
|
|
47
|
+
"@ant-design/colors": "^7.0.0",
|
|
48
|
+
"@babel/core": "^7.21.4",
|
|
49
49
|
"@vue/cli-plugin-babel": "^4.5.19",
|
|
50
50
|
"@vue/cli-plugin-eslint": "^4.5.19",
|
|
51
51
|
"@vue/cli-service": "^4.5.19",
|
|
52
52
|
"@vue/eslint-config-standard": "^4.0.0",
|
|
53
|
-
"@vuepress/plugin-back-to-top": "^1.9.
|
|
53
|
+
"@vuepress/plugin-back-to-top": "^1.9.9",
|
|
54
54
|
"babel-eslint": "^10.1.0",
|
|
55
55
|
"babel-plugin-transform-remove-console": "^6.9.4",
|
|
56
56
|
"babel-polyfill": "^6.26.0",
|
|
57
57
|
"compression-webpack-plugin": "^4.0.1",
|
|
58
|
-
"deepmerge": "^4.
|
|
58
|
+
"deepmerge": "^4.3.1",
|
|
59
59
|
"eslint": "^6.8.0",
|
|
60
60
|
"eslint-plugin-import": "^2.26.0",
|
|
61
61
|
"eslint-plugin-node": "^11.1.0",
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"style-resources-loader": "^1.5.0",
|
|
68
68
|
"vue-cli-plugin-style-resources-loader": "^0.1.5",
|
|
69
69
|
"vue-template-compiler": "2.6.14",
|
|
70
|
-
"vuepress": "^1.9.
|
|
70
|
+
"vuepress": "^1.9.9",
|
|
71
71
|
"webpack": "^4.46.0",
|
|
72
|
-
"webpack-theme-color-replacer": "1.4.
|
|
72
|
+
"webpack-theme-color-replacer": "^1.4.7",
|
|
73
73
|
"whatwg-fetch": "^3.6.2"
|
|
74
74
|
},
|
|
75
75
|
"browserslist": [
|
|
@@ -1,592 +1,591 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<!-- 输入框 -->
|
|
3
|
-
<x-form-col
|
|
4
|
-
v-if="attr.type === 'input'"
|
|
5
|
-
:xl="xl"
|
|
6
|
-
:xxl="xxl">
|
|
7
|
-
<a-form-model-item
|
|
8
|
-
:ref="attr.model"
|
|
9
|
-
:label="attr.name"
|
|
10
|
-
:prop="attr.model">
|
|
11
|
-
<a-input v-model="form[attr.model]" :disabled="disabled" :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"/>
|
|
12
|
-
</a-form-model-item>
|
|
13
|
-
</x-form-col>
|
|
14
|
-
<!-- 下拉框 -->
|
|
15
|
-
<x-form-col
|
|
16
|
-
v-else-if="attr.type === 'select'"
|
|
17
|
-
:xl="xl"
|
|
18
|
-
:xxl="xxl">
|
|
19
|
-
<a-form-model-item
|
|
20
|
-
:ref="attr.model"
|
|
21
|
-
:label="attr.name"
|
|
22
|
-
:prop="attr.model">
|
|
23
|
-
<a-select
|
|
24
|
-
v-if="!attr.lazyLoad || attr.lazyLoad === 'false'"
|
|
25
|
-
v-model="form[attr.model]"
|
|
26
|
-
:disabled="disabled"
|
|
27
|
-
:filter-option="filterOption"
|
|
28
|
-
:getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
|
|
29
|
-
:placeholder="attr.placeholder ? attr.placeholder : '请选择'"
|
|
30
|
-
show-search
|
|
31
|
-
>
|
|
32
|
-
<a-select-option
|
|
33
|
-
v-if="mode === '查询'"
|
|
34
|
-
key="999999"
|
|
35
|
-
value="全部">全部
|
|
36
|
-
</a-select-option>
|
|
37
|
-
<template v-if="attr.keys">
|
|
38
|
-
<a-select-option
|
|
39
|
-
v-for="(item,index) in attr.keys"
|
|
40
|
-
:key="index"
|
|
41
|
-
:value="item.value">
|
|
42
|
-
{{ item.label }}
|
|
43
|
-
</a-select-option>
|
|
44
|
-
</template>
|
|
45
|
-
<template v-else>
|
|
46
|
-
<template v-if="attr.keyName.indexOf('logic@') !== -1">
|
|
47
|
-
<a-select-option
|
|
48
|
-
v-for="(item,index) in option"
|
|
49
|
-
:key="index"
|
|
50
|
-
:value="item.value">{{ item.label }}
|
|
51
|
-
</a-select-option>
|
|
52
|
-
</template>
|
|
53
|
-
<template v-else>
|
|
54
|
-
<a-select-option
|
|
55
|
-
v-for="item in $appdata.getDictionaryList(attr.keyName)"
|
|
56
|
-
:key="item.value"
|
|
57
|
-
:value="item.value">
|
|
58
|
-
<!-- 徽标(badge) -->
|
|
59
|
-
<x-badge :badge-key="attr.keyName" :replaceText="item.text" :value="item.value"/>
|
|
60
|
-
</a-select-option>
|
|
61
|
-
</template>
|
|
62
|
-
</template>
|
|
63
|
-
</a-select>
|
|
64
|
-
<a-select
|
|
65
|
-
v-else
|
|
66
|
-
v-model="form[attr.model]"
|
|
67
|
-
:disabled="disabled"
|
|
68
|
-
:filter-option="filterOption"
|
|
69
|
-
:getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
|
|
70
|
-
:placeholder="attr.placeholder ? attr.placeholder : '搜索' + attr.name"
|
|
71
|
-
show-search
|
|
72
|
-
@search="fetchFunction"
|
|
73
|
-
>
|
|
74
|
-
<a-spin v-if="searching" slot="notFoundContent" size="small" />
|
|
75
|
-
<a-select-option
|
|
76
|
-
v-if="mode === '查询'"
|
|
77
|
-
key="999999"
|
|
78
|
-
value="全部">全部
|
|
79
|
-
</a-select-option>
|
|
80
|
-
<a-select-option
|
|
81
|
-
v-for="(item,index) in option"
|
|
82
|
-
:key="index"
|
|
83
|
-
:value="item.value">{{ item.label }}
|
|
84
|
-
</a-select-option>
|
|
85
|
-
</a-select>
|
|
86
|
-
</a-form-model-item>
|
|
87
|
-
</x-form-col>
|
|
88
|
-
<!-- 多选框 -->
|
|
89
|
-
<x-form-col
|
|
90
|
-
v-else-if="attr.type === 'checkbox'"
|
|
91
|
-
:xl="xl"
|
|
92
|
-
:xxl="xxl">
|
|
93
|
-
<a-form-model-item
|
|
94
|
-
:ref="attr.model"
|
|
95
|
-
:label="attr.name"
|
|
96
|
-
:prop="attr.model">
|
|
97
|
-
<a-select
|
|
98
|
-
v-if="!attr.lazyLoad || attr.lazyLoad === 'false'"
|
|
99
|
-
v-model="form[attr.model]"
|
|
100
|
-
:disabled="disabled"
|
|
101
|
-
:filter-option="filterOption"
|
|
102
|
-
:getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
|
|
103
|
-
:placeholder="attr.placeholder ? attr.placeholder : '请选择'"
|
|
104
|
-
mode="multiple"
|
|
105
|
-
show-search
|
|
106
|
-
allowClear
|
|
107
|
-
>
|
|
108
|
-
<template v-if="attr.keys">
|
|
109
|
-
<a-select-option
|
|
110
|
-
v-for="(item,index) in attr.keys"
|
|
111
|
-
:key="index"
|
|
112
|
-
:value="item.value">
|
|
113
|
-
{{ item.label }}
|
|
114
|
-
</a-select-option>
|
|
115
|
-
</template>
|
|
116
|
-
<template v-else>
|
|
117
|
-
<template v-if="attr.keyName.indexOf('logic@') !== -1">
|
|
118
|
-
<a-select-option
|
|
119
|
-
v-for="(item,index) in option"
|
|
120
|
-
:key="index"
|
|
121
|
-
:value="item.value">{{ item.label }}
|
|
122
|
-
</a-select-option>
|
|
123
|
-
</template>
|
|
124
|
-
<template v-else>
|
|
125
|
-
<a-select-option
|
|
126
|
-
v-for="item in $appdata.getDictionaryList(attr.keyName)"
|
|
127
|
-
:key="item.value"
|
|
128
|
-
:value="item.value">{{ item.text }}
|
|
129
|
-
</a-select-option>
|
|
130
|
-
</template>
|
|
131
|
-
</template>
|
|
132
|
-
</a-select>
|
|
133
|
-
<a-select
|
|
134
|
-
v-else
|
|
135
|
-
v-model="form[attr.model]"
|
|
136
|
-
:disabled="disabled"
|
|
137
|
-
:filter-option="filterOption"
|
|
138
|
-
:getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
|
|
139
|
-
:placeholder="attr.placeholder ? attr.placeholder : '搜索' + attr.name"
|
|
140
|
-
mode="multiple"
|
|
141
|
-
show-search
|
|
142
|
-
allowClear
|
|
143
|
-
@search="fetchFunction"
|
|
144
|
-
>
|
|
145
|
-
<a-spin v-if="searching" slot="notFoundContent" size="small" />
|
|
146
|
-
<a-select-option
|
|
147
|
-
v-for="(item,index) in option"
|
|
148
|
-
:key="index"
|
|
149
|
-
:value="item.value">{{ item.label }}
|
|
150
|
-
</a-select-option>
|
|
151
|
-
</a-select>
|
|
152
|
-
</a-form-model-item>
|
|
153
|
-
</x-form-col>
|
|
154
|
-
<!-- TODO 单选框 -->
|
|
155
|
-
<!-- 日期范围选择器 -->
|
|
156
|
-
<x-form-col
|
|
157
|
-
v-else-if="attr.type === 'rangePicker'"
|
|
158
|
-
:xl="xl"
|
|
159
|
-
:xxl="xxl">
|
|
160
|
-
<a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
|
|
161
|
-
<a-range-picker v-model="form[attr.model]" :disabled="disabled" :show-time="true" valueFormat="YYYY-MM-DD HH:mm:ss"/>
|
|
162
|
-
</a-form-model-item>
|
|
163
|
-
</x-form-col>
|
|
164
|
-
<!-- 月份选择器 -->
|
|
165
|
-
<x-form-col
|
|
166
|
-
v-else-if="attr.type === 'monthPicker'"
|
|
167
|
-
:xl="xl"
|
|
168
|
-
:xxl="xxl">
|
|
169
|
-
<a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
|
|
170
|
-
<a-month-picker v-model="form[attr.model]" :disabled="disabled" :show-time="true" valueFormat="YYYY-MM"/>
|
|
171
|
-
</a-form-model-item>
|
|
172
|
-
</x-form-col>
|
|
173
|
-
<!-- 年份选择器 -->
|
|
174
|
-
<x-form-col
|
|
175
|
-
v-else-if="attr.type === 'yearPicker'"
|
|
176
|
-
:xl="xl"
|
|
177
|
-
:xxl="xxl">
|
|
178
|
-
<a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
|
|
179
|
-
<a-date-picker
|
|
180
|
-
v-model="form[attr.model]"
|
|
181
|
-
:disabled="disabled"
|
|
182
|
-
format="YYYY"
|
|
183
|
-
mode="year"
|
|
184
|
-
v-decorator="['year']"
|
|
185
|
-
placeholder="请输入年份"
|
|
186
|
-
:open="yearShowOne"
|
|
187
|
-
@openChange="openChangeOne"
|
|
188
|
-
@panelChange="panelChangeOne"/>
|
|
189
|
-
</a-form-model-item>
|
|
190
|
-
</x-form-col>
|
|
191
|
-
<!-- 日期选择器 -->
|
|
192
|
-
<x-form-col
|
|
193
|
-
v-else-if="attr.type === 'datePicker'"
|
|
194
|
-
:xl="xl"
|
|
195
|
-
:xxl="xxl">
|
|
196
|
-
<a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
|
|
197
|
-
<a-range-picker
|
|
198
|
-
v-if="mode === '查询'"
|
|
199
|
-
v-model="form[attr.model]"
|
|
200
|
-
:disabled="disabled"
|
|
201
|
-
:show-time="{ defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')] }"
|
|
202
|
-
format="YYYY-MM-DD"
|
|
203
|
-
valueFormat="YYYY-MM-DD HH:mm:ss" />
|
|
204
|
-
<a-date-picker v-else v-model="form[attr.model]" :disabled="disabled" :show-time="{ defaultValue: moment('00:00:00', 'HH:mm:ss') }" valueFormat="YYYY-MM-DD HH:mm:ss"/>
|
|
205
|
-
</a-form-model-item>
|
|
206
|
-
</x-form-col>
|
|
207
|
-
<!-- 文本域 -->
|
|
208
|
-
<x-form-col
|
|
209
|
-
v-else-if="attr.type === 'textarea'"
|
|
210
|
-
:lg="24"
|
|
211
|
-
:md="24"
|
|
212
|
-
:sm="24"
|
|
213
|
-
:xl="24"
|
|
214
|
-
:xs="24"
|
|
215
|
-
:xxl="24">
|
|
216
|
-
<a-form-model-item
|
|
217
|
-
:ref="attr.model"
|
|
218
|
-
:label="attr.name"
|
|
219
|
-
:prop="attr.model">
|
|
220
|
-
<a-textarea v-model="form[attr.model]" :disabled="disabled" :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')" :rows="4"/>
|
|
221
|
-
</a-form-model-item>
|
|
222
|
-
</x-form-col>
|
|
223
|
-
<!-- 文件上传 -->
|
|
224
|
-
<x-form-col
|
|
225
|
-
v-else-if="attr.type === 'file' || attr.type === 'image'"
|
|
226
|
-
:lg="24"
|
|
227
|
-
:md="24"
|
|
228
|
-
:sm="24"
|
|
229
|
-
:xl="24"
|
|
230
|
-
:xs="24"
|
|
231
|
-
:xxl="24">
|
|
232
|
-
<a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
|
|
233
|
-
<upload :files="files" :images="images" :model="attr" :service-name="serviceName" @setFiles="setFiles"></upload>
|
|
234
|
-
</a-form-model-item>
|
|
235
|
-
</x-form-col>
|
|
236
|
-
<!-- 省市区选择框 -->
|
|
237
|
-
<x-form-col
|
|
238
|
-
v-else-if="attr.type === 'citySelect'"
|
|
239
|
-
:xl="xl"
|
|
240
|
-
:xxl="xxl">
|
|
241
|
-
<a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
|
|
242
|
-
<citySelect v-model="form[attr.model]" ></citySelect>
|
|
243
|
-
</a-form-model-item>
|
|
244
|
-
</x-form-col>
|
|
245
|
-
<!-- 地点搜索框 -->
|
|
246
|
-
<x-form-col
|
|
247
|
-
v-else-if="attr.type === 'addressSearch'"
|
|
248
|
-
:xl="xl"
|
|
249
|
-
:xxl="xxl">
|
|
250
|
-
<a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
|
|
251
|
-
<address-search-combobox
|
|
252
|
-
v-model="searchResult"
|
|
253
|
-
:resultKeys="{ address: attr.model, coords: `${attr.model}_lng_lat` }"
|
|
254
|
-
searchResultType="Object"
|
|
255
|
-
@onSelect="form=Object.assign(form,JSON.parse(searchResult))"
|
|
256
|
-
></address-search-combobox>
|
|
257
|
-
</a-form-model-item>
|
|
258
|
-
</x-form-col>
|
|
259
|
-
<!-- 人员选择框 -->
|
|
260
|
-
<x-form-col
|
|
261
|
-
v-else-if="attr.type === 'personSetting'"
|
|
262
|
-
:xl="xl"
|
|
263
|
-
:xxl="xxl">
|
|
264
|
-
<a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
|
|
265
|
-
<PersonSetting v-model="form[attr.model]" ></PersonSetting>
|
|
266
|
-
</a-form-model-item>
|
|
267
|
-
</x-form-col>
|
|
268
|
-
<!-- 树形选择框 -->
|
|
269
|
-
<x-form-col
|
|
270
|
-
v-else-if="attr.type === 'treeSelect'"
|
|
271
|
-
:xl="xl"
|
|
272
|
-
:xxl="xxl">
|
|
273
|
-
<a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
|
|
274
|
-
<a-tree-select
|
|
275
|
-
v-model="treeSelectValue"
|
|
276
|
-
:disabled="disabled"
|
|
277
|
-
:tree-data="getTreeData()"
|
|
278
|
-
:tree-checkable="mode === '查询' && attr.queryType !== 'RIGHT_LIKE'"
|
|
279
|
-
:placeholder="'请选择' + attr.name"
|
|
280
|
-
:dropdown-style="{ maxHeight: '400px' }"
|
|
281
|
-
tree-node-filter-prop="label"
|
|
282
|
-
:show-checked-strategy="attr.queryType === 'RIGHT_LIKE' ? 'SHOW_ALL' : undefined"
|
|
283
|
-
allow-clear
|
|
284
|
-
class="tree-select"
|
|
285
|
-
@change="onTreeSelectChange">
|
|
286
|
-
</a-tree-select>
|
|
287
|
-
</a-form-model-item>
|
|
288
|
-
</x-form-col>
|
|
289
|
-
</template>
|
|
290
|
-
<script>
|
|
291
|
-
|
|
292
|
-
import { post } from '@vue2-client/services/api'
|
|
293
|
-
import { debounce } from 'ant-design-vue/lib/vc-table/src/utils'
|
|
294
|
-
import XFormCol from '@vue2-client/base-client/components/common/XFormCol'
|
|
295
|
-
import XBadge from '@vue2-client/base-client/components/common/XBadge'
|
|
296
|
-
import CitySelect from '@vue2-client/base-client/components/common/CitySelect'
|
|
297
|
-
import PersonSetting from '@vue2-client/base-client/components/common/PersonSetting'
|
|
298
|
-
import AddressSearchCombobox from '@vue2-client/base-client/components/common/AddressSearchCombobox'
|
|
299
|
-
import Upload from '@vue2-client/base-client/components/common/Upload'
|
|
300
|
-
import moment from 'moment'
|
|
301
|
-
|
|
302
|
-
export default {
|
|
303
|
-
name: 'XFormItem',
|
|
304
|
-
components: {
|
|
305
|
-
XFormCol,
|
|
306
|
-
XBadge,
|
|
307
|
-
CitySelect,
|
|
308
|
-
PersonSetting,
|
|
309
|
-
AddressSearchCombobox,
|
|
310
|
-
Upload
|
|
311
|
-
},
|
|
312
|
-
data () {
|
|
313
|
-
// 检索去抖
|
|
314
|
-
this.fetchFunction = debounce(this.fetchFunction, 800)
|
|
315
|
-
return {
|
|
316
|
-
option: [],
|
|
317
|
-
// 最后检索版本
|
|
318
|
-
lastFetchId: 0,
|
|
319
|
-
// 检索中
|
|
320
|
-
searching: false,
|
|
321
|
-
searchResult: '',
|
|
322
|
-
yearShowOne: false,
|
|
323
|
-
// moment
|
|
324
|
-
moment,
|
|
325
|
-
// 树形选择框选中值
|
|
326
|
-
treeSelectValue: undefined
|
|
327
|
-
}
|
|
328
|
-
},
|
|
329
|
-
props: {
|
|
330
|
-
attr: {
|
|
331
|
-
type: Object,
|
|
332
|
-
default: () => {
|
|
333
|
-
return {}
|
|
334
|
-
}
|
|
335
|
-
},
|
|
336
|
-
form: {
|
|
337
|
-
type: Object,
|
|
338
|
-
required: true
|
|
339
|
-
},
|
|
340
|
-
disabled: {
|
|
341
|
-
type: Boolean,
|
|
342
|
-
default: () => {
|
|
343
|
-
return false
|
|
344
|
-
}
|
|
345
|
-
},
|
|
346
|
-
mode: {
|
|
347
|
-
type: String,
|
|
348
|
-
default: () => {
|
|
349
|
-
return '查询'
|
|
350
|
-
}
|
|
351
|
-
},
|
|
352
|
-
xl: {
|
|
353
|
-
type: Number,
|
|
354
|
-
default: undefined
|
|
355
|
-
},
|
|
356
|
-
xxl: {
|
|
357
|
-
type: Number,
|
|
358
|
-
default: undefined
|
|
359
|
-
},
|
|
360
|
-
files: {
|
|
361
|
-
type: Array,
|
|
362
|
-
default: () => {
|
|
363
|
-
return []
|
|
364
|
-
}
|
|
365
|
-
},
|
|
366
|
-
images: {
|
|
367
|
-
type: Array,
|
|
368
|
-
default: () => {
|
|
369
|
-
return []
|
|
370
|
-
}
|
|
371
|
-
},
|
|
372
|
-
serviceName: {
|
|
373
|
-
type: String,
|
|
374
|
-
default: 'af-system'
|
|
375
|
-
},
|
|
376
|
-
// 调用logic获取数据源的追加参数
|
|
377
|
-
getDataParams: {
|
|
378
|
-
type: Object,
|
|
379
|
-
default: undefined
|
|
380
|
-
}
|
|
381
|
-
},
|
|
382
|
-
created () {
|
|
383
|
-
this.init()
|
|
384
|
-
},
|
|
385
|
-
watch: {
|
|
386
|
-
attr: {
|
|
387
|
-
handler (newVal) {
|
|
388
|
-
this.init()
|
|
389
|
-
},
|
|
390
|
-
deep: true
|
|
391
|
-
},
|
|
392
|
-
form: {
|
|
393
|
-
handler (newVal) {
|
|
394
|
-
const value = newVal[this.attr.model]
|
|
395
|
-
const isEmpty = !value || !value.toString()
|
|
396
|
-
// 查询表单点击重置按钮时清空树形选择框选中状态
|
|
397
|
-
if (this.attr.type === 'treeSelect' && isEmpty) {
|
|
398
|
-
this.treeSelectValue = undefined
|
|
399
|
-
}
|
|
400
|
-
},
|
|
401
|
-
deep: true
|
|
402
|
-
}
|
|
403
|
-
},
|
|
404
|
-
methods: {
|
|
405
|
-
init () {
|
|
406
|
-
if (this.attr.keyName && this.attr.keyName.indexOf('logic@') !== -1) {
|
|
407
|
-
this.getData({}, res => {
|
|
408
|
-
this.option = res
|
|
409
|
-
// 修改时恢复树形选择框选中状态
|
|
410
|
-
if (this.attr.type === 'treeSelect' && this.attr.queryType !== 'RIGHT_LIKE') {
|
|
411
|
-
const value = this.form[this.attr.model]
|
|
412
|
-
if (value) {
|
|
413
|
-
// 如果数据源中值含'-',代表是由多个数据源组成的树,需要重新组织新增/编辑时的表单值
|
|
414
|
-
if (this.option.length > 0 && this.option[0].value.indexOf('-') !== -1) {
|
|
415
|
-
this.treeSelectValue = this.attr.model + '-' + value
|
|
416
|
-
} else {
|
|
417
|
-
this.treeSelectValue = value
|
|
418
|
-
}
|
|
419
|
-
} else {
|
|
420
|
-
this.treeSelectValue = undefined
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
})
|
|
424
|
-
}
|
|
425
|
-
},
|
|
426
|
-
openChangeOne (status) {
|
|
427
|
-
if (status) {
|
|
428
|
-
this.yearShowOne = true
|
|
429
|
-
}
|
|
430
|
-
},
|
|
431
|
-
// 得到年份选择器的值
|
|
432
|
-
panelChangeOne (value) {
|
|
433
|
-
this.yearShowOne = false
|
|
434
|
-
this.form[this.attr.model] = value.format('YYYY')
|
|
435
|
-
},
|
|
436
|
-
// 文件框时设置上传组件的值
|
|
437
|
-
setFiles (fileIds) {
|
|
438
|
-
if (!this.form[this.attr.model]) {
|
|
439
|
-
this.form[this.attr.model] = []
|
|
440
|
-
}
|
|
441
|
-
this.form[this.attr.model] = [...fileIds]
|
|
442
|
-
},
|
|
443
|
-
// 懒加载检索方法
|
|
444
|
-
fetchFunction (value) {
|
|
445
|
-
this.lastFetchId += 1
|
|
446
|
-
const fetchId = this.lastFetchId
|
|
447
|
-
this.option = []
|
|
448
|
-
this.searching = true
|
|
449
|
-
this.getData({
|
|
450
|
-
word: value
|
|
451
|
-
}, res => {
|
|
452
|
-
if (fetchId !== this.lastFetchId) {
|
|
453
|
-
return
|
|
454
|
-
}
|
|
455
|
-
this.option = res
|
|
456
|
-
this.searching = false
|
|
457
|
-
})
|
|
458
|
-
},
|
|
459
|
-
// 获取数据
|
|
460
|
-
getData (value, callback) {
|
|
461
|
-
if (value !== '') {
|
|
462
|
-
const logicName = this.attr.keyName
|
|
463
|
-
const logic = logicName.substring(6)
|
|
464
|
-
// 调用logic前设置参数
|
|
465
|
-
if (this.getDataParams && this.getDataParams[this.attr.model]) {
|
|
466
|
-
Object.assign(value, this.getDataParams[this.attr.model])
|
|
467
|
-
}
|
|
468
|
-
post('/api/' + this.serviceName + '/logic/' + logic, value).then(res => {
|
|
469
|
-
callback(res)
|
|
470
|
-
})
|
|
471
|
-
}
|
|
472
|
-
},
|
|
473
|
-
filterOption (input, option) {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
item.
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
this.form
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
*
|
|
560
|
-
* @param
|
|
561
|
-
* @
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
const
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
.
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 输入框 -->
|
|
3
|
+
<x-form-col
|
|
4
|
+
v-if="attr.type === 'input'"
|
|
5
|
+
:xl="xl"
|
|
6
|
+
:xxl="xxl">
|
|
7
|
+
<a-form-model-item
|
|
8
|
+
:ref="attr.model"
|
|
9
|
+
:label="attr.name"
|
|
10
|
+
:prop="attr.model">
|
|
11
|
+
<a-input v-model="form[attr.model]" :disabled="disabled" :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"/>
|
|
12
|
+
</a-form-model-item>
|
|
13
|
+
</x-form-col>
|
|
14
|
+
<!-- 下拉框 -->
|
|
15
|
+
<x-form-col
|
|
16
|
+
v-else-if="attr.type === 'select'"
|
|
17
|
+
:xl="xl"
|
|
18
|
+
:xxl="xxl">
|
|
19
|
+
<a-form-model-item
|
|
20
|
+
:ref="attr.model"
|
|
21
|
+
:label="attr.name"
|
|
22
|
+
:prop="attr.model">
|
|
23
|
+
<a-select
|
|
24
|
+
v-if="!attr.lazyLoad || attr.lazyLoad === 'false'"
|
|
25
|
+
v-model="form[attr.model]"
|
|
26
|
+
:disabled="disabled"
|
|
27
|
+
:filter-option="filterOption"
|
|
28
|
+
:getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
|
|
29
|
+
:placeholder="attr.placeholder ? attr.placeholder : '请选择'"
|
|
30
|
+
show-search
|
|
31
|
+
>
|
|
32
|
+
<a-select-option
|
|
33
|
+
v-if="mode === '查询'"
|
|
34
|
+
key="999999"
|
|
35
|
+
value="全部">全部
|
|
36
|
+
</a-select-option>
|
|
37
|
+
<template v-if="attr.keys">
|
|
38
|
+
<a-select-option
|
|
39
|
+
v-for="(item,index) in attr.keys"
|
|
40
|
+
:key="index"
|
|
41
|
+
:value="item.value">
|
|
42
|
+
{{ item.label }}
|
|
43
|
+
</a-select-option>
|
|
44
|
+
</template>
|
|
45
|
+
<template v-else>
|
|
46
|
+
<template v-if="attr.keyName.indexOf('logic@') !== -1">
|
|
47
|
+
<a-select-option
|
|
48
|
+
v-for="(item,index) in option"
|
|
49
|
+
:key="index"
|
|
50
|
+
:value="item.value">{{ item.label }}
|
|
51
|
+
</a-select-option>
|
|
52
|
+
</template>
|
|
53
|
+
<template v-else>
|
|
54
|
+
<a-select-option
|
|
55
|
+
v-for="item in $appdata.getDictionaryList(attr.keyName)"
|
|
56
|
+
:key="item.value"
|
|
57
|
+
:value="item.value">
|
|
58
|
+
<!-- 徽标(badge) -->
|
|
59
|
+
<x-badge :badge-key="attr.keyName" :replaceText="item.text" :value="item.value"/>
|
|
60
|
+
</a-select-option>
|
|
61
|
+
</template>
|
|
62
|
+
</template>
|
|
63
|
+
</a-select>
|
|
64
|
+
<a-select
|
|
65
|
+
v-else
|
|
66
|
+
v-model="form[attr.model]"
|
|
67
|
+
:disabled="disabled"
|
|
68
|
+
:filter-option="filterOption"
|
|
69
|
+
:getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
|
|
70
|
+
:placeholder="attr.placeholder ? attr.placeholder : '搜索' + attr.name"
|
|
71
|
+
show-search
|
|
72
|
+
@search="fetchFunction"
|
|
73
|
+
>
|
|
74
|
+
<a-spin v-if="searching" slot="notFoundContent" size="small" />
|
|
75
|
+
<a-select-option
|
|
76
|
+
v-if="mode === '查询'"
|
|
77
|
+
key="999999"
|
|
78
|
+
value="全部">全部
|
|
79
|
+
</a-select-option>
|
|
80
|
+
<a-select-option
|
|
81
|
+
v-for="(item,index) in option"
|
|
82
|
+
:key="index"
|
|
83
|
+
:value="item.value">{{ item.label }}
|
|
84
|
+
</a-select-option>
|
|
85
|
+
</a-select>
|
|
86
|
+
</a-form-model-item>
|
|
87
|
+
</x-form-col>
|
|
88
|
+
<!-- 多选框 -->
|
|
89
|
+
<x-form-col
|
|
90
|
+
v-else-if="attr.type === 'checkbox'"
|
|
91
|
+
:xl="xl"
|
|
92
|
+
:xxl="xxl">
|
|
93
|
+
<a-form-model-item
|
|
94
|
+
:ref="attr.model"
|
|
95
|
+
:label="attr.name"
|
|
96
|
+
:prop="attr.model">
|
|
97
|
+
<a-select
|
|
98
|
+
v-if="!attr.lazyLoad || attr.lazyLoad === 'false'"
|
|
99
|
+
v-model="form[attr.model]"
|
|
100
|
+
:disabled="disabled"
|
|
101
|
+
:filter-option="filterOption"
|
|
102
|
+
:getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
|
|
103
|
+
:placeholder="attr.placeholder ? attr.placeholder : '请选择'"
|
|
104
|
+
mode="multiple"
|
|
105
|
+
show-search
|
|
106
|
+
allowClear
|
|
107
|
+
>
|
|
108
|
+
<template v-if="attr.keys">
|
|
109
|
+
<a-select-option
|
|
110
|
+
v-for="(item,index) in attr.keys"
|
|
111
|
+
:key="index"
|
|
112
|
+
:value="item.value">
|
|
113
|
+
{{ item.label }}
|
|
114
|
+
</a-select-option>
|
|
115
|
+
</template>
|
|
116
|
+
<template v-else>
|
|
117
|
+
<template v-if="attr.keyName.indexOf('logic@') !== -1">
|
|
118
|
+
<a-select-option
|
|
119
|
+
v-for="(item,index) in option"
|
|
120
|
+
:key="index"
|
|
121
|
+
:value="item.value">{{ item.label }}
|
|
122
|
+
</a-select-option>
|
|
123
|
+
</template>
|
|
124
|
+
<template v-else>
|
|
125
|
+
<a-select-option
|
|
126
|
+
v-for="item in $appdata.getDictionaryList(attr.keyName)"
|
|
127
|
+
:key="item.value"
|
|
128
|
+
:value="item.value">{{ item.text }}
|
|
129
|
+
</a-select-option>
|
|
130
|
+
</template>
|
|
131
|
+
</template>
|
|
132
|
+
</a-select>
|
|
133
|
+
<a-select
|
|
134
|
+
v-else
|
|
135
|
+
v-model="form[attr.model]"
|
|
136
|
+
:disabled="disabled"
|
|
137
|
+
:filter-option="filterOption"
|
|
138
|
+
:getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
|
|
139
|
+
:placeholder="attr.placeholder ? attr.placeholder : '搜索' + attr.name"
|
|
140
|
+
mode="multiple"
|
|
141
|
+
show-search
|
|
142
|
+
allowClear
|
|
143
|
+
@search="fetchFunction"
|
|
144
|
+
>
|
|
145
|
+
<a-spin v-if="searching" slot="notFoundContent" size="small" />
|
|
146
|
+
<a-select-option
|
|
147
|
+
v-for="(item,index) in option"
|
|
148
|
+
:key="index"
|
|
149
|
+
:value="item.value">{{ item.label }}
|
|
150
|
+
</a-select-option>
|
|
151
|
+
</a-select>
|
|
152
|
+
</a-form-model-item>
|
|
153
|
+
</x-form-col>
|
|
154
|
+
<!-- TODO 单选框 -->
|
|
155
|
+
<!-- 日期范围选择器 -->
|
|
156
|
+
<x-form-col
|
|
157
|
+
v-else-if="attr.type === 'rangePicker'"
|
|
158
|
+
:xl="xl"
|
|
159
|
+
:xxl="xxl">
|
|
160
|
+
<a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
|
|
161
|
+
<a-range-picker v-model="form[attr.model]" :disabled="disabled" :show-time="true" valueFormat="YYYY-MM-DD HH:mm:ss"/>
|
|
162
|
+
</a-form-model-item>
|
|
163
|
+
</x-form-col>
|
|
164
|
+
<!-- 月份选择器 -->
|
|
165
|
+
<x-form-col
|
|
166
|
+
v-else-if="attr.type === 'monthPicker'"
|
|
167
|
+
:xl="xl"
|
|
168
|
+
:xxl="xxl">
|
|
169
|
+
<a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
|
|
170
|
+
<a-month-picker v-model="form[attr.model]" :disabled="disabled" :show-time="true" valueFormat="YYYY-MM"/>
|
|
171
|
+
</a-form-model-item>
|
|
172
|
+
</x-form-col>
|
|
173
|
+
<!-- 年份选择器 -->
|
|
174
|
+
<x-form-col
|
|
175
|
+
v-else-if="attr.type === 'yearPicker'"
|
|
176
|
+
:xl="xl"
|
|
177
|
+
:xxl="xxl">
|
|
178
|
+
<a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
|
|
179
|
+
<a-date-picker
|
|
180
|
+
v-model="form[attr.model]"
|
|
181
|
+
:disabled="disabled"
|
|
182
|
+
format="YYYY"
|
|
183
|
+
mode="year"
|
|
184
|
+
v-decorator="['year']"
|
|
185
|
+
placeholder="请输入年份"
|
|
186
|
+
:open="yearShowOne"
|
|
187
|
+
@openChange="openChangeOne"
|
|
188
|
+
@panelChange="panelChangeOne"/>
|
|
189
|
+
</a-form-model-item>
|
|
190
|
+
</x-form-col>
|
|
191
|
+
<!-- 日期选择器 -->
|
|
192
|
+
<x-form-col
|
|
193
|
+
v-else-if="attr.type === 'datePicker'"
|
|
194
|
+
:xl="xl"
|
|
195
|
+
:xxl="xxl">
|
|
196
|
+
<a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
|
|
197
|
+
<a-range-picker
|
|
198
|
+
v-if="mode === '查询'"
|
|
199
|
+
v-model="form[attr.model]"
|
|
200
|
+
:disabled="disabled"
|
|
201
|
+
:show-time="{ defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')] }"
|
|
202
|
+
format="YYYY-MM-DD"
|
|
203
|
+
valueFormat="YYYY-MM-DD HH:mm:ss" />
|
|
204
|
+
<a-date-picker v-else v-model="form[attr.model]" :disabled="disabled" :show-time="{ defaultValue: moment('00:00:00', 'HH:mm:ss') }" valueFormat="YYYY-MM-DD HH:mm:ss"/>
|
|
205
|
+
</a-form-model-item>
|
|
206
|
+
</x-form-col>
|
|
207
|
+
<!-- 文本域 -->
|
|
208
|
+
<x-form-col
|
|
209
|
+
v-else-if="attr.type === 'textarea'"
|
|
210
|
+
:lg="24"
|
|
211
|
+
:md="24"
|
|
212
|
+
:sm="24"
|
|
213
|
+
:xl="24"
|
|
214
|
+
:xs="24"
|
|
215
|
+
:xxl="24">
|
|
216
|
+
<a-form-model-item
|
|
217
|
+
:ref="attr.model"
|
|
218
|
+
:label="attr.name"
|
|
219
|
+
:prop="attr.model">
|
|
220
|
+
<a-textarea v-model="form[attr.model]" :disabled="disabled" :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')" :rows="4"/>
|
|
221
|
+
</a-form-model-item>
|
|
222
|
+
</x-form-col>
|
|
223
|
+
<!-- 文件上传 -->
|
|
224
|
+
<x-form-col
|
|
225
|
+
v-else-if="attr.type === 'file' || attr.type === 'image'"
|
|
226
|
+
:lg="24"
|
|
227
|
+
:md="24"
|
|
228
|
+
:sm="24"
|
|
229
|
+
:xl="24"
|
|
230
|
+
:xs="24"
|
|
231
|
+
:xxl="24">
|
|
232
|
+
<a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
|
|
233
|
+
<upload :files="files" :images="images" :model="attr" :service-name="serviceName" @setFiles="setFiles"></upload>
|
|
234
|
+
</a-form-model-item>
|
|
235
|
+
</x-form-col>
|
|
236
|
+
<!-- 省市区选择框 -->
|
|
237
|
+
<x-form-col
|
|
238
|
+
v-else-if="attr.type === 'citySelect'"
|
|
239
|
+
:xl="xl"
|
|
240
|
+
:xxl="xxl">
|
|
241
|
+
<a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
|
|
242
|
+
<citySelect v-model="form[attr.model]" ></citySelect>
|
|
243
|
+
</a-form-model-item>
|
|
244
|
+
</x-form-col>
|
|
245
|
+
<!-- 地点搜索框 -->
|
|
246
|
+
<x-form-col
|
|
247
|
+
v-else-if="attr.type === 'addressSearch'"
|
|
248
|
+
:xl="xl"
|
|
249
|
+
:xxl="xxl">
|
|
250
|
+
<a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
|
|
251
|
+
<address-search-combobox
|
|
252
|
+
v-model="searchResult"
|
|
253
|
+
:resultKeys="{ address: attr.model, coords: `${attr.model}_lng_lat` }"
|
|
254
|
+
searchResultType="Object"
|
|
255
|
+
@onSelect="form=Object.assign(form,JSON.parse(searchResult))"
|
|
256
|
+
></address-search-combobox>
|
|
257
|
+
</a-form-model-item>
|
|
258
|
+
</x-form-col>
|
|
259
|
+
<!-- 人员选择框 -->
|
|
260
|
+
<x-form-col
|
|
261
|
+
v-else-if="attr.type === 'personSetting'"
|
|
262
|
+
:xl="xl"
|
|
263
|
+
:xxl="xxl">
|
|
264
|
+
<a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
|
|
265
|
+
<PersonSetting v-model="form[attr.model]" ></PersonSetting>
|
|
266
|
+
</a-form-model-item>
|
|
267
|
+
</x-form-col>
|
|
268
|
+
<!-- 树形选择框 -->
|
|
269
|
+
<x-form-col
|
|
270
|
+
v-else-if="attr.type === 'treeSelect'"
|
|
271
|
+
:xl="xl"
|
|
272
|
+
:xxl="xxl">
|
|
273
|
+
<a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.model">
|
|
274
|
+
<a-tree-select
|
|
275
|
+
v-model="treeSelectValue"
|
|
276
|
+
:disabled="disabled"
|
|
277
|
+
:tree-data="getTreeData()"
|
|
278
|
+
:tree-checkable="mode === '查询' && attr.queryType !== 'RIGHT_LIKE'"
|
|
279
|
+
:placeholder="'请选择' + attr.name"
|
|
280
|
+
:dropdown-style="{ maxHeight: '400px' }"
|
|
281
|
+
tree-node-filter-prop="label"
|
|
282
|
+
:show-checked-strategy="attr.queryType === 'RIGHT_LIKE' ? 'SHOW_ALL' : undefined"
|
|
283
|
+
allow-clear
|
|
284
|
+
class="tree-select"
|
|
285
|
+
@change="onTreeSelectChange">
|
|
286
|
+
</a-tree-select>
|
|
287
|
+
</a-form-model-item>
|
|
288
|
+
</x-form-col>
|
|
289
|
+
</template>
|
|
290
|
+
<script>
|
|
291
|
+
|
|
292
|
+
import { post } from '@vue2-client/services/api'
|
|
293
|
+
import { debounce } from 'ant-design-vue/lib/vc-table/src/utils'
|
|
294
|
+
import XFormCol from '@vue2-client/base-client/components/common/XFormCol'
|
|
295
|
+
import XBadge from '@vue2-client/base-client/components/common/XBadge'
|
|
296
|
+
import CitySelect from '@vue2-client/base-client/components/common/CitySelect'
|
|
297
|
+
import PersonSetting from '@vue2-client/base-client/components/common/PersonSetting'
|
|
298
|
+
import AddressSearchCombobox from '@vue2-client/base-client/components/common/AddressSearchCombobox'
|
|
299
|
+
import Upload from '@vue2-client/base-client/components/common/Upload'
|
|
300
|
+
import moment from 'moment'
|
|
301
|
+
|
|
302
|
+
export default {
|
|
303
|
+
name: 'XFormItem',
|
|
304
|
+
components: {
|
|
305
|
+
XFormCol,
|
|
306
|
+
XBadge,
|
|
307
|
+
CitySelect,
|
|
308
|
+
PersonSetting,
|
|
309
|
+
AddressSearchCombobox,
|
|
310
|
+
Upload
|
|
311
|
+
},
|
|
312
|
+
data () {
|
|
313
|
+
// 检索去抖
|
|
314
|
+
this.fetchFunction = debounce(this.fetchFunction, 800)
|
|
315
|
+
return {
|
|
316
|
+
option: [],
|
|
317
|
+
// 最后检索版本
|
|
318
|
+
lastFetchId: 0,
|
|
319
|
+
// 检索中
|
|
320
|
+
searching: false,
|
|
321
|
+
searchResult: '',
|
|
322
|
+
yearShowOne: false,
|
|
323
|
+
// moment
|
|
324
|
+
moment,
|
|
325
|
+
// 树形选择框选中值
|
|
326
|
+
treeSelectValue: undefined
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
props: {
|
|
330
|
+
attr: {
|
|
331
|
+
type: Object,
|
|
332
|
+
default: () => {
|
|
333
|
+
return {}
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
form: {
|
|
337
|
+
type: Object,
|
|
338
|
+
required: true
|
|
339
|
+
},
|
|
340
|
+
disabled: {
|
|
341
|
+
type: Boolean,
|
|
342
|
+
default: () => {
|
|
343
|
+
return false
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
mode: {
|
|
347
|
+
type: String,
|
|
348
|
+
default: () => {
|
|
349
|
+
return '查询'
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
xl: {
|
|
353
|
+
type: Number,
|
|
354
|
+
default: undefined
|
|
355
|
+
},
|
|
356
|
+
xxl: {
|
|
357
|
+
type: Number,
|
|
358
|
+
default: undefined
|
|
359
|
+
},
|
|
360
|
+
files: {
|
|
361
|
+
type: Array,
|
|
362
|
+
default: () => {
|
|
363
|
+
return []
|
|
364
|
+
}
|
|
365
|
+
},
|
|
366
|
+
images: {
|
|
367
|
+
type: Array,
|
|
368
|
+
default: () => {
|
|
369
|
+
return []
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
serviceName: {
|
|
373
|
+
type: String,
|
|
374
|
+
default: 'af-system'
|
|
375
|
+
},
|
|
376
|
+
// 调用logic获取数据源的追加参数
|
|
377
|
+
getDataParams: {
|
|
378
|
+
type: Object,
|
|
379
|
+
default: undefined
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
created () {
|
|
383
|
+
this.init()
|
|
384
|
+
},
|
|
385
|
+
watch: {
|
|
386
|
+
attr: {
|
|
387
|
+
handler (newVal) {
|
|
388
|
+
this.init()
|
|
389
|
+
},
|
|
390
|
+
deep: true
|
|
391
|
+
},
|
|
392
|
+
form: {
|
|
393
|
+
handler (newVal) {
|
|
394
|
+
const value = newVal[this.attr.model]
|
|
395
|
+
const isEmpty = !value || !value.toString()
|
|
396
|
+
// 查询表单点击重置按钮时清空树形选择框选中状态
|
|
397
|
+
if (this.attr.type === 'treeSelect' && isEmpty) {
|
|
398
|
+
this.treeSelectValue = undefined
|
|
399
|
+
}
|
|
400
|
+
},
|
|
401
|
+
deep: true
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
methods: {
|
|
405
|
+
init () {
|
|
406
|
+
if (this.attr.keyName && this.attr.keyName.indexOf('logic@') !== -1) {
|
|
407
|
+
this.getData({}, res => {
|
|
408
|
+
this.option = res
|
|
409
|
+
// 修改时恢复树形选择框选中状态
|
|
410
|
+
if (this.attr.type === 'treeSelect' && this.attr.queryType !== 'RIGHT_LIKE') {
|
|
411
|
+
const value = this.form[this.attr.model]
|
|
412
|
+
if (value) {
|
|
413
|
+
// 如果数据源中值含'-',代表是由多个数据源组成的树,需要重新组织新增/编辑时的表单值
|
|
414
|
+
if (this.option.length > 0 && this.option[0].value.indexOf('-') !== -1) {
|
|
415
|
+
this.treeSelectValue = this.attr.model + '-' + value
|
|
416
|
+
} else {
|
|
417
|
+
this.treeSelectValue = value
|
|
418
|
+
}
|
|
419
|
+
} else {
|
|
420
|
+
this.treeSelectValue = undefined
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
})
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
openChangeOne (status) {
|
|
427
|
+
if (status) {
|
|
428
|
+
this.yearShowOne = true
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
// 得到年份选择器的值
|
|
432
|
+
panelChangeOne (value) {
|
|
433
|
+
this.yearShowOne = false
|
|
434
|
+
this.form[this.attr.model] = value.format('YYYY')
|
|
435
|
+
},
|
|
436
|
+
// 文件框时设置上传组件的值
|
|
437
|
+
setFiles (fileIds) {
|
|
438
|
+
if (!this.form[this.attr.model]) {
|
|
439
|
+
this.form[this.attr.model] = []
|
|
440
|
+
}
|
|
441
|
+
this.form[this.attr.model] = [...fileIds]
|
|
442
|
+
},
|
|
443
|
+
// 懒加载检索方法
|
|
444
|
+
fetchFunction (value) {
|
|
445
|
+
this.lastFetchId += 1
|
|
446
|
+
const fetchId = this.lastFetchId
|
|
447
|
+
this.option = []
|
|
448
|
+
this.searching = true
|
|
449
|
+
this.getData({
|
|
450
|
+
word: value
|
|
451
|
+
}, res => {
|
|
452
|
+
if (fetchId !== this.lastFetchId) {
|
|
453
|
+
return
|
|
454
|
+
}
|
|
455
|
+
this.option = res
|
|
456
|
+
this.searching = false
|
|
457
|
+
})
|
|
458
|
+
},
|
|
459
|
+
// 获取数据
|
|
460
|
+
getData (value, callback) {
|
|
461
|
+
if (value !== '') {
|
|
462
|
+
const logicName = this.attr.keyName
|
|
463
|
+
const logic = logicName.substring(6)
|
|
464
|
+
// 调用logic前设置参数
|
|
465
|
+
if (this.getDataParams && this.getDataParams[this.attr.model]) {
|
|
466
|
+
Object.assign(value, this.getDataParams[this.attr.model])
|
|
467
|
+
}
|
|
468
|
+
post('/api/' + this.serviceName + '/logic/' + logic, value).then(res => {
|
|
469
|
+
callback(res)
|
|
470
|
+
})
|
|
471
|
+
}
|
|
472
|
+
},
|
|
473
|
+
filterOption (input, option) {
|
|
474
|
+
const child = option.componentOptions.children[0]
|
|
475
|
+
if (child.text) {
|
|
476
|
+
return child.text.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
|
477
|
+
} else if (child.elm.innerText) {
|
|
478
|
+
return child.elm.innerText.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
|
479
|
+
} else {
|
|
480
|
+
return child.child.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
|
481
|
+
}
|
|
482
|
+
},
|
|
483
|
+
// 获取树形选择框数据
|
|
484
|
+
getTreeData () {
|
|
485
|
+
let treeData = this.attr.keys
|
|
486
|
+
if (!treeData) {
|
|
487
|
+
treeData = this.option
|
|
488
|
+
}
|
|
489
|
+
if (this.mode === '新增/修改') {
|
|
490
|
+
this.setParentSelectable(treeData)
|
|
491
|
+
}
|
|
492
|
+
return treeData
|
|
493
|
+
},
|
|
494
|
+
// 设置树形选择框不能选择父节点
|
|
495
|
+
setParentSelectable (treeData) {
|
|
496
|
+
treeData.forEach(item => {
|
|
497
|
+
if (item.children && item.children.length) {
|
|
498
|
+
item.selectable = false
|
|
499
|
+
this.setParentSelectable(item.children)
|
|
500
|
+
}
|
|
501
|
+
})
|
|
502
|
+
},
|
|
503
|
+
// 选中树节点
|
|
504
|
+
onTreeSelectChange (value, label, extra) {
|
|
505
|
+
if (this.attr.queryType === 'RIGHT_LIKE') {
|
|
506
|
+
// 获取可用于模糊查询的组织机构字符串
|
|
507
|
+
let node = extra.triggerNode.$parent
|
|
508
|
+
label = label[0]
|
|
509
|
+
while (node && node.label) {
|
|
510
|
+
label = node.label + '.' + label
|
|
511
|
+
node = node.$parent
|
|
512
|
+
}
|
|
513
|
+
this.form[this.attr.model] = label
|
|
514
|
+
} else {
|
|
515
|
+
// 如果选中值含'-',代表是由多个数据源组成的树,需要重新组织查询或新增/编辑时的表单
|
|
516
|
+
if ((value instanceof Array && value.length > 0 && value[0].indexOf('-') !== -1) || (typeof value === 'string' && value.indexOf('-') !== -1)) {
|
|
517
|
+
const treeDatas = {}
|
|
518
|
+
// 单选情况用于新增.修改表单场景,使用extra.triggerNode获取选中节点信息
|
|
519
|
+
if (!extra.allCheckedNodes) {
|
|
520
|
+
this.setNodeData(treeDatas, extra.triggerNode)
|
|
521
|
+
} else {
|
|
522
|
+
// 多选情况用于查询表单场景,使用extra.allCheckedNodes获取选中节点集合
|
|
523
|
+
const nodes = extra.allCheckedNodes
|
|
524
|
+
// 获取任意选中节点的叶子节点的字段名,用于查询时组织查询项的key
|
|
525
|
+
const name = this.getNodeDataProps(nodes[0])
|
|
526
|
+
// 获取所有选中节点的叶子节点的value,用于查询时组织查询项的value
|
|
527
|
+
const values = []
|
|
528
|
+
for (const node of nodes) {
|
|
529
|
+
const ref = this.setDataRef(node)
|
|
530
|
+
if (ref instanceof Array) {
|
|
531
|
+
for (const nodeRef of ref) {
|
|
532
|
+
const keyValue = nodeRef.node.key
|
|
533
|
+
values.push(keyValue.substring(keyValue.lastIndexOf('-') + 1))
|
|
534
|
+
}
|
|
535
|
+
} else {
|
|
536
|
+
const keyValue = ref.node.key
|
|
537
|
+
values.push(keyValue.substring(keyValue.lastIndexOf('-') + 1))
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
treeDatas[name] = values
|
|
541
|
+
}
|
|
542
|
+
// 移除默认的表单项,将组织好后的表单项合并进表单
|
|
543
|
+
this.form[this.attr.model] = undefined
|
|
544
|
+
Object.assign(this.form, treeDatas)
|
|
545
|
+
} else {
|
|
546
|
+
// 从单一数据源组成的树可以直接赋值
|
|
547
|
+
this.form[this.attr.model] = value
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
},
|
|
551
|
+
setDataRef (node) {
|
|
552
|
+
if (node.children) {
|
|
553
|
+
return this.setDataRef(node.children)
|
|
554
|
+
}
|
|
555
|
+
return node
|
|
556
|
+
},
|
|
557
|
+
/**
|
|
558
|
+
* 组织节点和每层父节点的数据,用于新增/修改时更新表单数据
|
|
559
|
+
* @param data 组织完成的数据
|
|
560
|
+
* @param node 节点
|
|
561
|
+
* @return 返回示例: { parentId: 1, childId: 2 }
|
|
562
|
+
*/
|
|
563
|
+
setNodeData (data, node) {
|
|
564
|
+
if (node.value) {
|
|
565
|
+
const value = node.value
|
|
566
|
+
const columnsName = value.substring(0, value.indexOf('-'))
|
|
567
|
+
data[columnsName] = value.substring(value.lastIndexOf('-') + 1)
|
|
568
|
+
if (node.$parent) {
|
|
569
|
+
this.setNodeData(data, node.$parent)
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
},
|
|
573
|
+
getNodeDataProps (node) {
|
|
574
|
+
if (node.children && node.children.length > 0) {
|
|
575
|
+
return this.getNodeDataProps(node.children[0])
|
|
576
|
+
}
|
|
577
|
+
const value = node.node.key
|
|
578
|
+
return value.substring(0, value.indexOf('-'))
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
</script>
|
|
583
|
+
|
|
584
|
+
<style lang="less" scoped>
|
|
585
|
+
.tree-select {
|
|
586
|
+
/deep/ .ant-select-selection.ant-select-selection--multiple {
|
|
587
|
+
max-height: 32px;
|
|
588
|
+
overflow-y: auto;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
</style>
|