vue2-client 1.2.0 → 1.2.3

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 (134) hide show
  1. package/README.md +65 -65
  2. package/babel.config.js +1 -0
  3. package/docs/notice.md +22 -0
  4. package/index.js +28 -28
  5. package/package.json +1 -1
  6. package/src/App.vue +93 -93
  7. package/src/assets/img/SunClientDownload.png +0 -0
  8. package/src/assets/img/SunClientManual/1.png +0 -0
  9. package/src/assets/img/SunClientManual/2.png +0 -0
  10. package/src/assets/img/SunClientManual/3.png +0 -0
  11. package/src/assets/img/SunClientManual/4.png +0 -0
  12. package/src/assets/img/ToDeskDownload.png +0 -0
  13. package/src/assets/img/ToDeskManual/1.png +0 -0
  14. package/src/assets/img/ToDeskManual/2.png +0 -0
  15. package/src/assets/img/ToDeskManual/3.png +0 -0
  16. package/src/assets/img/ToDeskManual/4.png +0 -0
  17. package/src/assets/sound/newNote.mp3 +0 -0
  18. package/src/base-client/all.js +57 -57
  19. package/src/base-client/components/common/CreateQuery/CreateQuery.vue +1157 -1159
  20. package/src/base-client/components/common/CreateQuery/index.md +42 -42
  21. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQuery.vue +540 -540
  22. package/src/base-client/components/common/CreateSimpleFormQuery/index.md +42 -42
  23. package/src/base-client/components/common/CustomColumnsDrawer/index.md +46 -46
  24. package/src/base-client/components/common/FormGroupEdit/FormGroupEdit.vue +150 -150
  25. package/src/base-client/components/common/FormGroupEdit/index.md +43 -43
  26. package/src/base-client/components/common/FormGroupQuery/index.md +43 -43
  27. package/src/base-client/components/common/XAddForm/XAddForm.vue +323 -323
  28. package/src/base-client/components/common/XAddForm/index.md +60 -60
  29. package/src/base-client/components/common/XBadge/index.md +39 -39
  30. package/src/base-client/components/common/XCard/index.md +43 -43
  31. package/src/base-client/components/common/XForm/XForm.vue +275 -275
  32. package/src/base-client/components/common/XForm/XFormItem.vue +217 -217
  33. package/src/base-client/components/common/XForm/index.md +196 -196
  34. package/src/base-client/components/common/XFormCol/index.md +35 -35
  35. package/src/base-client/components/common/XFormTable/XFormTable.vue +407 -405
  36. package/src/base-client/components/common/XFormTable/index.md +89 -89
  37. package/src/base-client/components/common/XTable/XTable.vue +262 -262
  38. package/src/base-client/components/common/XTable/index.md +255 -255
  39. package/src/base-client/components/common/XTreeOne/XTreeOne.vue +105 -105
  40. package/src/base-client/components/iot/CustomerDetailsView/CustomerDetailsView.vue +226 -226
  41. package/src/base-client/components/iot/CustomerDetailsView/index.md +41 -41
  42. package/src/base-client/components/iot/DataAnalysisUser/DataAnalysisUser.vue +127 -127
  43. package/src/base-client/components/iot/DataAnalysisView/DataAnalysisView.vue +244 -250
  44. package/src/base-client/components/iot/DataAnalysisViewGD/DataAnalysisViewGD.vue +548 -548
  45. package/src/base-client/components/iot/DeviceBrandDetailsView/DeviceBrandDetailsView.vue +453 -453
  46. package/src/base-client/components/iot/DeviceDetailsView/DeviceDetailsView.vue +231 -231
  47. package/src/base-client/components/iot/DeviceDetailsView/index.md +43 -43
  48. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsCount.vue +330 -330
  49. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsException.vue +57 -57
  50. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsInstruct.vue +122 -122
  51. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsInstructOperate.vue +122 -122
  52. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsMain.vue +225 -225
  53. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsRead.vue +135 -135
  54. package/src/base-client/components/iot/DeviceTypeDetailsView/DeviceTypeDetailsView.vue +277 -277
  55. package/src/base-client/components/iot/InstructDetailsView/InstructDetailsView.vue +472 -472
  56. package/src/base-client/components/iot/InstructDetailsView/index.md +45 -45
  57. package/src/base-client/components/iot/LogDetailsView/LogDetailsView.vue +380 -380
  58. package/src/base-client/components/iot/LogDetailsView/index.md +43 -43
  59. package/src/base-client/components/iot/MeterDetailsView/MeterDetailsView.vue +360 -360
  60. package/src/base-client/components/iot/MeterDetailsView/index.md +43 -43
  61. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsCount.vue +335 -335
  62. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsException.vue +185 -185
  63. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsHandPlan.vue +292 -292
  64. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsInstruct.vue +237 -237
  65. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsMain.vue +257 -257
  66. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsSellGas.vue +190 -190
  67. package/src/base-client/components/iot/WebmeterAnalysisView/WebmeterAnalysisView.vue +723 -723
  68. package/src/base-client/components/iot/WebmeterAnalysisView/index.md +48 -48
  69. package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +232 -232
  70. package/src/base-client/components/system/DictionaryDetailsView/index.md +41 -41
  71. package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +248 -248
  72. package/src/base-client/components/ticket/EmployeeDetailsView/EmployeeDetailsView.vue +371 -406
  73. package/src/base-client/components/ticket/TicketDetailsView/TicketDetailsView.vue +838 -486
  74. package/src/base-client/components/ticket/TicketDetailsView/part/TicketDetailsFlow.vue +261 -184
  75. package/src/base-client/components/ticket/TicketSubmitSuccessView/TicketSubmitSuccessView.vue +528 -303
  76. package/src/base-client/plugins/AppData.js +69 -69
  77. package/src/base-client/plugins/GetLoginInfoService.js +221 -221
  78. package/src/base-client/plugins/index.js +21 -21
  79. package/src/bootstrap.js +27 -27
  80. package/src/components/Ellipsis/Ellipsis.vue +64 -64
  81. package/src/components/Ellipsis/index.md +38 -38
  82. package/src/components/NumberInfo/index.md +43 -43
  83. package/src/components/STable/README.md +341 -341
  84. package/src/components/Trend/index.md +45 -45
  85. package/src/components/cache/AKeepAlive.js +172 -172
  86. package/src/components/checkbox/index.js +7 -7
  87. package/src/components/index.js +36 -36
  88. package/src/components/menu/menu.js +273 -273
  89. package/src/components/setting/Setting.vue +237 -237
  90. package/src/components/table/advance/AdvanceTable.vue +275 -275
  91. package/src/components/transition/PageToggleTransition.vue +97 -97
  92. package/src/layouts/CommonLayout.vue +42 -42
  93. package/src/layouts/PageLayout.vue +151 -151
  94. package/src/layouts/SinglePageView.vue +74 -74
  95. package/src/layouts/header/AdminHeader.vue +109 -109
  96. package/src/layouts/header/HeaderAvatar.vue +60 -60
  97. package/src/layouts/header/HeaderNotice.vue +97 -97
  98. package/src/layouts/tabs/TabsHead.vue +190 -190
  99. package/src/layouts/tabs/TabsView.vue +355 -355
  100. package/src/main.js +20 -20
  101. package/src/mock/goods/index.js +108 -108
  102. package/src/mock/index.js +12 -12
  103. package/src/mock/project/index.js +17 -17
  104. package/src/mock/user/current.js +13 -13
  105. package/src/mock/user/login.js +39 -39
  106. package/src/mock/workplace/index.js +15 -15
  107. package/src/pages/exception/403.vue +25 -25
  108. package/src/pages/exception/404.vue +25 -25
  109. package/src/pages/exception/500.vue +25 -25
  110. package/src/pages/login/Login.vue +194 -194
  111. package/src/pages/report/ReportTableHome.vue +28 -28
  112. package/src/pages/resourceManage/resourceManageMain.vue +55 -55
  113. package/src/pages/system/applyInstallView/Core.vue +570 -570
  114. package/src/pages/system/applyInstallView/index.vue +34 -34
  115. package/src/pages/system/dictionary/index.vue +41 -41
  116. package/src/pages/system/queryParams/index.vue +41 -41
  117. package/src/router/async/config.async.js +25 -25
  118. package/src/router/async/router.map.js +59 -59
  119. package/src/router/guards.js +104 -104
  120. package/src/router/index.js +27 -27
  121. package/src/services/api/EmployeeDetailsViewApi.js +3 -1
  122. package/src/services/api/TicketDetailsViewApi.js +9 -1
  123. package/src/services/api/common.js +37 -39
  124. package/src/services/api/restTools.js +23 -23
  125. package/src/services/dataSource.js +12 -12
  126. package/src/services/user.js +34 -34
  127. package/src/store/modules/setting.js +114 -114
  128. package/src/utils/i18n.js +80 -80
  129. package/src/utils/indexedDB.js +146 -146
  130. package/src/utils/request.js +197 -197
  131. package/src/utils/routerUtil.js +15 -2
  132. package/tests/unit/ReportTable.spec.js +15 -15
  133. package/vue.config.js +153 -153
  134. package/webpack.config.js +12 -12
