vue2-client 1.2.32 → 1.2.35

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 (28) hide show
  1. package/.eslintrc.js +1 -0
  2. package/CHANGELOG.md +15 -0
  3. package/package.json +1 -1
  4. package/src/base-client/all.js +2 -0
  5. package/src/base-client/components/common/CreateQuery/CreateQuery.vue +46 -19
  6. package/src/base-client/components/common/Upload/Upload.vue +124 -0
  7. package/src/base-client/components/common/Upload/index.js +3 -0
  8. package/src/base-client/components/common/XAddForm/XAddForm.vue +1 -0
  9. package/src/base-client/components/common/XAddNativeForm/index.js +3 -3
  10. package/src/base-client/components/common/XAddNativeForm/index.md +56 -56
  11. package/src/base-client/components/common/XForm/XFormItem.vue +6 -33
  12. package/src/base-client/components/common/XFormTable/XFormTable.vue +484 -484
  13. package/src/base-client/components/common/XFormTable/index.md +5 -0
  14. package/src/base-client/components/common/XTable/index.md +255 -255
  15. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsException.vue +57 -57
  16. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsRead.vue +131 -131
  17. package/src/base-client/components/ticket/TicketSubmitSuccessView/TicketSubmitSuccessView.vue +532 -528
  18. package/src/config/default/setting.config.js +34 -34
  19. package/src/pages/login/Login.vue +198 -198
  20. package/src/pages/system/ticket/index.vue +440 -437
  21. package/src/router/async/config.async.js +26 -26
  22. package/src/router/async/router.map.js +59 -59
  23. package/src/router/index.js +27 -27
  24. package/src/services/api/EmployeeDetailsViewApi.js +16 -16
  25. package/src/services/api/applyInstallApi.js +14 -14
  26. package/src/services/api/restTools.js +3 -2
  27. package/src/utils/request.js +198 -197
  28. package/vue.config.js +143 -143
