vue2-client 1.2.49 → 1.2.52
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/.env +15 -14
- package/.eslintrc.js +82 -82
- package/CHANGELOG.md +8 -0
- package/package.json +2 -1
- package/src/base-client/all.js +64 -61
- package/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox.vue +225 -0
- package/src/base-client/components/common/AmapMarker/AmapPointRendering.vue +36 -29
- package/src/base-client/components/common/CitySelect/CitySelect.vue +244 -0
- package/src/base-client/components/common/CitySelect/index.js +3 -0
- package/src/base-client/components/common/CitySelect/index.md +109 -0
- package/src/base-client/components/common/CreateQuery/CreateQuery.vue +483 -1342
- package/src/base-client/components/common/CreateQuery/CreateQueryItem.vue +770 -555
- package/src/base-client/components/common/Upload/Upload.vue +124 -124
- package/src/base-client/components/common/Upload/index.js +3 -3
- package/src/base-client/components/common/XAddForm/XAddForm.vue +38 -46
- package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +316 -316
- package/src/base-client/components/common/XForm/XForm.vue +268 -275
- package/src/base-client/components/common/XForm/XFormItem.vue +348 -280
- package/src/base-client/components/common/XFormTable/XFormTable.vue +0 -2
- package/src/base-client/components/iot/CustomerDetailsView/index.md +1 -2
- package/src/base-client/components/iot/DeviceBrandDetailsView/DeviceBrandDetailsView.vue +1 -1
- package/src/base-client/components/iot/DeviceDetailsView/DeviceDetailsView.vue +2 -7
- package/src/base-client/components/iot/DeviceDetailsView/index.md +0 -2
- package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsException.vue +57 -57
- package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsMain.vue +240 -196
- package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsRead.vue +131 -131
- package/src/base-client/components/iot/DeviceTypeDetailsView/DeviceTypeDetailsView.vue +1 -5
- package/src/base-client/components/iot/InstructDetailsView/InstructDetailsView.vue +6 -14
- package/src/base-client/components/iot/InstructDetailsView/index.md +0 -2
- package/src/base-client/components/iot/LogDetailsView/LogDetailsView.vue +6 -13
- package/src/base-client/components/iot/LogDetailsView/index.md +0 -2
- package/src/base-client/components/iot/MeterDetailsView/MeterDetailsView.vue +17 -24
- package/src/base-client/components/iot/MeterDetailsView/index.md +0 -2
- package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsCount.vue +0 -5
- package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsException.vue +0 -5
- package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsHandPlan.vue +0 -6
- package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsInstruct.vue +0 -6
- package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsMain.vue +1 -6
- package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsSellGas.vue +1 -6
- package/src/base-client/components/iot/WebmeterAnalysisView/WebmeterAnalysisView.vue +213 -288
- package/src/base-client/components/iot/WebmeterAnalysisView/index.md +0 -6
- package/src/base-client/components/ticket/TicketDetailsView/TicketDetailsView.vue +853 -853
- package/src/base-client/components/ticket/TicketSubmitSuccessView/TicketSubmitSuccessView.vue +532 -532
- package/src/base-client/plugins/AppData.js +16 -1
- package/src/base-client/plugins/compatible/LoginServiceOA.js +19 -0
- package/src/config/CreateQueryConfig.js +298 -80
- package/src/config/default/setting.config.js +2 -2
- package/src/layouts/header/HeaderNotice.vue +96 -96
- package/src/layouts/tabs/TabsView.vue +0 -3
- package/src/pages/login/Login.vue +53 -22
- package/src/pages/resourceManage/orgListManage.vue +40 -40
- package/src/pages/system/ticket/submitTicketSuccess.vue +268 -268
- package/src/router/async/config.async.js +26 -26
- package/src/router/index.js +27 -27
- package/src/services/api/manage.js +16 -14
- package/src/services/api/restTools.js +24 -24
- package/src/theme/default/style.less +47 -47
- package/src/utils/map-utils.js +22 -11
- package/src/utils/request.js +198 -198
- package/src/utils/routerUtil.js +1 -10
- package/src/utils/util.js +222 -176
- package/vue.config.js +2 -2
|
@@ -1,1342 +1,483 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<a-drawer
|
|
3
|
-
title="查询配置生成"
|
|
4
|
-
placement="right"
|
|
5
|
-
:width="isMobile ? screenWidth : screenWidth * 0.85"
|
|
6
|
-
:visible="visible"
|
|
7
|
-
@close="onClose"
|
|
8
|
-
>
|
|
9
|
-
<a-row :gutter="24">
|
|
10
|
-
<a-col :xl="14" :lg="12" :md="12" :sm="24" :xs="24">
|
|
11
|
-
<a-form-model
|
|
12
|
-
ref="businessCreateForm"
|
|
13
|
-
:rules="rules"
|
|
14
|
-
:model="form"
|
|
15
|
-
:label-col="labelCol"
|
|
16
|
-
:wrapper-col="wrapperCol"
|
|
17
|
-
>
|
|
18
|
-
<a-form-model-item label="查询主表名" prop="tableName">
|
|
19
|
-
<a-input v-model="form.tableName" placeholder="查询用的主表+别名,用空格隔开,如:t_userfiles u"/>
|
|
20
|
-
</a-form-model-item>
|
|
21
|
-
<a-form-model-item label="预设关联表" prop="joinArray">
|
|
22
|
-
<a-popover title="说明" placement="right">
|
|
23
|
-
<template slot="content">
|
|
24
|
-
<p>配置你的查询中可能涉及到的所有关联表</p>
|
|
25
|
-
<p>比如你的查询中涉及到了t_userinfo表,就需要加入t_userinfo表的关联,和你写SQL的关联一样</p>
|
|
26
|
-
<p>请注意,你关联的<span style="color: #ff0000">除主表外的任何表</span>都需要配置</p>
|
|
27
|
-
<a-input-group compact style="width: 400px;">
|
|
28
|
-
<a-input style="width: 20%" placeholder="表别名" readOnly/>
|
|
29
|
-
<a-input style="width: 80%" placeholder="关联条件" readOnly/>
|
|
30
|
-
</a-input-group>
|
|
31
|
-
<a-input-group compact style="width: 400px;">
|
|
32
|
-
<a-input value="ui" style="width: 20%" placeholder="表别名" readOnly/>
|
|
33
|
-
<a-input
|
|
34
|
-
value="t_userinfo ui on i.f_userinfo_id = ui.f_userinfo_id"
|
|
35
|
-
style="width: 80%"
|
|
36
|
-
placeholder="关联条件"
|
|
37
|
-
readOnly/>
|
|
38
|
-
</a-input-group>
|
|
39
|
-
</template>
|
|
40
|
-
<a-button type="primary" @click="addJoinItem()">增加</a-button>
|
|
41
|
-
</a-popover>
|
|
42
|
-
<div v-for="(itemObj, index) in joinArray" :key="index">
|
|
43
|
-
<a-input-group compact>
|
|
44
|
-
<a-input
|
|
45
|
-
@change="changeJoinArray()"
|
|
46
|
-
v-model="itemObj.key"
|
|
47
|
-
style="width: 20%;position: relative;bottom: 1px;"
|
|
48
|
-
placeholder="表别名"/>
|
|
49
|
-
<a-input @change="changeJoinArray()" v-model="itemObj.value" style="width: 80%" placeholder="关联条件">
|
|
50
|
-
<a-icon slot="addonAfter" type="close" @click="removeJoinItem(index)"/>
|
|
51
|
-
</a-input>
|
|
52
|
-
</a-input-group>
|
|
53
|
-
</div>
|
|
54
|
-
</a-form-model-item>
|
|
55
|
-
<a-form-model-item label="SQL查询表达式" prop="condition">
|
|
56
|
-
<a-input v-model="form.condition.value" placeholder="用作SQL查询的固定条件表达式,如:gb.f_meter_type='物联网表',可选"/>
|
|
57
|
-
<template v-if="form.condition.value && Object.keys(form.joinArray).length > 0">
|
|
58
|
-
<a-alert message="提示:如果SQL查询表达式中用到了关联表,需要勾选用到的关联表别名" type="success"/>
|
|
59
|
-
<a-checkbox-group v-model="form.condition.join" :options="conditionJoinArray"/>
|
|
60
|
-
</template>
|
|
61
|
-
</a-form-model-item>
|
|
62
|
-
<a-form-model-item label="排序方式" prop="orderBy">
|
|
63
|
-
<a-input v-model="form.orderBy" placeholder="排序字段,用别名+字段名+排序方式(可选)表示,如:u.id desc"/>
|
|
64
|
-
</a-form-model-item>
|
|
65
|
-
<a-form-model-item label="数据字段" prop="column">
|
|
66
|
-
<a-button type="primary" @click="addColumnItem()">增加</a-button>
|
|
67
|
-
<div v-for="(columnItem, index) in form.column" :key="index">
|
|
68
|
-
<a-row :gutter="16">
|
|
69
|
-
<a-col :span="16">
|
|
70
|
-
<span style="font-weight: bold">{{ columnItem.title }}({{ columnItem.key }})</span>
|
|
71
|
-
</a-col>
|
|
72
|
-
<a-col v-if="index > 0 && form.column.length > 1" :span="2">
|
|
73
|
-
<a-icon type="up-square" @click="upColumnItem(columnItem.key,index)"/>
|
|
74
|
-
</a-col>
|
|
75
|
-
<a-col v-if="(index !== form.column.length - 1) && form.column.length > 1" :span="2">
|
|
76
|
-
<a-icon type="down-square" @click="downColumnItem(columnItem.key,index)"/>
|
|
77
|
-
</a-col>
|
|
78
|
-
<a-col :span="2">
|
|
79
|
-
<a-icon type="edit" @click="editColumnItem(columnItem.key,index)"/>
|
|
80
|
-
</a-col>
|
|
81
|
-
<a-col :span="2">
|
|
82
|
-
<a-icon type="close" @click="removeColumnItem(columnItem.key,index)"/>
|
|
83
|
-
</a-col>
|
|
84
|
-
</a-row>
|
|
85
|
-
</div>
|
|
86
|
-
</a-form-model-item>
|
|
87
|
-
<a-form-model-item label="操作按钮配置" prop="buttonState">
|
|
88
|
-
<a-checkbox-group v-model="buttonStateData" :options="buttonStateArray"/>
|
|
89
|
-
</a-form-model-item>
|
|
90
|
-
</a-form-model>
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
<a-select-option key="version">版本号</a-select-option>
|
|
485
|
-
<a-popover
|
|
486
|
-
slot="suffixIcon"
|
|
487
|
-
title="关于新增/修改场景选择"
|
|
488
|
-
placement="bottom">
|
|
489
|
-
<template slot="content">
|
|
490
|
-
<p>设置表单项的新增/修改场景</p>
|
|
491
|
-
<p>静默新增类型用于非人为新增的数据,不会生成表单项,且必须设置字段用途</p>
|
|
492
|
-
</template>
|
|
493
|
-
<a-icon type="info-circle" style="color: rgba(0,0,0,.45)"/>
|
|
494
|
-
</a-popover>
|
|
495
|
-
</a-select>
|
|
496
|
-
</a-form-model-item>
|
|
497
|
-
</a-col>
|
|
498
|
-
<a-col :span="8" v-if="item.addOrEdit === 'silenceAdd'">
|
|
499
|
-
<a-form-model-item
|
|
500
|
-
ref="silencePurpose"
|
|
501
|
-
label="字段用途"
|
|
502
|
-
prop="silencePurpose">
|
|
503
|
-
<a-select v-model="item.silencePurpose" placeholder="请选择字段用途">
|
|
504
|
-
<a-select-option key="createTime">创建时间</a-select-option>
|
|
505
|
-
<a-select-option key="operator">创建/操作人</a-select-option>
|
|
506
|
-
<a-select-option key="orgId">组织机构ID</a-select-option>
|
|
507
|
-
<a-select-option key="customize">自定义</a-select-option>
|
|
508
|
-
<a-popover
|
|
509
|
-
slot="suffixIcon"
|
|
510
|
-
title="关于字段用途"
|
|
511
|
-
placement="bottom">
|
|
512
|
-
<template slot="content">
|
|
513
|
-
<p>用于静默新增时设置字段用途</p>
|
|
514
|
-
<p>在新增数据的表单提交时,页面会根据设置的字段用途获取相关数据并追加到表单中</p>
|
|
515
|
-
<p>当字段用途选择为<span style="font-weight: bold">自定义</span>时,必须指定一个业务逻辑(Logic)名称,表单提交前会将表单内容作为参数调用该Logic接口,并将Logic返回值作为表单值
|
|
516
|
-
</p>
|
|
517
|
-
</template>
|
|
518
|
-
<a-icon type="info-circle" style="color: rgba(0,0,0,.45)"/>
|
|
519
|
-
</a-popover>
|
|
520
|
-
</a-select>
|
|
521
|
-
</a-form-model-item>
|
|
522
|
-
</a-col>
|
|
523
|
-
<a-col :span="8" v-if="item.silencePurpose === 'customize'" label="业务逻辑" prop="silenceSource">
|
|
524
|
-
<a-form-model-item>
|
|
525
|
-
<a-input v-model="item.silenceSource" placeholder="请输入业务逻辑名称"/>
|
|
526
|
-
</a-form-model-item>
|
|
527
|
-
</a-col>
|
|
528
|
-
</a-row>
|
|
529
|
-
</template>
|
|
530
|
-
<template v-if="dataMode.table">
|
|
531
|
-
<a-row :gutter="16">
|
|
532
|
-
<a-col :span="8">
|
|
533
|
-
<a-form-model-item label="作用域插槽" prop="slot">
|
|
534
|
-
<a-select v-model="item.slot.type" placeholder="插槽类型,可选">
|
|
535
|
-
<a-select-option key="default">不设置</a-select-option>
|
|
536
|
-
<a-select-option key="ellipsis">文本溢出省略</a-select-option>
|
|
537
|
-
<a-select-option key="badge">多彩徽标</a-select-option>
|
|
538
|
-
<a-select-option key="date">日期格式化</a-select-option>
|
|
539
|
-
<a-select-option key="dateTime">日期时间格式化</a-select-option>
|
|
540
|
-
<a-select-option key="action">操作列</a-select-option>
|
|
541
|
-
<a-popover slot="suffixIcon" title="关于作用域插槽" placement="bottom">
|
|
542
|
-
<template slot="content">
|
|
543
|
-
<p>你可以通过设置表格列的作用域插槽实现一些效果</p>
|
|
544
|
-
<p>如果没有指定,默认会设置为文本溢出省略(长度:16)</p>
|
|
545
|
-
<p>如果你选择文本溢出省略,需要设置文本溢出上限长度</p>
|
|
546
|
-
<p>如果你选择多彩徽标,需要设置徽标对应的数据样式字典键</p>
|
|
547
|
-
</template>
|
|
548
|
-
<a-icon type="info-circle" style="color: rgba(0,0,0,.45)"/>
|
|
549
|
-
</a-popover>
|
|
550
|
-
</a-select>
|
|
551
|
-
</a-form-model-item>
|
|
552
|
-
</a-col>
|
|
553
|
-
<a-col :span="8">
|
|
554
|
-
<a-form-model-item label="表格列宽度" prop="width">
|
|
555
|
-
<a-popover
|
|
556
|
-
title="关于表格列宽度"
|
|
557
|
-
placement="bottom">
|
|
558
|
-
<template slot="content">
|
|
559
|
-
<p>当作用域插槽设置为文本溢出省略时,表格列宽度将自适应,计算方式为文本溢出上限长度 * 7 + 42</p>
|
|
560
|
-
<p>当作用域插槽设置为多彩徽标时,表格列宽度为固定为130</p>
|
|
561
|
-
<p>当作用域插槽设置为日期时间格式化时,表格列宽度为固定为160</p>
|
|
562
|
-
<p>当该列数据过长导致换行时,建议设置作用域插槽为文本溢出省略,或将表格列设置为固定宽度值</p>
|
|
563
|
-
</template>
|
|
564
|
-
<a-input-number style="width: 100%" v-model="item.width" placeholder="表格列宽度,可选"/>
|
|
565
|
-
</a-popover>
|
|
566
|
-
</a-form-model-item>
|
|
567
|
-
</a-col>
|
|
568
|
-
<a-col :span="8" v-if="dataMode.sqlQueryItem">
|
|
569
|
-
<a-form-model-item label="字段默认值" prop="default">
|
|
570
|
-
<a-input v-model="item.default" placeholder="当查询结果为null时,指定默认值,可选"/>
|
|
571
|
-
</a-form-model-item>
|
|
572
|
-
</a-col>
|
|
573
|
-
</a-row>
|
|
574
|
-
<a-row :gutter="16">
|
|
575
|
-
<a-col :span="8">
|
|
576
|
-
<a-form-model-item label="文本溢出上限长度" prop="slotValue" v-if="item.slot.type === 'ellipsis'">
|
|
577
|
-
<a-input-number style="width: 100%" v-model="item.slotValue" placeholder="请输入文本溢出上限长度"/>
|
|
578
|
-
</a-form-model-item>
|
|
579
|
-
<a-form-model-item label="徽标字典键" prop="slotKeyMap" v-if="item.slot.type === 'badge'">
|
|
580
|
-
<a-input v-model="item.slotKeyMap" placeholder="请输入徽标字典键">
|
|
581
|
-
<a-popover
|
|
582
|
-
title="关于徽标字典键"
|
|
583
|
-
placement="bottom"
|
|
584
|
-
slot="suffix">
|
|
585
|
-
<template slot="content">
|
|
586
|
-
<p>如果你设置了表单类型为选择框,且数据源是字典键,该值会自动带出</p>
|
|
587
|
-
</template>
|
|
588
|
-
<a-icon type="info-circle" style="color: rgba(0,0,0,.45)"/>
|
|
589
|
-
</a-popover>
|
|
590
|
-
</a-input>
|
|
591
|
-
</a-form-model-item>
|
|
592
|
-
<a-form-model-item label="操作列文本" prop="actionText" v-if="item.slot.type === 'action'">
|
|
593
|
-
<a-input v-model="item.actionText" placeholder="请输入操作列显示文本,默认为详情"/>
|
|
594
|
-
</a-form-model-item>
|
|
595
|
-
</a-col>
|
|
596
|
-
</a-row>
|
|
597
|
-
</template>
|
|
598
|
-
<a-alert
|
|
599
|
-
style="margin-top: 5px"
|
|
600
|
-
v-if="dataModeArrayData.length === 0"
|
|
601
|
-
show-icon
|
|
602
|
-
message="错误:请至少选择一种数据模式"
|
|
603
|
-
type="error"/>
|
|
604
|
-
<a-alert
|
|
605
|
-
style="margin-top: 5px"
|
|
606
|
-
v-if="!(item.formType === 'file' || item.formType === 'image') && dataMode.addOrEditForm && !dataMode.sqlQueryItem"
|
|
607
|
-
show-icon
|
|
608
|
-
message="错误:如果要生成新增/修改表单项,必须勾选生成SQL查询项"
|
|
609
|
-
type="error"/>
|
|
610
|
-
<a-alert
|
|
611
|
-
style="margin-top: 5px"
|
|
612
|
-
v-if="(item.formType === 'file' || item.formType === 'image') && !(!dataMode.table && !dataMode.sqlQueryCondition && !dataMode.queryForm)"
|
|
613
|
-
show-icon
|
|
614
|
-
message="错误:上传类表单的数据模式只能选择 生成新增/修改表单项 和 生成SQL查询项 "
|
|
615
|
-
type="error"/>
|
|
616
|
-
<a-alert
|
|
617
|
-
style="margin-top: 5px"
|
|
618
|
-
v-if="dataMode.queryForm && !dataMode.sqlQueryCondition"
|
|
619
|
-
show-icon
|
|
620
|
-
message="提示:您没有勾选生成SQL查询表达式,渲染的表单项不会生成SQL查询条件"
|
|
621
|
-
type="info"/>
|
|
622
|
-
<a-alert
|
|
623
|
-
style="margin-top: 5px"
|
|
624
|
-
v-if="dataMode.table && !dataMode.sqlQueryItem"
|
|
625
|
-
show-icon
|
|
626
|
-
message="提示:您没有勾选生成SQL查询项,渲染的表格列不会绑定SQL结果集数据"
|
|
627
|
-
type="info"/>
|
|
628
|
-
</a-form-model>
|
|
629
|
-
</a-modal>
|
|
630
|
-
<a-button type="primary" @click="view">操作</a-button>
|
|
631
|
-
</a-col>
|
|
632
|
-
<a-col :xl="10" :lg="12" :md="12" :sm="24" :xs="24">
|
|
633
|
-
<a-card :bordered="false" title="预览" size="small" style="overflow: auto">
|
|
634
|
-
<json-viewer
|
|
635
|
-
:copyable="{copyText: '复制', copiedText: '已复制'}"
|
|
636
|
-
:value="result"
|
|
637
|
-
:expand-depth="parseInt('100')"
|
|
638
|
-
style="overflow: auto;max-height: 440px"></json-viewer>
|
|
639
|
-
</a-card>
|
|
640
|
-
</a-col>
|
|
641
|
-
</a-row>
|
|
642
|
-
<a-modal
|
|
643
|
-
title="效果预览"
|
|
644
|
-
:width="isMobile ? screenWidth : screenWidth * 0.8"
|
|
645
|
-
:centered="true"
|
|
646
|
-
:visible="modelVisible"
|
|
647
|
-
:zIndex="1001"
|
|
648
|
-
@cancel="onModelClose"
|
|
649
|
-
:destroyOnClose="true">
|
|
650
|
-
<template slot="footer">
|
|
651
|
-
<a-button key="close" @click="onModelClose">
|
|
652
|
-
返回
|
|
653
|
-
</a-button>
|
|
654
|
-
<a-button key="submit" type="primary" @click="submit">
|
|
655
|
-
保存
|
|
656
|
-
</a-button>
|
|
657
|
-
</template>
|
|
658
|
-
<x-form-table
|
|
659
|
-
:view-mode="true"
|
|
660
|
-
:queryParamsJson="result">
|
|
661
|
-
</x-form-table>
|
|
662
|
-
</a-modal>
|
|
663
|
-
</a-drawer>
|
|
664
|
-
</template>
|
|
665
|
-
|
|
666
|
-
<script>
|
|
667
|
-
import XFormItem from '@vue2-client/base-client/components/common/XForm/XFormItem'
|
|
668
|
-
import XFormTable from '@vue2-client/base-client/components/common/XFormTable/XFormTable'
|
|
669
|
-
import JsonViewer from 'vue-json-viewer'
|
|
670
|
-
import FileSaver from 'file-saver'
|
|
671
|
-
import { queryType, fileType } from '@vue2-client/config/CreateQueryConfig'
|
|
672
|
-
import { mapState } from 'vuex'
|
|
673
|
-
import { commonApi, post } from '@vue2-client/services/api'
|
|
674
|
-
|
|
675
|
-
const DemoJson = [{
|
|
676
|
-
value: 'zhejiang',
|
|
677
|
-
label: 'Zhejiang',
|
|
678
|
-
children: [{ value: 'hangzhou', label: 'Hangzhou', children: [{ value: 'xihu', label: 'West Lake' }] }]
|
|
679
|
-
}]
|
|
680
|
-
export default {
|
|
681
|
-
name: 'CreateQuery',
|
|
682
|
-
components: {
|
|
683
|
-
JsonViewer,
|
|
684
|
-
XFormTable,
|
|
685
|
-
XFormItem
|
|
686
|
-
},
|
|
687
|
-
data () {
|
|
688
|
-
return {
|
|
689
|
-
DemoJson,
|
|
690
|
-
fileType,
|
|
691
|
-
// 页面宽度
|
|
692
|
-
screenWidth: document.documentElement.clientWidth,
|
|
693
|
-
// 效果预览模态框是否展示
|
|
694
|
-
modelVisible: false,
|
|
695
|
-
// 数据列配置模态框是否展示
|
|
696
|
-
dataColumnVisible: false,
|
|
697
|
-
// 数据列操作类型:新增,修改
|
|
698
|
-
type: '新增',
|
|
699
|
-
// 数据模式类型集合
|
|
700
|
-
dataModeArray: [
|
|
701
|
-
{ label: '生成查询表单项', value: 'queryForm' },
|
|
702
|
-
{ label: '生成表格列', value: 'table' },
|
|
703
|
-
{ label: '生成新增/修改表单项', value: 'addOrEditForm' },
|
|
704
|
-
{ label: '生成SQL查询项', value: 'sqlQueryItem' },
|
|
705
|
-
{ label: '生成SQL查询表达式', value: 'sqlQueryCondition' }
|
|
706
|
-
],
|
|
707
|
-
// 操作按钮状态集合
|
|
708
|
-
buttonStateArray: [
|
|
709
|
-
{ label: '新增', value: 'add' },
|
|
710
|
-
{ label: '修改', value: 'edit' },
|
|
711
|
-
{ label: '删除', value: 'delete' },
|
|
712
|
-
{ label: '导出', value: 'export' }
|
|
713
|
-
],
|
|
714
|
-
// 数据模式类型集合值
|
|
715
|
-
dataModeArrayData: ['queryForm', 'table', 'addOrEditForm', 'sqlQueryItem', 'sqlQueryCondition'],
|
|
716
|
-
// 操作按钮状态集合值
|
|
717
|
-
buttonStateData: ['add', 'edit', 'delete', 'export'],
|
|
718
|
-
labelCol: { span: 4 },
|
|
719
|
-
wrapperCol: { span: 14 },
|
|
720
|
-
form: {
|
|
721
|
-
tableName: '',
|
|
722
|
-
joinArray: {},
|
|
723
|
-
condition: {},
|
|
724
|
-
orderBy: '',
|
|
725
|
-
column: []
|
|
726
|
-
},
|
|
727
|
-
result: {},
|
|
728
|
-
item: {
|
|
729
|
-
key: '',
|
|
730
|
-
title: '',
|
|
731
|
-
slot: {},
|
|
732
|
-
rule: {
|
|
733
|
-
required: 'false'
|
|
734
|
-
},
|
|
735
|
-
formType: '',
|
|
736
|
-
accept: '',
|
|
737
|
-
addOrEdit: '',
|
|
738
|
-
selectKeyName: '',
|
|
739
|
-
resUploadStock: '',
|
|
740
|
-
acceptCount: '',
|
|
741
|
-
dataModeArray: []
|
|
742
|
-
},
|
|
743
|
-
stockList: [],
|
|
744
|
-
lowerPath: [],
|
|
745
|
-
itemMap: {},
|
|
746
|
-
selectIndex: null,
|
|
747
|
-
selectType: undefined,
|
|
748
|
-
joinArray: [],
|
|
749
|
-
rules: {
|
|
750
|
-
tableName: [{ required: true, message: '请输入查询表名', trigger: 'blur' }],
|
|
751
|
-
orderBy: [{ required: true, message: '请输入排序方式', trigger: 'blur' }]
|
|
752
|
-
},
|
|
753
|
-
itemRules: {
|
|
754
|
-
key: [{ required: true, message: '请输入数据列名', trigger: 'blur' }],
|
|
755
|
-
title: [{ required: true, message: '请输入中文名称', trigger: 'blur' }],
|
|
756
|
-
selectType: [{ required: true, message: '请选择数据源类型', trigger: 'change' }],
|
|
757
|
-
selectKey: [{ required: true, message: '请输入数据源内容', trigger: 'blur' }],
|
|
758
|
-
slotValue: [{ required: true, message: '请输入文本溢出上限长度', trigger: 'blur' }],
|
|
759
|
-
slotKeyMap: [{ required: true, message: '请输入徽标字典键', trigger: 'blur' }],
|
|
760
|
-
silencePurpose: [{ required: true, message: '请选择字段用途', trigger: 'change' }],
|
|
761
|
-
silenceSource: [{ required: true, message: '请输入业务逻辑名称', trigger: 'blur' }],
|
|
762
|
-
group: [{ required: true, message: '请选择父节点', trigger: 'blur' }],
|
|
763
|
-
groupIndex: [{ required: true, message: '如果不是根节点请选择自己的父节点', trigger: 'blur' }]
|
|
764
|
-
|
|
765
|
-
},
|
|
766
|
-
// 字典键集合
|
|
767
|
-
option: []
|
|
768
|
-
}
|
|
769
|
-
},
|
|
770
|
-
mounted () {
|
|
771
|
-
this.initView()
|
|
772
|
-
},
|
|
773
|
-
computed: {
|
|
774
|
-
...mapState('setting', ['isMobile']),
|
|
775
|
-
parent_node () {
|
|
776
|
-
return this.form.column.filter(item => item.formType === 'selects' && item.key != this.item.key)
|
|
777
|
-
},
|
|
778
|
-
queryTypeV () {
|
|
779
|
-
if (this.item.formType) {
|
|
780
|
-
return queryType.filter(item => item.match.includes(this.item.formType))
|
|
781
|
-
}
|
|
782
|
-
return queryType
|
|
783
|
-
},
|
|
784
|
-
conditionJoinArray: function () {
|
|
785
|
-
const result = []
|
|
786
|
-
for (const item in this.form.joinArray) {
|
|
787
|
-
if (item !== '') {
|
|
788
|
-
result.push({
|
|
789
|
-
label: item,
|
|
790
|
-
value: item
|
|
791
|
-
})
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
if (result.length === 0) {
|
|
795
|
-
result.push({
|
|
796
|
-
label: '-',
|
|
797
|
-
value: '-'
|
|
798
|
-
})
|
|
799
|
-
}
|
|
800
|
-
return result
|
|
801
|
-
},
|
|
802
|
-
dataMode: function () {
|
|
803
|
-
const result = {
|
|
804
|
-
queryForm: false,
|
|
805
|
-
table: false,
|
|
806
|
-
addOrEditForm: false,
|
|
807
|
-
sqlQueryItem: false,
|
|
808
|
-
sqlQueryCondition: false
|
|
809
|
-
}
|
|
810
|
-
for (const item of this.dataModeArrayData) {
|
|
811
|
-
result[item] = true
|
|
812
|
-
}
|
|
813
|
-
return result
|
|
814
|
-
},
|
|
815
|
-
buttonState: function () {
|
|
816
|
-
const result = {
|
|
817
|
-
add: false,
|
|
818
|
-
edit: false,
|
|
819
|
-
delete: false,
|
|
820
|
-
export: false
|
|
821
|
-
}
|
|
822
|
-
for (const item of this.buttonStateData) {
|
|
823
|
-
result[item] = true
|
|
824
|
-
}
|
|
825
|
-
return result
|
|
826
|
-
}
|
|
827
|
-
},
|
|
828
|
-
props: {
|
|
829
|
-
visible: {
|
|
830
|
-
type: Boolean,
|
|
831
|
-
default: false
|
|
832
|
-
},
|
|
833
|
-
toEditJson: {
|
|
834
|
-
type: Object,
|
|
835
|
-
default: () => {}
|
|
836
|
-
}
|
|
837
|
-
},
|
|
838
|
-
watch: {
|
|
839
|
-
visible (rel) {
|
|
840
|
-
if (rel) {
|
|
841
|
-
this.initView()
|
|
842
|
-
}
|
|
843
|
-
if (rel && this.toEditJson) {
|
|
844
|
-
// 处理预设关联表
|
|
845
|
-
if (this.joinArray.length === 0) {
|
|
846
|
-
for (const key in this.toEditJson.joinArray) {
|
|
847
|
-
this.joinArray.push({
|
|
848
|
-
key: key,
|
|
849
|
-
value: this.toEditJson.joinArray[key]
|
|
850
|
-
})
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
// 处理具体表单项
|
|
854
|
-
this.form = Object.assign(
|
|
855
|
-
{
|
|
856
|
-
tableName: '',
|
|
857
|
-
joinArray: {},
|
|
858
|
-
condition: {},
|
|
859
|
-
orderBy: '',
|
|
860
|
-
column: []
|
|
861
|
-
}, this.toEditJson
|
|
862
|
-
)
|
|
863
|
-
for (const columnItem of this.form.column) {
|
|
864
|
-
// 数据模式兼容性处理
|
|
865
|
-
if (!(columnItem.dataMode || columnItem.dataModeArray)) {
|
|
866
|
-
columnItem.dataModeArray = ['queryForm', 'table', 'addOrEditForm', 'sqlQueryItem', 'sqlQueryCondition']
|
|
867
|
-
} else if (columnItem.dataMode) {
|
|
868
|
-
if (columnItem.dataMode === 'all') {
|
|
869
|
-
columnItem.dataModeArray = ['queryForm', 'table', 'addOrEditForm', 'sqlQueryItem', 'sqlQueryCondition']
|
|
870
|
-
} else if (columnItem.dataMode === 'form') {
|
|
871
|
-
columnItem.dataModeArray = ['queryForm', 'addOrEditForm', 'sqlQueryCondition']
|
|
872
|
-
} else if (columnItem.dataMode === 'table') {
|
|
873
|
-
columnItem.dataModeArray = ['table', 'sqlQueryItem']
|
|
874
|
-
} else if (columnItem.dataMode === 'table_form') {
|
|
875
|
-
columnItem.dataModeArray = ['table', 'sqlQueryItem', 'sqlQueryCondition']
|
|
876
|
-
} else if (columnItem.dataMode === 'only_form') {
|
|
877
|
-
columnItem.dataModeArray = ['queryForm']
|
|
878
|
-
} else if (columnItem.dataMode === 'only_table') {
|
|
879
|
-
columnItem.dataModeArray = ['table']
|
|
880
|
-
} else if (columnItem.dataMode === 'clear') {
|
|
881
|
-
columnItem.dataModeArray = ['sqlQueryItem', 'sqlQueryCondition']
|
|
882
|
-
} else if (columnItem.dataMode === 'only_add_modify') {
|
|
883
|
-
columnItem.dataModeArray = ['addOrEditForm', 'sqlQueryItem']
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
delete columnItem.dataMode
|
|
887
|
-
// 插槽兼容处理
|
|
888
|
-
if (columnItem.slot) {
|
|
889
|
-
if (columnItem.slot.value && columnItem.slot.type === 'ellipsis') {
|
|
890
|
-
columnItem.slotValue = columnItem.slot.value
|
|
891
|
-
} else if (columnItem.slot.keyMap && columnItem.slot.type === 'badge') {
|
|
892
|
-
columnItem.slotKeyMap = columnItem.slot.keyMap
|
|
893
|
-
} else if (columnItem.slot.actionText && columnItem.slot.type === 'action') {
|
|
894
|
-
columnItem.actionText = columnItem.slot.actionText
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
// 必选项兼容处理
|
|
898
|
-
if (columnItem.rule && columnItem.rule.required && columnItem.rule.required !== 'false') {
|
|
899
|
-
columnItem.rule.required = columnItem.rule.required.toString()
|
|
900
|
-
} else {
|
|
901
|
-
if (!columnItem.rule) {
|
|
902
|
-
columnItem.rule = {}
|
|
903
|
-
}
|
|
904
|
-
columnItem.rule.required = 'false'
|
|
905
|
-
}
|
|
906
|
-
// 数据源加载方式兼容处理
|
|
907
|
-
if (columnItem.lazyLoad && columnItem.lazyLoad !== 'false') {
|
|
908
|
-
columnItem.lazyLoad = columnItem.lazyLoad.toString()
|
|
909
|
-
} else {
|
|
910
|
-
columnItem.lazyLoad = 'false'
|
|
911
|
-
}
|
|
912
|
-
// 下拉框数据源兼容处理
|
|
913
|
-
if ((columnItem.formType === 'select' || columnItem.formType === 'cascader') && columnItem.selectKey) {
|
|
914
|
-
// 数据源为logic
|
|
915
|
-
if (columnItem.selectKey.toString().startsWith('logic@')) {
|
|
916
|
-
columnItem.selectType = 'logic'
|
|
917
|
-
} else if (columnItem.selectKey instanceof Array || this.isJSON(columnItem.selectKey)) {
|
|
918
|
-
// 数据源为固定json集合
|
|
919
|
-
if (columnItem.selectKey instanceof Array) {
|
|
920
|
-
columnItem.selectKey = JSON.stringify(columnItem.selectKey)
|
|
921
|
-
}
|
|
922
|
-
columnItem.selectType = 'fixArray'
|
|
923
|
-
} else {
|
|
924
|
-
columnItem.selectType = 'key'
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
this.itemMap[columnItem.key] = Object.assign({
|
|
928
|
-
key: '',
|
|
929
|
-
title: '',
|
|
930
|
-
slot: {},
|
|
931
|
-
rule: {
|
|
932
|
-
required: 'false'
|
|
933
|
-
},
|
|
934
|
-
dataModeArray: []
|
|
935
|
-
}, columnItem)
|
|
936
|
-
}
|
|
937
|
-
// 处理操作按钮配置
|
|
938
|
-
if (this.toEditJson.buttonState) {
|
|
939
|
-
this.buttonStateData = []
|
|
940
|
-
for (const buttonStateKey of Object.keys(this.toEditJson.buttonState)) {
|
|
941
|
-
if (this.toEditJson.buttonState[buttonStateKey]) {
|
|
942
|
-
this.buttonStateData.push(buttonStateKey)
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
} else {
|
|
946
|
-
this.buttonStateData = ['add', 'edit', 'delete', 'export']
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
},
|
|
951
|
-
methods: {
|
|
952
|
-
// 文件上传限制类型修改
|
|
953
|
-
itemAcceptChange (newVal) {
|
|
954
|
-
// newVal = [accept1,accept2,...]
|
|
955
|
-
if (newVal.includes('*')) {
|
|
956
|
-
this.item.accept = ['*']
|
|
957
|
-
// return
|
|
958
|
-
}
|
|
959
|
-
// 如果除了 无限制 都选择 改成无限制
|
|
960
|
-
// if (newVal.length === this.fileType.length - 1){
|
|
961
|
-
// this.item.accept = ['*']
|
|
962
|
-
// }
|
|
963
|
-
},
|
|
964
|
-
parent_title_change (parentKey) {
|
|
965
|
-
const parentArr = this.form.column.filter(item => item.formType === 'selects' && item.key === parentKey)
|
|
966
|
-
if (parentArr.length === 1) {
|
|
967
|
-
this.item.groupIndex = parentArr[0].groupIndex + 1
|
|
968
|
-
this.item.group = parentArr[0].group
|
|
969
|
-
this.item.parent_title = parentArr[0].title
|
|
970
|
-
} else {
|
|
971
|
-
this.$message.error('数据字段中有字段别名相同,请检查!')
|
|
972
|
-
}
|
|
973
|
-
},
|
|
974
|
-
groupIndexChange ({ target }) {
|
|
975
|
-
if (target.value === 1) {
|
|
976
|
-
this.item.groupIndex = 1
|
|
977
|
-
if (this.item.title) {
|
|
978
|
-
this.item.group = this.item.title + '组'
|
|
979
|
-
} else {
|
|
980
|
-
this.item.groupIndex = ''
|
|
981
|
-
this.$message.error('请先输入字段中文名称!')
|
|
982
|
-
}
|
|
983
|
-
} else {
|
|
984
|
-
this.item.groupIndex = ''
|
|
985
|
-
}
|
|
986
|
-
},
|
|
987
|
-
// 初始化组件
|
|
988
|
-
initView () {
|
|
989
|
-
this.joinArray = []
|
|
990
|
-
this.result = {}
|
|
991
|
-
post(commonApi.getDictionaryParam, {}).then(res => {
|
|
992
|
-
this.option = res
|
|
993
|
-
})
|
|
994
|
-
},
|
|
995
|
-
onClose () {
|
|
996
|
-
this.$emit('update:visible', false)
|
|
997
|
-
},
|
|
998
|
-
filterOption (input, option) {
|
|
999
|
-
return (
|
|
1000
|
-
option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
|
1001
|
-
)
|
|
1002
|
-
},
|
|
1003
|
-
onModelClose () {
|
|
1004
|
-
this.modelVisible = false
|
|
1005
|
-
},
|
|
1006
|
-
addJoinItem () {
|
|
1007
|
-
this.joinArray.push({
|
|
1008
|
-
key: '',
|
|
1009
|
-
value: ''
|
|
1010
|
-
})
|
|
1011
|
-
this.changeJoinArray()
|
|
1012
|
-
},
|
|
1013
|
-
removeJoinItem (index) {
|
|
1014
|
-
this.joinArray.splice(index, 1)
|
|
1015
|
-
this.changeJoinArray()
|
|
1016
|
-
},
|
|
1017
|
-
addColumnItem () {
|
|
1018
|
-
this.type = '新增'
|
|
1019
|
-
this.dataColumnVisible = true
|
|
1020
|
-
},
|
|
1021
|
-
editColumnItem (key, index) {
|
|
1022
|
-
if (this.itemMap[key]) {
|
|
1023
|
-
this.type = '修改'
|
|
1024
|
-
this.item = Object.assign({ formType: 'input', type: 'string' }, this.itemMap[key])
|
|
1025
|
-
if (this.item.formType === 'file' || this.item.formType === 'image') {
|
|
1026
|
-
this.getStocks()
|
|
1027
|
-
if (this.item.resUploadStock) {
|
|
1028
|
-
this.lowerPath = this.stockList.filter(item => item.id == this.item.resUploadStock)[0]?.f_lower_path_json ?? []
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
if (this.item.formType === 'selects') {
|
|
1032
|
-
// 因为 groupIndex 可能有很多值 单选框不行 赋给一个新的变量
|
|
1033
|
-
this.item.groupIndexView = this.item.groupIndex === 1 ? 1 : 'None'
|
|
1034
|
-
}
|
|
1035
|
-
if (this.item.formType === 'selects') {
|
|
1036
|
-
// 因为 groupIndex 可能有很多值 单选框不行 赋给一个新的变量
|
|
1037
|
-
this.item.groupIndexView = this.item.groupIndex === 1 ? 1 : 'None'
|
|
1038
|
-
}
|
|
1039
|
-
this.dataModeArrayData = this.item.dataModeArray
|
|
1040
|
-
this.selectIndex = index
|
|
1041
|
-
this.dataColumnVisible = true
|
|
1042
|
-
} else {
|
|
1043
|
-
this.$message.warn('编辑失败')
|
|
1044
|
-
}
|
|
1045
|
-
},
|
|
1046
|
-
removeColumnItem (key, index) {
|
|
1047
|
-
const _this = this
|
|
1048
|
-
this.$confirm({
|
|
1049
|
-
title: '您确定要删除该数据项?',
|
|
1050
|
-
content: '删除的数据项无法恢复',
|
|
1051
|
-
okText: '确定',
|
|
1052
|
-
okType: 'danger',
|
|
1053
|
-
cancelText: '取消',
|
|
1054
|
-
onOk () {
|
|
1055
|
-
delete _this.itemMap[key]
|
|
1056
|
-
_this.form.column.splice(index, 1)
|
|
1057
|
-
}
|
|
1058
|
-
})
|
|
1059
|
-
},
|
|
1060
|
-
upColumnItem (key, index) {
|
|
1061
|
-
const newIndex = index - 1
|
|
1062
|
-
const itemA = this.form.column[newIndex]
|
|
1063
|
-
const itemB = this.form.column[index]
|
|
1064
|
-
this.form.column.splice(index, 1, itemA)
|
|
1065
|
-
this.form.column.splice(newIndex, 1, itemB)
|
|
1066
|
-
},
|
|
1067
|
-
downColumnItem (key, index) {
|
|
1068
|
-
const newIndex = index + 1
|
|
1069
|
-
const itemA = this.form.column[newIndex]
|
|
1070
|
-
const itemB = this.form.column[index]
|
|
1071
|
-
this.form.column.splice(index, 1, itemA)
|
|
1072
|
-
this.form.column.splice(newIndex, 1, itemB)
|
|
1073
|
-
},
|
|
1074
|
-
changeJoinArray () {
|
|
1075
|
-
const joinArrayObject = {}
|
|
1076
|
-
for (const item of this.joinArray) {
|
|
1077
|
-
joinArrayObject[item.key] = item.value
|
|
1078
|
-
}
|
|
1079
|
-
this.form.joinArray = joinArrayObject
|
|
1080
|
-
},
|
|
1081
|
-
submitItem () {
|
|
1082
|
-
this.$refs.itemForm.validate(valid => {
|
|
1083
|
-
if (valid) {
|
|
1084
|
-
const fileBool = this.item.formType === 'file' || this.item.formType === 'image'
|
|
1085
|
-
if (this.dataModeArrayData.length === 0) {
|
|
1086
|
-
this.$message.error('请至少选择一种数据模式')
|
|
1087
|
-
return
|
|
1088
|
-
}
|
|
1089
|
-
if (!fileBool && (this.dataMode.addOrEditForm && !this.dataMode.sqlQueryItem)) {
|
|
1090
|
-
this.$message.error('如果要生成新增/修改表单项,必须勾选生成SQL查询项')
|
|
1091
|
-
return
|
|
1092
|
-
}
|
|
1093
|
-
if (fileBool && !(!this.dataMode.table && !this.dataMode.sqlQueryCondition && !this.dataMode.queryForm)) {
|
|
1094
|
-
this.$message.error(`上传类表单项只能选择 "生成新增/修改表单项"`)
|
|
1095
|
-
return
|
|
1096
|
-
}
|
|
1097
|
-
this.itemHandle()
|
|
1098
|
-
}
|
|
1099
|
-
})
|
|
1100
|
-
},
|
|
1101
|
-
itemHandle () {
|
|
1102
|
-
const str = JSON.stringify(this.item)
|
|
1103
|
-
const item = JSON.parse(str)
|
|
1104
|
-
this.itemMap[item.key] = JSON.parse(str)
|
|
1105
|
-
this.itemMap[item.key].dataModeArray = this.dataModeArrayData
|
|
1106
|
-
// 查询表单项或者新增/修改表单项
|
|
1107
|
-
if (this.dataMode.queryForm || this.dataMode.addOrEditForm) {
|
|
1108
|
-
if (!this.dataMode.sqlQueryItem || !this.dataMode.addOrEditForm) {
|
|
1109
|
-
delete item.addOrEdit
|
|
1110
|
-
delete item.silencePurpose
|
|
1111
|
-
delete item.silenceSource
|
|
1112
|
-
}
|
|
1113
|
-
// 不生成SQL查询表达式,或者表单查询类型为=
|
|
1114
|
-
if (!this.dataMode.sqlQueryCondition || (item.queryType && item.queryType === '=')) {
|
|
1115
|
-
delete item.queryType
|
|
1116
|
-
}
|
|
1117
|
-
// 表单类型为输入框
|
|
1118
|
-
if (item.formType && item.formType === 'input') {
|
|
1119
|
-
delete item.formType
|
|
1120
|
-
}
|
|
1121
|
-
// 校验类型
|
|
1122
|
-
if (item.rule.required) {
|
|
1123
|
-
item.rule.required = item.rule.required.toString() === 'true'
|
|
1124
|
-
} else {
|
|
1125
|
-
item.rule.required = false
|
|
1126
|
-
}
|
|
1127
|
-
// 下拉框
|
|
1128
|
-
if ((item.formType === 'select' || (item.formType === 'selects' && item.groupIndex == '1') || item.formType === 'cascader') && item.selectKey) {
|
|
1129
|
-
// 数据源为logic
|
|
1130
|
-
if (item.selectType === 'logic') {
|
|
1131
|
-
// 如果已经有了 logic@ 将不再拼接
|
|
1132
|
-
if (item.selectKey.substring(0, 6) !== 'logic@') {
|
|
1133
|
-
item.selectKey = 'logic@' + item.selectKey
|
|
1134
|
-
}
|
|
1135
|
-
if (!item.lazyLoad) {
|
|
1136
|
-
delete item.lazyLoad
|
|
1137
|
-
}
|
|
1138
|
-
} else if (item.selectType === 'fixArray') {
|
|
1139
|
-
// 数据源为固定json集合
|
|
1140
|
-
if (!this.isJSON(item.selectKey)) {
|
|
1141
|
-
this.$message.warning('下拉框数据源不是JSON集合')
|
|
1142
|
-
return
|
|
1143
|
-
}
|
|
1144
|
-
delete item.lazyLoad
|
|
1145
|
-
} else {
|
|
1146
|
-
delete item.lazyLoad
|
|
1147
|
-
}
|
|
1148
|
-
if (item.formType !== 'selects') {
|
|
1149
|
-
delete item.selectType
|
|
1150
|
-
}
|
|
1151
|
-
} else {
|
|
1152
|
-
if (item.formType !== 'selects') {
|
|
1153
|
-
delete item.group
|
|
1154
|
-
delete item.groupIndex
|
|
1155
|
-
}
|
|
1156
|
-
delete item.selectType
|
|
1157
|
-
delete item.selectKey
|
|
1158
|
-
delete item.selectKeyName
|
|
1159
|
-
delete item.lazyLoad
|
|
1160
|
-
}
|
|
1161
|
-
} else {
|
|
1162
|
-
delete item.queryType
|
|
1163
|
-
delete item.formType
|
|
1164
|
-
delete item.addOrEdit
|
|
1165
|
-
delete item.silencePurpose
|
|
1166
|
-
delete item.silenceSource
|
|
1167
|
-
delete item.placeholder
|
|
1168
|
-
delete item.rule
|
|
1169
|
-
delete item.selectType
|
|
1170
|
-
delete item.selectKey
|
|
1171
|
-
delete item.selectKeyName
|
|
1172
|
-
delete item.lazyLoad
|
|
1173
|
-
}
|
|
1174
|
-
// 表格列
|
|
1175
|
-
if (this.dataMode.table) {
|
|
1176
|
-
if (item.slot.type && item.slot.type !== 'default') {
|
|
1177
|
-
if (item.slotValue && item.slot.type === 'ellipsis') {
|
|
1178
|
-
item.slot.value = item.slotValue
|
|
1179
|
-
} else if (item.slotKeyMap && item.slot.type === 'badge') {
|
|
1180
|
-
item.slot.keyMap = item.slotKeyMap
|
|
1181
|
-
} else if (item.actionText && item.slot.type === 'action') {
|
|
1182
|
-
item.slot.actionText = item.actionText
|
|
1183
|
-
}
|
|
1184
|
-
} else {
|
|
1185
|
-
delete item.slot
|
|
1186
|
-
}
|
|
1187
|
-
if (!item.width) {
|
|
1188
|
-
delete item.width
|
|
1189
|
-
}
|
|
1190
|
-
delete item.slotValue
|
|
1191
|
-
delete item.slotKeyMap
|
|
1192
|
-
delete item.actionText
|
|
1193
|
-
} else {
|
|
1194
|
-
delete item.slot
|
|
1195
|
-
delete item.slotValue
|
|
1196
|
-
delete item.slotKeyMap
|
|
1197
|
-
delete item.actionText
|
|
1198
|
-
delete item.width
|
|
1199
|
-
}
|
|
1200
|
-
// SQL查询项
|
|
1201
|
-
if (!this.dataMode.sqlQueryItem) {
|
|
1202
|
-
delete item.default
|
|
1203
|
-
}
|
|
1204
|
-
item.dataModeArray = this.dataModeArrayData
|
|
1205
|
-
if (this.type === '新增') {
|
|
1206
|
-
this.form.column.push(item)
|
|
1207
|
-
} else {
|
|
1208
|
-
this.form.column[this.selectIndex] = item
|
|
1209
|
-
}
|
|
1210
|
-
this.item = {
|
|
1211
|
-
key: '',
|
|
1212
|
-
title: '',
|
|
1213
|
-
slot: {},
|
|
1214
|
-
rule: {
|
|
1215
|
-
required: 'false'
|
|
1216
|
-
},
|
|
1217
|
-
dataModeArray: []
|
|
1218
|
-
}
|
|
1219
|
-
this.$message.success('增加成功')
|
|
1220
|
-
this.dataModeArrayData = ['queryForm', 'table', 'addOrEditForm', 'sqlQueryItem', 'sqlQueryCondition']
|
|
1221
|
-
this.dataColumnVisible = false
|
|
1222
|
-
},
|
|
1223
|
-
// 判断是否为json字符串
|
|
1224
|
-
isJSON (str) {
|
|
1225
|
-
if (typeof str == 'string') {
|
|
1226
|
-
try {
|
|
1227
|
-
const obj = JSON.parse(str)
|
|
1228
|
-
return !!(typeof obj == 'object' && obj)
|
|
1229
|
-
} catch (e) {
|
|
1230
|
-
return false
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
},
|
|
1234
|
-
exportJson () {
|
|
1235
|
-
const data = JSON.stringify(this.form, null, 2)
|
|
1236
|
-
const blob = new Blob([data], { type: 'application/json' })
|
|
1237
|
-
FileSaver.saveAs(blob, `Query.json`)
|
|
1238
|
-
this.$message.success('导出成功!')
|
|
1239
|
-
},
|
|
1240
|
-
viewHandle (then) {
|
|
1241
|
-
if (this.form.column.length === 0) {
|
|
1242
|
-
this.$message.error('你没有增加任何数据字段')
|
|
1243
|
-
return
|
|
1244
|
-
}
|
|
1245
|
-
this.result = JSON.parse(JSON.stringify(this.form))
|
|
1246
|
-
if (this.result.condition && (!this.result.condition.value || this.result.condition.value === '')) {
|
|
1247
|
-
delete this.result.condition
|
|
1248
|
-
}
|
|
1249
|
-
for (const item of this.result.column) {
|
|
1250
|
-
if (item.selectType === 'fixArray') {
|
|
1251
|
-
item.selectKey = JSON.parse(item.selectKey)
|
|
1252
|
-
}
|
|
1253
|
-
if (item.dataModeArray.length === 5) {
|
|
1254
|
-
delete item.dataModeArray
|
|
1255
|
-
}
|
|
1256
|
-
}
|
|
1257
|
-
if (this.buttonStateData.length !== 4) {
|
|
1258
|
-
this.result.buttonState = this.buttonState
|
|
1259
|
-
}
|
|
1260
|
-
then()
|
|
1261
|
-
},
|
|
1262
|
-
view () {
|
|
1263
|
-
this.$refs.businessCreateForm.validate(valid => {
|
|
1264
|
-
if (valid) {
|
|
1265
|
-
this.viewHandle(() => {
|
|
1266
|
-
this.modelVisible = true
|
|
1267
|
-
})
|
|
1268
|
-
}
|
|
1269
|
-
})
|
|
1270
|
-
},
|
|
1271
|
-
submit () {
|
|
1272
|
-
this.onModelClose()
|
|
1273
|
-
this.$refs.businessCreateForm.validate(valid => {
|
|
1274
|
-
if (valid) {
|
|
1275
|
-
this.viewHandle(() => {
|
|
1276
|
-
// saveQueryParams
|
|
1277
|
-
this.$emit('saveQueryParams', this.result)
|
|
1278
|
-
})
|
|
1279
|
-
}
|
|
1280
|
-
})
|
|
1281
|
-
},
|
|
1282
|
-
modelCancel () {
|
|
1283
|
-
this.dataColumnVisible = false
|
|
1284
|
-
// 延迟是为了避免编辑数据窗口关闭时重置表单导致的闪烁
|
|
1285
|
-
setTimeout(() => {
|
|
1286
|
-
this.item = {
|
|
1287
|
-
key: '',
|
|
1288
|
-
title: '',
|
|
1289
|
-
slot: {},
|
|
1290
|
-
rule: {
|
|
1291
|
-
required: 'false'
|
|
1292
|
-
},
|
|
1293
|
-
dataModeArray: []
|
|
1294
|
-
}
|
|
1295
|
-
this.dataModeArrayData = ['queryForm', 'table', 'addOrEditForm', 'sqlQueryItem', 'sqlQueryCondition']
|
|
1296
|
-
}, 100)
|
|
1297
|
-
},
|
|
1298
|
-
// 获取所有仓库
|
|
1299
|
-
getStocks () {
|
|
1300
|
-
if (this.stockList.length === 0) {
|
|
1301
|
-
post('/webmeterapi/getFilesStock', {}).then(res => {
|
|
1302
|
-
this.stockList = res.sort((a, b) => b.progress - a.progress)
|
|
1303
|
-
}).catch(e => {})
|
|
1304
|
-
}
|
|
1305
|
-
},
|
|
1306
|
-
changeFormType (item) {
|
|
1307
|
-
this.item.queryType = null
|
|
1308
|
-
if (item.formType === 'file' || item.formType === 'image') {
|
|
1309
|
-
this.item.accept = item.formType === 'file' ? ['*'] : ['.jpg,.jpeg,.ico,.gif,svg,.webp,.png,.bmp,.pjpeg,']
|
|
1310
|
-
this.item.resUploadMode = 'server'
|
|
1311
|
-
this.item.key = 'FilesId'
|
|
1312
|
-
this.dataModeArrayData = ['addOrEditForm']
|
|
1313
|
-
this.getStocks()
|
|
1314
|
-
} else {
|
|
1315
|
-
this.dataModeArrayData = ['queryForm', 'table', 'addOrEditForm', 'sqlQueryItem', 'sqlQueryCondition']
|
|
1316
|
-
delete this.item.accept
|
|
1317
|
-
delete this.item.resUploadMode
|
|
1318
|
-
}
|
|
1319
|
-
},
|
|
1320
|
-
// 修改上传到哪个仓库
|
|
1321
|
-
changeStock (stock) {
|
|
1322
|
-
if (stock) {
|
|
1323
|
-
const stockValue = this.stockList.filter(item => item.id === stock)[0]
|
|
1324
|
-
this.lowerPath = stockValue.f_lower_path_json ?? []
|
|
1325
|
-
this.item.resUploadMode = stockValue.f_stock_type
|
|
1326
|
-
this.item.stockAlias = stockValue.f_alias
|
|
1327
|
-
}
|
|
1328
|
-
},
|
|
1329
|
-
changeSelectKey (item) {
|
|
1330
|
-
if (item.selectType === 'key' && item.selectKey) {
|
|
1331
|
-
item.slot.type = 'badge'
|
|
1332
|
-
item.slotKeyMap = item.selectKey
|
|
1333
|
-
}
|
|
1334
|
-
},
|
|
1335
|
-
visitAcceptFile () {
|
|
1336
|
-
window.open('https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/input/file#attr-accept')
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
}
|
|
1340
|
-
</script>
|
|
1341
|
-
<style lang="less" scoped>
|
|
1342
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<a-drawer
|
|
3
|
+
title="查询配置生成"
|
|
4
|
+
placement="right"
|
|
5
|
+
:width="isMobile ? screenWidth : screenWidth * 0.85"
|
|
6
|
+
:visible="visible"
|
|
7
|
+
@close="onClose"
|
|
8
|
+
>
|
|
9
|
+
<a-row :gutter="24">
|
|
10
|
+
<a-col :xl="14" :lg="12" :md="12" :sm="24" :xs="24">
|
|
11
|
+
<a-form-model
|
|
12
|
+
ref="businessCreateForm"
|
|
13
|
+
:rules="rules"
|
|
14
|
+
:model="form"
|
|
15
|
+
:label-col="labelCol"
|
|
16
|
+
:wrapper-col="wrapperCol"
|
|
17
|
+
>
|
|
18
|
+
<a-form-model-item label="查询主表名" prop="tableName">
|
|
19
|
+
<a-input v-model="form.tableName" placeholder="查询用的主表+别名,用空格隔开,如:t_userfiles u"/>
|
|
20
|
+
</a-form-model-item>
|
|
21
|
+
<a-form-model-item label="预设关联表" prop="joinArray">
|
|
22
|
+
<a-popover title="说明" placement="right">
|
|
23
|
+
<template slot="content">
|
|
24
|
+
<p>配置你的查询中可能涉及到的所有关联表</p>
|
|
25
|
+
<p>比如你的查询中涉及到了t_userinfo表,就需要加入t_userinfo表的关联,和你写SQL的关联一样</p>
|
|
26
|
+
<p>请注意,你关联的<span style="color: #ff0000">除主表外的任何表</span>都需要配置</p>
|
|
27
|
+
<a-input-group compact style="width: 400px;">
|
|
28
|
+
<a-input style="width: 20%" placeholder="表别名" readOnly/>
|
|
29
|
+
<a-input style="width: 80%" placeholder="关联条件" readOnly/>
|
|
30
|
+
</a-input-group>
|
|
31
|
+
<a-input-group compact style="width: 400px;">
|
|
32
|
+
<a-input value="ui" style="width: 20%" placeholder="表别名" readOnly/>
|
|
33
|
+
<a-input
|
|
34
|
+
value="t_userinfo ui on i.f_userinfo_id = ui.f_userinfo_id"
|
|
35
|
+
style="width: 80%"
|
|
36
|
+
placeholder="关联条件"
|
|
37
|
+
readOnly/>
|
|
38
|
+
</a-input-group>
|
|
39
|
+
</template>
|
|
40
|
+
<a-button type="primary" @click="addJoinItem()">增加</a-button>
|
|
41
|
+
</a-popover>
|
|
42
|
+
<div v-for="(itemObj, index) in joinArray" :key="index">
|
|
43
|
+
<a-input-group compact>
|
|
44
|
+
<a-input
|
|
45
|
+
@change="changeJoinArray()"
|
|
46
|
+
v-model="itemObj.key"
|
|
47
|
+
style="width: 20%;position: relative;bottom: 1px;"
|
|
48
|
+
placeholder="表别名"/>
|
|
49
|
+
<a-input @change="changeJoinArray()" v-model="itemObj.value" style="width: 80%" placeholder="关联条件">
|
|
50
|
+
<a-icon slot="addonAfter" type="close" @click="removeJoinItem(index)"/>
|
|
51
|
+
</a-input>
|
|
52
|
+
</a-input-group>
|
|
53
|
+
</div>
|
|
54
|
+
</a-form-model-item>
|
|
55
|
+
<a-form-model-item label="SQL查询表达式" prop="condition">
|
|
56
|
+
<a-input v-model="form.condition.value" placeholder="用作SQL查询的固定条件表达式,如:gb.f_meter_type='物联网表',可选"/>
|
|
57
|
+
<template v-if="form.condition.value && Object.keys(form.joinArray).length > 0">
|
|
58
|
+
<a-alert message="提示:如果SQL查询表达式中用到了关联表,需要勾选用到的关联表别名" type="success"/>
|
|
59
|
+
<a-checkbox-group v-model="form.condition.join" :options="conditionJoinArray"/>
|
|
60
|
+
</template>
|
|
61
|
+
</a-form-model-item>
|
|
62
|
+
<a-form-model-item label="排序方式" prop="orderBy">
|
|
63
|
+
<a-input v-model="form.orderBy" placeholder="排序字段,用别名+字段名+排序方式(可选)表示,如:u.id desc"/>
|
|
64
|
+
</a-form-model-item>
|
|
65
|
+
<a-form-model-item label="数据字段" prop="column">
|
|
66
|
+
<a-button type="primary" @click="addColumnItem()">增加</a-button>
|
|
67
|
+
<div v-for="(columnItem, index) in form.column" :key="index">
|
|
68
|
+
<a-row :gutter="16">
|
|
69
|
+
<a-col :span="16">
|
|
70
|
+
<span style="font-weight: bold">{{ columnItem.title }}({{ columnItem.key }})</span>
|
|
71
|
+
</a-col>
|
|
72
|
+
<a-col v-if="index > 0 && form.column.length > 1" :span="2">
|
|
73
|
+
<a-icon type="up-square" @click="upColumnItem(columnItem.key,index)"/>
|
|
74
|
+
</a-col>
|
|
75
|
+
<a-col v-if="(index !== form.column.length - 1) && form.column.length > 1" :span="2">
|
|
76
|
+
<a-icon type="down-square" @click="downColumnItem(columnItem.key,index)"/>
|
|
77
|
+
</a-col>
|
|
78
|
+
<a-col :span="2">
|
|
79
|
+
<a-icon type="edit" @click="editColumnItem(columnItem.key,index)"/>
|
|
80
|
+
</a-col>
|
|
81
|
+
<a-col :span="2">
|
|
82
|
+
<a-icon type="close" @click="removeColumnItem(columnItem.key,index)"/>
|
|
83
|
+
</a-col>
|
|
84
|
+
</a-row>
|
|
85
|
+
</div>
|
|
86
|
+
</a-form-model-item>
|
|
87
|
+
<a-form-model-item label="操作按钮配置" prop="buttonState">
|
|
88
|
+
<a-checkbox-group v-model="buttonStateData" :options="buttonStateArray"/>
|
|
89
|
+
</a-form-model-item>
|
|
90
|
+
</a-form-model>
|
|
91
|
+
<create-query-item ref="queryItem" @itemHandle="itemHandle" @getColumn="getColumn"/>
|
|
92
|
+
<a-button type="primary" @click="view">操作</a-button>
|
|
93
|
+
</a-col>
|
|
94
|
+
<a-col :xl="10" :lg="12" :md="12" :sm="24" :xs="24">
|
|
95
|
+
<a-card :bordered="false" title="预览" size="small" style="overflow: auto">
|
|
96
|
+
<json-viewer
|
|
97
|
+
:copyable="{copyText: '复制', copiedText: '已复制'}"
|
|
98
|
+
:value="result"
|
|
99
|
+
:expand-depth="parseInt('100')"
|
|
100
|
+
style="overflow: auto;max-height: 440px"></json-viewer>
|
|
101
|
+
</a-card>
|
|
102
|
+
</a-col>
|
|
103
|
+
</a-row>
|
|
104
|
+
<a-modal
|
|
105
|
+
title="效果预览"
|
|
106
|
+
:width="isMobile ? screenWidth : screenWidth * 0.8"
|
|
107
|
+
:centered="true"
|
|
108
|
+
:visible="modelVisible"
|
|
109
|
+
:zIndex="1001"
|
|
110
|
+
@cancel="onModelClose"
|
|
111
|
+
:destroyOnClose="true">
|
|
112
|
+
<template slot="footer">
|
|
113
|
+
<a-button key="close" @click="onModelClose">
|
|
114
|
+
返回
|
|
115
|
+
</a-button>
|
|
116
|
+
<a-button key="submit" type="primary" @click="submit">
|
|
117
|
+
保存
|
|
118
|
+
</a-button>
|
|
119
|
+
</template>
|
|
120
|
+
<x-form-table
|
|
121
|
+
:view-mode="true"
|
|
122
|
+
:queryParamsJson="result">
|
|
123
|
+
</x-form-table>
|
|
124
|
+
</a-modal>
|
|
125
|
+
</a-drawer>
|
|
126
|
+
</template>
|
|
127
|
+
|
|
128
|
+
<script>
|
|
129
|
+
import XFormItem from '@vue2-client/base-client/components/common/XForm/XFormItem'
|
|
130
|
+
import XFormTable from '@vue2-client/base-client/components/common/XFormTable/XFormTable'
|
|
131
|
+
import JsonViewer from 'vue-json-viewer'
|
|
132
|
+
import FileSaver from 'file-saver'
|
|
133
|
+
import { mapState } from 'vuex'
|
|
134
|
+
import CreateQueryItem from '@/base-client/components/common/CreateQuery/CreateQueryItem'
|
|
135
|
+
|
|
136
|
+
export default {
|
|
137
|
+
name: 'CreateQuery',
|
|
138
|
+
components: {
|
|
139
|
+
CreateQueryItem,
|
|
140
|
+
JsonViewer,
|
|
141
|
+
XFormTable,
|
|
142
|
+
XFormItem
|
|
143
|
+
},
|
|
144
|
+
data () {
|
|
145
|
+
return {
|
|
146
|
+
// 页面宽度
|
|
147
|
+
screenWidth: document.documentElement.clientWidth,
|
|
148
|
+
// 效果预览模态框是否展示
|
|
149
|
+
modelVisible: false,
|
|
150
|
+
// 操作按钮状态集合
|
|
151
|
+
buttonStateArray: [
|
|
152
|
+
{ label: '新增', value: 'add' },
|
|
153
|
+
{ label: '修改', value: 'edit' },
|
|
154
|
+
{ label: '删除', value: 'delete' },
|
|
155
|
+
{ label: '导出', value: 'export' }
|
|
156
|
+
],
|
|
157
|
+
// 数据模式类型集合值
|
|
158
|
+
buttonStateData: ['add', 'edit', 'delete', 'export'],
|
|
159
|
+
labelCol: { span: 4 },
|
|
160
|
+
wrapperCol: { span: 14 },
|
|
161
|
+
form: {
|
|
162
|
+
tableName: '',
|
|
163
|
+
joinArray: {},
|
|
164
|
+
condition: {},
|
|
165
|
+
orderBy: '',
|
|
166
|
+
column: []
|
|
167
|
+
},
|
|
168
|
+
result: {},
|
|
169
|
+
itemMap: {},
|
|
170
|
+
selectIndex: null,
|
|
171
|
+
joinArray: [],
|
|
172
|
+
rules: {
|
|
173
|
+
tableName: [{ required: true, message: '请输入查询表名', trigger: 'blur' }],
|
|
174
|
+
orderBy: [{ required: true, message: '请输入排序方式', trigger: 'blur' }]
|
|
175
|
+
},
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
mounted () {
|
|
179
|
+
this.initView()
|
|
180
|
+
},
|
|
181
|
+
computed: {
|
|
182
|
+
...mapState('setting', ['isMobile']),
|
|
183
|
+
conditionJoinArray: function () {
|
|
184
|
+
const result = []
|
|
185
|
+
for (const item in this.form.joinArray) {
|
|
186
|
+
if (item !== '') {
|
|
187
|
+
result.push({
|
|
188
|
+
label: item,
|
|
189
|
+
value: item
|
|
190
|
+
})
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (result.length === 0) {
|
|
194
|
+
result.push({
|
|
195
|
+
label: '-',
|
|
196
|
+
value: '-'
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
return result
|
|
200
|
+
},
|
|
201
|
+
buttonState: function () {
|
|
202
|
+
const result = {
|
|
203
|
+
add: false,
|
|
204
|
+
edit: false,
|
|
205
|
+
delete: false,
|
|
206
|
+
export: false
|
|
207
|
+
}
|
|
208
|
+
for (const item of this.buttonStateData) {
|
|
209
|
+
result[item] = true
|
|
210
|
+
}
|
|
211
|
+
return result
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
props: {
|
|
215
|
+
visible: {
|
|
216
|
+
type: Boolean,
|
|
217
|
+
default: false
|
|
218
|
+
},
|
|
219
|
+
toEditJson: {
|
|
220
|
+
type: Object,
|
|
221
|
+
default: () => {}
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
watch: {
|
|
225
|
+
visible (rel) {
|
|
226
|
+
if (rel) {
|
|
227
|
+
this.initView()
|
|
228
|
+
}
|
|
229
|
+
if (rel && this.toEditJson) {
|
|
230
|
+
// 处理预设关联表
|
|
231
|
+
if (this.joinArray.length === 0) {
|
|
232
|
+
for (const key in this.toEditJson.joinArray) {
|
|
233
|
+
this.joinArray.push({
|
|
234
|
+
key: key,
|
|
235
|
+
value: this.toEditJson.joinArray[key]
|
|
236
|
+
})
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
// 处理具体表单项
|
|
240
|
+
this.form = Object.assign(
|
|
241
|
+
{
|
|
242
|
+
tableName: '',
|
|
243
|
+
joinArray: {},
|
|
244
|
+
condition: {},
|
|
245
|
+
orderBy: '',
|
|
246
|
+
column: []
|
|
247
|
+
}, this.toEditJson
|
|
248
|
+
)
|
|
249
|
+
for (const columnItem of this.form.column) {
|
|
250
|
+
// 数据模式兼容性处理
|
|
251
|
+
if (!(columnItem.dataMode || columnItem.dataModeArray)) {
|
|
252
|
+
columnItem.dataModeArray = ['queryForm', 'table', 'addOrEditForm', 'sqlQueryItem', 'sqlQueryCondition']
|
|
253
|
+
} else if (columnItem.dataMode) {
|
|
254
|
+
if (columnItem.dataMode === 'all') {
|
|
255
|
+
columnItem.dataModeArray = ['queryForm', 'table', 'addOrEditForm', 'sqlQueryItem', 'sqlQueryCondition']
|
|
256
|
+
} else if (columnItem.dataMode === 'form') {
|
|
257
|
+
columnItem.dataModeArray = ['queryForm', 'addOrEditForm', 'sqlQueryCondition']
|
|
258
|
+
} else if (columnItem.dataMode === 'table') {
|
|
259
|
+
columnItem.dataModeArray = ['table', 'sqlQueryItem']
|
|
260
|
+
} else if (columnItem.dataMode === 'table_form') {
|
|
261
|
+
columnItem.dataModeArray = ['table', 'sqlQueryItem', 'sqlQueryCondition']
|
|
262
|
+
} else if (columnItem.dataMode === 'only_form') {
|
|
263
|
+
columnItem.dataModeArray = ['queryForm']
|
|
264
|
+
} else if (columnItem.dataMode === 'only_table') {
|
|
265
|
+
columnItem.dataModeArray = ['table']
|
|
266
|
+
} else if (columnItem.dataMode === 'clear') {
|
|
267
|
+
columnItem.dataModeArray = ['sqlQueryItem', 'sqlQueryCondition']
|
|
268
|
+
} else if (columnItem.dataMode === 'only_add_modify') {
|
|
269
|
+
columnItem.dataModeArray = ['addOrEditForm', 'sqlQueryItem']
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
delete columnItem.dataMode
|
|
273
|
+
// 插槽兼容处理
|
|
274
|
+
if (columnItem.slot) {
|
|
275
|
+
if (columnItem.slot.value && columnItem.slot.type === 'ellipsis') {
|
|
276
|
+
columnItem.slotValue = columnItem.slot.value
|
|
277
|
+
} else if (columnItem.slot.keyMap && columnItem.slot.type === 'badge') {
|
|
278
|
+
columnItem.slotKeyMap = columnItem.slot.keyMap
|
|
279
|
+
} else if (columnItem.slot.actionText && columnItem.slot.type === 'action') {
|
|
280
|
+
columnItem.actionText = columnItem.slot.actionText
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
// 必选项兼容处理
|
|
284
|
+
if (columnItem.rule && columnItem.rule.required && columnItem.rule.required !== 'false') {
|
|
285
|
+
columnItem.rule.required = columnItem.rule.required.toString()
|
|
286
|
+
} else {
|
|
287
|
+
if (!columnItem.rule) {
|
|
288
|
+
columnItem.rule = {}
|
|
289
|
+
}
|
|
290
|
+
columnItem.rule.required = 'false'
|
|
291
|
+
}
|
|
292
|
+
// 数据源加载方式兼容处理
|
|
293
|
+
if (columnItem.lazyLoad && columnItem.lazyLoad !== 'false') {
|
|
294
|
+
columnItem.lazyLoad = columnItem.lazyLoad.toString()
|
|
295
|
+
} else {
|
|
296
|
+
columnItem.lazyLoad = 'false'
|
|
297
|
+
}
|
|
298
|
+
// 下拉框数据源兼容处理
|
|
299
|
+
if ((columnItem.formType === 'select' || columnItem.formType === 'cascader') && columnItem.selectKey) {
|
|
300
|
+
// 数据源为logic
|
|
301
|
+
if (columnItem.selectKey.toString().startsWith('logic@')) {
|
|
302
|
+
columnItem.selectType = 'logic'
|
|
303
|
+
} else if (columnItem.selectKey instanceof Array || this.isJSON(columnItem.selectKey)) {
|
|
304
|
+
// 数据源为固定json集合
|
|
305
|
+
if (columnItem.selectKey instanceof Array) {
|
|
306
|
+
columnItem.selectKey = JSON.stringify(columnItem.selectKey)
|
|
307
|
+
}
|
|
308
|
+
columnItem.selectType = 'fixArray'
|
|
309
|
+
} else {
|
|
310
|
+
columnItem.selectType = 'key'
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
this.itemMap[columnItem.key] = Object.assign({
|
|
314
|
+
key: '',
|
|
315
|
+
title: '',
|
|
316
|
+
slot: {},
|
|
317
|
+
rule: {
|
|
318
|
+
required: 'false'
|
|
319
|
+
},
|
|
320
|
+
dataModeArray: []
|
|
321
|
+
}, columnItem)
|
|
322
|
+
}
|
|
323
|
+
// 处理操作按钮配置
|
|
324
|
+
if (this.toEditJson.buttonState) {
|
|
325
|
+
this.buttonStateData = []
|
|
326
|
+
for (const buttonStateKey of Object.keys(this.toEditJson.buttonState)) {
|
|
327
|
+
if (this.toEditJson.buttonState[buttonStateKey]) {
|
|
328
|
+
this.buttonStateData.push(buttonStateKey)
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
} else {
|
|
332
|
+
this.buttonStateData = ['add', 'edit', 'delete', 'export']
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
methods: {
|
|
338
|
+
// 初始化组件
|
|
339
|
+
initView () {
|
|
340
|
+
this.joinArray = []
|
|
341
|
+
this.result = {}
|
|
342
|
+
},
|
|
343
|
+
onClose () {
|
|
344
|
+
this.$emit('update:visible', false)
|
|
345
|
+
},
|
|
346
|
+
onModelClose () {
|
|
347
|
+
this.modelVisible = false
|
|
348
|
+
},
|
|
349
|
+
addJoinItem () {
|
|
350
|
+
this.joinArray.push({
|
|
351
|
+
key: '',
|
|
352
|
+
value: ''
|
|
353
|
+
})
|
|
354
|
+
this.changeJoinArray()
|
|
355
|
+
},
|
|
356
|
+
removeJoinItem (index) {
|
|
357
|
+
this.joinArray.splice(index, 1)
|
|
358
|
+
this.changeJoinArray()
|
|
359
|
+
},
|
|
360
|
+
itemHandle (item, type) {
|
|
361
|
+
this.itemMap[item.key] = item
|
|
362
|
+
if (type === '新增') {
|
|
363
|
+
this.form.column.push(item)
|
|
364
|
+
} else {
|
|
365
|
+
this.$set(this.form.column, this.selectIndex, item)
|
|
366
|
+
}
|
|
367
|
+
this.$message.success(`${type}成功`)
|
|
368
|
+
this.$refs.queryItem.flashModal(false)
|
|
369
|
+
},
|
|
370
|
+
getColumn (callback) {
|
|
371
|
+
callback(JSON.parse(JSON.stringify(this.form.column)))
|
|
372
|
+
},
|
|
373
|
+
addColumnItem () {
|
|
374
|
+
this.type = '新增'
|
|
375
|
+
this.$refs.queryItem.addColumnItemExecute()
|
|
376
|
+
},
|
|
377
|
+
editColumnItem (key, index) {
|
|
378
|
+
if (this.itemMap[key]) {
|
|
379
|
+
this.$refs.queryItem.editColumnItemExecute(this.itemMap[key])
|
|
380
|
+
this.selectIndex = index
|
|
381
|
+
} else {
|
|
382
|
+
this.$message.warn('编辑失败')
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
removeColumnItem (key, index) {
|
|
386
|
+
const _this = this
|
|
387
|
+
this.$confirm({
|
|
388
|
+
title: '您确定要删除该数据项?',
|
|
389
|
+
content: '删除的数据项无法恢复',
|
|
390
|
+
okText: '确定',
|
|
391
|
+
okType: 'danger',
|
|
392
|
+
cancelText: '取消',
|
|
393
|
+
onOk () {
|
|
394
|
+
delete _this.itemMap[key]
|
|
395
|
+
_this.form.column.splice(index, 1)
|
|
396
|
+
}
|
|
397
|
+
})
|
|
398
|
+
},
|
|
399
|
+
upColumnItem (key, index) {
|
|
400
|
+
const newIndex = index - 1
|
|
401
|
+
const itemA = this.form.column[newIndex]
|
|
402
|
+
const itemB = this.form.column[index]
|
|
403
|
+
this.form.column.splice(index, 1, itemA)
|
|
404
|
+
this.form.column.splice(newIndex, 1, itemB)
|
|
405
|
+
},
|
|
406
|
+
downColumnItem (key, index) {
|
|
407
|
+
const newIndex = index + 1
|
|
408
|
+
const itemA = this.form.column[newIndex]
|
|
409
|
+
const itemB = this.form.column[index]
|
|
410
|
+
this.form.column.splice(index, 1, itemA)
|
|
411
|
+
this.form.column.splice(newIndex, 1, itemB)
|
|
412
|
+
},
|
|
413
|
+
changeJoinArray () {
|
|
414
|
+
const joinArrayObject = {}
|
|
415
|
+
for (const item of this.joinArray) {
|
|
416
|
+
joinArrayObject[item.key] = item.value
|
|
417
|
+
}
|
|
418
|
+
this.form.joinArray = joinArrayObject
|
|
419
|
+
},
|
|
420
|
+
exportJson () {
|
|
421
|
+
const data = JSON.stringify(this.form, null, 2)
|
|
422
|
+
const blob = new Blob([data], { type: 'application/json' })
|
|
423
|
+
FileSaver.saveAs(blob, `Query.json`)
|
|
424
|
+
this.$message.success('导出成功!')
|
|
425
|
+
},
|
|
426
|
+
viewHandle (then) {
|
|
427
|
+
if (this.form.column.length === 0) {
|
|
428
|
+
this.$message.error('你没有增加任何数据字段')
|
|
429
|
+
return
|
|
430
|
+
}
|
|
431
|
+
this.result = JSON.parse(JSON.stringify(this.form))
|
|
432
|
+
if (this.result.condition && (!this.result.condition.value || this.result.condition.value === '')) {
|
|
433
|
+
delete this.result.condition
|
|
434
|
+
}
|
|
435
|
+
for (const item of this.result.column) {
|
|
436
|
+
if (item.selectType === 'fixArray') {
|
|
437
|
+
item.selectKey = JSON.parse(item.selectKey)
|
|
438
|
+
}
|
|
439
|
+
if (item.dataModeArray.length === 5) {
|
|
440
|
+
delete item.dataModeArray
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
if (this.buttonStateData.length !== 4) {
|
|
444
|
+
this.result.buttonState = this.buttonState
|
|
445
|
+
}
|
|
446
|
+
then()
|
|
447
|
+
},
|
|
448
|
+
view () {
|
|
449
|
+
this.$refs.businessCreateForm.validate(valid => {
|
|
450
|
+
if (valid) {
|
|
451
|
+
this.viewHandle(() => {
|
|
452
|
+
this.modelVisible = true
|
|
453
|
+
})
|
|
454
|
+
}
|
|
455
|
+
})
|
|
456
|
+
},
|
|
457
|
+
submit () {
|
|
458
|
+
this.onModelClose()
|
|
459
|
+
this.$refs.businessCreateForm.validate(valid => {
|
|
460
|
+
if (valid) {
|
|
461
|
+
this.viewHandle(() => {
|
|
462
|
+
// saveQueryParams
|
|
463
|
+
this.$emit('saveQueryParams', this.result)
|
|
464
|
+
})
|
|
465
|
+
}
|
|
466
|
+
})
|
|
467
|
+
},
|
|
468
|
+
// 判断是否为json字符串
|
|
469
|
+
isJSON (str) {
|
|
470
|
+
if (typeof str == 'string') {
|
|
471
|
+
try {
|
|
472
|
+
const obj = JSON.parse(str)
|
|
473
|
+
return !!(typeof obj == 'object' && obj)
|
|
474
|
+
} catch (e) {
|
|
475
|
+
return false
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
</script>
|
|
482
|
+
<style lang="less" scoped>
|
|
483
|
+
</style>
|