@@ -1,540 +1,540 @@
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="group">
19
- <a-input v-model="form.group" placeholder="设置表单项的组名,如:设置上报参数" />
20
- </a-form-model-item>
21
- <a-form-model-item label="参数组描述" prop="describe">
22
- <a-input v-model="form.describe" placeholder="简单描述参数组,如:用于配置物联网设备的上报参数" />
23
- </a-form-model-item>
24
- <a-form-model-item label="数据字段" prop="column">
25
- <a-button type="primary" @click="addColumnItem()">增加</a-button>
26
- <div v-for="(columnItem, index) in form.column" :key="index">
27
- <a-row :gutter="16">
28
- <a-col :span="16">
29
- <span style="font-weight: bold">{{ columnItem.title }}({{ columnItem.key }})</span>
30
- </a-col>
31
- <a-col v-if="index > 0 && form.column.length > 1" :span="2">
32
- <a-icon type="up-square" @click="upColumnItem(columnItem.key,index)"/>
33
- </a-col>
34
- <a-col v-if="(index !== form.column.length - 1) && form.column.length > 1" :span="2">
35
- <a-icon type="down-square" @click="downColumnItem(columnItem.key,index)"/>
36
- </a-col>
37
- <a-col :span="2">
38
- <a-icon type="edit" @click="editColumnItem(columnItem.key,index)"/>
39
- </a-col>
40
- <a-col :span="2">
41
- <a-icon type="close" @click="removeColumnItem(columnItem.key,index)"/>
42
- </a-col>
43
- </a-row>
44
- </div>
45
- </a-form-model-item>
46
- </a-form-model>
47
- <a-modal
48
- title="数据字段配置"
49
- :visible="dataColumnVisible"
50
- :width="1000"
51
- :zIndex="1001"
52
- @cancel="modelCancel"
53
- @ok="submitItem">
54
- <a-form-model
55
- ref="itemForm"
56
- :rules="itemRules"
57
- :model="item">
58
- <a-row :gutter="16">
59
- <a-col :span="8">
60
- <a-form-model-item label="表单项名" prop="key">
61
- <a-input v-model="item.key" placeholder="请输入表单项名" ref="key">
62
- <a-popover slot="suffix" title="关于表单项名" placement="bottom">
63
- <template slot="content">
64
- <p>设置表单项的名称</p>
65
- </template>
66
- <a-icon type="info-circle" style="color: rgba(0,0,0,.45)" />
67
- </a-popover>
68
- </a-input>
69
- </a-form-model-item>
70
- </a-col>
71
- <a-col :span="8">
72
- <a-form-model-item label="表单项中文名" prop="title">
73
- <a-input v-model="item.title" placeholder="请输入表单项中文名,如:姓名" />
74
- </a-form-model-item>
75
- </a-col>
76
- </a-row>
77
- <template>
78
- <a-row :gutter="16">
79
- <a-col :span="8">
80
- <a-form-model-item label="表单类型" prop="formType">
81
- <a-select v-model="item.formType" placeholder="表单类型,可选">
82
- <a-select-option key="input">输入框</a-select-option>
83
- <a-select-option key="select">选择框</a-select-option>
84
- <a-select-option key="rangePicker">日期范围选择框</a-select-option>
85
- <a-select-option key="monthPicker">月份选择框</a-select-option>
86
- <a-select-option key="datePicker">单日选择框</a-select-option>
87
- <a-select-option key="cascader">级联选择框</a-select-option>
88
- <a-select-option key="textarea">文本域</a-select-option>
89
- <a-popover slot="suffixIcon" title="关于表单类型" placement="bottom">
90
- <template slot="content">
91
- <p>预览设置的表单类型</p>
92
- <a-input-group compact style="width: 400px;">
93
- <a-input value="输入框" style="width: 20%" readOnly/>
94
- <a-input style="width: 80%" placeholder="请输入"/>
95
- </a-input-group>
96
- <br/>
97
- <a-input-group compact style="width: 400px;">
98
- <a-input value="选择框" style="width: 20%" readOnly/>
99
- <a-select style="width: 80%" placeholder="请选择"/>
100
- </a-input-group>
101
- <br/>
102
- <a-input-group compact style="width: 400px;">
103
- <a-input value="日期范围选择框" style="width: 20%" readOnly/>
104
- <a-range-picker style="width: 80%" :show-time="true" format="YYYY-MM-DD HH:mm:ss" valueFormat="YYYY-MM-DD HH:mm:ss" />
105
- </a-input-group>
106
- <br/>
107
- <a-input-group compact style="width: 400px;">
108
- <a-input value="月份选择框" style="width: 20%" readOnly/>
109
- <a-month-picker style="width: 80%"/>
110
- </a-input-group>
111
- <br/>
112
- <a-input-group compact style="width: 400px;">
113
- <a-input value="单日选择框" style="width: 20%" readOnly/>
114
- <a-date-picker style="width: 80%"/>
115
- </a-input-group>
116
- <br/>
117
- <a-input-group compact style="width: 400px;">
118
- <a-input value="级联选择框" style="width: 20%" readOnly/>
119
- <a-cascader style="width: 80%" placeholder="请选择"/>
120
- </a-input-group>
121
- <a-input-group compact style="width: 400px;">
122
- <a-input value="文本域" style="width: 20%" readOnly/>
123
- <a-textarea style="width: 80%" placeholder="请输入" :rows="4"/>
124
- </a-input-group>
125
- </template>
126
- <a-icon type="info-circle" style="color: rgba(0,0,0,.45)" />
127
- </a-popover>
128
- </a-select>
129
- </a-form-model-item>
130
- </a-col>
131
- <a-col :span="8">
132
- <a-form-model-item label="表单水印" prop="placeholder">
133
- <a-input v-model="item.placeholder" placeholder="表单水印(placeholder),可选" />
134
- </a-form-model-item>
135
- </a-col>
136
- </a-row>
137
- <a-row :gutter="16">
138
- <a-col :span="8">
139
- <a-form-model-item label="数据源类型" prop="selectType" v-if="item.formType === 'select' || item.formType === 'cascader'">
140
- <a-select v-model="item.selectType" placeholder="请选择数据源类型" @change="changeSelectKey(item)">
141
- <a-select-option key="key">字典键</a-select-option>
142
- <a-select-option key="fixArray">固定集合</a-select-option>
143
- <a-select-option key="logic">业务逻辑</a-select-option>
144
- <a-popover
145
- slot="suffixIcon"
146
- title="关于下拉框或级联框数据源类型"
147
- placement="bottom">
148
- <template slot="content">
149
- <p>设置下拉框或级联框的数据源</p>
150
- <p>数据源类型分为三种,你可以根据需要选择</p>
151
- <p>字典键:选项从字典表(t_dictionary)获取,你只需要选择字典键的名称即可</p>
152
- <p>业务逻辑名称:选项通过发起http请求调用指定的Logic接口获取</p>
153
- <p>固定集合:选项为静态值,JSONArray格式</p>
154
- </template>
155
- <a-icon type="info-circle" style="color: rgba(0,0,0,.45)" />
156
- </a-popover>
157
- </a-select>
158
- </a-form-model-item>
159
- </a-col>
160
- <a-col :span="8">
161
- <a-form-model-item label="数据源" prop="selectKey" v-if="(item.formType === 'select' || item.formType === 'cascader') && item.selectType">
162
- <a-select
163
- show-search
164
- v-model="item.selectKey"
165
- v-if="item.selectType === 'key'"
166
- placeholder="请选择字典键"
167
- :filter-option="filterOption"
168
- @change="changeSelectKey(item)"
169
- >
170
- <template>
171
- <a-select-option
172
- v-for="(optionItem,index) in option"
173
- :key="index"
174
- :value="Object.keys(optionItem)[0]">{{ optionItem[Object.keys(optionItem)[0]] }}
175
- </a-select-option>
176
- </template>
177
- </a-select>
178
- <a-input v-model="item.selectKey" v-if="item.selectType === 'logic'" placeholder="请输入业务逻辑名称"/>
179
- <a-textarea v-model="item.selectKey" v-if="item.selectType === 'fixArray'" placeholder="请录入数据源" />
180
- </a-form-model-item>
181
- </a-col>
182
- </a-row>
183
- <a-form-model-item label="表单校验类型" prop="rule">
184
- <a-row :gutter="16">
185
- <a-col :span="8">
186
- <a-select v-model="item.rule.type" placeholder="校验类型,可选">
187
- <a-select-option key="string">字符串</a-select-option>
188
- <a-select-option key="number">数字</a-select-option>
189
- <a-select-option key="boolean">布尔值</a-select-option>
190
- <a-select-option key="regexp">正则表达式</a-select-option>
191
- <a-select-option key="integer">整数</a-select-option>
192
- <a-select-option key="float">小数</a-select-option>
193
- <a-select-option key="array">数组或集合</a-select-option>
194
- <a-select-option key="date">日期</a-select-option>
195
- <a-select-option key="email">邮箱</a-select-option>
196
- <a-popover slot="suffixIcon" title="关于表单校验类型" placement="bottom">
197
- <template slot="content">
198
- <p>设置表单项的校验类型,默认字符串类型</p>
199
- <p>你也可以设置该表单项是否必填</p>
200
- </template>
201
- <a-icon type="info-circle" style="color: rgba(0,0,0,.45)" />
202
- </a-popover>
203
- </a-select>
204
- </a-col>
205
- <a-col :span="8">
206
- <a-radio-group v-model="item.rule.required" v-if="item.rule.type" default-value="true" button-style="solid">
207
- <a-radio-button value="true">
208
- 必选项
209
- </a-radio-button>
210
- <a-radio-button value="false">
211
- 非必选项
212
- </a-radio-button>
213
- </a-radio-group>
214
- </a-col>
215
- </a-row>
216
- </a-form-model-item>
217
- </template>
218
- </a-form-model>
219
- </a-modal>
220
- <a-button type="primary" @click="view">操作</a-button>
221
- </a-col>
222
- <a-col :xl="10" :lg="12" :md="12" :sm="24" :xs="24">
223
- <a-card :bordered="false" title="预览" size="small" style="overflow: auto">
224
- <json-viewer :copyable="{copyText: '复制', copiedText: '已复制'}" :value="result" :expand-depth="parseInt('100')" style="overflow: auto;max-height: 440px"></json-viewer>
225
- </a-card>
226
- </a-col>
227
- </a-row>
228
- <x-add-form
229
- business-title="效果预览"
230
- business-type="新增"
231
- :visible.sync="modelVisible"
232
- :json-data="formItems"
233
- @onSubmit="submit"/>
234
- </a-drawer>
235
- </template>
236
-
237
- <script>
238
- import XAddForm from '@vue2-client/base-client/components/common/XAddForm/XAddForm'
239
- import JsonViewer from 'vue-json-viewer'
240
- import FileSaver from 'file-saver'
241
- import { mapState } from 'vuex'
242
- import { post } from '@vue2-client/services/api/restTools'
243
- import { commonApi } from '@vue2-client/services/api/common'
244
-
245
- export default {
246
- name: 'CreateSimpleFormQuery',
247
- components: {
248
- JsonViewer,
249
- XAddForm
250
- },
251
- data () {
252
- return {
253
- // 页面宽度
254
- screenWidth: document.documentElement.clientWidth,
255
- // 效果预览模态框是否展示
256
- modelVisible: false,
257
- // 数据列配置模态框是否展示
258
- dataColumnVisible: false,
259
- // 数据列操作类型:新增,修改
260
- type: '新增',
261
- labelCol: { span: 4 },
262
- wrapperCol: { span: 14 },
263
- form: {
264
- group: '',
265
- describe: '',
266
- column: []
267
- },
268
- result: {},
269
- item: {
270
- key: '',
271
- title: '',
272
- rule: {}
273
- },
274
- itemMap: {},
275
- selectIndex: null,
276
- selectType: undefined,
277
- rules: {
278
- group: [{ required: true, message: '请输入参数组名称', trigger: 'blur' }],
279
- describe: [{ required: true, message: '请输入参数组描述', trigger: 'blur' }]
280
- },
281
- itemRules: {
282
- key: [{ required: true, message: '请输入表单项名', trigger: 'blur' }],
283
- title: [{ required: true, message: '请输入中文名称', trigger: 'blur' }],
284
- selectType: [{ required: true, message: '请选择数据源类型', trigger: 'change' }],
285
- selectKey: [{ required: true, message: '请输入数据源内容', trigger: 'blur' }]
286
- },
287
- formItems: [],
288
- // 字典键集合
289
- option: []
290
- }
291
- },
292
- mounted () {
293
- this.initView()
294
- },
295
- computed: {
296
- ...mapState('setting', ['isMobile'])
297
- },
298
- props: {
299
- visible: {
300
- type: Boolean,
301
- default: false
302
- },
303
- toEditJson: {
304
- type: Object,
305
- default: () => {}
306
- }
307
- },
308
- watch: {
309
- visible (rel) {
310
- if (rel) {
311
- this.initView()
312
- }
313
- if (rel && this.toEditJson) {
314
- this.form = Object.assign(
315
- {
316
- group: '',
317
- describe: '',
318
- column: []
319
- }, this.toEditJson
320
- )
321
- for (const columnItem of this.form.column) {
322
- // 必选项兼容处理
323
- if (columnItem.rule && !isNaN(columnItem.rule.required)) {
324
- columnItem.rule.required = columnItem.rule.required.toString()
325
- }
326
- // 下拉框数据源兼容处理
327
- if ((columnItem.formType === 'select' || columnItem.formType === 'cascader') && columnItem.selectKey) {
328
- // 数据源为logic
329
- if (columnItem.selectKey instanceof String && columnItem.selectKey.startsWith('logic@')) {
330
- columnItem.selectType = 'logic'
331
- } else if (columnItem.selectKey instanceof Array || this.isJSON(columnItem.selectKey)) {
332
- // 数据源为固定json集合
333
- if (columnItem.selectKey instanceof Array) {
334
- columnItem.selectKey = JSON.stringify(columnItem.selectKey)
335
- }
336
- columnItem.selectType = 'fixArray'
337
- } else {
338
- columnItem.selectType = 'key'
339
- }
340
- }
341
- this.itemMap[columnItem.key] = Object.assign({
342
- key: '',
343
- title: '',
344
- rule: {}
345
- }, columnItem)
346
- }
347
- }
348
- }
349
- },
350
- methods: {
351
- // 初始化组件
352
- initView () {
353
- this.result = {}
354
- post(commonApi.getDictionaryParam, {}).then(res => {
355
- this.option = res
356
- })
357
- },
358
- onClose () {
359
- this.$emit('update:visible', false)
360
- },
361
- filterOption (input, option) {
362
- return (
363
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
364
- )
365
- },
366
- onModelClose () {
367
- this.modelVisible = false
368
- },
369
- addColumnItem () {
370
- this.type = '新增'
371
- this.dataColumnVisible = true
372
- },
373
- editColumnItem (key, index) {
374
- if (this.itemMap[key]) {
375
- this.type = '修改'
376
- this.item = this.itemMap[key]
377
- this.selectIndex = index
378
- this.dataColumnVisible = true
379
- } else {
380
- this.$message.warn('编辑失败')
381
- }
382
- },
383
- removeColumnItem (key, index) {
384
- const _this = this
385
- this.$confirm({
386
- title: '您确定要删除该数据项?',
387
- content: '删除的数据项无法恢复',
388
- okText: '确定',
389
- okType: 'danger',
390
- cancelText: '取消',
391
- onOk () {
392
- delete _this.itemMap[key]
393
- _this.form.column.splice(index, 1)
394
- }
395
- })
396
- },
397
- upColumnItem (key, index) {
398
- const newIndex = index - 1
399
- const itemA = this.form.column[newIndex]
400
- const itemB = this.form.column[index]
401
- this.form.column.splice(index, 1, itemA)
402
- this.form.column.splice(newIndex, 1, itemB)
403
- },
404
- downColumnItem (key, index) {
405
- const newIndex = index + 1
406
- const itemA = this.form.column[newIndex]
407
- const itemB = this.form.column[index]
408
- this.form.column.splice(index, 1, itemA)
409
- this.form.column.splice(newIndex, 1, itemB)
410
- },
411
- submitItem () {
412
- this.$refs.itemForm.validate(valid => {
413
- if (valid) {
414
- this.itemHandle()
415
- }
416
- })
417
- },
418
- itemHandle () {
419
- const str = JSON.stringify(this.item)
420
- const item = JSON.parse(str)
421
- this.itemMap[item.key] = JSON.parse(str)
422
- // 表单类型为输入框
423
- if (item.formType && item.formType === 'input') {
424
- delete item.formType
425
- }
426
- // 校验类型
427
- if (!item.rule.type) {
428
- delete item.rule
429
- } else {
430
- if (item.rule.required) {
431
- item.rule.required = item.rule.required.toString() === 'true'
432
- } else {
433
- item.rule.required = true
434
- }
435
- }
436
- // 下拉框
437
- if ((item.formType === 'select' || item.formType === 'cascader') && item.selectKey) {
438
- // 数据源为logic
439
- if (item.selectType === 'logic') {
440
- item.selectKey = 'logic@' + item.selectKey
441
- } else if (item.selectType === 'fixArray') {
442
- // 数据源为固定json集合
443
- if (!this.isJSON(item.selectKey)) {
444
- this.$message.warning('下拉框数据源不是JSON集合')
445
- return
446
- }
447
- }
448
- delete item.selectType
449
- } else {
450
- delete item.selectType
451
- delete item.selectKey
452
- }
453
- if (this.type === '新增') {
454
- this.form.column.push(item)
455
- } else {
456
- this.form.column[this.selectIndex] = item
457
- }
458
- this.item = {
459
- key: '',
460
- title: '',
461
- rule: {}
462
- }
463
- this.$message.success('增加成功')
464
- this.dataColumnVisible = false
465
- },
466
- // 判断是否为json字符串
467
- isJSON (str) {
468
- if (typeof str == 'string') {
469
- try {
470
- const obj = JSON.parse(str)
471
- return !!(typeof obj == 'object' && obj)
472
- } catch (e) {
473
- return false
474
- }
475
- }
476
- },
477
- exportJson () {
478
- const data = JSON.stringify(this.form, null, 2)
479
- const blob = new Blob([data], { type: 'application/json' })
480
- FileSaver.saveAs(blob, `SimpleFormQuery.json`)
481
- this.$message.success('导出成功!')
482
- },
483
- viewHandle (then) {
484
- if (this.form.column.length === 0) {
485
- this.$message.error('你没有增加任何数据字段')
486
- return
487
- }
488
- this.result = JSON.parse(JSON.stringify(this.form))
489
- for (const item of this.result.column) {
490
- if (item.selectType === 'fixArray') {
491
- item.selectKey = JSON.parse(item.selectKey)
492
- }
493
- }
494
- then()
495
- },
496
- view () {
497
- this.$refs.businessCreateForm.validate(valid => {
498
- if (valid) {
499
- this.viewHandle(() => {
500
- post(commonApi.getColumnsJson, { queryObject: this.result }).then(res => {
501
- this.formItems = res.formJson
502
- this.modelVisible = true
503
- })
504
- })
505
- }
506
- })
507
- },
508
- submit () {
509
- this.onModelClose()
510
- this.$refs.businessCreateForm.validate(valid => {
511
- if (valid) {
512
- this.viewHandle(() => {
513
- // saveQueryParams
514
- this.$emit('saveSimpleFormQueryParams', this.result)
515
- })
516
- }
517
- })
518
- },
519
- modelCancel () {
520
- this.dataColumnVisible = false
521
- // 延迟是为了避免编辑数据窗口关闭时重置表单导致的闪烁
522
- setTimeout(() => {
523
- this.item = {
524
- key: '',
525
- title: '',
526
- rule: {}
527
- }
528
- }, 100)
529
- },
530
- changeSelectKey (item) {
531
- if (item.selectType === 'key' && item.selectKey) {
532
- item.slot.type = 'badge'
533
- item.slotKeyMap = item.selectKey
534
- }
535
- }
536
- }
537
- }
538
- </script>
539
- <style lang="less" scoped>
540
- </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="group">
19
+ <a-input v-model="form.group" placeholder="设置表单项的组名,如:设置上报参数" />
20
+ </a-form-model-item>
21
+ <a-form-model-item label="参数组描述" prop="describe">
22
+ <a-input v-model="form.describe" placeholder="简单描述参数组,如:用于配置物联网设备的上报参数" />
23
+ </a-form-model-item>
24
+ <a-form-model-item label="数据字段" prop="column">
25
+ <a-button type="primary" @click="addColumnItem()">增加</a-button>
26
+ <div v-for="(columnItem, index) in form.column" :key="index">
27
+ <a-row :gutter="16">
28
+ <a-col :span="16">
29
+ <span style="font-weight: bold">{{ columnItem.title }}({{ columnItem.key }})</span>
30
+ </a-col>
31
+ <a-col v-if="index > 0 && form.column.length > 1" :span="2">
32
+ <a-icon type="up-square" @click="upColumnItem(columnItem.key,index)"/>
33
+ </a-col>
34
+ <a-col v-if="(index !== form.column.length - 1) && form.column.length > 1" :span="2">
35
+ <a-icon type="down-square" @click="downColumnItem(columnItem.key,index)"/>
36
+ </a-col>
37
+ <a-col :span="2">
38
+ <a-icon type="edit" @click="editColumnItem(columnItem.key,index)"/>
39
+ </a-col>
40
+ <a-col :span="2">
41
+ <a-icon type="close" @click="removeColumnItem(columnItem.key,index)"/>
42
+ </a-col>
43
+ </a-row>
44
+ </div>
45
+ </a-form-model-item>
46
+ </a-form-model>
47
+ <a-modal
48
+ title="数据字段配置"
49
+ :visible="dataColumnVisible"
50
+ :width="1000"
51
+ :zIndex="1001"
52
+ @cancel="modelCancel"
53
+ @ok="submitItem">
54
+ <a-form-model
55
+ ref="itemForm"
56
+ :rules="itemRules"
57
+ :model="item">
58
+ <a-row :gutter="16">
59
+ <a-col :span="8">
60
+ <a-form-model-item label="表单项名" prop="key">
61
+ <a-input v-model="item.key" placeholder="请输入表单项名" ref="key">
62
+ <a-popover slot="suffix" title="关于表单项名" placement="bottom">
63
+ <template slot="content">
64
+ <p>设置表单项的名称</p>
65
+ </template>
66
+ <a-icon type="info-circle" style="color: rgba(0,0,0,.45)" />
67
+ </a-popover>
68
+ </a-input>
69
+ </a-form-model-item>
70
+ </a-col>
71
+ <a-col :span="8">
72
+ <a-form-model-item label="表单项中文名" prop="title">
73
+ <a-input v-model="item.title" placeholder="请输入表单项中文名,如:姓名" />
74
+ </a-form-model-item>
75
+ </a-col>
76
+ </a-row>
77
+ <template>
78
+ <a-row :gutter="16">
79
+ <a-col :span="8">
80
+ <a-form-model-item label="表单类型" prop="formType">
81
+ <a-select v-model="item.formType" placeholder="表单类型,可选">
82
+ <a-select-option key="input">输入框</a-select-option>
83
+ <a-select-option key="select">选择框</a-select-option>
84
+ <a-select-option key="rangePicker">日期范围选择框</a-select-option>
85
+ <a-select-option key="monthPicker">月份选择框</a-select-option>
86
+ <a-select-option key="datePicker">单日选择框</a-select-option>
87
+ <a-select-option key="cascader">级联选择框</a-select-option>
88
+ <a-select-option key="textarea">文本域</a-select-option>
89
+ <a-popover slot="suffixIcon" title="关于表单类型" placement="bottom">
90
+ <template slot="content">
91
+ <p>预览设置的表单类型</p>
92
+ <a-input-group compact style="width: 400px;">
93
+ <a-input value="输入框" style="width: 20%" readOnly/>
94
+ <a-input style="width: 80%" placeholder="请输入"/>
95
+ </a-input-group>
96
+ <br/>
97
+ <a-input-group compact style="width: 400px;">
98
+ <a-input value="选择框" style="width: 20%" readOnly/>
99
+ <a-select style="width: 80%" placeholder="请选择"/>
100
+ </a-input-group>
101
+ <br/>
102
+ <a-input-group compact style="width: 400px;">
103
+ <a-input value="日期范围选择框" style="width: 20%" readOnly/>
104
+ <a-range-picker style="width: 80%" :show-time="true" format="YYYY-MM-DD HH:mm:ss" valueFormat="YYYY-MM-DD HH:mm:ss" />
105
+ </a-input-group>
106
+ <br/>
107
+ <a-input-group compact style="width: 400px;">
108
+ <a-input value="月份选择框" style="width: 20%" readOnly/>
109
+ <a-month-picker style="width: 80%"/>
110
+ </a-input-group>
111
+ <br/>
112
+ <a-input-group compact style="width: 400px;">
113
+ <a-input value="单日选择框" style="width: 20%" readOnly/>
114
+ <a-date-picker style="width: 80%"/>
115
+ </a-input-group>
116
+ <br/>
117
+ <a-input-group compact style="width: 400px;">
118
+ <a-input value="级联选择框" style="width: 20%" readOnly/>
119
+ <a-cascader style="width: 80%" placeholder="请选择"/>
120
+ </a-input-group>
121
+ <a-input-group compact style="width: 400px;">
122
+ <a-input value="文本域" style="width: 20%" readOnly/>
123
+ <a-textarea style="width: 80%" placeholder="请输入" :rows="4"/>
124
+ </a-input-group>
125
+ </template>
126
+ <a-icon type="info-circle" style="color: rgba(0,0,0,.45)" />
127
+ </a-popover>
128
+ </a-select>
129
+ </a-form-model-item>
130
+ </a-col>
131
+ <a-col :span="8">
132
+ <a-form-model-item label="表单水印" prop="placeholder">
133
+ <a-input v-model="item.placeholder" placeholder="表单水印(placeholder),可选" />
134
+ </a-form-model-item>
135
+ </a-col>
136
+ </a-row>
137
+ <a-row :gutter="16">
138
+ <a-col :span="8">
139
+ <a-form-model-item label="数据源类型" prop="selectType" v-if="item.formType === 'select' || item.formType === 'cascader'">
140
+ <a-select v-model="item.selectType" placeholder="请选择数据源类型" @change="changeSelectKey(item)">
141
+ <a-select-option key="key">字典键</a-select-option>
142
+ <a-select-option key="fixArray">固定集合</a-select-option>
143
+ <a-select-option key="logic">业务逻辑</a-select-option>
144
+ <a-popover
145
+ slot="suffixIcon"
146
+ title="关于下拉框或级联框数据源类型"
147
+ placement="bottom">
148
+ <template slot="content">
149
+ <p>设置下拉框或级联框的数据源</p>
150
+ <p>数据源类型分为三种,你可以根据需要选择</p>
151
+ <p>字典键:选项从字典表(t_dictionary)获取,你只需要选择字典键的名称即可</p>
152
+ <p>业务逻辑名称:选项通过发起http请求调用指定的Logic接口获取</p>
153
+ <p>固定集合:选项为静态值,JSONArray格式</p>
154
+ </template>
155
+ <a-icon type="info-circle" style="color: rgba(0,0,0,.45)" />
156
+ </a-popover>
157
+ </a-select>
158
+ </a-form-model-item>
159
+ </a-col>
160
+ <a-col :span="8">
161
+ <a-form-model-item label="数据源" prop="selectKey" v-if="(item.formType === 'select' || item.formType === 'cascader') && item.selectType">
162
+ <a-select
163
+ show-search
164
+ v-model="item.selectKey"
165
+ v-if="item.selectType === 'key'"
166
+ placeholder="请选择字典键"
167
+ :filter-option="filterOption"
168
+ @change="changeSelectKey(item)"
169
+ >
170
+ <template>
171
+ <a-select-option
172
+ v-for="(optionItem,index) in option"
173
+ :key="index"
174
+ :value="Object.keys(optionItem)[0]">{{ optionItem[Object.keys(optionItem)[0]] }}
175
+ </a-select-option>
176
+ </template>
177
+ </a-select>
178
+ <a-input v-model="item.selectKey" v-if="item.selectType === 'logic'" placeholder="请输入业务逻辑名称"/>
179
+ <a-textarea v-model="item.selectKey" v-if="item.selectType === 'fixArray'" placeholder="请录入数据源" />
180
+ </a-form-model-item>
181
+ </a-col>
182
+ </a-row>
183
+ <a-form-model-item label="表单校验类型" prop="rule">
184
+ <a-row :gutter="16">
185
+ <a-col :span="8">
186
+ <a-select v-model="item.rule.type" placeholder="校验类型,可选">
187
+ <a-select-option key="string">字符串</a-select-option>
188
+ <a-select-option key="number">数字</a-select-option>
189
+ <a-select-option key="boolean">布尔值</a-select-option>
190
+ <a-select-option key="regexp">正则表达式</a-select-option>
191
+ <a-select-option key="integer">整数</a-select-option>
192
+ <a-select-option key="float">小数</a-select-option>
193
+ <a-select-option key="array">数组或集合</a-select-option>
194
+ <a-select-option key="date">日期</a-select-option>
195
+ <a-select-option key="email">邮箱</a-select-option>
196
+ <a-popover slot="suffixIcon" title="关于表单校验类型" placement="bottom">
197
+ <template slot="content">
198
+ <p>设置表单项的校验类型,默认字符串类型</p>
199
+ <p>你也可以设置该表单项是否必填</p>
200
+ </template>
201
+ <a-icon type="info-circle" style="color: rgba(0,0,0,.45)" />
202
+ </a-popover>
203
+ </a-select>
204
+ </a-col>
205
+ <a-col :span="8">
206
+ <a-radio-group v-model="item.rule.required" v-if="item.rule.type" default-value="true" button-style="solid">
207
+ <a-radio-button value="true">
208
+ 必选项
209
+ </a-radio-button>
210
+ <a-radio-button value="false">
211
+ 非必选项
212
+ </a-radio-button>
213
+ </a-radio-group>
214
+ </a-col>
215
+ </a-row>
216
+ </a-form-model-item>
217
+ </template>
218
+ </a-form-model>
219
+ </a-modal>
220
+ <a-button type="primary" @click="view">操作</a-button>
221
+ </a-col>
222
+ <a-col :xl="10" :lg="12" :md="12" :sm="24" :xs="24">
223
+ <a-card :bordered="false" title="预览" size="small" style="overflow: auto">
224
+ <json-viewer :copyable="{copyText: '复制', copiedText: '已复制'}" :value="result" :expand-depth="parseInt('100')" style="overflow: auto;max-height: 440px"></json-viewer>
225
+ </a-card>
226
+ </a-col>
227
+ </a-row>
228
+ <x-add-form
229
+ business-title="效果预览"
230
+ business-type="新增"
231
+ :visible.sync="modelVisible"
232
+ :json-data="formItems"
233
+ @onSubmit="submit"/>
234
+ </a-drawer>
235
+ </template>
236
+
237
+ <script>
238
+ import XAddForm from '@vue2-client/base-client/components/common/XAddForm/XAddForm'
239
+ import JsonViewer from 'vue-json-viewer'
240
+ import FileSaver from 'file-saver'
241
+ import { mapState } from 'vuex'
242
+ import { post } from '@vue2-client/services/api/restTools'
243
+ import { commonApi } from '@vue2-client/services/api/common'
244
+
245
+ export default {
246
+ name: 'CreateSimpleFormQuery',
247
+ components: {
248
+ JsonViewer,
249
+ XAddForm
250
+ },
251
+ data () {
252
+ return {
253
+ // 页面宽度
254
+ screenWidth: document.documentElement.clientWidth,
255
+ // 效果预览模态框是否展示
256
+ modelVisible: false,
257
+ // 数据列配置模态框是否展示
258
+ dataColumnVisible: false,
259
+ // 数据列操作类型:新增,修改
260
+ type: '新增',
261
+ labelCol: { span: 4 },
262
+ wrapperCol: { span: 14 },
263
+ form: {
264
+ group: '',
265
+ describe: '',
266
+ column: []
267
+ },
268
+ result: {},
269
+ item: {
270
+ key: '',
271
+ title: '',
272
+ rule: {}
273
+ },
274
+ itemMap: {},
275
+ selectIndex: null,
276
+ selectType: undefined,
277
+ rules: {
278
+ group: [{ required: true, message: '请输入参数组名称', trigger: 'blur' }],
279
+ describe: [{ required: true, message: '请输入参数组描述', trigger: 'blur' }]
280
+ },
281
+ itemRules: {
282
+ key: [{ required: true, message: '请输入表单项名', trigger: 'blur' }],
283
+ title: [{ required: true, message: '请输入中文名称', trigger: 'blur' }],
284
+ selectType: [{ required: true, message: '请选择数据源类型', trigger: 'change' }],
285
+ selectKey: [{ required: true, message: '请输入数据源内容', trigger: 'blur' }]
286
+ },
287
+ formItems: [],
288
+ // 字典键集合
289
+ option: []
290
+ }
291
+ },
292
+ mounted () {
293
+ this.initView()
294
+ },
295
+ computed: {
296
+ ...mapState('setting', ['isMobile'])
297
+ },
298
+ props: {
299
+ visible: {
300
+ type: Boolean,
301
+ default: false
302
+ },
303
+ toEditJson: {
304
+ type: Object,
305
+ default: () => {}
306
+ }
307
+ },
308
+ watch: {
309
+ visible (rel) {
310
+ if (rel) {
311
+ this.initView()
312
+ }
313
+ if (rel && this.toEditJson) {
314
+ this.form = Object.assign(
315
+ {
316
+ group: '',
317
+ describe: '',
318
+ column: []
319
+ }, this.toEditJson
320
+ )
321
+ for (const columnItem of this.form.column) {
322
+ // 必选项兼容处理
323
+ if (columnItem.rule && !isNaN(columnItem.rule.required)) {
324
+ columnItem.rule.required = columnItem.rule.required.toString()
325
+ }
326
+ // 下拉框数据源兼容处理
327
+ if ((columnItem.formType === 'select' || columnItem.formType === 'cascader') && columnItem.selectKey) {
328
+ // 数据源为logic
329
+ if (columnItem.selectKey instanceof String && columnItem.selectKey.startsWith('logic@')) {
330
+ columnItem.selectType = 'logic'
331
+ } else if (columnItem.selectKey instanceof Array || this.isJSON(columnItem.selectKey)) {
332
+ // 数据源为固定json集合
333
+ if (columnItem.selectKey instanceof Array) {
334
+ columnItem.selectKey = JSON.stringify(columnItem.selectKey)
335
+ }
336
+ columnItem.selectType = 'fixArray'
337
+ } else {
338
+ columnItem.selectType = 'key'
339
+ }
340
+ }
341
+ this.itemMap[columnItem.key] = Object.assign({
342
+ key: '',
343
+ title: '',
344
+ rule: {}
345
+ }, columnItem)
346
+ }
347
+ }
348
+ }
349
+ },
350
+ methods: {
351
+ // 初始化组件
352
+ initView () {
353
+ this.result = {}
354
+ post(commonApi.getDictionaryParam, {}).then(res => {
355
+ this.option = res
356
+ })
357
+ },
358
+ onClose () {
359
+ this.$emit('update:visible', false)
360
+ },
361
+ filterOption (input, option) {
362
+ return (
363
+ option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
364
+ )
365
+ },
366
+ onModelClose () {
367
+ this.modelVisible = false
368
+ },
369
+ addColumnItem () {
370
+ this.type = '新增'
371
+ this.dataColumnVisible = true
372
+ },
373
+ editColumnItem (key, index) {
374
+ if (this.itemMap[key]) {
375
+ this.type = '修改'
376
+ this.item = this.itemMap[key]
377
+ this.selectIndex = index
378
+ this.dataColumnVisible = true
379
+ } else {
380
+ this.$message.warn('编辑失败')
381
+ }
382
+ },
383
+ removeColumnItem (key, index) {
384
+ const _this = this
385
+ this.$confirm({
386
+ title: '您确定要删除该数据项?',
387
+ content: '删除的数据项无法恢复',
388
+ okText: '确定',
389
+ okType: 'danger',
390
+ cancelText: '取消',
391
+ onOk () {
392
+ delete _this.itemMap[key]
393
+ _this.form.column.splice(index, 1)
394
+ }
395
+ })
396
+ },
397
+ upColumnItem (key, index) {
398
+ const newIndex = index - 1
399
+ const itemA = this.form.column[newIndex]
400
+ const itemB = this.form.column[index]
401
+ this.form.column.splice(index, 1, itemA)
402
+ this.form.column.splice(newIndex, 1, itemB)
403
+ },
404
+ downColumnItem (key, index) {
405
+ const newIndex = index + 1
406
+ const itemA = this.form.column[newIndex]
407
+ const itemB = this.form.column[index]
408
+ this.form.column.splice(index, 1, itemA)
409
+ this.form.column.splice(newIndex, 1, itemB)
410
+ },
411
+ submitItem () {
412
+ this.$refs.itemForm.validate(valid => {
413
+ if (valid) {
414
+ this.itemHandle()
415
+ }
416
+ })
417
+ },
418
+ itemHandle () {
419
+ const str = JSON.stringify(this.item)
420
+ const item = JSON.parse(str)
421
+ this.itemMap[item.key] = JSON.parse(str)
422
+ // 表单类型为输入框
423
+ if (item.formType && item.formType === 'input') {
424
+ delete item.formType
425
+ }
426
+ // 校验类型
427
+ if (!item.rule.type) {
428
+ delete item.rule
429
+ } else {
430
+ if (item.rule.required) {
431
+ item.rule.required = item.rule.required.toString() === 'true'
432
+ } else {
433
+ item.rule.required = true
434
+ }
435
+ }
436
+ // 下拉框
437
+ if ((item.formType === 'select' || item.formType === 'cascader') && item.selectKey) {
438
+ // 数据源为logic
439
+ if (item.selectType === 'logic') {
440
+ item.selectKey = 'logic@' + item.selectKey
441
+ } else if (item.selectType === 'fixArray') {
442
+ // 数据源为固定json集合
443
+ if (!this.isJSON(item.selectKey)) {
444
+ this.$message.warning('下拉框数据源不是JSON集合')
445
+ return
446
+ }
447
+ }
448
+ delete item.selectType
449
+ } else {
450
+ delete item.selectType
451
+ delete item.selectKey
452
+ }
453
+ if (this.type === '新增') {
454
+ this.form.column.push(item)
455
+ } else {
456
+ this.form.column[this.selectIndex] = item
457
+ }
458
+ this.item = {
459
+ key: '',
460
+ title: '',
461
+ rule: {}
462
+ }
463
+ this.$message.success('增加成功')
464
+ this.dataColumnVisible = false
465
+ },
466
+ // 判断是否为json字符串
467
+ isJSON (str) {
468
+ if (typeof str == 'string') {
469
+ try {
470
+ const obj = JSON.parse(str)
471
+ return !!(typeof obj == 'object' && obj)
472
+ } catch (e) {
473
+ return false
474
+ }
475
+ }
476
+ },
477
+ exportJson () {
478
+ const data = JSON.stringify(this.form, null, 2)
479
+ const blob = new Blob([data], { type: 'application/json' })
480
+ FileSaver.saveAs(blob, `SimpleFormQuery.json`)
481
+ this.$message.success('导出成功!')
482
+ },
483
+ viewHandle (then) {
484
+ if (this.form.column.length === 0) {
485
+ this.$message.error('你没有增加任何数据字段')
486
+ return
487
+ }
488
+ this.result = JSON.parse(JSON.stringify(this.form))
489
+ for (const item of this.result.column) {
490
+ if (item.selectType === 'fixArray') {
491
+ item.selectKey = JSON.parse(item.selectKey)
492
+ }
493
+ }
494
+ then()
495
+ },
496
+ view () {
497
+ this.$refs.businessCreateForm.validate(valid => {
498
+ if (valid) {
499
+ this.viewHandle(() => {
500
+ post(commonApi.getColumnsJson, { queryObject: this.result }).then(res => {
501
+ this.formItems = res.formJson
502
+ this.modelVisible = true
503
+ })
504
+ })
505
+ }
506
+ })
507
+ },
508
+ submit () {
509
+ this.onModelClose()
510
+ this.$refs.businessCreateForm.validate(valid => {
511
+ if (valid) {
512
+ this.viewHandle(() => {
513
+ // saveQueryParams
514
+ this.$emit('saveSimpleFormQueryParams', this.result)
515
+ })
516
+ }
517
+ })
518
+ },
519
+ modelCancel () {
520
+ this.dataColumnVisible = false
521
+ // 延迟是为了避免编辑数据窗口关闭时重置表单导致的闪烁
522
+ setTimeout(() => {
523
+ this.item = {
524
+ key: '',
525
+ title: '',
526
+ rule: {}
527
+ }
528
+ }, 100)
529
+ },
530
+ changeSelectKey (item) {
531
+ if (item.selectType === 'key' && item.selectKey) {
532
+ item.slot.type = 'badge'
533
+ item.slotKeyMap = item.selectKey
534
+ }
535
+ }
536
+ }
537
+ }
538
+ </script>
539
+ <style lang="less" scoped>
540
+ </style>