@@ -1,484 +1,484 @@
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
- :queryParamsName="queryParamsName"
27
- :fixedQueryForm="fixedQueryForm"
28
- @loadData="loadData"
29
- @action="action"
30
- :form="form">
31
- <template slot="expand">
32
- <a-space>
33
- <a-button type="primary" @click="addItem" v-if="!buttonState || buttonState.add">
34
- <a-icon :style="iconStyle" type="plus"/>新增
35
- </a-button>
36
- <a-button
37
- v-if="!buttonState || buttonState.edit"
38
- :loading="editDataLoading"
39
- :disabled="!isModify"
40
- class="btn-success"
41
- type="dashed"
42
- @click="editItem">
43
- <a-icon :style="iconStyle" type="edit"/>修改
44
- </a-button>
45
- <a-button :disabled="!isDelete" type="danger" @click="deleteItem" v-if="!buttonState || buttonState.delete">
46
- <a-icon :style="iconStyle" type="delete"/>删除
47
- </a-button>
48
-
49
- </a-space>
50
- <slot name="expand"></slot>
51
- </template>
52
- </x-table>
53
- </template>
54
- </a-skeleton>
55
- </template>
56
- <script>
57
- import XForm from '@vue2-client/base-client/components/common/XForm/XForm'
58
- import XAddForm from '@vue2-client/base-client/components/common/XAddForm/XAddForm'
59
- import XTable from '@vue2-client/base-client/components/common/XTable/XTable'
60
- import { query, commonApi, addOrModify, remove } from '@vue2-client/services/api/common'
61
- import { indexedDB } from '@vue2-client/utils/indexedDB'
62
- import { mapState } from 'vuex'
63
- import { Modal } from 'ant-design-vue'
64
- import { post } from '@vue2-client/services/api/restTools'
65
- import { ApplyInstallApi } from '@vue2-client/services/api/applyInstallApi'
66
-
67
- export default {
68
- name: 'XFormTable',
69
- components: {
70
- XTable,
71
- XForm,
72
- XAddForm
73
- },
74
- data () {
75
- return {
76
- // Query参数文件内容加载中
77
- mainLoading: false,
78
- // Query参数文件内容加载完成
79
- loaded: false,
80
- // 是否展示表单
81
- isFormShow: true,
82
- // 当使用logic获取到表单表格配置时, 将配置对象直接传入到x-table用于查询
83
- queryParams: null,
84
- // 表格列集合
85
- tableColumns: [],
86
- // 操作按钮集合
87
- buttonState: {},
88
- // 表格选择列Key集合
89
- selectedRowKeys: [],
90
- // 表单项集合
91
- formItems: [],
92
- // 表单
93
- form: {},
94
- // 图标样式
95
- iconStyle: {
96
- position: 'relative',
97
- top: '1px'
98
- },
99
- // 当前业务类型:新增,修改
100
- businessType: '',
101
- // 是否显示新增/修改模态框
102
- modelVisible: false,
103
- // 修改业务时查询的单条业务数据
104
- modifyModelData: {},
105
- // 是否允许修改
106
- isModify: false,
107
- // 是否允许删除
108
- isDelete: false,
109
- // 新增,修改业务执行状态
110
- loading: false,
111
- // 被修改数据加载状态
112
- editDataLoading: false,
113
- // 是否为临时表
114
- isTableTemp: false
115
- }
116
- },
117
- computed: {
118
- ...mapState('setting', ['isMobile']),
119
- businessTitle () {
120
- return this.businessType + this.title
121
- }
122
- },
123
- props: {
124
- // 业务名称
125
- title: {
126
- type: String,
127
- default: ''
128
- },
129
- // 查询配置文件名
130
- queryParamsName: {
131
- type: String,
132
- default: null
133
- },
134
- // 查询配置文件Json,用于查询配置生成器的预览
135
- queryParamsJson: {
136
- type: Object,
137
- default: null
138
- },
139
- // 业务逻辑名称, 通过logic获取表单表格配置
140
- logicName: {
141
- type: String,
142
- default: null
143
- },
144
- // 执行logic传递的参数
145
- logicParam: {
146
- type: Object,
147
- default: () => {}
148
- },
149
- // 固定新增表单
150
- fixedAddForm: {
151
- type: Object,
152
- default: () => {
153
- return {}
154
- }
155
- },
156
- // 固定查询表单
157
- fixedQueryForm: {
158
- type: Object,
159
- default: () => {
160
- return {}
161
- }
162
- },
163
- // 预览模式
164
- viewMode: {
165
- type: Boolean,
166
- default: () => {
167
- return false
168
- }
169
- },
170
- // 动态创建子表需要的定义
171
- tempTableData: {
172
- type: Object,
173
- default: null
174
- }
175
- },
176
- watch: {
177
- logicParam: {
178
- handler () {
179
- this.mainLoading = true
180
- this.form = {}
181
- indexedDB.getByWeb(`${this.logicName}_${JSON.stringify(this.logicParam)}`, commonApi.getColumnsJson, { logic: this.logicName, logicParam: this.logicParam }, (ret) => {
182
- this.queryParams = ret
183
- this.tableColumns = ret.columnJson
184
- this.formItems = ret.formJson
185
- this.mainLoading = false
186
- this.loaded = true
187
- })
188
- },
189
- deep: true
190
- },
191
- fixedQueryForm: {
192
- handler () {
193
- this.mainLoading = true
194
- this.form = {}
195
- indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
196
- this.tableColumns = ret.columnJson
197
- this.formItems = ret.formJson
198
- this.buttonState = ret.buttonState
199
- this.mainLoading = false
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
- getColumnsJsonBySource () {
221
- this.mainLoading = true
222
- post(commonApi.getColumnsJson, { queryObject: this.queryParamsJson }).then(res => {
223
- this.queryParams = res
224
- this.tableColumns = this.queryParams.columnJson
225
- this.formItems = this.queryParams.formJson
226
- this.buttonState = this.queryParams.buttonState
227
- this.mainLoading = false
228
- this.loaded = true
229
- })
230
- },
231
- getColumnsJson () {
232
- this.mainLoading = true
233
- indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
234
- this.tableColumns = ret.columnJson
235
- this.formItems = ret.formJson
236
- this.buttonState = ret.buttonState
237
- this.mainLoading = false
238
- this.loaded = true
239
- })
240
- },
241
- // 查询表单提交
242
- onSubmit (res) {
243
- if (res.valid) {
244
- // 设置当前燃气公司
245
- this.$emit('update:selectOrgName', res.form.orgName)
246
- // 表单赋值
247
- this.form = res.form
248
- // commit
249
- this.$emit('afterSearchSubmit', res)
250
- } else {
251
- return false
252
- }
253
- },
254
- // TODO 新增/修改数据表单提交
255
- onAddOrModify (res) {
256
- if (this.viewMode) {
257
- this.$message.info('预览模式禁止新增')
258
- return false
259
- }
260
- // 如果是临时表
261
- if (this.isTableTemp) {
262
- this.$emit('tempTableModify',res)
263
- return
264
- }
265
- if (res.valid) {
266
- this.loading = true
267
- const requestParameters = {
268
- queryParamsName: this.queryParamsName,
269
- form: {}
270
- }
271
- if (this.businessType === '修改') {
272
- const rowKeyValue = this.selectedRowKeys[0]
273
- const key = this.tableColumns[0].dataIndex
274
- const realKey = key.substring(key.indexOf('_') + 1)
275
- requestParameters.form[realKey] = rowKeyValue
276
- }
277
- for (const key of Object.keys(res.form)) {
278
- const realKey = key.substring(key.indexOf('_') + 1)
279
- requestParameters.form[realKey] = res.form[key]
280
- }
281
- addOrModify(requestParameters).then(res => {
282
- this.$message.success(this.businessType + '成功!')
283
- this.loading = false
284
- this.modelVisible = false
285
- this.$refs.xTable.refresh(true)
286
- // commit
287
- this.$emit('afterSubmit', res)
288
- }).catch(e => {
289
- this.loading = false
290
- this.modelVisible = false
291
- this.$message.error(this.businessType + '失败!')
292
- })
293
- } else {
294
- return false
295
- }
296
- },
297
- // 刷新加载表格数据
298
- loadData (requestParameters, callback) {
299
- let result = {}
300
- if (this.queryParamsJson) {
301
- if (this.queryParamsJson.tableName.startsWith('##')) {
302
- this.isTableTemp = true
303
- result = this.initTempTable(requestParameters)
304
- }
305
- }
306
- if (!this.isTableTemp) {
307
- result = query(requestParameters)
308
- }
309
- this.$emit('afterQuery', result)
310
- callback(result)
311
- },
312
- // 详情按钮事件
313
- action (record, id) {
314
- this.$emit('action', record, id)
315
- },
316
- // 新增业务
317
- addItem () {
318
- this.businessType = '新增'
319
- this.modifyModelData = {}
320
- this.modelVisible = true
321
- },
322
- // 修改业务
323
- editItem () {
324
- this.businessType = '修改'
325
- if (!this.viewMode) {
326
- const requestParameters = {
327
- queryParamsName: this.queryParamsName,
328
- conditionParams: {},
329
- pageNo: 1,
330
- pageSize: 1
331
- }
332
- requestParameters.conditionParams[this.tableColumns[0].dataIndex] = this.selectedRowKeys[0]
333
- if (this.isTableTemp) {
334
- this.$emit('tempTableEdit',requestParameters)
335
- return
336
- }
337
- this.editDataLoading = true
338
- query(requestParameters).then(res => {
339
- this.modifyModelData = res.data[0]
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
- // commit
371
- this.$emit('afterSubmit', res)
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
- let params = {}
411
- params.define = defineJson.column
412
- params.applyId = 4
413
- params.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
+ :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
+ :queryParamsName="queryParamsName"
27
+ :fixedQueryForm="fixedQueryForm"
28
+ @loadData="loadData"
29
+ @action="action"
30
+ :form="form">
31
+ <template slot="expand">
32
+ <a-space>
33
+ <a-button type="primary" @click="addItem" v-if="!buttonState || buttonState.add">
34
+ <a-icon :style="iconStyle" type="plus"/>新增
35
+ </a-button>
36
+ <a-button
37
+ v-if="!buttonState || buttonState.edit"
38
+ :loading="editDataLoading"
39
+ :disabled="!isModify"
40
+ class="btn-success"
41
+ type="dashed"
42
+ @click="editItem">
43
+ <a-icon :style="iconStyle" type="edit"/>修改
44
+ </a-button>
45
+ <a-button :disabled="!isDelete" type="danger" @click="deleteItem" v-if="!buttonState || buttonState.delete">
46
+ <a-icon :style="iconStyle" type="delete"/>删除
47
+ </a-button>
48
+
49
+ </a-space>
50
+ <slot name="expand"></slot>
51
+ </template>
52
+ </x-table>
53
+ </template>
54
+ </a-skeleton>
55
+ </template>
56
+ <script>
57
+ import XForm from '@vue2-client/base-client/components/common/XForm/XForm'
58
+ import XAddForm from '@vue2-client/base-client/components/common/XAddForm/XAddForm'
59
+ import XTable from '@vue2-client/base-client/components/common/XTable/XTable'
60
+ import { query, commonApi, addOrModify, remove } from '@vue2-client/services/api/common'
61
+ import { indexedDB } from '@vue2-client/utils/indexedDB'
62
+ import { mapState } from 'vuex'
63
+ import { Modal } from 'ant-design-vue'
64
+ import { post } from '@vue2-client/services/api/restTools'
65
+ import { ApplyInstallApi } from '@vue2-client/services/api/applyInstallApi'
66
+
67
+ export default {
68
+ name: 'XFormTable',
69
+ components: {
70
+ XTable,
71
+ XForm,
72
+ XAddForm
73
+ },
74
+ data () {
75
+ return {
76
+ // Query参数文件内容加载中
77
+ mainLoading: false,
78
+ // Query参数文件内容加载完成
79
+ loaded: false,
80
+ // 是否展示表单
81
+ isFormShow: true,
82
+ // 当使用logic获取到表单表格配置时, 将配置对象直接传入到x-table用于查询
83
+ queryParams: null,
84
+ // 表格列集合
85
+ tableColumns: [],
86
+ // 操作按钮集合
87
+ buttonState: {},
88
+ // 表格选择列Key集合
89
+ selectedRowKeys: [],
90
+ // 表单项集合
91
+ formItems: [],
92
+ // 表单
93
+ form: {},
94
+ // 图标样式
95
+ iconStyle: {
96
+ position: 'relative',
97
+ top: '1px'
98
+ },
99
+ // 当前业务类型:新增,修改
100
+ businessType: '',
101
+ // 是否显示新增/修改模态框
102
+ modelVisible: false,
103
+ // 修改业务时查询的单条业务数据
104
+ modifyModelData: {},
105
+ // 是否允许修改
106
+ isModify: false,
107
+ // 是否允许删除
108
+ isDelete: false,
109
+ // 新增,修改业务执行状态
110
+ loading: false,
111
+ // 被修改数据加载状态
112
+ editDataLoading: false,
113
+ // 是否为临时表
114
+ isTableTemp: false
115
+ }
116
+ },
117
+ computed: {
118
+ ...mapState('setting', ['isMobile']),
119
+ businessTitle () {
120
+ return this.businessType + this.title
121
+ }
122
+ },
123
+ props: {
124
+ // 业务名称
125
+ title: {
126
+ type: String,
127
+ default: ''
128
+ },
129
+ // 查询配置文件名
130
+ queryParamsName: {
131
+ type: String,
132
+ default: null
133
+ },
134
+ // 查询配置文件Json,用于查询配置生成器的预览
135
+ queryParamsJson: {
136
+ type: Object,
137
+ default: null
138
+ },
139
+ // 业务逻辑名称, 通过logic获取表单表格配置
140
+ logicName: {
141
+ type: String,
142
+ default: null
143
+ },
144
+ // 执行logic传递的参数
145
+ logicParam: {
146
+ type: Object,
147
+ default: () => {}
148
+ },
149
+ // 固定新增表单
150
+ fixedAddForm: {
151
+ type: Object,
152
+ default: () => {
153
+ return {}
154
+ }
155
+ },
156
+ // 固定查询表单
157
+ fixedQueryForm: {
158
+ type: Object,
159
+ default: () => {
160
+ return {}
161
+ }
162
+ },
163
+ // 预览模式
164
+ viewMode: {
165
+ type: Boolean,
166
+ default: () => {
167
+ return false
168
+ }
169
+ },
170
+ // 动态创建子表需要的定义
171
+ tempTableData: {
172
+ type: Object,
173
+ default: null
174
+ }
175
+ },
176
+ watch: {
177
+ logicParam: {
178
+ handler () {
179
+ this.mainLoading = true
180
+ this.form = {}
181
+ indexedDB.getByWeb(`${this.logicName}_${JSON.stringify(this.logicParam)}`, commonApi.getColumnsJson, { logic: this.logicName, logicParam: this.logicParam }, (ret) => {
182
+ this.queryParams = ret
183
+ this.tableColumns = ret.columnJson
184
+ this.formItems = ret.formJson
185
+ this.mainLoading = false
186
+ this.loaded = true
187
+ })
188
+ },
189
+ deep: true
190
+ },
191
+ fixedQueryForm: {
192
+ handler () {
193
+ this.mainLoading = true
194
+ this.form = {}
195
+ indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
196
+ this.tableColumns = ret.columnJson
197
+ this.formItems = ret.formJson
198
+ this.buttonState = ret.buttonState
199
+ this.mainLoading = false
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
+ getColumnsJsonBySource () {
221
+ this.mainLoading = true
222
+ post(commonApi.getColumnsJson, { queryObject: this.queryParamsJson }).then(res => {
223
+ this.queryParams = res
224
+ this.tableColumns = this.queryParams.columnJson
225
+ this.formItems = this.queryParams.formJson
226
+ this.buttonState = this.queryParams.buttonState
227
+ this.mainLoading = false
228
+ this.loaded = true
229
+ })
230
+ },
231
+ getColumnsJson () {
232
+ this.mainLoading = true
233
+ indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
234
+ this.tableColumns = ret.columnJson
235
+ this.formItems = ret.formJson
236
+ this.buttonState = ret.buttonState
237
+ this.mainLoading = false
238
+ this.loaded = true
239
+ })
240
+ },
241
+ // 查询表单提交
242
+ onSubmit (res) {
243
+ if (res.valid) {
244
+ // 设置当前燃气公司
245
+ this.$emit('update:selectOrgName', res.form.orgName)
246
+ // 表单赋值
247
+ this.form = res.form
248
+ // commit
249
+ this.$emit('afterSearchSubmit', res)
250
+ } else {
251
+ return false
252
+ }
253
+ },
254
+ // TODO 新增/修改数据表单提交
255
+ onAddOrModify (res) {
256
+ if (this.viewMode) {
257
+ this.$message.info('预览模式禁止新增')
258
+ return false
259
+ }
260
+ // 如果是临时表
261
+ if (this.isTableTemp) {
262
+ this.$emit('tempTableModify', res)
263
+ return
264
+ }
265
+ if (res.valid) {
266
+ this.loading = true
267
+ const requestParameters = {
268
+ queryParamsName: this.queryParamsName,
269
+ form: {}
270
+ }
271
+ if (this.businessType === '修改') {
272
+ const rowKeyValue = this.selectedRowKeys[0]
273
+ const key = this.tableColumns[0].dataIndex
274
+ const realKey = key.substring(key.indexOf('_') + 1)
275
+ requestParameters.form[realKey] = rowKeyValue
276
+ }
277
+ for (const key of Object.keys(res.form)) {
278
+ const realKey = key.substring(key.indexOf('_') + 1)
279
+ requestParameters.form[realKey] = res.form[key]
280
+ }
281
+ addOrModify(requestParameters).then(res => {
282
+ this.$message.success(this.businessType + '成功!')
283
+ this.loading = false
284
+ this.modelVisible = false
285
+ this.$refs.xTable.refresh(true)
286
+ // commit
287
+ this.$emit('afterSubmit', res)
288
+ }).catch(e => {
289
+ this.loading = false
290
+ this.modelVisible = false
291
+ this.$message.error(this.businessType + '失败!')
292
+ })
293
+ } else {
294
+ return false
295
+ }
296
+ },
297
+ // 刷新加载表格数据
298
+ loadData (requestParameters, callback) {
299
+ let result = {}
300
+ if (this.queryParamsJson) {
301
+ if (this.queryParamsJson.tableName.startsWith('##')) {
302
+ this.isTableTemp = true
303
+ result = this.initTempTable(requestParameters)
304
+ }
305
+ }
306
+ if (!this.isTableTemp) {
307
+ result = query(requestParameters)
308
+ }
309
+ this.$emit('afterQuery', result)
310
+ callback(result)
311
+ },
312
+ // 详情按钮事件
313
+ action (record, id) {
314
+ this.$emit('action', record, id)
315
+ },
316
+ // 新增业务
317
+ addItem () {
318
+ this.businessType = '新增'
319
+ this.modifyModelData = {}
320
+ this.modelVisible = true
321
+ },
322
+ // 修改业务
323
+ editItem () {
324
+ this.businessType = '修改'
325
+ if (!this.viewMode) {
326
+ const requestParameters = {
327
+ queryParamsName: this.queryParamsName,
328
+ conditionParams: {},
329
+ pageNo: 1,
330
+ pageSize: 1
331
+ }
332
+ requestParameters.conditionParams[this.tableColumns[0].dataIndex] = this.selectedRowKeys[0]
333
+ if (this.isTableTemp) {
334
+ this.$emit('tempTableEdit', requestParameters)
335
+ return
336
+ }
337
+ this.editDataLoading = true
338
+ query(requestParameters).then(res => {
339
+ this.modifyModelData = res.data[0]
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
+ // commit
371
+ this.$emit('afterSubmit', res)
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>