vue2-client 1.2.55-test → 1.2.55-test3

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,482 +1,483 @@
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.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
- if (this.isTableTemp) {
332
- this.$emit('tempTableEdit', requestParameters)
333
- return
334
- }
335
- this.editDataLoading = true
336
- query(requestParameters).then(res => {
337
- this.modifyModelData = res.data[0]
338
- this.modelVisible = true
339
- this.editDataLoading = false
340
- console.warn(this.modifyModelData)
341
- })
342
- } else {
343
- this.$message.info('预览模式禁止修改')
344
- }
345
- },
346
- // 删除业务
347
- deleteItem () {
348
- if (this.viewMode) {
349
- this.$message.info('预览模式禁止删除')
350
- return
351
- }
352
- Modal.confirm({
353
- title: '提示',
354
- content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
355
- confirmLoading: this.loading,
356
- zIndex: 1001,
357
- onOk: () => {
358
- this.loading = true
359
- const requestParameters = {
360
- queryParamsName: this.queryParamsName,
361
- idList: this.selectedRowKeys
362
- }
363
- remove(requestParameters).then(res => {
364
- this.loading = false
365
- this.$message.success('删除成功!')
366
- this.$refs.xTable.clearRowKeys()
367
- this.$refs.xTable.refresh(true)
368
- // commit
369
- this.$emit('afterSubmit', res)
370
- }).catch(e => {
371
- this.loading = false
372
- this.$message.error('删除失败!')
373
- })
374
- },
375
- onCancel () {}
376
- })
377
- },
378
- // 查询表单部分显示/隐藏切换
379
- toggleIsFormShow () {
380
- this.isFormShow = !this.isFormShow
381
- },
382
- // 控制业务操作按钮组的显示
383
- selectRow (rowKeys) {
384
- this.selectedRowKeys = rowKeys
385
- this.isModify = this.selectedRowKeys.length === 1
386
- this.isDelete = this.selectedRowKeys.length > 0
387
- },
388
- // 创建临时表sql生成
389
- createTempTable (defineJson) {
390
- const tableName = defineJson.tableName
391
- const define = defineJson.column
392
- return post(ApplyInstallApi.createTempTable, {
393
- define: define,
394
- tableName: tableName
395
- })
396
- .then(
397
- res => {
398
- return res
399
- },
400
- err => {
401
- console.log(err)
402
- }
403
- )
404
- },
405
- // 插入临时表数据sql生成
406
- insertTempTableData (defineJson) {
407
- const tableName = defineJson.tableName
408
- const params = {}
409
- params.define = defineJson.column
410
- params.applyId = defineJson.applyId
411
- params.stepName = defineJson.stepName
412
- params.tableName = tableName
413
- return post(ApplyInstallApi.insertDataToTempTable, {
414
- tempTableData: params
415
- })
416
- .then(
417
- res => {
418
- return res
419
- }
420
- )
421
- },
422
- // 初始化临时表
423
- async initTempTable (json) {
424
- await this.createTempTable(this.queryParamsJson)
425
- await this.insertTempTableData(this.queryParamsJson)
426
- let result = {}
427
- await post(ApplyInstallApi.initApplySubTable, {
428
- define: json
429
- })
430
- .then(
431
- res => {
432
- console.log('子表临时表已创建')
433
- result = res
434
- }
435
- )
436
- return result
437
- }
438
- }
439
- }
440
- </script>
441
- <style lang="less" scoped>
442
- .btn-success {
443
- color: #ffffff;
444
- }
445
- .btn-success:hover {
446
- color: #ffffff !important;
447
- }
448
- .btn-success:focus {
449
- color: #ffffff !important;
450
- }
451
- .btn-success:enabled:hover {
452
- background-color: #85CE61 !important;
453
- border-color: #85CE61 !important;
454
- }
455
- .btn-success:enabled {
456
- background-color: #67c23a;
457
- border-color: #67c23a;
458
- }
459
- .btn-success:disabled {
460
- color: rgba(0, 0, 0, 0.25);
461
- }
462
- .btn-warn {
463
- color: #ffffff;
464
- }
465
- .btn-warn:hover {
466
- color: #ffffff !important;
467
- }
468
- .btn-warn:focus {
469
- color: #ffffff !important;
470
- }
471
- .btn-warn:enabled:hover {
472
- background-color: #ffc833 !important;
473
- border-color: #ffc833 !important;
474
- }
475
- .btn-warn:enabled {
476
- background-color: #ffba00;
477
- border-color: #ffba00;
478
- }
479
- .btn-warn:disabled {
480
- color: rgba(0, 0, 0, 0.25);
481
- }
482
- </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, 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>