vue2-client 1.2.91 → 1.2.93-test

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