vue2-client 1.2.66 → 1.2.69

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 (40) hide show
  1. package/.env +15 -15
  2. package/.eslintrc.js +82 -82
  3. package/CHANGELOG.md +171 -171
  4. package/package.json +1 -1
  5. package/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox.vue +1 -1
  6. package/src/base-client/components/common/AmapMarker/AmapPointRendering.vue +8 -6
  7. package/src/base-client/components/common/CitySelect/CitySelect.vue +244 -244
  8. package/src/base-client/components/common/CitySelect/index.js +3 -3
  9. package/src/base-client/components/common/CitySelect/index.md +109 -109
  10. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQuery.vue +310 -310
  11. package/src/base-client/components/common/Upload/Upload.vue +151 -151
  12. package/src/base-client/components/common/Upload/index.js +3 -3
  13. package/src/base-client/components/common/XAddForm/XAddForm.vue +345 -345
  14. package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +322 -322
  15. package/src/base-client/components/common/XForm/XForm.vue +268 -268
  16. package/src/base-client/components/common/XForm/XFormItem.vue +358 -358
  17. package/src/base-client/components/common/XFormTable/XFormTable.vue +491 -484
  18. package/src/base-client/components/common/XTable/XTable.vue +14 -12
  19. package/src/base-client/components/iot/DeviceBrandDetailsView/DeviceBrandDetailsView.vue +1 -1
  20. package/src/base-client/components/iot/DeviceDetailsView/DeviceDetailsView.vue +1 -2
  21. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsException.vue +57 -57
  22. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsMain.vue +1 -1
  23. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsRead.vue +131 -131
  24. package/src/base-client/components/iot/DeviceTypeDetailsView/DeviceTypeDetailsView.vue +300 -300
  25. package/src/base-client/components/iot/WebmeterAnalysisView/WebmeterAnalysisView.vue +647 -647
  26. package/src/base-client/components/ticket/TicketSubmitSuccessView/TicketSubmitSuccessView.vue +532 -532
  27. package/src/base-client/plugins/AppData.js +70 -70
  28. package/src/base-client/plugins/compatible/LoginServiceOA.js +20 -20
  29. package/src/config/CreateQueryConfig.js +301 -301
  30. package/src/pages/resourceManage/orgListManage.vue +98 -98
  31. package/src/router/async/config.async.js +26 -26
  32. package/src/router/async/router.map.js +60 -60
  33. package/src/router/index.js +27 -27
  34. package/src/services/api/common.js +56 -56
  35. package/src/services/api/manage.js +16 -16
  36. package/src/services/api/restTools.js +24 -24
  37. package/src/theme/default/style.less +47 -47
  38. package/src/utils/map-utils.js +28 -28
  39. package/src/utils/request.js +198 -198
  40. package/src/utils/util.js +222 -222
