vue2-client 1.2.74 → 1.2.75

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 (46) hide show
  1. package/.env +15 -15
  2. package/.eslintrc.js +82 -82
  3. package/CHANGELOG.md +5 -0
  4. package/package.json +46 -46
  5. package/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox.vue +225 -225
  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 +539 -539
  11. package/src/base-client/components/common/CreateQuery/CreateQueryItem.vue +773 -773
  12. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQuery.vue +310 -310
  13. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQueryItem.vue +553 -553
  14. package/src/base-client/components/common/Upload/Upload.vue +151 -151
  15. package/src/base-client/components/common/Upload/index.js +3 -3
  16. package/src/base-client/components/common/XAddForm/XAddForm.vue +345 -345
  17. package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +322 -322
  18. package/src/base-client/components/common/XForm/XForm.vue +268 -268
  19. package/src/base-client/components/common/XForm/XFormItem.vue +358 -358
  20. package/src/base-client/components/common/XFormTable/XFormTable.vue +491 -491
  21. package/src/base-client/components/common/XTable/XTable.vue +269 -269
  22. package/src/base-client/components/iot/DeviceDetailsView/DeviceDetailsView.vue +232 -230
  23. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsCount.vue +623 -330
  24. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsException.vue +57 -57
  25. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsRead.vue +131 -131
  26. package/src/base-client/components/iot/DeviceTypeDetailsView/DeviceTypeDetailsView.vue +300 -300
  27. package/src/base-client/components/iot/WebmeterAnalysisView/WebmeterAnalysisView.vue +647 -647
  28. package/src/base-client/components/ticket/TicketSubmitSuccessView/TicketSubmitSuccessView.vue +532 -532
  29. package/src/base-client/plugins/AppData.js +70 -70
  30. package/src/base-client/plugins/compatible/LoginServiceOA.js +20 -20
  31. package/src/components/Charts/ChartCard.vue +14 -0
  32. package/src/config/CreateQueryConfig.js +301 -301
  33. package/src/pages/resourceManage/orgListManage.vue +98 -98
  34. package/src/router/async/config.async.js +26 -26
  35. package/src/router/async/router.map.js +60 -60
  36. package/src/router/index.js +27 -27
  37. package/src/services/api/common.js +56 -56
  38. package/src/services/api/index.js +39 -39
  39. package/src/services/api/iot/DeviceDetailsView/DeviceDetailsCountApi.js +14 -0
  40. package/src/services/api/manage.js +16 -16
  41. package/src/services/api/restTools.js +24 -24
  42. package/src/theme/default/style.less +47 -47
  43. package/src/utils/map-utils.js +28 -28
  44. package/src/utils/request.js +198 -198
  45. package/src/utils/util.js +222 -222
  46. package/vue.config.js +153 -153
@@ -1,491 +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
- :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>
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>