vue2-client 1.2.51 → 1.2.54

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.
Files changed (35) hide show
  1. package/.env +15 -14
  2. package/.eslintrc.js +82 -82
  3. package/CHANGELOG.md +5 -0
  4. package/package.json +1 -1
  5. package/src/base-client/all.js +64 -61
  6. package/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox.vue +225 -0
  7. package/src/base-client/components/common/AddressSearchCombobox/index.js +3 -0
  8. package/src/base-client/components/common/AmapMarker/AmapPointRendering.vue +111 -107
  9. package/src/base-client/components/common/CitySelect/CitySelect.vue +244 -0
  10. package/src/base-client/components/common/CitySelect/index.js +3 -0
  11. package/src/base-client/components/common/CitySelect/index.md +109 -0
  12. package/src/base-client/components/common/CreateQuery/CreateQuery.vue +483 -1342
  13. package/src/base-client/components/common/CreateQuery/CreateQueryItem.vue +770 -555
  14. package/src/base-client/components/common/Upload/Upload.vue +124 -124
  15. package/src/base-client/components/common/Upload/index.js +3 -3
  16. package/src/base-client/components/common/XAddForm/XAddForm.vue +38 -46
  17. package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +316 -316
  18. package/src/base-client/components/common/XForm/XForm.vue +268 -275
  19. package/src/base-client/components/common/XForm/XFormItem.vue +348 -285
  20. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsException.vue +57 -57
  21. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsRead.vue +131 -131
  22. package/src/base-client/components/iot/WebmeterAnalysisView/WebmeterAnalysisView.vue +205 -205
  23. package/src/base-client/components/ticket/TicketSubmitSuccessView/TicketSubmitSuccessView.vue +532 -532
  24. package/src/base-client/plugins/AppData.js +72 -57
  25. package/src/config/CreateQueryConfig.js +298 -80
  26. package/src/pages/resourceManage/orgListManage.vue +40 -40
  27. package/src/router/async/config.async.js +26 -26
  28. package/src/router/index.js +27 -27
  29. package/src/services/api/manage.js +16 -14
  30. package/src/services/api/restTools.js +24 -24
  31. package/src/theme/default/style.less +47 -47
  32. package/src/utils/map-utils.js +28 -29
  33. package/src/utils/request.js +198 -198
  34. package/src/utils/util.js +222 -176
  35. package/vue.config.js +2 -2