@@ -1,484 +1,491 @@
1
- <template>
2
- <a-skeleton :loading="mainLoading">
3
- <template v-if="loaded">
4
- <x-add-form
5
- :business-title="businessTitle"
6
- :business-type="businessType"
7
- :visible.sync="modelVisible"
8
- :json-data="formItems"
9
- :modify-model-data="modifyModelData"
10
- :fixedAddForm="fixedAddForm"
11
- :loading="loading"
12
- @onSubmit="onAddOrModify"/>
13
- <x-form
14
- :json-data="formItems"
15
- :is-show="isFormShow"
16
- @onSubmit="onSubmit"
17
- style="margin-bottom: 14px;">
18
- <slot></slot>
19
- </x-form>
20
- <x-table
21
- ref="xTable"
22
- :json-data="tableColumns"
23
- @toggleIsFormShow="toggleIsFormShow"
24
- @selectRow="selectRow"
25
- :queryParams="queryParams"
26
- :buttonState="buttonState"
27
- :queryParamsName="queryParamsName"
28
- :fixedQueryForm="fixedQueryForm"
29
- @loadData="loadData"
30
- @action="action"
31
- :form="form">
32
- <template slot="expand">
33
- <a-space>
34
- <a-button type="primary" @click="addItem" v-if="!buttonState || buttonState.add">
35
- <a-icon :style="iconStyle" type="plus"/>新增
36
- </a-button>
37
- <a-button
38
- v-if="!buttonState || buttonState.edit"
39
- :loading="editDataLoading"
40
- :disabled="!isModify"
41
- class="btn-success"
42
- type="dashed"
43
- @click="editItem">
44
- <a-icon :style="iconStyle" type="edit"/>修改
45
- </a-button>
46
- <a-button :disabled="!isDelete" type="danger" @click="deleteItem" v-if="!buttonState || buttonState.delete">
47
- <a-icon :style="iconStyle" type="delete"/>删除
48
- </a-button>
49
- <slot name="button" :selectedRowKeys="selectedRowKeys"></slot>
50
- </a-space>
51
- <slot name="expand"></slot>
52
- </template>
53
- </x-table>
54
- </template>
55
- </a-skeleton>
56
- </template>
57
- <script>
58
- import XForm from '@vue2-client/base-client/components/common/XForm/XForm'
59
- import XAddForm from '@vue2-client/base-client/components/common/XAddForm/XAddForm'
60
- import XTable from '@vue2-client/base-client/components/common/XTable/XTable'
61
- import { query, commonApi, addOrModify, remove, queryWithResource } from '@vue2-client/services/api/common'
62
- import { indexedDB } from '@vue2-client/utils/indexedDB'
63
- import { mapState } from 'vuex'
64
- import { Modal } from 'ant-design-vue'
65
- import { post } from '@vue2-client/services/api/restTools'
66
- import { ApplyInstallApi } from '@vue2-client/services/api/applyInstallApi'
67
-
68
- export default {
69
- name: 'XFormTable',
70
- components: {
71
- XTable,
72
- XForm,
73
- XAddForm
74
- },
75
- data () {
76
- return {
77
- // Query参数文件内容加载中
78
- mainLoading: false,
79
- // Query参数文件内容加载完成
80
- loaded: false,
81
- // 是否展示表单
82
- isFormShow: true,
83
- // 当使用logic获取到表单表格配置时, 将配置对象直接传入到x-table用于查询
84
- queryParams: null,
85
- // 表格列集合
86
- tableColumns: [],
87
- // 操作按钮集合
88
- buttonState: {},
89
- // 表格选择列Key集合
90
- selectedRowKeys: [],
91
- // 表单项集合
92
- formItems: [],
93
- // 表单
94
- form: {},
95
- // 图标样式
96
- iconStyle: {
97
- position: 'relative',
98
- top: '1px'
99
- },
100
- // 当前业务类型:新增,修改
101
- businessType: '',
102
- // 是否显示新增/修改模态框
103
- modelVisible: false,
104
- // 修改业务时查询的单条业务数据
105
- modifyModelData: {},
106
- // 是否允许修改
107
- isModify: false,
108
- // 是否允许删除
109
- isDelete: false,
110
- // 新增,修改业务执行状态
111
- loading: false,
112
- // 被修改数据加载状态
113
- editDataLoading: false,
114
- // 是否为临时表
115
- isTableTemp: false
116
- }
117
- },
118
- computed: {
119
- ...mapState('setting', ['isMobile']),
120
- businessTitle () {
121
- return this.businessType + this.title
122
- }
123
- },
124
- props: {
125
- // 业务名称
126
- title: {
127
- type: String,
128
- default: ''
129
- },
130
- // 查询配置文件名
131
- queryParamsName: {
132
- type: String,
133
- default: null
134
- },
135
- // 查询配置文件Json,用于查询配置生成器的预览
136
- queryParamsJson: {
137
- type: Object,
138
- default: null
139
- },
140
- // 业务逻辑名称, 通过logic获取表单表格配置
141
- logicName: {
142
- type: String,
143
- default: null
144
- },
145
- // 执行logic传递的参数
146
- logicParam: {
147
- type: Object,
148
- default: () => {}
149
- },
150
- // 固定新增表单
151
- fixedAddForm: {
152
- type: Object,
153
- default: () => {
154
- return {}
155
- }
156
- },
157
- // 固定查询表单
158
- fixedQueryForm: {
159
- type: Object,
160
- default: () => {
161
- return {}
162
- }
163
- },
164
- // 预览模式
165
- viewMode: {
166
- type: Boolean,
167
- default: () => {
168
- return false
169
- }
170
- },
171
- // 动态创建子表需要的定义
172
- tempTableData: {
173
- type: Object,
174
- default: null
175
- }
176
- },
177
- watch: {
178
- logicParam: {
179
- handler () {
180
- this.mainLoading = true
181
- this.form = {}
182
- indexedDB.getByWeb(`${this.logicName}_${JSON.stringify(this.logicParam)}`, commonApi.getColumnsJson, { logic: this.logicName, logicParam: this.logicParam }, (ret) => {
183
- this.queryParams = ret
184
- this.tableColumns = ret.columnJson
185
- this.formItems = ret.formJson
186
- this.mainLoading = false
187
- this.loaded = true
188
- })
189
- },
190
- deep: true
191
- },
192
- fixedQueryForm: {
193
- handler () {
194
- this.mainLoading = true
195
- this.form = {}
196
- indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
197
- this.tableColumns = ret.columnJson
198
- this.formItems = ret.formJson
199
- this.buttonState = ret.buttonState
200
- this.mainLoading = false
201
- this.loaded = true
202
- })
203
- },
204
- deep: true
205
- },
206
- queryParamsJson: {
207
- handler () {
208
- this.getColumnsJsonBySource()
209
- },
210
- deep: true
211
- }
212
- },
213
- created () {
214
- if (this.queryParamsName) {
215
- this.getColumnsJson()
216
- } else if (this.queryParamsJson) {
217
- this.getColumnsJsonBySource()
218
- }
219
- },
220
- methods: {
221
- getColumnsJsonBySource () {
222
- this.mainLoading = true
223
- post(commonApi.getColumnsJson, { queryObject: this.queryParamsJson }).then(res => {
224
- this.queryParams = res
225
- this.tableColumns = this.queryParams.columnJson
226
- this.formItems = this.queryParams.formJson
227
- this.buttonState = this.queryParams.buttonState
228
- this.mainLoading = false
229
- this.loaded = true
230
- })
231
- },
232
- getColumnsJson () {
233
- this.mainLoading = true
234
- indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
235
- this.tableColumns = ret.columnJson
236
- this.formItems = ret.formJson
237
- this.buttonState = ret.buttonState
238
- this.mainLoading = false
239
- this.loaded = true
240
- })
241
- },
242
- // 查询表单提交
243
- onSubmit (res) {
244
- if (res.valid) {
245
- // 表单赋值
246
- this.form = res.form
247
- // commit
248
- this.$emit('afterSearchSubmit', res)
249
- } else {
250
- return false
251
- }
252
- },
253
- // TODO 新增/修改数据表单提交
254
- onAddOrModify (res) {
255
- if (this.viewMode) {
256
- this.$message.info('预览模式禁止新增')
257
- return false
258
- }
259
- // 如果是临时表
260
- if (this.isTableTemp) {
261
- this.$emit('tempTableModify', res)
262
- return
263
- }
264
- if (res.valid) {
265
- this.loading = true
266
- const requestParameters = {
267
- queryParamsName: this.queryParamsName,
268
- form: {}
269
- }
270
- if (this.businessType === '修改') {
271
- const rowKeyValue = this.selectedRowKeys[0]
272
- const key = this.tableColumns[0].dataIndex
273
- const realKey = key.substring(key.indexOf('_') + 1)
274
- requestParameters.form[realKey] = rowKeyValue
275
- }
276
- for (const key of Object.keys(res.form)) {
277
- const realKey = key.substring(key.indexOf('_') + 1)
278
- requestParameters.form[realKey] = res.form[key]
279
- }
280
- addOrModify(requestParameters).then(res => {
281
- this.$message.success(this.businessType + '成功!')
282
- this.loading = false
283
- this.modelVisible = false
284
- this.$refs.xTable.refresh(true)
285
- // commit
286
- this.$emit('afterSubmit', { type: this.businessType, id: res.id })
287
- }).catch(e => {
288
- this.loading = false
289
- this.modelVisible = false
290
- this.$message.error(this.businessType + '失败!')
291
- })
292
- } else {
293
- return false
294
- }
295
- },
296
- // 刷新加载表格数据
297
- loadData (requestParameters, callback) {
298
- let result = {}
299
- if (this.queryParamsJson) {
300
- if (this.queryParamsJson.tableName.startsWith('##')) {
301
- this.isTableTemp = true
302
- result = this.initTempTable(requestParameters)
303
- }
304
- }
305
- if (!this.isTableTemp) {
306
- result = query(requestParameters)
307
- }
308
- this.$emit('afterQuery', result)
309
- callback(result)
310
- },
311
- // 详情按钮事件
312
- action (record, id) {
313
- this.$emit('action', record, id)
314
- },
315
- // 新增业务
316
- addItem () {
317
- this.businessType = '新增'
318
- this.modifyModelData = {}
319
- this.modelVisible = true
320
- },
321
- // 修改业务
322
- editItem () {
323
- this.businessType = '修改'
324
- if (!this.viewMode) {
325
- const requestParameters = {
326
- queryParamsName: this.queryParamsName,
327
- conditionParams: {},
328
- pageNo: 1,
329
- pageSize: 1
330
- }
331
- requestParameters.conditionParams[this.tableColumns[0].dataIndex] = this.selectedRowKeys[0]
332
- requestParameters.f_businessid = this.selectedRowKeys[0]
333
- if (this.isTableTemp) {
334
- this.$emit('tempTableEdit', requestParameters)
335
- return
336
- }
337
- this.editDataLoading = true
338
- queryWithResource(requestParameters).then(res => {
339
- this.modifyModelData = { data: res.data[0], images: res.images, files: res.files }
340
- this.modelVisible = true
341
- this.editDataLoading = false
342
- console.warn(this.modifyModelData)
343
- })
344
- } else {
345
- this.$message.info('预览模式禁止修改')
346
- }
347
- },
348
- // 删除业务
349
- deleteItem () {
350
- if (this.viewMode) {
351
- this.$message.info('预览模式禁止删除')
352
- return
353
- }
354
- Modal.confirm({
355
- title: '提示',
356
- content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
357
- confirmLoading: this.loading,
358
- zIndex: 1001,
359
- onOk: () => {
360
- this.loading = true
361
- const requestParameters = {
362
- queryParamsName: this.queryParamsName,
363
- idList: this.selectedRowKeys
364
- }
365
- remove(requestParameters).then(res => {
366
- this.loading = false
367
- this.$message.success('删除成功!')
368
- this.$refs.xTable.clearRowKeys()
369
- this.$refs.xTable.refresh(true)
370
- // afterDelete
371
- this.$emit('afterDelete', { idList: requestParameters.idList })
372
- }).catch(e => {
373
- this.loading = false
374
- this.$message.error('删除失败!')
375
- })
376
- },
377
- onCancel () {}
378
- })
379
- },
380
- // 查询表单部分显示/隐藏切换
381
- toggleIsFormShow () {
382
- this.isFormShow = !this.isFormShow
383
- },
384
- // 控制业务操作按钮组的显示
385
- selectRow (rowKeys) {
386
- this.selectedRowKeys = rowKeys
387
- this.isModify = this.selectedRowKeys.length === 1
388
- this.isDelete = this.selectedRowKeys.length > 0
389
- },
390
- // 创建临时表sql生成
391
- createTempTable (defineJson) {
392
- const tableName = defineJson.tableName
393
- const define = defineJson.column
394
- return post(ApplyInstallApi.createTempTable, {
395
- define: define,
396
- tableName: tableName
397
- })
398
- .then(
399
- res => {
400
- return res
401
- },
402
- err => {
403
- console.log(err)
404
- }
405
- )
406
- },
407
- // 插入临时表数据sql生成
408
- insertTempTableData (defineJson) {
409
- const tableName = defineJson.tableName
410
- const params = {}
411
- params.define = defineJson.column
412
- params.applyId = defineJson.applyId
413
- params.stepName = defineJson.stepName
414
- params.tableName = tableName
415
- return post(ApplyInstallApi.insertDataToTempTable, {
416
- tempTableData: params
417
- })
418
- .then(
419
- res => {
420
- return res
421
- }
422
- )
423
- },
424
- // 初始化临时表
425
- async initTempTable (json) {
426
- await this.createTempTable(this.queryParamsJson)
427
- await this.insertTempTableData(this.queryParamsJson)
428
- let result = {}
429
- await post(ApplyInstallApi.initApplySubTable, {
430
- define: json
431
- })
432
- .then(
433
- res => {
434
- console.log('子表临时表已创建')
435
- result = res
436
- }
437
- )
438
- return result
439
- }
440
- }
441
- }
442
- </script>
443
- <style lang="less" scoped>
444
- .btn-success {
445
- color: #ffffff;
446
- }
447
- .btn-success:hover {
448
- color: #ffffff !important;
449
- }
450
- .btn-success:focus {
451
- color: #ffffff !important;
452
- }
453
- .btn-success:enabled:hover {
454
- background-color: #85CE61 !important;
455
- border-color: #85CE61 !important;
456
- }
457
- .btn-success:enabled {
458
- background-color: #67c23a;
459
- border-color: #67c23a;
460
- }
461
- .btn-success:disabled {
462
- color: rgba(0, 0, 0, 0.25);
463
- }
464
- .btn-warn {
465
- color: #ffffff;
466
- }
467
- .btn-warn:hover {
468
- color: #ffffff !important;
469
- }
470
- .btn-warn:focus {
471
- color: #ffffff !important;
472
- }
473
- .btn-warn:enabled:hover {
474
- background-color: #ffc833 !important;
475
- border-color: #ffc833 !important;
476
- }
477
- .btn-warn:enabled {
478
- background-color: #ffba00;
479
- border-color: #ffba00;
480
- }
481
- .btn-warn:disabled {
482
- color: rgba(0, 0, 0, 0.25);
483
- }
484
- </style>
1
+ <template>
2
+ <a-skeleton :loading="mainLoading">
3
+ <template v-if="loaded">
4
+ <x-add-form
5
+ :business-title="businessTitle"
6
+ :business-type="businessType"
7
+ :fixedAddForm="fixedAddForm"
8
+ :json-data="formItems"
9
+ :loading="loading"
10
+ :modify-model-data="modifyModelData"
11
+ :visible.sync="modelVisible"
12
+ @onSubmit="onAddOrModify"/>
13
+ <x-form
14
+ :is-show="isFormShow"
15
+ :json-data="formItems"
16
+ style="margin-bottom: 14px;"
17
+ @onSubmit="onSubmit">
18
+ <slot></slot>
19
+ </x-form>
20
+ <x-table
21
+ ref="xTable"
22
+ :buttonState="buttonState"
23
+ :fixedQueryForm="fixedQueryForm"
24
+ :form="form"
25
+ :json-data="tableColumns"
26
+ :queryParams="queryParams"
27
+ :queryParamsName="queryParamsName"
28
+ @action="action"
29
+ @loadData="loadData"
30
+ @selectRow="selectRow"
31
+ @toggleIsFormShow="toggleIsFormShow">
32
+ <template slot="expand">
33
+ <a-space>
34
+ <a-button v-if="!buttonState || buttonState.add" type="primary" @click="addItem">
35
+ <a-icon :style="iconStyle" type="plus"/>新增
36
+ </a-button>
37
+ <a-button
38
+ v-if="!buttonState || buttonState.edit"
39
+ :disabled="!isModify"
40
+ :loading="editDataLoading"
41
+ class="btn-success"
42
+ type="dashed"
43
+ @click="editItem">
44
+ <a-icon :style="iconStyle" type="edit"/>修改
45
+ </a-button>
46
+ <a-button v-if="!buttonState || buttonState.delete" :disabled="!isDelete" type="danger" @click="deleteItem">
47
+ <a-icon :style="iconStyle" type="delete"/>删除
48
+ </a-button>
49
+ <slot :selectedRowKeys="selectedRowKeys" name="button"></slot>
50
+ </a-space>
51
+ <slot name="expand"></slot>
52
+ </template>
53
+ </x-table>
54
+ </template>
55
+ </a-skeleton>
56
+ </template>
57
+ <script>
58
+ import XForm from '@vue2-client/base-client/components/common/XForm/XForm'
59
+ import XAddForm from '@vue2-client/base-client/components/common/XAddForm/XAddForm'
60
+ import XTable from '@vue2-client/base-client/components/common/XTable/XTable'
61
+ import { query, commonApi, addOrModify, remove, queryWithResource } from '@vue2-client/services/api/common'
62
+ import { indexedDB } from '@vue2-client/utils/indexedDB'
63
+ import { mapState } from 'vuex'
64
+ import { Modal } from 'ant-design-vue'
65
+ import { post } from '@vue2-client/services/api/restTools'
66
+ import { ApplyInstallApi } from '@vue2-client/services/api/applyInstallApi'
67
+
68
+ export default {
69
+ name: 'XFormTable',
70
+ components: {
71
+ XTable,
72
+ XForm,
73
+ XAddForm
74
+ },
75
+ data () {
76
+ return {
77
+ // Query参数文件内容加载中
78
+ mainLoading: false,
79
+ // Query参数文件内容加载完成
80
+ loaded: false,
81
+ // 是否展示表单
82
+ isFormShow: true,
83
+ // 当使用logic获取到表单表格配置时, 将配置对象直接传入到x-table用于查询
84
+ queryParams: null,
85
+ // 表格列集合
86
+ tableColumns: [],
87
+ // 操作按钮集合
88
+ buttonState: {},
89
+ // 表格选择列Key集合
90
+ selectedRowKeys: [],
91
+ // 表单项集合
92
+ formItems: [],
93
+ // 表单
94
+ form: {},
95
+ // 图标样式
96
+ iconStyle: {
97
+ position: 'relative',
98
+ top: '1px'
99
+ },
100
+ // 当前业务类型:新增,修改
101
+ businessType: '',
102
+ // 是否显示新增/修改模态框
103
+ modelVisible: false,
104
+ // 修改业务时查询的单条业务数据
105
+ modifyModelData: {},
106
+ // 是否允许修改
107
+ isModify: false,
108
+ // 是否允许删除
109
+ isDelete: false,
110
+ // 新增,修改业务执行状态
111
+ loading: false,
112
+ // 被修改数据加载状态
113
+ editDataLoading: false,
114
+ // 是否为临时表
115
+ isTableTemp: false
116
+ }
117
+ },
118
+ computed: {
119
+ ...mapState('setting', ['isMobile']),
120
+ businessTitle () {
121
+ return this.businessType + this.title
122
+ }
123
+ },
124
+ props: {
125
+ // 业务名称
126
+ title: {
127
+ type: String,
128
+ default: ''
129
+ },
130
+ // 查询配置文件名
131
+ queryParamsName: {
132
+ type: String,
133
+ default: null
134
+ },
135
+ // 查询配置文件Json,用于查询配置生成器的预览
136
+ queryParamsJson: {
137
+ type: Object,
138
+ default: null
139
+ },
140
+ // 业务逻辑名称, 通过logic获取表单表格配置
141
+ logicName: {
142
+ type: String,
143
+ default: null
144
+ },
145
+ // 执行logic传递的参数
146
+ logicParam: {
147
+ type: Object,
148
+ default: () => {}
149
+ },
150
+ // 固定新增表单
151
+ fixedAddForm: {
152
+ type: Object,
153
+ default: () => {
154
+ return {}
155
+ }
156
+ },
157
+ // 固定查询表单
158
+ fixedQueryForm: {
159
+ type: Object,
160
+ default: () => {
161
+ return {}
162
+ }
163
+ },
164
+ // 预览模式
165
+ viewMode: {
166
+ type: Boolean,
167
+ default: () => {
168
+ return false
169
+ }
170
+ },
171
+ // 动态创建子表需要的定义
172
+ tempTableData: {
173
+ type: Object,
174
+ default: null
175
+ }
176
+ },
177
+ watch: {
178
+ logicParam: {
179
+ handler () {
180
+ this.mainLoading = true
181
+ this.form = {}
182
+ indexedDB.getByWeb(`${this.logicName}_${JSON.stringify(this.logicParam)}`, commonApi.getColumnsJson, { logic: this.logicName, logicParam: this.logicParam }, (ret) => {
183
+ this.queryParams = ret
184
+ this.tableColumns = ret.columnJson
185
+ this.formItems = ret.formJson
186
+ this.buttonState = ret.buttonState
187
+ this.mainLoading = false
188
+ this.loaded = true
189
+ })
190
+ },
191
+ deep: true
192
+ },
193
+ fixedQueryForm: {
194
+ handler () {
195
+ this.mainLoading = true
196
+ this.form = {}
197
+ indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
198
+ this.tableColumns = ret.columnJson
199
+ this.formItems = ret.formJson
200
+ this.buttonState = ret.buttonState
201
+ this.mainLoading = false
202
+ this.loaded = true
203
+ })
204
+ },
205
+ deep: true
206
+ },
207
+ queryParamsJson: {
208
+ handler () {
209
+ this.getColumnsJsonBySource()
210
+ },
211
+ deep: true
212
+ }
213
+ },
214
+ created () {
215
+ if (this.queryParamsName) {
216
+ this.getColumnsJson()
217
+ } else if (this.queryParamsJson) {
218
+ this.getColumnsJsonBySource()
219
+ }
220
+ },
221
+ methods: {
222
+ refreshTable () {
223
+ this.$refs.xTable.refresh(true)
224
+ },
225
+ clearRowKeys () {
226
+ this.$refs.xTable.clearRowKeys()
227
+ },
228
+ getColumnsJsonBySource () {
229
+ this.mainLoading = true
230
+ post(commonApi.getColumnsJson, { queryObject: this.queryParamsJson }).then(res => {
231
+ this.queryParams = res
232
+ this.tableColumns = this.queryParams.columnJson
233
+ this.formItems = this.queryParams.formJson
234
+ this.buttonState = this.queryParams.buttonState
235
+ this.mainLoading = false
236
+ this.loaded = true
237
+ })
238
+ },
239
+ getColumnsJson () {
240
+ this.mainLoading = true
241
+ indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
242
+ this.tableColumns = ret.columnJson
243
+ this.formItems = ret.formJson
244
+ this.buttonState = ret.buttonState
245
+ this.mainLoading = false
246
+ this.loaded = true
247
+ })
248
+ },
249
+ // 查询表单提交
250
+ onSubmit (res) {
251
+ if (res.valid) {
252
+ // 表单赋值
253
+ this.form = res.form
254
+ // commit
255
+ this.$emit('afterSearchSubmit', res)
256
+ } else {
257
+ return false
258
+ }
259
+ },
260
+ // TODO 新增/修改数据表单提交
261
+ onAddOrModify (res) {
262
+ if (this.viewMode) {
263
+ this.$message.info('预览模式禁止新增')
264
+ return false
265
+ }
266
+ // 如果是临时表
267
+ if (this.isTableTemp) {
268
+ this.$emit('tempTableModify', res)
269
+ return
270
+ }
271
+ if (res.valid) {
272
+ this.loading = true
273
+ const requestParameters = {
274
+ queryParamsName: this.queryParamsName,
275
+ form: {}
276
+ }
277
+ if (this.businessType === '修改') {
278
+ const rowKeyValue = this.selectedRowKeys[0]
279
+ const key = this.tableColumns[0].dataIndex
280
+ const realKey = key.substring(key.indexOf('_') + 1)
281
+ requestParameters.form[realKey] = rowKeyValue
282
+ }
283
+ for (const key of Object.keys(res.form)) {
284
+ const realKey = key.substring(key.indexOf('_') + 1)
285
+ requestParameters.form[realKey] = res.form[key]
286
+ }
287
+ addOrModify(requestParameters).then(res => {
288
+ this.$message.success(this.businessType + '成功!')
289
+ this.loading = false
290
+ this.modelVisible = false
291
+ this.$refs.xTable.refresh(true)
292
+ // commit
293
+ this.$emit('afterSubmit', { type: this.businessType, id: res.id })
294
+ }).catch(e => {
295
+ this.loading = false
296
+ this.modelVisible = false
297
+ this.$message.error(this.businessType + '失败!')
298
+ })
299
+ } else {
300
+ return false
301
+ }
302
+ },
303
+ // 刷新加载表格数据
304
+ loadData (requestParameters, callback) {
305
+ let result = {}
306
+ if (this.queryParamsJson) {
307
+ if (this.queryParamsJson.tableName.startsWith('##')) {
308
+ this.isTableTemp = true
309
+ result = this.initTempTable(requestParameters)
310
+ }
311
+ }
312
+ if (!this.isTableTemp) {
313
+ result = query(requestParameters)
314
+ }
315
+ this.$emit('afterQuery', result)
316
+ callback(result)
317
+ },
318
+ // 详情按钮事件
319
+ action (record, id) {
320
+ this.$emit('action', record, id)
321
+ },
322
+ // 新增业务
323
+ addItem () {
324
+ this.businessType = '新增'
325
+ this.modifyModelData = {}
326
+ this.modelVisible = true
327
+ },
328
+ // 修改业务
329
+ editItem () {
330
+ this.businessType = '修改'
331
+ if (!this.viewMode) {
332
+ const requestParameters = {
333
+ queryParamsName: this.queryParamsName,
334
+ conditionParams: {},
335
+ pageNo: 1,
336
+ pageSize: 1
337
+ }
338
+ requestParameters.conditionParams[this.tableColumns[0].dataIndex] = this.selectedRowKeys[0]
339
+ requestParameters.f_businessid = this.selectedRowKeys[0]
340
+ if (this.isTableTemp) {
341
+ this.$emit('tempTableEdit', requestParameters)
342
+ return
343
+ }
344
+ this.editDataLoading = true
345
+ queryWithResource(requestParameters).then(res => {
346
+ this.modifyModelData = { data: res.data[0], images: res.images, files: res.files }
347
+ this.modelVisible = true
348
+ this.editDataLoading = false
349
+ console.warn(this.modifyModelData)
350
+ })
351
+ } else {
352
+ this.$message.info('预览模式禁止修改')
353
+ }
354
+ },
355
+ // 删除业务
356
+ deleteItem () {
357
+ if (this.viewMode) {
358
+ this.$message.info('预览模式禁止删除')
359
+ return
360
+ }
361
+ Modal.confirm({
362
+ title: '提示',
363
+ content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
364
+ confirmLoading: this.loading,
365
+ zIndex: 1001,
366
+ onOk: () => {
367
+ this.loading = true
368
+ const requestParameters = {
369
+ queryParamsName: this.queryParamsName,
370
+ idList: this.selectedRowKeys
371
+ }
372
+ remove(requestParameters).then(res => {
373
+ this.loading = false
374
+ this.$message.success('删除成功!')
375
+ this.$refs.xTable.clearRowKeys()
376
+ this.$refs.xTable.refresh(true)
377
+ // afterDelete
378
+ this.$emit('afterDelete', { idList: requestParameters.idList })
379
+ }).catch(e => {
380
+ this.loading = false
381
+ this.$message.error('删除失败!')
382
+ })
383
+ },
384
+ onCancel () {}
385
+ })
386
+ },
387
+ // 查询表单部分显示/隐藏切换
388
+ toggleIsFormShow () {
389
+ this.isFormShow = !this.isFormShow
390
+ },
391
+ // 控制业务操作按钮组的显示
392
+ selectRow (rowKeys) {
393
+ this.selectedRowKeys = rowKeys
394
+ this.isModify = this.selectedRowKeys.length === 1
395
+ this.isDelete = this.selectedRowKeys.length > 0
396
+ },
397
+ // 创建临时表sql生成
398
+ createTempTable (defineJson) {
399
+ const tableName = defineJson.tableName
400
+ const define = defineJson.column
401
+ return post(ApplyInstallApi.createTempTable, {
402
+ define: define,
403
+ tableName: tableName
404
+ })
405
+ .then(
406
+ res => {
407
+ return res
408
+ },
409
+ err => {
410
+ console.log(err)
411
+ }
412
+ )
413
+ },
414
+ // 插入临时表数据sql生成
415
+ insertTempTableData (defineJson) {
416
+ const tableName = defineJson.tableName
417
+ const params = {}
418
+ params.define = defineJson.column
419
+ params.applyId = defineJson.applyId
420
+ params.stepName = defineJson.stepName
421
+ params.tableName = tableName
422
+ return post(ApplyInstallApi.insertDataToTempTable, {
423
+ tempTableData: params
424
+ })
425
+ .then(
426
+ res => {
427
+ return res
428
+ }
429
+ )
430
+ },
431
+ // 初始化临时表
432
+ async initTempTable (json) {
433
+ await this.createTempTable(this.queryParamsJson)
434
+ await this.insertTempTableData(this.queryParamsJson)
435
+ let result = {}
436
+ await post(ApplyInstallApi.initApplySubTable, {
437
+ define: json
438
+ })
439
+ .then(
440
+ res => {
441
+ console.log('子表临时表已创建')
442
+ result = res
443
+ }
444
+ )
445
+ return result
446
+ }
447
+ }
448
+ }
449
+ </script>
450
+ <style lang="less" scoped>
451
+ .btn-success {
452
+ color: #ffffff;
453
+ }
454
+ .btn-success:hover {
455
+ color: #ffffff !important;
456
+ }
457
+ .btn-success:focus {
458
+ color: #ffffff !important;
459
+ }
460
+ .btn-success:enabled:hover {
461
+ background-color: #85CE61 !important;
462
+ border-color: #85CE61 !important;
463
+ }
464
+ .btn-success:enabled {
465
+ background-color: #67c23a;
466
+ border-color: #67c23a;
467
+ }
468
+ .btn-success:disabled {
469
+ color: rgba(0, 0, 0, 0.25);
470
+ }
471
+ .btn-warn {
472
+ color: #ffffff;
473
+ }
474
+ .btn-warn:hover {
475
+ color: #ffffff !important;
476
+ }
477
+ .btn-warn:focus {
478
+ color: #ffffff !important;
479
+ }
480
+ .btn-warn:enabled:hover {
481
+ background-color: #ffc833 !important;
482
+ border-color: #ffc833 !important;
483
+ }
484
+ .btn-warn:enabled {
485
+ background-color: #ffba00;
486
+ border-color: #ffba00;
487
+ }
488
+ .btn-warn:disabled {
489
+ color: rgba(0, 0, 0, 0.25);
490
+ }
491
+ </style>