vue2-client 1.2.29 → 1.2.32

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,406 +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 { commonApi, query, addOrModify, remove, post } from '@vue2-client/services/api'
61
- import { indexedDB } from '@vue2-client/utils/indexedDB'
62
- import { mapState } from 'vuex'
63
- import { Modal } from 'ant-design-vue'
64
-
65
- export default {
66
- name: 'XFormTable',
67
- components: {
68
- XTable,
69
- XForm,
70
- XAddForm
71
- },
72
- data () {
73
- return {
74
- // Query参数文件内容加载中
75
- mainLoading: false,
76
- // Query参数文件内容加载完成
77
- loaded: false,
78
- // 是否展示表单
79
- isFormShow: true,
80
- // 当使用logic获取到表单表格配置时, 将配置对象直接传入到x-table用于查询
81
- queryParams: null,
82
- // 表格列集合
83
- tableColumns: [],
84
- // 操作按钮集合
85
- buttonState: {},
86
- // 表格选择列Key集合
87
- selectedRowKeys: [],
88
- // 表单项集合
89
- formItems: [],
90
- // 表单
91
- form: {},
92
- // 图标样式
93
- iconStyle: {
94
- position: 'relative',
95
- top: '1px'
96
- },
97
- // 当前业务类型:新增,修改
98
- businessType: '',
99
- // 是否显示新增/修改模态框
100
- modelVisible: false,
101
- // 修改业务时查询的单条业务数据
102
- modifyModelData: {},
103
- // 是否允许修改
104
- isModify: false,
105
- // 是否允许删除
106
- isDelete: false,
107
- // 新增,修改业务执行状态
108
- loading: false,
109
- // 被修改数据加载状态
110
- editDataLoading: false
111
- }
112
- },
113
- computed: {
114
- ...mapState('setting', ['isMobile']),
115
- businessTitle () {
116
- return this.businessType + this.title
117
- }
118
- },
119
- props: {
120
- // 业务名称
121
- title: {
122
- type: String,
123
- default: ''
124
- },
125
- // 查询配置文件名
126
- queryParamsName: {
127
- type: String,
128
- default: null
129
- },
130
- // 查询配置文件Json,用于查询配置生成器的预览
131
- queryParamsJson: {
132
- type: Object,
133
- default: null
134
- },
135
- // 业务逻辑名称, 通过logic获取表单表格配置
136
- logicName: {
137
- type: String,
138
- default: null
139
- },
140
- // 执行logic传递的参数
141
- logicParam: {
142
- type: Object,
143
- default: () => {}
144
- },
145
- // 固定新增表单
146
- fixedAddForm: {
147
- type: Object,
148
- default: () => {
149
- return {}
150
- }
151
- },
152
- // 固定查询表单
153
- fixedQueryForm: {
154
- type: Object,
155
- default: () => {
156
- return {}
157
- }
158
- },
159
- // 预览模式
160
- viewMode: {
161
- type: Boolean,
162
- default: () => {
163
- return false
164
- }
165
- }
166
- },
167
- watch: {
168
- logicParam: {
169
- handler () {
170
- this.mainLoading = true
171
- this.form = {}
172
- indexedDB.getByWeb(`${this.logicName}_${JSON.stringify(this.logicParam)}`, commonApi.getColumnsJson, { logic: this.logicName, logicParam: this.logicParam }, (ret) => {
173
- this.queryParams = ret
174
- this.tableColumns = ret.columnJson
175
- this.formItems = ret.formJson
176
- this.mainLoading = false
177
- this.loaded = true
178
- })
179
- },
180
- deep: true
181
- },
182
- fixedQueryForm: {
183
- handler () {
184
- this.mainLoading = true
185
- this.form = {}
186
- indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
187
- this.tableColumns = ret.columnJson
188
- this.formItems = ret.formJson
189
- this.buttonState = ret.buttonState
190
- this.mainLoading = false
191
- this.loaded = true
192
- })
193
- },
194
- deep: true
195
- },
196
- queryParamsJson: {
197
- handler () {
198
- this.getColumnsJsonBySource()
199
- },
200
- deep: true
201
- }
202
- },
203
- created () {
204
- if (this.queryParamsName) {
205
- this.getColumnsJson()
206
- } else if (this.queryParamsJson) {
207
- this.getColumnsJsonBySource()
208
- }
209
- },
210
- methods: {
211
- getColumnsJsonBySource () {
212
- this.mainLoading = true
213
- post(commonApi.getColumnsJson, { queryObject: this.queryParamsJson }).then(res => {
214
- this.queryParams = res
215
- this.tableColumns = this.queryParams.columnJson
216
- this.formItems = this.queryParams.formJson
217
- this.buttonState = this.queryParams.buttonState
218
- this.mainLoading = false
219
- this.loaded = true
220
- })
221
- },
222
- getColumnsJson () {
223
- this.mainLoading = true
224
- indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
225
- this.tableColumns = ret.columnJson
226
- this.formItems = ret.formJson
227
- this.buttonState = ret.buttonState
228
- this.mainLoading = false
229
- this.loaded = true
230
- })
231
- },
232
- // 查询表单提交
233
- onSubmit (res) {
234
- if (res.valid) {
235
- // 设置当前燃气公司
236
- this.$emit('update:selectOrgName', res.form.orgName)
237
- // 表单赋值
238
- this.form = res.form
239
- // commit
240
- this.$emit('afterSearchSubmit', res)
241
- } else {
242
- return false
243
- }
244
- },
245
- // 新增/修改数据表单提交
246
- onAddOrModify (res) {
247
- if (this.viewMode) {
248
- this.$message.info('预览模式禁止新增')
249
- return false
250
- }
251
- if (res.valid) {
252
- this.loading = true
253
- const requestParameters = {
254
- queryParamsName: this.queryParamsName,
255
- form: {}
256
- }
257
- if (this.businessType === '修改') {
258
- const rowKeyValue = this.selectedRowKeys[0]
259
- const key = this.tableColumns[0].dataIndex
260
- const realKey = key.substring(key.indexOf('_') + 1)
261
- requestParameters.form[realKey] = rowKeyValue
262
- }
263
- for (const key of Object.keys(res.form)) {
264
- const realKey = key.substring(key.indexOf('_') + 1)
265
- requestParameters.form[realKey] = res.form[key]
266
- }
267
- addOrModify(requestParameters).then(res => {
268
- this.$message.success(this.businessType + '成功!')
269
- this.loading = false
270
- this.modelVisible = false
271
- this.$refs.xTable.refresh(true)
272
- // commit
273
- this.$emit('afterSubmit', res)
274
- }).catch(e => {
275
- this.loading = false
276
- this.modelVisible = false
277
- this.$message.error(this.businessType + '失败!')
278
- })
279
- } else {
280
- return false
281
- }
282
- },
283
- // 刷新加载表格数据
284
- loadData (requestParameters, callback) {
285
- const result = query(requestParameters)
286
- this.$emit('afterQuery', result)
287
- callback(result)
288
- },
289
- // 详情按钮事件
290
- action (record, id) {
291
- this.$emit('action', record, id)
292
- },
293
- // 新增业务
294
- addItem () {
295
- this.businessType = '新增'
296
- this.modifyModelData = {}
297
- this.modelVisible = true
298
- },
299
- // 修改业务
300
- editItem () {
301
- this.businessType = '修改'
302
- if (!this.viewMode) {
303
- const requestParameters = {
304
- queryParamsName: this.queryParamsName,
305
- conditionParams: {},
306
- pageNo: 1,
307
- pageSize: 1
308
- }
309
- requestParameters.conditionParams[this.tableColumns[0].dataIndex] = this.selectedRowKeys[0]
310
- this.editDataLoading = true
311
- query(requestParameters).then(res => {
312
- this.modifyModelData = res.data[0]
313
- this.modelVisible = true
314
- this.editDataLoading = false
315
- })
316
- } else {
317
- this.$message.info('预览模式禁止修改')
318
- }
319
- },
320
- // 删除业务
321
- deleteItem () {
322
- if (this.viewMode) {
323
- this.$message.info('预览模式禁止删除')
324
- return
325
- }
326
- Modal.confirm({
327
- title: '提示',
328
- content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
329
- confirmLoading: this.loading,
330
- zIndex: 1001,
331
- onOk: () => {
332
- this.loading = true
333
- const requestParameters = {
334
- queryParamsName: this.queryParamsName,
335
- idList: this.selectedRowKeys
336
- }
337
- remove(requestParameters).then(res => {
338
- this.loading = false
339
- this.$message.success('删除成功!')
340
- this.$refs.xTable.clearRowKeys()
341
- this.$refs.xTable.refresh(true)
342
- // commit
343
- this.$emit('afterSubmit', res)
344
- }).catch(e => {
345
- this.loading = false
346
- this.$message.error('删除失败!')
347
- })
348
- },
349
- onCancel () {}
350
- })
351
- },
352
- // 查询表单部分显示/隐藏切换
353
- toggleIsFormShow () {
354
- this.isFormShow = !this.isFormShow
355
- },
356
- // 控制业务操作按钮组的显示
357
- selectRow (rowKeys) {
358
- this.selectedRowKeys = rowKeys
359
- this.isModify = this.selectedRowKeys.length === 1
360
- this.isDelete = this.selectedRowKeys.length > 0
361
- }
362
- }
363
- }
364
- </script>
365
- <style lang="less" scoped>
366
- .btn-success {
367
- color: #ffffff;
368
- }
369
- .btn-success:hover {
370
- color: #ffffff !important;
371
- }
372
- .btn-success:focus {
373
- color: #ffffff !important;
374
- }
375
- .btn-success:enabled:hover {
376
- background-color: #85CE61 !important;
377
- border-color: #85CE61 !important;
378
- }
379
- .btn-success:enabled {
380
- background-color: #67c23a;
381
- border-color: #67c23a;
382
- }
383
- .btn-success:disabled {
384
- color: rgba(0, 0, 0, 0.25);
385
- }
386
- .btn-warn {
387
- color: #ffffff;
388
- }
389
- .btn-warn:hover {
390
- color: #ffffff !important;
391
- }
392
- .btn-warn:focus {
393
- color: #ffffff !important;
394
- }
395
- .btn-warn:enabled:hover {
396
- background-color: #ffc833 !important;
397
- border-color: #ffc833 !important;
398
- }
399
- .btn-warn:enabled {
400
- background-color: #ffba00;
401
- border-color: #ffba00;
402
- }
403
- .btn-warn:disabled {
404
- color: rgba(0, 0, 0, 0.25);
405
- }
406
- </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
+ 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>