@@ -1,555 +1,770 @@
1
- <template>
2
- <a-modal
3
- title="数据字段配置"
4
- :visible="visible"
5
- :width="1250"
6
- :zIndex="1001"
7
- @cancel="modelCancel"
8
- @ok="submitItem">
9
- <a-form-model
10
- ref="itemForm"
11
- :rules="itemRules"
12
- layout="vertical"
13
- :model="item">
14
- <a-row :gutter="16">
15
- <a-col :span="5">
16
- <a-card title="基础属性" :bodyStyle="{height: '500px', overflowY: 'auto'}">
17
- <a-form-model-item label="表单类型" prop="formType">
18
- <a-select v-model="item.formType" placeholder="表单类型,可选" @change="changeFormType(item)">
19
- <a-select-option key="input">输入框</a-select-option>
20
- <a-select-option key="select">选择框</a-select-option>
21
- <a-select-option key="checkbox">多选框</a-select-option>
22
- <a-select-option key="radio">单选框</a-select-option>
23
- <a-select-option key="rangePicker">日期范围选择框</a-select-option>
24
- <a-select-option key="monthPicker">月份选择框</a-select-option>
25
- <a-select-option key="datePicker">单日选择框</a-select-option>
26
- <!-- <a-select-option key="cascader">级联选择框(单个下拉)</a-select-option>-->
27
- <a-select-option key="selects">级联选择框</a-select-option>
28
- <a-select-option key="textarea">文本域</a-select-option>
29
- <a-select-option key="file">文件上传</a-select-option>
30
- <a-select-option key="image">图片上传</a-select-option>
31
- <a-popover slot="suffixIcon" title="关于表单类型" placement="right">
32
- <template slot="content">
33
- <p>预览设置的表单类型</p>
34
- <a-input-group compact style="width: 400px;">
35
- <a-input value="输入框" style="width: 20%" readOnly/>
36
- <a-input style="width: 80%" placeholder="请输入"/>
37
- </a-input-group>
38
- <br/>
39
- <a-input-group compact style="width: 400px;">
40
- <a-input value="选择框" style="width: 20%" readOnly/>
41
- <a-select style="width: 80%" placeholder="请选择"/>
42
- </a-input-group>
43
- <br/>
44
- <a-input-group compact style="width: 400px;">
45
- <a-input value="多选框" style="width: 20%" readOnly/>
46
- <a-checkbox-group
47
- style="margin-left: 10px;margin-top: 5px; width: 70%"
48
- :options="['数据1','数据2']"/>
49
- </a-input-group>
50
- <br/>
51
- <a-input-group compact style="width: 400px;">
52
- <a-input value="单选框" style="width: 20%" readOnly/>
53
- <a-radio-group
54
- style="margin-left: 10px;margin-top: 5px; width: 70%"
55
- :options="[{label: '数据1', value: 'a'},{label: '数据2', value: 'b'}]"
56
- name="radioGroup"/>
57
- </a-input-group>
58
- <br/>
59
- <a-input-group compact style="width: 400px;">
60
- <a-input value="日期范围选择框" style="width: 20%" readOnly/>
61
- <a-range-picker
62
- style="width: 80%"
63
- :show-time="true"
64
- format="YYYY-MM-DD HH:mm:ss"
65
- valueFormat="YYYY-MM-DD HH:mm:ss"/>
66
- </a-input-group>
67
- <br/>
68
- <a-input-group compact style="width: 400px;">
69
- <a-input value="月份选择框" style="width: 20%" readOnly/>
70
- <a-month-picker style="width: 80%"/>
71
- </a-input-group>
72
- <br/>
73
- <a-input-group compact style="width: 400px;">
74
- <a-input value="单日选择框" style="width: 20%" readOnly/>
75
- <a-date-picker style="width: 80%"/>
76
- </a-input-group>
77
- <br/>
78
- <a-input-group compact style="width: 400px;">
79
- <a-input value="级联选择框" style="width: 20%" readOnly/>
80
- <a-cascader style="width: 80%" placeholder="请选择"/>
81
- </a-input-group>
82
- <br/>
83
- <a-input-group compact style="width: 400px;">
84
- <a-input value="文本域" style="width: 20%" readOnly/>
85
- <a-textarea style="width: 80%" placeholder="请输入" :rows="1"/>
86
- </a-input-group>
87
- <br/>
88
- <a-input-group compact style="width: 400px;">
89
- <a-input value="文件上传" style="width: 20%" readOnly/>
90
- <a-upload-dragger
91
- name="file"
92
- :multiple="true"
93
- style="margin-left: 5px; width: 75%"
94
- action="https://www.mocky.io/v2/5cc8019d300000980a055e76">
95
- <p class="ant-upload-drag-icon">
96
- <a-icon type="inbox"/>
97
- </p>
98
- <p class="ant-upload-text">
99
- 点击或拖动文件到该区域上传
100
- </p>
101
- <p class="ant-upload-hint">
102
- 支持单个或多个文件
103
- </p>
104
- </a-upload-dragger>
105
- </a-input-group>
106
- <br/>
107
- <a-input-group compact style="width: 400px;">
108
- <a-input value="图片上传" style="width: 20%" readOnly/>
109
- <a-upload style="margin-left: 5px; width: 75%" list-type="picture-card" :file-list="[]">
110
- <a-icon type="plus"/>
111
- <div class="ant-upload-text">
112
- Upload
113
- </div>
114
- </a-upload>
115
- </a-input-group>
116
- </template>
117
- <a-icon type="info-circle" style="color: rgba(0,0,0,.45)"/>
118
- </a-popover>
119
- </a-select>
120
- </a-form-model-item>
121
- <a-form-model-item
122
- v-if="!(item.formType === 'file' || item.formType === 'image')"
123
- label="数据字段名"
124
- prop="key">
125
- <a-input v-model="item.key" placeholder="请输入数据字段名" ref="key">
126
- <a-popover slot="suffix" title="关于数据字段名" placement="bottom">
127
- <template slot="content">
128
- <p>设置数据字段的名称</p>
129
- <p>用作SQL查询时必须遵守<span style="font-weight: bold">表别名.列名</span>的格式,如:i.id</p>
130
- <p>其他情况下不限制</p>
131
- </template>
132
- <a-icon type="info-circle" style="color: rgba(0,0,0,.45)"/>
133
- </a-popover>
134
- </a-input>
135
- </a-form-model-item>
136
- <a-form-model-item label="数据字段中文名" prop="title">
137
- <a-input v-model="item.title" placeholder="请输入数据字段中文名,如:编号"/>
138
- </a-form-model-item>
139
- <a-form-model-item label="数据模式" prop="dataMode">
140
- <a-checkbox-group v-model="dataModeArrayData" :options="dataModeArray"/>
141
- </a-form-model-item>
142
- </a-card>
143
- </a-col>
144
- <a-col :span="9">
145
- <a-card title="扩展属性" :bodyStyle="{height: '500px', overflowY: 'auto'}">
146
- <a-form-model-item
147
- label="表单水印"
148
- prop="placeholder">
149
- <a-input v-model="item.placeholder" placeholder="表单水印(placeholder),可选" />
150
- </a-form-model-item>
151
- <a-form-model-item label="表单查询方式" prop="queryType">
152
- <a-select v-model="item.queryType" placeholder="表单查询方式,可选">
153
- <template v-for="queryTypeItem in queryTypeV">
154
- <a-select-option :key="queryTypeItem.key">{{ queryTypeItem.label }}</a-select-option>
155
- </template>
156
- </a-select>
157
- </a-form-model-item>
158
- <a-form-model-item label="是否根节点" prop="groupIndexView">
159
- <a-radio-group
160
- defaultValue="None"
161
- v-model="item.groupIndexView"
162
- @change="groupIndexChange"
163
- default-value="false"
164
- button-style="solid">
165
- <a-radio-button :value="1">
166
-
167
- </a-radio-button>
168
- <a-radio-button value="None">
169
-
170
- </a-radio-button>
171
- </a-radio-group>
172
- </a-form-model-item>
173
- <a-form-model-item label="数据所属节点" prop="groupIndex">
174
- <a-select
175
- v-model="item.parent_title"
176
- placeholder="请选择父节点"
177
- ref="groupIndex"
178
- @change="parent_title_change">
179
- <a-select-option v-for="parent_item in parent_node" :key="parent_item.key">{{
180
- parent_item.title
181
- }}
182
- </a-select-option>
183
- <a-popover slot="suffixIcon" title="关于父节点" placement="bottom">
184
- <template slot="content">
185
- <p>多个下拉框为一组时,需要首先选择的为父节点</p>
186
- </template>
187
- <a-icon type="info-circle" style="color: rgba(0,0,0,.45)"/>
188
- </a-popover>
189
- </a-select>
190
- </a-form-model-item>
191
- <a-form-model-item
192
- label="数据源加载方式"
193
- prop="selectLoadType"
194
- v-if="item.formType === 'select' && item.selectType === 'logic'">
195
- <a-radio-group v-model="item.lazyLoad" default-value="false" button-style="solid">
196
- <a-radio-button value="true">
197
- 懒加载搜索
198
- </a-radio-button>
199
- <a-radio-button value="false">
200
- 一次性加载
201
- </a-radio-button>
202
- </a-radio-group>
203
- </a-form-model-item>
204
- <a-form-model-item label="作用域插槽" prop="slot">
205
- <a-select v-model="item.slot.type" placeholder="插槽类型,可选">
206
- <a-select-option key="default">不设置</a-select-option>
207
- <a-select-option key="ellipsis">文本溢出省略</a-select-option>
208
- <a-select-option key="badge">多彩徽标</a-select-option>
209
- <a-select-option key="date">日期格式化</a-select-option>
210
- <a-select-option key="dateTime">日期时间格式化</a-select-option>
211
- <a-select-option key="action">操作列</a-select-option>
212
- <a-popover slot="suffixIcon" title="关于作用域插槽" placement="bottom">
213
- <template slot="content">
214
- <p>你可以通过设置表格列的作用域插槽实现一些效果</p>
215
- <p>如果没有指定,默认会设置为文本溢出省略(长度:16)</p>
216
- <p>如果你选择文本溢出省略,需要设置文本溢出上限长度</p>
217
- <p>如果你选择多彩徽标,需要设置徽标对应的数据样式字典键</p>
218
- </template>
219
- <a-icon type="info-circle" style="color: rgba(0,0,0,.45)"/>
220
- </a-popover>
221
- </a-select>
222
- </a-form-model-item>
223
- <a-form-model-item label="表格列宽度" prop="width">
224
- <a-popover
225
- title="关于表格列宽度"
226
- placement="bottom">
227
- <template slot="content">
228
- <p>当作用域插槽设置为文本溢出省略时,表格列宽度将自适应,计算方式为文本溢出上限长度 * 7 + 42</p>
229
- <p>当作用域插槽设置为多彩徽标时,表格列宽度为固定为130</p>
230
- <p>当作用域插槽设置为日期时间格式化时,表格列宽度为固定为160</p>
231
- <p>当该列数据过长导致换行时,建议设置作用域插槽为文本溢出省略,或将表格列设置为固定宽度值</p>
232
- </template>
233
- <a-input-number style="width: 100%" v-model="item.width" placeholder="表格列宽度,可选"/>
234
- </a-popover>
235
- </a-form-model-item>
236
- <a-form-model-item label="字段默认值" prop="default">
237
- <a-input v-model="item.default" placeholder="当查询结果为null时,指定默认值,可选"/>
238
- </a-form-model-item>
239
- </a-card>
240
- </a-col>
241
- <a-col :span="9">
242
- <a-card title="附加属性" :bodyStyle="{height: '500px', overflowY: 'auto'}">
243
- <a-form-model-item label="表单校验类型" prop="rule">
244
- <a-row :gutter="16">
245
- <a-col :span="8" v-if="item.formType === 'input' || item.formType === 'textarea'">
246
- <a-select v-model="item.rule.type" placeholder="校验类型,可选">
247
- <a-select-option key="string">字符串</a-select-option>
248
- <a-select-option key="number">数字</a-select-option>
249
- <a-select-option key="boolean">布尔值</a-select-option>
250
- <a-select-option key="regexp">正则表达式</a-select-option>
251
- <a-select-option key="integer">整数</a-select-option>
252
- <a-select-option key="float">小数</a-select-option>
253
- <a-select-option key="array">数组或集合</a-select-option>
254
- <a-select-option key="date">日期</a-select-option>
255
- <a-select-option key="email">邮箱</a-select-option>
256
- <a-popover slot="suffixIcon" title="关于表单校验类型" placement="bottom">
257
- <template slot="content">
258
- <p>设置表单项的校验类型,默认字符串类型</p>
259
- <p>你也可以设置该表单项是否必填</p>
260
- </template>
261
- <a-icon type="info-circle" style="color: rgba(0,0,0,.45)"/>
262
- </a-popover>
263
- </a-select>
264
- </a-col>
265
- <a-col :span="8">
266
- <a-radio-group v-model="item.rule.required" default-value="false" button-style="solid">
267
- <a-radio-button value="true">
268
- 必选项
269
- </a-radio-button>
270
- <a-radio-button value="false">
271
- 非必选项
272
- </a-radio-button>
273
- </a-radio-group>
274
- </a-col>
275
- </a-row>
276
- </a-form-model-item>
277
- <a-form-model-item ref="addOrEdit" label="新增/修改场景选择" prop="addOrEdit">
278
- <a-select v-model="item.addOrEdit" placeholder="请选择场景">
279
- <a-select-option key="all">新增和修改</a-select-option>
280
- <a-select-option key="add">仅支持新增</a-select-option>
281
- <a-select-option key="edit">仅支持修改</a-select-option>
282
- <a-select-option key="silenceAdd">静默新增(不生成表单)</a-select-option>
283
- <a-select-option key="version">版本号</a-select-option>
284
- <a-popover
285
- slot="suffixIcon"
286
- title="关于新增/修改场景选择"
287
- placement="bottom">
288
- <template slot="content">
289
- <p>设置表单项的新增/修改场景</p>
290
- <p>静默新增类型用于非人为新增的数据,不会生成表单项,且必须设置字段用途</p>
291
- </template>
292
- <a-icon type="info-circle" style="color: rgba(0,0,0,.45)"/>
293
- </a-popover>
294
- </a-select>
295
- </a-form-model-item>
296
- <a-form-model-item
297
- ref="silencePurpose"
298
- label="字段用途"
299
- prop="silencePurpose">
300
- <a-select v-model="item.silencePurpose" placeholder="请选择字段用途">
301
- <a-select-option key="createTime">创建时间</a-select-option>
302
- <a-select-option key="operator">创建/操作人</a-select-option>
303
- <a-select-option key="orgId">组织机构ID</a-select-option>
304
- <a-select-option key="customize">自定义</a-select-option>
305
- <a-popover
306
- slot="suffixIcon"
307
- title="关于字段用途"
308
- placement="bottom">
309
- <template slot="content">
310
- <p>用于静默新增时设置字段用途</p>
311
- <p>在新增数据的表单提交时,页面会根据设置的字段用途获取相关数据并追加到表单中</p>
312
- <p>当字段用途选择为<span style="font-weight: bold">自定义</span>时,必须指定一个业务逻辑(Logic)名称,表单提交前会将表单内容作为参数调用该Logic接口,并将Logic返回值作为表单值
313
- </p>
314
- </template>
315
- <a-icon type="info-circle" style="color: rgba(0,0,0,.45)"/>
316
- </a-popover>
317
- </a-select>
318
- </a-form-model-item>
319
- <a-form-model-item>
320
- <a-input v-model="item.silenceSource" placeholder="请输入业务逻辑名称"/>
321
- </a-form-model-item>
322
- <a-form-model-item
323
- label="数据源类型"
324
- prop="selectType">
325
- <a-select v-model="item.selectType" placeholder="请选择数据源类型" @change="changeSelectKey(item)">
326
- <a-select-option key="key">字典键</a-select-option>
327
- <a-select-option key="fixArray">固定集合</a-select-option>
328
- <a-select-option key="logic">业务逻辑</a-select-option>
329
- <a-popover
330
- slot="suffixIcon"
331
- title="关于下拉框或级联框数据源类型"
332
- placement="bottom">
333
- <template slot="content">
334
- <p>设置下拉框或级联框的数据源</p>
335
- <p>数据源类型分为三种,你可以根据需要选择</p>
336
- <p>字典键:选项从字典表(t_dictionary)获取,你只需要选择字典键的名称即可</p>
337
- <p>业务逻辑名称:选项通过发起http请求调用指定的业务逻辑(Logic)接口获取</p>
338
- <p>固定集合:选项为静态值,JSONArray格式</p>
339
- <p>当表单类型为 " 级联选择框(多个下拉) " 是数据模式为
340
- [{lable,value,children[{lable,value,children[]},{lable,value,children[]}]}] 形式</p>
341
- <p>如:</p>
342
- <json-viewer
343
- :value="DemoJson"
344
- :expand-depth="parseInt('100')"
345
- style="overflow: auto;max-height: 440px"></json-viewer>
346
- </template>
347
- <a-icon type="info-circle" style="color: rgba(0,0,0,.45)"/>
348
- </a-popover>
349
- </a-select>
350
- </a-form-model-item>
351
- <a-form-model-item
352
- label="数据源"
353
- prop="selectKey">
354
- <a-select
355
- show-search
356
- v-model="item.selectKey"
357
- v-if="item.selectType === 'key'"
358
- placeholder="请选择字典键"
359
- :filter-option="filterOption"
360
- @change="changeSelectKey(item)"
361
- >
362
- <template>
363
- <a-select-option
364
- v-for="(optionItem,index) in option"
365
- :key="index"
366
- :value="Object.keys(optionItem)[0]">{{ optionItem[Object.keys(optionItem)[0]] }}
367
- </a-select-option>
368
- </template>
369
- </a-select>
370
- <a-input v-model="item.selectKey" v-if="item.selectType === 'logic'" placeholder="请输入业务逻辑名称"/>
371
- <a-textarea v-model="item.selectKey" v-if="item.selectType === 'fixArray'" placeholder="请录入数据源"/>
372
- </a-form-model-item>
373
- <a-form-model-item label="数据外键字段名" prop="selectKeyName">
374
- <a-input v-model="item.selectKeyName" placeholder="该列所在表在主表的外键名,可选">
375
- <a-popover slot="suffix" title="关于数据外键字段名" placement="bottom">
376
- <template slot="content">
377
- <p>当该列所属表为主表的关联表,且存在主外键关联关系,你可以指定<span style="font-weight: bold">该列所在表在主表的外键名</span>,如:i.f_type_id
378
- </p>
379
- <p>如果你的<a @click="$refs['key'].focus()">数据字段名</a>所属表为主表,或字段名已经是主表外键名时,不用设置该值</p>
380
- <p>设置该参数是为了表单查询时可以通过外键id列而非具体值筛选数据</p>
381
- <p>示例:</p>
382
- <p>主表为t_userfiles表,别名为u,与t_gasbrand(气表品牌表)有关联关系,别名为g,数据字段名设置为g.f_gasbrand</p>
383
- <p>如果指定了数据外键字段名,例如u.f_gasbrand_id,则使用数据外键字段名筛选数据,如果不指定该值,则使用<a @click="$refs['key'].focus()">数据字段名</a>筛选
384
- </p>
385
- </template>
386
- <a-icon type="info-circle" style="color: rgba(0,0,0,.45)"/>
387
- </a-popover>
388
- </a-input>
389
- </a-form-model-item>
390
- <a-form-model-item
391
- style="margin-bottom: 0"
392
- label="允许上传文件数量"
393
- prop="accept">
394
- <a-slider
395
- v-model="item.acceptCount"
396
- :min="1"
397
- :max="20"
398
- :marks="{ 1: '1', 3: '3', 5: '5', 10: '10', 15: '15', 20: '20'}"
399
- :default-value="3"
400
- />
401
- </a-form-model-item>
402
- <a-form-model-item
403
- label="上传至仓库"
404
- prop="resUploadStock">
405
- <a-select v-model="item.resUploadStock" placeholder="选择文件上传到的仓库" @change="changeStock">
406
- <a-select-option v-for="stock in stockList" :key="stock.id">{{ stock.f_name }}</a-select-option>
407
- </a-select>
408
- </a-form-model-item>
409
- <a-form-model-item
410
- label="仓库扩展路径"
411
- prop="pathKey">
412
- <a-select v-model="item.pathKey" placeholder="仓库扩展路径">
413
- <a-select-option v-for="pathKey in lowerPath" :key="pathKey.label">{{ pathKey.label }}</a-select-option>
414
- </a-select>
415
- </a-form-model-item>
416
- <a-form-model-item label="允许上传文件类型" prop="accept" >
417
- <a-select
418
- mode="tags"
419
- v-model="item.accept"
420
- placeholder="指定文件类型,默认不限制,可选"
421
- @change="itemAcceptChange">
422
- <a-select-option v-for="type_item in fileType" :key="type_item.accept">{{ type_item.label }}
423
- </a-select-option>
424
- <a-popover slot="suffixIcon" title="关于允许上传文件类型" placement="right">
425
- <template slot="content">
426
- <p>指定允许上传的文件类型扩展名,如:.doc,.docx等,详情请参考<a target="_blank" @click="visitAcceptFile">允许上传文件类型</a>
427
- </p>
428
- </template>
429
- <a-icon type="info-circle" style="color: rgba(0,0,0,.45)"/>
430
- </a-popover>
431
- </a-select>
432
- </a-form-model-item>
433
- </a-card>
434
- </a-col>
435
- </a-row>
436
- <a-alert
437
- style="margin-top: 5px"
438
- v-if="dataModeArrayData.length === 0"
439
- show-icon
440
- message="错误:请至少选择一种数据模式"
441
- type="error"/>
442
- <a-alert
443
- style="margin-top: 5px"
444
- v-if="!(item.formType === 'file' || item.formType === 'image') && dataMode.addOrEditForm && !dataMode.sqlQueryItem"
445
- show-icon
446
- message="错误:如果要生成新增/修改表单项,必须勾选生成SQL查询项"
447
- type="error"/>
448
- <a-alert
449
- style="margin-top: 5px"
450
- v-if="(item.formType === 'file' || item.formType === 'image') && !(!dataMode.table && !dataMode.sqlQueryCondition && !dataMode.queryForm)"
451
- show-icon
452
- message="错误:上传类表单的数据模式只能选择 生成新增/修改表单项 和 生成SQL查询项 "
453
- type="error"/>
454
- <a-alert
455
- style="margin-top: 5px"
456
- v-if="dataMode.queryForm && !dataMode.sqlQueryCondition"
457
- show-icon
458
- message="提示:您没有勾选生成SQL查询表达式,渲染的表单项不会生成SQL查询条件"
459
- type="info"/>
460
- <a-alert
461
- style="margin-top: 5px"
462
- v-if="dataMode.table && !dataMode.sqlQueryItem"
463
- show-icon
464
- message="提示:您没有勾选生成SQL查询项,渲染的表格列不会绑定SQL结果集数据"
465
- type="info"/>
466
- </a-form-model>
467
- </a-modal>
468
- </template>
469
-
470
- <script>
471
- export default {
472
- name: 'CreateQueryItem',
473
- components: {},
474
- computed: {
475
- dataMode: function () {
476
- const result = {
477
- queryForm: false,
478
- table: false,
479
- addOrEditForm: false,
480
- sqlQueryItem: false,
481
- sqlQueryCondition: false
482
- }
483
- for (const item of this.dataModeArrayData) {
484
- result[item] = true
485
- }
486
- return result
487
- }
488
- },
489
- data () {
490
- return {
491
- computed: {
492
- },
493
- // 数据模式类型集合
494
- dataModeArray: [
495
- { label: '生成查询表单项', value: 'queryForm' },
496
- { label: '生成表格列', value: 'table' },
497
- { label: '生成新增/修改表单项', value: 'addOrEditForm' },
498
- { label: '生成SQL查询项', value: 'sqlQueryItem' },
499
- { label: '生成SQL查询表达式', value: 'sqlQueryCondition' }
500
- ],
501
- // 数据模式类型集合值
502
- dataModeArrayData: ['queryForm', 'table', 'addOrEditForm', 'sqlQueryItem', 'sqlQueryCondition'],
503
- // 表单项
504
- item: {
505
- key: '',
506
- title: '',
507
- slot: {},
508
- rule: {
509
- required: 'false'
510
- },
511
- formType: undefined,
512
- accept: undefined,
513
- addOrEdit: undefined,
514
- selectKeyName: undefined,
515
- resUploadStock: undefined,
516
- acceptCount: undefined,
517
- dataModeArray: []
518
- },
519
- // 数据仓库列表
520
- stockList: [],
521
- // 扩展目录
522
- lowerPath: [],
523
- // 选择的数据源类型
524
- selectType: undefined,
525
- // 必填控制
526
- itemRules: {
527
- key: [{ required: true, message: '请输入数据列名', trigger: 'blur' }],
528
- title: [{ required: true, message: '请输入中文名称', trigger: 'blur' }],
529
- selectType: [{ required: true, message: '请选择数据源类型', trigger: 'change' }],
530
- selectKey: [{ required: true, message: '请输入数据源内容', trigger: 'blur' }],
531
- slotValue: [{ required: true, message: '请输入文本溢出上限长度', trigger: 'blur' }],
532
- slotKeyMap: [{ required: true, message: '请输入徽标字典键', trigger: 'blur' }],
533
- silencePurpose: [{ required: true, message: '请选择字段用途', trigger: 'change' }],
534
- silenceSource: [{ required: true, message: '请输入业务逻辑名称', trigger: 'blur' }],
535
- group: [{ required: true, message: '请选择父节点', trigger: 'blur' }],
536
- groupIndex: [{ required: true, message: '如果不是根节点请选择自己的父节点', trigger: 'blur' }]
537
- },
538
- // 字典键集合
539
- option: []
540
- }
541
- },
542
- mounted () {
543
- },
544
- props: {
545
- visible: {
546
- type: Boolean,
547
- default: false
548
- },
549
- toEditJson: {
550
- type: Object,
551
- default: () => {}
552
- }
553
- }
554
- }
555
- </script>
1
+ <template>
2
+ <a-modal
3
+ :destroyOnClose="true"
4
+ :visible="visible"
5
+ :width="1250"
6
+ :zIndex="1001"
7
+ title="数据字段配置"
8
+ @cancel="modelCancel"
9
+ @ok="submitItem">
10
+ <a-form-model
11
+ ref="itemForm"
12
+ :model="item"
13
+ :rules="itemRules"
14
+ layout="vertical">
15
+ <a-row :gutter="16">
16
+ <a-col :span="6">
17
+ <a-card :bodyStyle="bodyStyle" title="基本属性">
18
+ <a-divider style="font-size: 14px;margin-top: 0">字段信息</a-divider>
19
+ <a-form-model-item label="标签名称" prop="title">
20
+ <a-input v-model="item.title" placeholder="请输入标签名称"/>
21
+ </a-form-model-item>
22
+ <a-form-model-item
23
+ label="字段名称"
24
+ prop="key">
25
+ <a-input ref="key" v-model="item.key" :disabled="keyDisabled" placeholder="请输入字段名">
26
+ <a-popover slot="suffix" placement="bottom" title="关于字段名称">
27
+ <template slot="content">
28
+ <p>设置数据字段的名称</p>
29
+ <p>用作SQL查询时为<span style="font-weight: bold">表别名.数据列名</span>的格式,如:i.id</p>
30
+ </template>
31
+ <a-icon style="color: rgba(0,0,0,.45)" type="info-circle"/>
32
+ </a-popover>
33
+ </a-input>
34
+ </a-form-model-item>
35
+ <a-form-model-item
36
+ v-if="item.formType ==='addressSearch'"
37
+ label="坐标字段名">
38
+ <a-input :value="`${item.key}_coords`" :disabled="true">
39
+ <a-popover slot="suffix" placement="bottom" title="坐标字段名">
40
+ <template slot="content">
41
+ <p>表单类型为地点搜索框时:</p>
42
+ <p>新增/修改表单内,字段名称会存放地址名称,坐标字段名会存放坐标信息</p>
43
+ </template>
44
+ <a-icon style="color: rgba(0,0,0,.45)" type="info-circle"/>
45
+ </a-popover>
46
+ </a-input>
47
+ </a-form-model-item>
48
+ <a-divider style="font-size: 14px;margin-top: 0">数据模式</a-divider>
49
+ <a-form-model-item
50
+ prop="dataMode"
51
+ style="margin-top: 10px;">
52
+ <a-checkbox-group v-model="dataModeArrayData" :disabled="dataModeDisabled" :options="dataModeTypeV"/>
53
+ </a-form-model-item>
54
+ </a-card>
55
+ </a-col>
56
+ <a-col :span="9">
57
+ <a-card v-if="dataMode.queryForm || dataMode.addOrEditForm || dataMode.table" :bodyStyle="bodyStyle" title="核心配置">
58
+ <template v-if="dataMode.queryForm || dataMode.addOrEditForm">
59
+ <a-divider style="font-size: 14px;margin-top: 0">表单配置</a-divider>
60
+ <a-form-model-item label="表单类型" prop="formType">
61
+ <a-select v-model="item.formType" placeholder="请选择表单类型" @change="changeFormType(item)">
62
+ <a-select-option v-for="formTypeItem in formType" :key="formTypeItem.key">{{ formTypeItem.label }}</a-select-option>
63
+ </a-select>
64
+ </a-form-model-item>
65
+ <template v-if="item.formType">
66
+ <a-form-model-item v-if="dataMode.sqlQueryCondition && item.formType !=='file' && item.formType !=='image' " label="表单查询方式" prop="queryType">
67
+ <a-select
68
+ v-model="item.queryType"
69
+ :disabled="formQueryTypeDisabled"
70
+ placeholder="表单查询方式"
71
+ :getPopupContainer=" triggerNode => { return triggerNode.parentNode } ">
72
+ <a-select-option v-for="queryTypeItem in queryTypeV" :key="queryTypeItem.key">{{ queryTypeItem.label }}</a-select-option>
73
+ </a-select>
74
+ </a-form-model-item>
75
+ <a-form-model-item v-if="dataMode.addOrEditForm" label="表单校验" prop="rule">
76
+ <a-row :gutter="16">
77
+ <a-col v-if="item.formType === 'input' || item.formType === 'textarea' && item.formType !=='file' && item.formType !=='image' " :span="12" >
78
+ <a-select v-model="item.rule.type" placeholder="校验类型" :getPopupContainer=" triggerNode => { return triggerNode.parentNode } ">
79
+ <a-select-option v-for="ruleTypeItem in formRuleType" :key="ruleTypeItem.key">{{ ruleTypeItem.label }}</a-select-option>
80
+ <a-popover slot="suffixIcon" placement="bottom" title="关于表单校验类型">
81
+ <template slot="content">
82
+ <p>设置表单项的校验类型</p>
83
+ </template>
84
+ <a-icon style="color: rgba(0,0,0,.45)" type="info-circle"/>
85
+ </a-popover>
86
+ </a-select>
87
+ </a-col>
88
+ <a-col :span="12">
89
+ <a-radio-group v-model="item.rule.required" button-style="solid" default-value="false">
90
+ <a-radio-button value="true">
91
+ 必选项
92
+ </a-radio-button>
93
+ <a-radio-button value="false">
94
+ 非必选项
95
+ </a-radio-button>
96
+ </a-radio-group>
97
+ </a-col>
98
+ </a-row>
99
+ </a-form-model-item>
100
+ <a-form-model-item v-if="dataMode.addOrEditForm" label="新增/修改场景选择" prop="addOrEdit">
101
+ <a-select v-model="item.addOrEdit" placeholder="请选择场景">
102
+ <a-select-option v-for="addOrEditItem in addOrEditTypeV" :key="addOrEditItem.key">{{ addOrEditItem.label }}</a-select-option>
103
+ <a-popover
104
+ slot="suffixIcon"
105
+ placement="bottom"
106
+ title="关于新增/修改场景选择">
107
+ <template slot="content">
108
+ <p>设置表单项的新增/修改场景</p>
109
+ <p>静默新增类型用于非人为新增的数据,不会生成表单项,且必须设置字段用途</p>
110
+ </template>
111
+ <a-icon style="color: rgba(0,0,0,.45)" type="info-circle"/>
112
+ </a-popover>
113
+ </a-select>
114
+ </a-form-model-item>
115
+ <a-form-model-item v-if="item.addOrEdit === 'silenceAdd'" label="字段用途" prop="silencePurpose">
116
+ <a-select v-model="item.silencePurpose" placeholder="请选择字段用途" :getPopupContainer=" triggerNode => { return triggerNode.parentNode } ">
117
+ <a-select-option v-for="silencePurposeTypeItem in silencePurposeType" :key="silencePurposeTypeItem.key">{{ silencePurposeTypeItem.label }}</a-select-option>
118
+ <a-popover
119
+ slot="suffixIcon"
120
+ placement="bottom"
121
+ title="关于字段用途">
122
+ <template slot="content">
123
+ <p>用于静默新增时设置字段用途</p>
124
+ <p>在新增数据的表单提交时,页面会根据设置的字段用途自动获取相关数据并追加到表单中</p>
125
+ <p>当字段用途选择为<span style="font-weight: bold">自定义</span>时,必须指定一个业务逻辑(Logic)名称,表单提交前会将表单内容作为参数调用该Logic接口,并将Logic返回值作为表单值
126
+ </p>
127
+ </template>
128
+ <a-icon style="color: rgba(0,0,0,.45)" type="info-circle"/>
129
+ </a-popover>
130
+ </a-select>
131
+ </a-form-model-item>
132
+ <a-form-model-item v-if="item.silencePurpose === 'customize'" label="字段用途对应Logic" prop="silenceSource">
133
+ <a-input v-model="item.silenceSource" placeholder="请输入业务逻辑名称"/>
134
+ </a-form-model-item>
135
+ </template>
136
+ </template>
137
+ <template v-if="dataMode.table">
138
+ <a-divider style="font-size: 14px;margin-top: 0">表格列配置</a-divider>
139
+ <a-form-model-item v-if="item.formType" label="作用域插槽" prop="slot">
140
+ <a-select v-model="item.slot.type" :disabled="slotTypeDisabled" placeholder="插槽类型" :getPopupContainer=" triggerNode => { return triggerNode.parentNode } ">
141
+ <a-select-option v-for="slotTypeItem in slotTypeV" :key="slotTypeItem.key">{{ slotTypeItem.label }}</a-select-option>
142
+ <a-popover slot="suffixIcon" placement="bottom" title="关于作用域插槽">
143
+ <template slot="content">
144
+ <p>你可以通过设置表格列的作用域插槽实现一些效果</p>
145
+ <p>如果没有指定,默认会设置为文本溢出省略(长度:16)</p>
146
+ <p>如果你选择文本溢出省略,需要设置文本溢出上限长度,建议ID主键等类型设置为8</p>
147
+ <p>如果你选择多彩徽标,需要设置徽标对应的数据样式字典键</p>
148
+ <a-divider style="font-size: 14px;margin-top: 0">关于表格列宽度</a-divider>
149
+ <p>V1.1之后不再支持自定义表格列宽度,表格列宽度将通过作用域插槽类型自适应</p>
150
+ <p>设置为文本溢出省略时,表格列宽度 = 文本溢出上限长度 * 7 + 42</p>
151
+ <p>设置为多彩徽标时,表格列宽度为130</p>
152
+ <p>设置为日期时间格式化时,表格列宽度为160</p>
153
+ </template>
154
+ <a-icon style="color: rgba(0,0,0,.45)" type="info-circle"/>
155
+ </a-popover>
156
+ </a-select>
157
+ </a-form-model-item>
158
+ <a-form-model-item v-if="item.slot.type === 'badge'" label="徽标字典键" prop="slot.keyMap">
159
+ <a-input v-model="item.slot.keyMap" :disabled="slotTypeDisabled" placeholder="请输入徽标字典键">
160
+ <a-popover
161
+ slot="suffix"
162
+ placement="bottom"
163
+ title="关于徽标字典键">
164
+ <template slot="content">
165
+ <p>如果你设置了表单类型为选择框,且数据源是字典键,该值会自动带出</p>
166
+ </template>
167
+ <a-icon style="color: rgba(0,0,0,.45)" type="info-circle"/>
168
+ </a-popover>
169
+ </a-input>
170
+ </a-form-model-item>
171
+ <a-form-model-item v-if="item.slot.type === 'ellipsis'" label="文本溢出上限长度" prop="slot.value">
172
+ <a-input-number v-model="item.slot.value" placeholder="请输入文本溢出上限长度" style="width: 100%"/>
173
+ </a-form-model-item>
174
+ <a-form-model-item v-if="item.slot.type === 'action'" label="操作列文本" prop="slot.actionText">
175
+ <a-input v-model="item.slot.actionText" placeholder="请输入操作列显示文本,默认为详情"/>
176
+ </a-form-model-item>
177
+ <a-form-model-item label="字段默认值" prop="default" v-if="dataMode.sqlQueryItem">
178
+ <a-input v-model="item.default" placeholder="当查询结果为null时,指定默认值"/>
179
+ </a-form-model-item>
180
+ </template>
181
+ </a-card>
182
+ </a-col>
183
+ <a-col v-if="item.formType" :span="9">
184
+ <a-card :bodyStyle="bodyStyle" title="扩展属性">
185
+ <template v-if="item.formType === 'input' || item.formType === 'select' || item.formType === 'selects'">
186
+ <a-divider style="font-size: 14px;margin-top: 0">提示相关</a-divider>
187
+ <a-form-model-item label="表单水印" prop="placeholder">
188
+ <a-input v-model="item.placeholder" placeholder="表单水印(placeholder)" />
189
+ </a-form-model-item>
190
+ </template>
191
+ <template v-if="item.formType === 'selects'">
192
+ <a-divider style="font-size: 14px;margin-top: 0">级联选择相关</a-divider>
193
+ <a-form-model-item label="是否根节点" prop="groupIndexView">
194
+ <a-radio-group
195
+ v-model="item.groupIndexView"
196
+ button-style="solid"
197
+ @change="groupIndexChange">
198
+ <a-radio-button value="1">
199
+
200
+ </a-radio-button>
201
+ <a-radio-button value="0">
202
+
203
+ </a-radio-button>
204
+ </a-radio-group>
205
+ </a-form-model-item>
206
+ <a-form-model-item v-show="item.groupIndexView === '0' && item.groupIndex !== -1" label="所属父级联动框" prop="groupIndex">
207
+ <a-select
208
+ ref="groupIndex"
209
+ v-model="item.parent_title"
210
+ placeholder="请选择父级联动框"
211
+ :getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
212
+ @change="parent_title_change">
213
+ <a-select-option v-for="parent_item in parent_node" :key="parent_item.key">
214
+ {{ parent_item.title }}
215
+ </a-select-option>
216
+ </a-select>
217
+ </a-form-model-item>
218
+ </template>
219
+ <template v-if="selectDataShow">
220
+ <a-divider style="font-size: 14px;margin-top: 0">数据源相关</a-divider>
221
+ <a-form-model-item label="数据源类型" prop="selectType">
222
+ <a-select v-model="item.selectType" placeholder="请选择数据源类型" @change="changeSelectKType">
223
+ <a-select-option v-for="selectDataTypeItem in selectDataType" :key="selectDataTypeItem.key">{{ selectDataTypeItem.label }}</a-select-option>
224
+ <a-popover
225
+ slot="suffixIcon"
226
+ placement="bottom"
227
+ title="关于数据源类型">
228
+ <template slot="content">
229
+ <p>设置数据源</p>
230
+ <p>数据源类型分为三种,你可以根据需要选择</p>
231
+ <p>字典键:选项从字典表(t_dictionary)获取,你只需要选择字典键的名称即可</p>
232
+ <p>业务逻辑名称:选项通过发起http请求调用指定的业务逻辑(Logic)接口获取</p>
233
+ <p>固定集合:选项为静态值,JSONArray格式</p>
234
+ <p>当表单为级联选择框类型时,返回的数据需按照以下形式:</p>
235
+ <json-viewer
236
+ :expand-depth="parseInt('100')"
237
+ :value="DemoJson"
238
+ style="overflow: auto;max-height: 440px"></json-viewer>
239
+ </template>
240
+ <a-icon style="color: rgba(0,0,0,.45)" type="info-circle"/>
241
+ </a-popover>
242
+ </a-select>
243
+ </a-form-model-item>
244
+ <a-form-model-item v-if="item.selectType" label="数据源" prop="selectKey">
245
+ <a-select
246
+ v-if="item.selectType === 'key'"
247
+ v-model="item.selectKey"
248
+ :filter-option="filterOption"
249
+ placeholder="请选择字典键"
250
+ show-search
251
+ @change="changeSelectKey(item)">
252
+ <template>
253
+ <a-select-option
254
+ v-for="(optionItem,index) in option"
255
+ :key="index"
256
+ :value="Object.keys(optionItem)[0]">{{ optionItem[Object.keys(optionItem)[0]] }}
257
+ </a-select-option>
258
+ </template>
259
+ </a-select>
260
+ <a-input v-if="item.selectType === 'logic'" v-model="item.selectKey" placeholder="请输入业务逻辑名称"/>
261
+ <a-textarea v-if="item.selectType === 'fixArray'" v-model="item.selectKey" placeholder="请录入数据源"/>
262
+ </a-form-model-item>
263
+ <a-form-model-item v-if="item.selectType === 'logic'" label="数据源加载方式" prop="selectLoadType">
264
+ <a-radio-group v-model="item.lazyLoad" button-style="solid" default-value="false">
265
+ <a-radio-button value="true">
266
+ 懒加载搜索
267
+ </a-radio-button>
268
+ <a-radio-button value="false">
269
+ 一次性加载
270
+ </a-radio-button>
271
+ </a-radio-group>
272
+ </a-form-model-item>
273
+ </template>
274
+ <a-form-model-item v-if="selectDataShow || item.groupIndexView" label="关联外键字段" prop="selectKeyName">
275
+ <a-input v-model="item.selectKeyName" placeholder="该列关联的外键字段">
276
+ <a-popover slot="suffix" placement="bottom" title="关于关联外键字段">
277
+ <template slot="content">
278
+ <p><span style="font-weight: bold;"><span style="color: #FF0036">非必需的实验性功能:</span>设置该参数需开发岗指导</span></p>
279
+ <p>当字段与主子表外键有关系时,你可以指定<span style="font-weight: bold">该列所关联的外键字段名</span>
280
+ </p>
281
+ <p>设置该参数是为了该字段用作表单查询时,系统可以通过设置的关联外键字段,而非字面值作为查询条件</p>
282
+ <p>示例:</p>
283
+ <p>主表为t_userfiles(表档案)表,别名为u,与t_gasbrand(气表品牌表)有关联关系,别名为g,为了显示表档案对应的气表品牌数据,我们将数据字段名设置为g.f_gasbrand</p>
284
+ <p>这样我们就可以在table中看到气表品牌了,但是用户如果通过气表品牌下拉框进行筛选,我们指定的g.f_gasbrand只是气表品牌的值,而实际关联字段是u.f_gasbrand_id</p>
285
+ <p>所以如果我们指定了关联外键字段u.f_gasbrand_id,系统则会使用u.f_gasbrand_id筛选数据,而不是g.f_gasbrand,从而优化了查询效率
286
+ </p>
287
+ </template>
288
+ <a-icon style="color: rgba(0,0,0,.45)" type="info-circle"/>
289
+ </a-popover>
290
+ </a-input>
291
+ </a-form-model-item>
292
+ <template v-if="item.formType === 'file' || item.formType === 'image'">
293
+ <a-divider style="font-size: 14px;margin-top: 0">文件上传相关</a-divider>
294
+ <a-form-model-item label="允许上传文件数量" prop="accept" style="margin-bottom: 5px;">
295
+ <a-slider
296
+ v-model="item.acceptCount"
297
+ :marks="{ 1: '1', 3: '3', 5: '5', 10: '10', 15: '15', 20: '20'}"
298
+ :max="20"
299
+ :min="1"
300
+ />
301
+ </a-form-model-item>
302
+ <a-form-model-item label="上传的仓库" prop="resUploadStock">
303
+ <a-select v-model="item.resUploadStock" placeholder="选择文件上传到的仓库" @change="changeStock">
304
+ <a-select-option v-for="stock in stockList" :key="stock.id">{{ stock.f_name }}</a-select-option>
305
+ </a-select>
306
+ </a-form-model-item>
307
+ <a-form-model-item v-if="item.resUploadStock" label="具体路径" prop="pathKey">
308
+ <a-select v-model="item.pathKey" placeholder="仓库扩展路径">
309
+ <a-select-option v-for="pathKey in lowerPath" :key="pathKey.label">{{ pathKey.label }}</a-select-option>
310
+ </a-select>
311
+ </a-form-model-item>
312
+ <a-form-model-item v-if="item.formType === 'file'" label="允许上传文件类型" prop="accept">
313
+ <a-select v-model="item.accept" mode="tags" placeholder="指定文件类型,默认不限制" @change="itemAcceptChange">
314
+ <a-select-option v-for="type_item in fileType" :key="type_item.accept">{{ type_item.label }}</a-select-option>
315
+ </a-select>
316
+ </a-form-model-item>
317
+ </template>
318
+ </a-card>
319
+ </a-col>
320
+ </a-row>
321
+ <a-alert
322
+ v-if="dataModeArrayData.length === 0"
323
+ message="错误:请至少选择一种数据模式"
324
+ show-icon
325
+ style="margin-top: 5px"
326
+ type="error"/>
327
+ <a-alert
328
+ v-if="dataMode.addOrEditForm && !dataMode.sqlQueryItem && item.formType !== 'file' && item.formType !== 'image' "
329
+ message="错误:如果要生成新增/修改表单项,必须勾选生成SQL查询项"
330
+ show-icon
331
+ style="margin-top: 5px"
332
+ type="error"/>
333
+ <a-alert
334
+ v-if="dataMode.queryForm && !dataMode.sqlQueryCondition"
335
+ message="提示:您没有勾选生成SQL查询表达式,渲染的表单项不会生成SQL查询条件"
336
+ show-icon
337
+ style="margin-top: 5px"
338
+ type="info"/>
339
+ <a-alert
340
+ v-if="dataMode.table && !dataMode.sqlQueryItem"
341
+ message="提示:您没有勾选生成SQL查询项,渲染的表格列不会绑定SQL结果集数据"
342
+ show-icon
343
+ style="margin-top: 5px"
344
+ type="info"/>
345
+ </a-form-model>
346
+ </a-modal>
347
+ </template>
348
+
349
+ <script>
350
+ import {
351
+ dataModeType,
352
+ fileType,
353
+ formRuleType,
354
+ formType,
355
+ queryType,
356
+ slotType,
357
+ silencePurposeType,
358
+ addOrEditType,
359
+ selectDataType
360
+ } from '@vue2-client/config/CreateQueryConfig'
361
+ import { commonApi, post } from '@/services/api'
362
+ import JsonViewer from 'vue-json-viewer'
363
+
364
+ const DemoJson = [{
365
+ value: 'zhejiang',
366
+ label: 'Zhejiang',
367
+ children: [{ value: 'hangzhou', label: 'Hangzhou', children: [{ value: 'xihu', label: 'West Lake' }] }]
368
+ }]
369
+
370
+ export default {
371
+ name: 'CreateQueryItem',
372
+ components: {
373
+ JsonViewer
374
+ },
375
+ computed: {
376
+ // 是否展示数据源相关字段
377
+ selectDataShow () {
378
+ return this.item.formType === 'select' || (this.item.formType === 'selects' && this.item.groupIndexView === '1') || this.item.formType === 'checkbox' || this.item.formType === 'radio'
379
+ },
380
+ // 作用域插槽是否禁用
381
+ slotTypeDisabled () {
382
+ return this.item.selectType === 'key' && this.item.selectKey
383
+ },
384
+ // 字段名称是否禁用
385
+ keyDisabled () {
386
+ return this.item.formType === 'file' || this.item.formType === 'image'
387
+ },
388
+ // 数据模式是否禁用
389
+ dataModeDisabled () {
390
+ return this.item.formType === 'file' || this.item.formType === 'image' || this.item.formType === 'addressSearch'
391
+ },
392
+ dataMode: function () {
393
+ const result = {
394
+ queryForm: false,
395
+ table: false,
396
+ addOrEditForm: false,
397
+ sqlQueryItem: false,
398
+ sqlQueryCondition: false
399
+ }
400
+ for (const item of this.dataModeArrayData) {
401
+ result[item] = true
402
+ }
403
+ return result
404
+ },
405
+ queryTypeV () {
406
+ return queryType.filter(item => {
407
+ return item.match.findIndex(type => type === this.item.formType || type === 'all') > -1
408
+ })
409
+ },
410
+ dataModeTypeV () {
411
+ if (this.item.formType) {
412
+ return dataModeType.filter(item => {
413
+ return item.noMatch.findIndex(type => type === this.item.formType) === -1
414
+ })
415
+ } else {
416
+ return dataModeType
417
+ }
418
+ },
419
+ slotTypeV () {
420
+ return slotType.filter(item => {
421
+ return item.match.findIndex(type => type === this.item.formType || type === 'all') > -1
422
+ })
423
+ },
424
+ addOrEditTypeV () {
425
+ return addOrEditType.filter(item => {
426
+ return item.match.findIndex(type => type === this.item.formType || type === 'all') > -1
427
+ })
428
+ }
429
+ },
430
+ data () {
431
+ return {
432
+ DemoJson,
433
+ dataModeType,
434
+ queryType,
435
+ formType,
436
+ formRuleType,
437
+ slotType,
438
+ fileType,
439
+ silencePurposeType,
440
+ addOrEditType,
441
+ selectDataType,
442
+ // 控制modal框
443
+ visible: false,
444
+ type: '',
445
+ bodyStyle: {
446
+ height: '500px',
447
+ overflowY: 'auto'
448
+ },
449
+ // 表单查询方式是否禁用
450
+ formQueryTypeDisabled: false,
451
+ // 数据模式类型集合值
452
+ dataModeArrayData: [],
453
+ // 表单项
454
+ item: {
455
+ key: '',
456
+ title: '',
457
+ slot: {
458
+ type: 'default'
459
+ },
460
+ rule: {
461
+ required: 'false'
462
+ },
463
+ queryType: '=',
464
+ formType: 'input',
465
+ accept: undefined,
466
+ pathKey: undefined,
467
+ groupIndexView: undefined,
468
+ selectType: undefined,
469
+ addOrEdit: 'all',
470
+ fileRootPath: undefined,
471
+ selectKeyName: undefined,
472
+ resUploadStock: undefined,
473
+ dataModeArray: []
474
+ },
475
+ // 数据仓库列表
476
+ stockList: [],
477
+ // 扩展目录
478
+ lowerPath: [],
479
+ parent_node: [],
480
+ // 必填控制
481
+ itemRules: {
482
+ formType: [{ required: true, message: '请输入表单类型', trigger: 'change' }],
483
+ key: [{ required: true, message: '请输入字段名称', trigger: 'blur' }],
484
+ title: [{ required: true, message: '请输入标签名称', trigger: 'blur' }],
485
+ selectType: [{ required: true, message: '请选择数据源类型', trigger: 'change' }],
486
+ selectKey: [{ required: true, message: '请输入数据源内容', trigger: 'blur' }],
487
+ 'slot.value': [{ required: true, message: '请输入文本溢出上限长度', trigger: 'blur' }],
488
+ 'slot.keyMap': [{ required: true, message: '请输入徽标字典键', trigger: 'blur' }],
489
+ silencePurpose: [{ required: true, message: '请选择字段用途', trigger: 'change' }],
490
+ silenceSource: [{ required: true, message: '请输入业务逻辑名称', trigger: 'blur' }],
491
+ groupIndex: [{ required: true, message: '请选择父级联动框', trigger: 'blur' }],
492
+ resUploadStock: [{ required: true, message: '请选择上传到的仓库', trigger: 'blur' }],
493
+ pathKey: [{ required: true, message: '请选择上传到的扩展目录', trigger: 'blur' }]
494
+ },
495
+ // 字典键集合
496
+ option: []
497
+ }
498
+ },
499
+ mounted () {
500
+ this.resetDataMode()
501
+ },
502
+ props: { },
503
+ methods: {
504
+ initItem (lysis = {}) {
505
+ this.item = Object.assign({
506
+ key: '',
507
+ title: '',
508
+ slot: {
509
+ type: 'default'
510
+ },
511
+ rule: {
512
+ required: 'false'
513
+ },
514
+ selectKey: undefined,
515
+ queryType: '=',
516
+ formType: 'input',
517
+ fileRootPath: undefined,
518
+ pathKey: undefined,
519
+ accept: undefined,
520
+ selectType: undefined,
521
+ groupIndexView: undefined,
522
+ addOrEdit: 'all',
523
+ selectKeyName: undefined,
524
+ resUploadStock: undefined,
525
+ dataModeArray: []
526
+ }, lysis)
527
+ },
528
+ // 控制 展示
529
+ flashModal (show = 'None') {
530
+ const bool = show === 'None' ? !this.visible : !!show
531
+ if (bool && this.option.length === 0) {
532
+ post(commonApi.getDictionaryParam, {}).then(res => {
533
+ this.option = res
534
+ })
535
+ }
536
+ this.visible = bool
537
+ },
538
+ // 编辑数据字段前准备数据
539
+ editColumnItemExecute (_item) {
540
+ this.type = '修改'
541
+ const defaultValue = { formType: 'input', type: 'string', addOrEdit: 'all', slot: { type: 'default' }, rule: {}, selectKey: {} }
542
+ if (!_item.queryType) {
543
+ defaultValue.queryType = '='
544
+ }
545
+ _item = Object.assign({}, defaultValue, _item)
546
+ if (_item.formType === 'file' || _item.formType === 'image') {
547
+ this.getStocks()
548
+ // 如果有仓库 则获取该仓库的扩展路径
549
+ if (_item.resUploadStock) {
550
+ this.lowerPath = this.stockList.filter(item => item.id === _item.resUploadStock)[0]?.f_lower_path_json ?? []
551
+ }
552
+ }
553
+ if (_item.formType === 'selects') {
554
+ // 因为 groupIndex 可能有很多值 单选框不行 赋给一个新的变量
555
+ _item.groupIndexView = _item.groupIndex === 1 ? '1' : '0'
556
+ }
557
+ // 兼容旧作用域插槽属性
558
+ this.compatibleTheSlot(_item)
559
+ this.item = _item
560
+ this.dataModeArrayData = this.item.dataModeArray
561
+ this.flashModal()
562
+ },
563
+ // 增加数据字段前数据处理
564
+ addColumnItemExecute () {
565
+ this.type = '新增'
566
+ this.dataModeArrayData = ['queryForm', 'table', 'addOrEditForm', 'sqlQueryItem', 'sqlQueryCondition']
567
+ this.initItem()
568
+ this.flashModal()
569
+ },
570
+ modelCancel () {
571
+ this.flashModal()
572
+ // this.$emit('update:visible', false)
573
+ // // 延迟是为了避免编辑数据窗口关闭时重置表单导致的闪烁
574
+ // setTimeout(() => {
575
+ // this.resetDataMode()
576
+ // this.resetFormProp()
577
+ // }, 100)
578
+ },
579
+ submitItem () {
580
+ this.$refs.itemForm.validate(valid => {
581
+ if (valid) {
582
+ const fileBool = this.item.formType === 'file' || this.item.formType === 'image'
583
+ if (this.dataModeArrayData.length === 0) {
584
+ this.$message.error('请至少选择一种数据模式')
585
+ return
586
+ }
587
+ if (!fileBool && (this.dataMode.addOrEditForm && !this.dataMode.sqlQueryItem)) {
588
+ this.$message.error('如果要生成新增/修改表单项,必须勾选生成SQL查询项')
589
+ return
590
+ }
591
+ if (fileBool && !(!this.dataMode.table && !this.dataMode.sqlQueryCondition && !this.dataMode.queryForm)) {
592
+ this.$message.error(`上传类表单项只能选择 "渲染新增/修改表单项"`)
593
+ return
594
+ }
595
+ this.itemHandle()
596
+ }
597
+ })
598
+ },
599
+ visitAcceptFile () {
600
+ window.open('https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/input/file#attr-accept')
601
+ },
602
+ // 修改上传到哪个仓库
603
+ changeStock (stock) {
604
+ if (stock) {
605
+ const stockValue = this.stockList.filter(item => item.id === stock)[0]
606
+ this.lowerPath = stockValue.f_lower_path_json ?? []
607
+ this.item.resUploadMode = stockValue.f_stock_type
608
+ this.item.fileRootPath = stockValue.f_root_path
609
+ this.item.stockAlias = stockValue.f_alias
610
+ this.item.pathKey = undefined
611
+ }
612
+ },
613
+ // 文件上传限制类型修改
614
+ itemAcceptChange (newVal) {
615
+ if (newVal.includes('*')) {
616
+ this.item.accept = ['*']
617
+ }
618
+ },
619
+ parent_title_change (parentKey) {
620
+ const parentArr = this.getColumn().filter(item => item.formType === 'selects' && item.key === parentKey)
621
+ if (parentArr.length === 1) {
622
+ this.item.groupIndex = parentArr[0].groupIndex + 1
623
+ this.item.group = parentArr[0].group
624
+ this.item.parent_title = parentArr[0].title
625
+ } else {
626
+ this.$message.error('数据字段中有字段别名相同,请检查!')
627
+ }
628
+ },
629
+ groupIndexChange ({ target }) {
630
+ if (target.value === '1') {
631
+ this.item.groupIndex = 1
632
+ this.item.groupIndexView = '1'
633
+ if (this.item.title) {
634
+ this.item.group = this.item.title + '组'
635
+ } else {
636
+ this.item.groupIndex = undefined
637
+ this.item.groupIndexView = undefined
638
+ this.$message.error('请先输入字段中文名称!')
639
+ }
640
+ } else {
641
+ if (!this.item.title) {
642
+ this.$message.error('请先输入字段名称!')
643
+ this.item.groupIndex = -1
644
+ this.item.groupIndexView = undefined
645
+ return
646
+ }
647
+ this.item.groupIndex = undefined
648
+ // 获取所有可以当作父节点的字段
649
+ this.parent_node = this.getColumn().filter(item => item.formType === 'selects' && item.key !== this.item.key)
650
+ }
651
+ },
652
+ getColumn () {
653
+ let result = {}
654
+ this.$emit('getColumn', val => { result = val })
655
+ return result
656
+ },
657
+ changeFormType (item) {
658
+ this.initItem({ key: item.key, title: item.title, formType: item.formType })
659
+ if (item.formType === 'file' || item.formType === 'image') {
660
+ this.item.acceptCount = 3
661
+ this.getStocks()
662
+ this.item.accept = item.formType === 'file' ? ['*'] : ['.jpg,.jpeg,.ico,.gif,svg,.webp,.png,.bmp,.pjpeg,']
663
+ this.item.resUploadMode = 'server'
664
+ this.item.key = 'FilesId'
665
+ this.dataModeArrayData = ['addOrEditForm']
666
+ } else if (item.formType === 'addressSearch') {
667
+ this.dataModeArrayData = ['addOrEditForm', 'sqlQueryItem']
668
+ } else {
669
+ if (this.item.key === 'FilesId') { this.item.key = '' }
670
+ this.resetDataMode()
671
+ // 表单查询方式有预选项时
672
+ if (this.queryTypeV.length === 1) {
673
+ this.item.queryType = this.queryTypeV[0].value
674
+ }
675
+ }
676
+ },
677
+ // 获取所有仓库
678
+ getStocks () {
679
+ if (this.stockList.length === 0) {
680
+ post('/webmeterapi/getFilesStock', {}).then(res => {
681
+ this.stockList = res.sort((a, b) => b.progress - a.progress)
682
+ }).catch(e => {})
683
+ }
684
+ },
685
+ // 重置数据模式
686
+ resetDataMode () {
687
+ this.dataModeArrayData = this.dataModeTypeV.map(item => item.value)
688
+ },
689
+ itemHandle () {
690
+ // 查询表单项或者新增/修改表单项
691
+ if (this.dataMode.queryForm || this.dataMode.addOrEditForm) {
692
+ if (!this.dataMode.sqlQueryItem || !this.dataMode.addOrEditForm) {
693
+ this.delKey(this.item, 'addOrEdit', 'silencePurpose', 'silenceSource')
694
+ }
695
+ if (this.item.selectType && this.item.selectType === 'logic' && this.item.selectKey.substring(0, 6) !== 'logic@') {
696
+ // 数据源为logic
697
+ this.item.selectKey = 'logic@' + this.item.selectKey
698
+ } else if (this.item.selectType && this.item.selectType === 'fixArray' && !this.isJSON(this.item.selectKey)) {
699
+ // 数据源为固定json集合
700
+ this.$message.warning('下拉框数据源不是JSON集合')
701
+ return
702
+ }
703
+ } else {
704
+ this.delKey(this.item, 'queryType', 'formType', 'addOrEdit', 'silencePurpose', 'silenceSource', 'placeholder', 'rule', 'selectKey', 'selectKeyName', 'lazyLoad')
705
+ }
706
+ // 如果和数据源字段无关
707
+ if (!this.selectDataShow) {
708
+ this.delKey(this.item, 'selectType', 'selectKey', 'lazyLoad', 'selectKeyName')
709
+ }
710
+ // 默认插槽就先删除
711
+ if (this.item.slot && (this.item.slot.type === 'default' || !this.item.slot.type)) { delete this.item.slot }
712
+ // 根据数据模式处理数据
713
+ if (!this.dataMode.sqlQueryCondition) {
714
+ delete this.item.queryType
715
+ }
716
+ if (!this.dataMode.sqlQueryItem) { this.delKey(this.item, 'default') }
717
+ this.item.dataModeArray = this.dataModeArrayData
718
+ this.$emit('itemHandle', this.item, this.type)
719
+ this.initItem()
720
+ this.resetDataMode()
721
+ },
722
+ changeSelectKType () {
723
+ this.item.selectKey = undefined
724
+ },
725
+ changeSelectKey (item) {
726
+ if (item.selectType === 'key' && item.selectKey) {
727
+ this.item.slot.type = 'badge'
728
+ this.item.slot.keyMap = item.selectKey
729
+ }
730
+ },
731
+ filterOption (input, option) {
732
+ return (
733
+ option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
734
+ )
735
+ },
736
+ delKey (obj, ...args) {
737
+ args.forEach(v => {
738
+ delete obj[v]
739
+ })
740
+ return obj
741
+ },
742
+ // 判断是否为json字符串
743
+ isJSON (str) {
744
+ if (typeof str == 'string') {
745
+ try {
746
+ const obj = JSON.parse(str)
747
+ return !!(typeof obj == 'object' && obj)
748
+ } catch (e) {
749
+ return false
750
+ }
751
+ }
752
+ },
753
+ // 兼容旧插槽函数
754
+ compatibleTheSlot (_item) {
755
+ if (_item.slotKeyMap) {
756
+ _item.slot.keyMap = _item.slotKeyMap
757
+ delete _item.slotKeyMap
758
+ }
759
+ if (_item.slotValue) {
760
+ _item.slot.value = _item.slotValue
761
+ delete _item.slotValue
762
+ }
763
+ if (_item.actionText) {
764
+ _item.slot.actionText = _item.actionText
765
+ delete _item.actionText
766
+ }
767
+ }
768
+ }
769
+ }
770
+ </script>