vue2-client 1.2.61 → 1.2.64

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.
@@ -1,483 +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, queryWithResource } 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.form = res.form
246
- // commit
247
- this.$emit('afterSearchSubmit', res)
248
- } else {
249
- return false
250
- }
251
- },
252
- // TODO 新增/修改数据表单提交
253
- onAddOrModify (res) {
254
- if (this.viewMode) {
255
- this.$message.info('预览模式禁止新增')
256
- return false
257
- }
258
- // 如果是临时表
259
- if (this.isTableTemp) {
260
- this.$emit('tempTableModify', res)
261
- return
262
- }
263
- if (res.valid) {
264
- this.loading = true
265
- const requestParameters = {
266
- queryParamsName: this.queryParamsName,
267
- form: {}
268
- }
269
- if (this.businessType === '修改') {
270
- const rowKeyValue = this.selectedRowKeys[0]
271
- const key = this.tableColumns[0].dataIndex
272
- const realKey = key.substring(key.indexOf('_') + 1)
273
- requestParameters.form[realKey] = rowKeyValue
274
- }
275
- for (const key of Object.keys(res.form)) {
276
- const realKey = key.substring(key.indexOf('_') + 1)
277
- requestParameters.form[realKey] = res.form[key]
278
- }
279
- addOrModify(requestParameters).then(res => {
280
- this.$message.success(this.businessType + '成功!')
281
- this.loading = false
282
- this.modelVisible = false
283
- this.$refs.xTable.refresh(true)
284
- // commit
285
- this.$emit('afterSubmit', res)
286
- }).catch(e => {
287
- this.loading = false
288
- this.modelVisible = false
289
- this.$message.error(this.businessType + '失败!')
290
- })
291
- } else {
292
- return false
293
- }
294
- },
295
- // 刷新加载表格数据
296
- loadData (requestParameters, callback) {
297
- let result = {}
298
- if (this.queryParamsJson) {
299
- if (this.queryParamsJson.tableName.startsWith('##')) {
300
- this.isTableTemp = true
301
- result = this.initTempTable(requestParameters)
302
- }
303
- }
304
- if (!this.isTableTemp) {
305
- result = query(requestParameters)
306
- }
307
- this.$emit('afterQuery', result)
308
- callback(result)
309
- },
310
- // 详情按钮事件
311
- action (record, id) {
312
- this.$emit('action', record, id)
313
- },
314
- // 新增业务
315
- addItem () {
316
- this.businessType = '新增'
317
- this.modifyModelData = {}
318
- this.modelVisible = true
319
- },
320
- // 修改业务
321
- editItem () {
322
- this.businessType = '修改'
323
- if (!this.viewMode) {
324
- const requestParameters = {
325
- queryParamsName: this.queryParamsName,
326
- conditionParams: {},
327
- pageNo: 1,
328
- pageSize: 1
329
- }
330
- requestParameters.conditionParams[this.tableColumns[0].dataIndex] = this.selectedRowKeys[0]
331
- requestParameters.f_businessid = this.selectedRowKeys[0]
332
- if (this.isTableTemp) {
333
- this.$emit('tempTableEdit', requestParameters)
334
- return
335
- }
336
- this.editDataLoading = true
337
- queryWithResource(requestParameters).then(res => {
338
- this.modifyModelData = { data: res.data[0], images: res.images, files: res.files }
339
- this.modelVisible = true
340
- this.editDataLoading = false
341
- console.warn(this.modifyModelData)
342
- })
343
- } else {
344
- this.$message.info('预览模式禁止修改')
345
- }
346
- },
347
- // 删除业务
348
- deleteItem () {
349
- if (this.viewMode) {
350
- this.$message.info('预览模式禁止删除')
351
- return
352
- }
353
- Modal.confirm({
354
- title: '提示',
355
- content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
356
- confirmLoading: this.loading,
357
- zIndex: 1001,
358
- onOk: () => {
359
- this.loading = true
360
- const requestParameters = {
361
- queryParamsName: this.queryParamsName,
362
- idList: this.selectedRowKeys
363
- }
364
- remove(requestParameters).then(res => {
365
- this.loading = false
366
- this.$message.success('删除成功!')
367
- this.$refs.xTable.clearRowKeys()
368
- this.$refs.xTable.refresh(true)
369
- // commit
370
- this.$emit('afterSubmit', res)
371
- }).catch(e => {
372
- this.loading = false
373
- this.$message.error('删除失败!')
374
- })
375
- },
376
- onCancel () {}
377
- })
378
- },
379
- // 查询表单部分显示/隐藏切换
380
- toggleIsFormShow () {
381
- this.isFormShow = !this.isFormShow
382
- },
383
- // 控制业务操作按钮组的显示
384
- selectRow (rowKeys) {
385
- this.selectedRowKeys = rowKeys
386
- this.isModify = this.selectedRowKeys.length === 1
387
- this.isDelete = this.selectedRowKeys.length > 0
388
- },
389
- // 创建临时表sql生成
390
- createTempTable (defineJson) {
391
- const tableName = defineJson.tableName
392
- const define = defineJson.column
393
- return post(ApplyInstallApi.createTempTable, {
394
- define: define,
395
- tableName: tableName
396
- })
397
- .then(
398
- res => {
399
- return res
400
- },
401
- err => {
402
- console.log(err)
403
- }
404
- )
405
- },
406
- // 插入临时表数据sql生成
407
- insertTempTableData (defineJson) {
408
- const tableName = defineJson.tableName
409
- const params = {}
410
- params.define = defineJson.column
411
- params.applyId = defineJson.applyId
412
- params.stepName = defineJson.stepName
413
- params.tableName = tableName
414
- return post(ApplyInstallApi.insertDataToTempTable, {
415
- tempTableData: params
416
- })
417
- .then(
418
- res => {
419
- return res
420
- }
421
- )
422
- },
423
- // 初始化临时表
424
- async initTempTable (json) {
425
- await this.createTempTable(this.queryParamsJson)
426
- await this.insertTempTableData(this.queryParamsJson)
427
- let result = {}
428
- await post(ApplyInstallApi.initApplySubTable, {
429
- define: json
430
- })
431
- .then(
432
- res => {
433
- console.log('子表临时表已创建')
434
- result = res
435
- }
436
- )
437
- return result
438
- }
439
- }
440
- }
441
- </script>
442
- <style lang="less" scoped>
443
- .btn-success {
444
- color: #ffffff;
445
- }
446
- .btn-success:hover {
447
- color: #ffffff !important;
448
- }
449
- .btn-success:focus {
450
- color: #ffffff !important;
451
- }
452
- .btn-success:enabled:hover {
453
- background-color: #85CE61 !important;
454
- border-color: #85CE61 !important;
455
- }
456
- .btn-success:enabled {
457
- background-color: #67c23a;
458
- border-color: #67c23a;
459
- }
460
- .btn-success:disabled {
461
- color: rgba(0, 0, 0, 0.25);
462
- }
463
- .btn-warn {
464
- color: #ffffff;
465
- }
466
- .btn-warn:hover {
467
- color: #ffffff !important;
468
- }
469
- .btn-warn:focus {
470
- color: #ffffff !important;
471
- }
472
- .btn-warn:enabled:hover {
473
- background-color: #ffc833 !important;
474
- border-color: #ffc833 !important;
475
- }
476
- .btn-warn:enabled {
477
- background-color: #ffba00;
478
- border-color: #ffba00;
479
- }
480
- .btn-warn:disabled {
481
- color: rgba(0, 0, 0, 0.25);
482
- }
483
- </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
+ :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
+
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>