vue2-client 1.2.66 → 1.2.67

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.
package/CHANGELOG.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Change Log
2
2
  > 所有关于本项目的变化都在该文档里。
3
3
 
4
- **1.2.66 -2022-06-08 @江超**
4
+ **1.2.66 - 1.2.67 -2022-06-08 @江超**
5
5
  - 功能修改:
6
6
  - 设备类型详情页新增设备查询配置
7
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2-client",
3
- "version": "1.2.66",
3
+ "version": "1.2.67",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -1,484 +1,485 @@
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
- <slot name="button" :selectedRowKeys="selectedRowKeys"></slot>
50
- </a-space>
51
- <slot name="expand"></slot>
52
- </template>
53
- </x-table>
54
- </template>
55
- </a-skeleton>
56
- </template>
57
- <script>
58
- import XForm from '@vue2-client/base-client/components/common/XForm/XForm'
59
- import XAddForm from '@vue2-client/base-client/components/common/XAddForm/XAddForm'
60
- import XTable from '@vue2-client/base-client/components/common/XTable/XTable'
61
- import { query, commonApi, addOrModify, remove, queryWithResource } from '@vue2-client/services/api/common'
62
- import { indexedDB } from '@vue2-client/utils/indexedDB'
63
- import { mapState } from 'vuex'
64
- import { Modal } from 'ant-design-vue'
65
- import { post } from '@vue2-client/services/api/restTools'
66
- import { ApplyInstallApi } from '@vue2-client/services/api/applyInstallApi'
67
-
68
- export default {
69
- name: 'XFormTable',
70
- components: {
71
- XTable,
72
- XForm,
73
- XAddForm
74
- },
75
- data () {
76
- return {
77
- // Query参数文件内容加载中
78
- mainLoading: false,
79
- // Query参数文件内容加载完成
80
- loaded: false,
81
- // 是否展示表单
82
- isFormShow: true,
83
- // 当使用logic获取到表单表格配置时, 将配置对象直接传入到x-table用于查询
84
- queryParams: null,
85
- // 表格列集合
86
- tableColumns: [],
87
- // 操作按钮集合
88
- buttonState: {},
89
- // 表格选择列Key集合
90
- selectedRowKeys: [],
91
- // 表单项集合
92
- formItems: [],
93
- // 表单
94
- form: {},
95
- // 图标样式
96
- iconStyle: {
97
- position: 'relative',
98
- top: '1px'
99
- },
100
- // 当前业务类型:新增,修改
101
- businessType: '',
102
- // 是否显示新增/修改模态框
103
- modelVisible: false,
104
- // 修改业务时查询的单条业务数据
105
- modifyModelData: {},
106
- // 是否允许修改
107
- isModify: false,
108
- // 是否允许删除
109
- isDelete: false,
110
- // 新增,修改业务执行状态
111
- loading: false,
112
- // 被修改数据加载状态
113
- editDataLoading: false,
114
- // 是否为临时表
115
- isTableTemp: false
116
- }
117
- },
118
- computed: {
119
- ...mapState('setting', ['isMobile']),
120
- businessTitle () {
121
- return this.businessType + this.title
122
- }
123
- },
124
- props: {
125
- // 业务名称
126
- title: {
127
- type: String,
128
- default: ''
129
- },
130
- // 查询配置文件名
131
- queryParamsName: {
132
- type: String,
133
- default: null
134
- },
135
- // 查询配置文件Json,用于查询配置生成器的预览
136
- queryParamsJson: {
137
- type: Object,
138
- default: null
139
- },
140
- // 业务逻辑名称, 通过logic获取表单表格配置
141
- logicName: {
142
- type: String,
143
- default: null
144
- },
145
- // 执行logic传递的参数
146
- logicParam: {
147
- type: Object,
148
- default: () => {}
149
- },
150
- // 固定新增表单
151
- fixedAddForm: {
152
- type: Object,
153
- default: () => {
154
- return {}
155
- }
156
- },
157
- // 固定查询表单
158
- fixedQueryForm: {
159
- type: Object,
160
- default: () => {
161
- return {}
162
- }
163
- },
164
- // 预览模式
165
- viewMode: {
166
- type: Boolean,
167
- default: () => {
168
- return false
169
- }
170
- },
171
- // 动态创建子表需要的定义
172
- tempTableData: {
173
- type: Object,
174
- default: null
175
- }
176
- },
177
- watch: {
178
- logicParam: {
179
- handler () {
180
- this.mainLoading = true
181
- this.form = {}
182
- indexedDB.getByWeb(`${this.logicName}_${JSON.stringify(this.logicParam)}`, commonApi.getColumnsJson, { logic: this.logicName, logicParam: this.logicParam }, (ret) => {
183
- this.queryParams = ret
184
- this.tableColumns = ret.columnJson
185
- this.formItems = ret.formJson
186
- this.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>
1
+ <template>
2
+ <a-skeleton :loading="mainLoading">
3
+ <template v-if="loaded">
4
+ <x-add-form
5
+ :business-title="businessTitle"
6
+ :business-type="businessType"
7
+ :fixedAddForm="fixedAddForm"
8
+ :json-data="formItems"
9
+ :loading="loading"
10
+ :modify-model-data="modifyModelData"
11
+ :visible.sync="modelVisible"
12
+ @onSubmit="onAddOrModify"/>
13
+ <x-form
14
+ :is-show="isFormShow"
15
+ :json-data="formItems"
16
+ style="margin-bottom: 14px;"
17
+ @onSubmit="onSubmit">
18
+ <slot></slot>
19
+ </x-form>
20
+ <x-table
21
+ ref="xTable"
22
+ :buttonState="buttonState"
23
+ :fixedQueryForm="fixedQueryForm"
24
+ :form="form"
25
+ :json-data="tableColumns"
26
+ :queryParams="queryParams"
27
+ :queryParamsName="queryParamsName"
28
+ @action="action"
29
+ @loadData="loadData"
30
+ @selectRow="selectRow"
31
+ @toggleIsFormShow="toggleIsFormShow">
32
+ <template slot="expand">
33
+ <a-space>
34
+ <a-button v-if="!buttonState || buttonState.add" type="primary" @click="addItem">
35
+ <a-icon :style="iconStyle" type="plus"/>新增
36
+ </a-button>
37
+ <a-button
38
+ v-if="!buttonState || buttonState.edit"
39
+ :disabled="!isModify"
40
+ :loading="editDataLoading"
41
+ class="btn-success"
42
+ type="dashed"
43
+ @click="editItem">
44
+ <a-icon :style="iconStyle" type="edit"/>修改
45
+ </a-button>
46
+ <a-button v-if="!buttonState || buttonState.delete" :disabled="!isDelete" type="danger" @click="deleteItem">
47
+ <a-icon :style="iconStyle" type="delete"/>删除
48
+ </a-button>
49
+ <slot :selectedRowKeys="selectedRowKeys" name="button"></slot>
50
+ </a-space>
51
+ <slot name="expand"></slot>
52
+ </template>
53
+ </x-table>
54
+ </template>
55
+ </a-skeleton>
56
+ </template>
57
+ <script>
58
+ import XForm from '@vue2-client/base-client/components/common/XForm/XForm'
59
+ import XAddForm from '@vue2-client/base-client/components/common/XAddForm/XAddForm'
60
+ import XTable from '@vue2-client/base-client/components/common/XTable/XTable'
61
+ import { query, commonApi, addOrModify, remove, queryWithResource } from '@vue2-client/services/api/common'
62
+ import { indexedDB } from '@vue2-client/utils/indexedDB'
63
+ import { mapState } from 'vuex'
64
+ import { Modal } from 'ant-design-vue'
65
+ import { post } from '@vue2-client/services/api/restTools'
66
+ import { ApplyInstallApi } from '@vue2-client/services/api/applyInstallApi'
67
+
68
+ export default {
69
+ name: 'XFormTable',
70
+ components: {
71
+ XTable,
72
+ XForm,
73
+ XAddForm
74
+ },
75
+ data () {
76
+ return {
77
+ // Query参数文件内容加载中
78
+ mainLoading: false,
79
+ // Query参数文件内容加载完成
80
+ loaded: false,
81
+ // 是否展示表单
82
+ isFormShow: true,
83
+ // 当使用logic获取到表单表格配置时, 将配置对象直接传入到x-table用于查询
84
+ queryParams: null,
85
+ // 表格列集合
86
+ tableColumns: [],
87
+ // 操作按钮集合
88
+ buttonState: {},
89
+ // 表格选择列Key集合
90
+ selectedRowKeys: [],
91
+ // 表单项集合
92
+ formItems: [],
93
+ // 表单
94
+ form: {},
95
+ // 图标样式
96
+ iconStyle: {
97
+ position: 'relative',
98
+ top: '1px'
99
+ },
100
+ // 当前业务类型:新增,修改
101
+ businessType: '',
102
+ // 是否显示新增/修改模态框
103
+ modelVisible: false,
104
+ // 修改业务时查询的单条业务数据
105
+ modifyModelData: {},
106
+ // 是否允许修改
107
+ isModify: false,
108
+ // 是否允许删除
109
+ isDelete: false,
110
+ // 新增,修改业务执行状态
111
+ loading: false,
112
+ // 被修改数据加载状态
113
+ editDataLoading: false,
114
+ // 是否为临时表
115
+ isTableTemp: false
116
+ }
117
+ },
118
+ computed: {
119
+ ...mapState('setting', ['isMobile']),
120
+ businessTitle () {
121
+ return this.businessType + this.title
122
+ }
123
+ },
124
+ props: {
125
+ // 业务名称
126
+ title: {
127
+ type: String,
128
+ default: ''
129
+ },
130
+ // 查询配置文件名
131
+ queryParamsName: {
132
+ type: String,
133
+ default: null
134
+ },
135
+ // 查询配置文件Json,用于查询配置生成器的预览
136
+ queryParamsJson: {
137
+ type: Object,
138
+ default: null
139
+ },
140
+ // 业务逻辑名称, 通过logic获取表单表格配置
141
+ logicName: {
142
+ type: String,
143
+ default: null
144
+ },
145
+ // 执行logic传递的参数
146
+ logicParam: {
147
+ type: Object,
148
+ default: () => {}
149
+ },
150
+ // 固定新增表单
151
+ fixedAddForm: {
152
+ type: Object,
153
+ default: () => {
154
+ return {}
155
+ }
156
+ },
157
+ // 固定查询表单
158
+ fixedQueryForm: {
159
+ type: Object,
160
+ default: () => {
161
+ return {}
162
+ }
163
+ },
164
+ // 预览模式
165
+ viewMode: {
166
+ type: Boolean,
167
+ default: () => {
168
+ return false
169
+ }
170
+ },
171
+ // 动态创建子表需要的定义
172
+ tempTableData: {
173
+ type: Object,
174
+ default: null
175
+ }
176
+ },
177
+ watch: {
178
+ logicParam: {
179
+ handler () {
180
+ this.mainLoading = true
181
+ this.form = {}
182
+ indexedDB.getByWeb(`${this.logicName}_${JSON.stringify(this.logicParam)}`, commonApi.getColumnsJson, { logic: this.logicName, logicParam: this.logicParam }, (ret) => {
183
+ this.queryParams = ret
184
+ this.tableColumns = ret.columnJson
185
+ this.formItems = ret.formJson
186
+ this.buttonState = ret.buttonState
187
+ this.mainLoading = false
188
+ this.loaded = true
189
+ })
190
+ },
191
+ deep: true
192
+ },
193
+ fixedQueryForm: {
194
+ handler () {
195
+ this.mainLoading = true
196
+ this.form = {}
197
+ indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
198
+ this.tableColumns = ret.columnJson
199
+ this.formItems = ret.formJson
200
+ this.buttonState = ret.buttonState
201
+ this.mainLoading = false
202
+ this.loaded = true
203
+ })
204
+ },
205
+ deep: true
206
+ },
207
+ queryParamsJson: {
208
+ handler () {
209
+ this.getColumnsJsonBySource()
210
+ },
211
+ deep: true
212
+ }
213
+ },
214
+ created () {
215
+ if (this.queryParamsName) {
216
+ this.getColumnsJson()
217
+ } else if (this.queryParamsJson) {
218
+ this.getColumnsJsonBySource()
219
+ }
220
+ },
221
+ methods: {
222
+ getColumnsJsonBySource () {
223
+ this.mainLoading = true
224
+ post(commonApi.getColumnsJson, { queryObject: this.queryParamsJson }).then(res => {
225
+ this.queryParams = res
226
+ this.tableColumns = this.queryParams.columnJson
227
+ this.formItems = this.queryParams.formJson
228
+ this.buttonState = this.queryParams.buttonState
229
+ this.mainLoading = false
230
+ this.loaded = true
231
+ })
232
+ },
233
+ getColumnsJson () {
234
+ this.mainLoading = true
235
+ indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
236
+ this.tableColumns = ret.columnJson
237
+ this.formItems = ret.formJson
238
+ this.buttonState = ret.buttonState
239
+ this.mainLoading = false
240
+ this.loaded = true
241
+ })
242
+ },
243
+ // 查询表单提交
244
+ onSubmit (res) {
245
+ if (res.valid) {
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', { type: this.businessType, id: res.id })
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
+ requestParameters.f_businessid = this.selectedRowKeys[0]
334
+ if (this.isTableTemp) {
335
+ this.$emit('tempTableEdit', requestParameters)
336
+ return
337
+ }
338
+ this.editDataLoading = true
339
+ queryWithResource(requestParameters).then(res => {
340
+ this.modifyModelData = { data: res.data[0], images: res.images, files: res.files }
341
+ this.modelVisible = true
342
+ this.editDataLoading = false
343
+ console.warn(this.modifyModelData)
344
+ })
345
+ } else {
346
+ this.$message.info('预览模式禁止修改')
347
+ }
348
+ },
349
+ // 删除业务
350
+ deleteItem () {
351
+ if (this.viewMode) {
352
+ this.$message.info('预览模式禁止删除')
353
+ return
354
+ }
355
+ Modal.confirm({
356
+ title: '提示',
357
+ content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
358
+ confirmLoading: this.loading,
359
+ zIndex: 1001,
360
+ onOk: () => {
361
+ this.loading = true
362
+ const requestParameters = {
363
+ queryParamsName: this.queryParamsName,
364
+ idList: this.selectedRowKeys
365
+ }
366
+ remove(requestParameters).then(res => {
367
+ this.loading = false
368
+ this.$message.success('删除成功!')
369
+ this.$refs.xTable.clearRowKeys()
370
+ this.$refs.xTable.refresh(true)
371
+ // afterDelete
372
+ this.$emit('afterDelete', { idList: requestParameters.idList })
373
+ }).catch(e => {
374
+ this.loading = false
375
+ this.$message.error('删除失败!')
376
+ })
377
+ },
378
+ onCancel () {}
379
+ })
380
+ },
381
+ // 查询表单部分显示/隐藏切换
382
+ toggleIsFormShow () {
383
+ this.isFormShow = !this.isFormShow
384
+ },
385
+ // 控制业务操作按钮组的显示
386
+ selectRow (rowKeys) {
387
+ this.selectedRowKeys = rowKeys
388
+ this.isModify = this.selectedRowKeys.length === 1
389
+ this.isDelete = this.selectedRowKeys.length > 0
390
+ },
391
+ // 创建临时表sql生成
392
+ createTempTable (defineJson) {
393
+ const tableName = defineJson.tableName
394
+ const define = defineJson.column
395
+ return post(ApplyInstallApi.createTempTable, {
396
+ define: define,
397
+ tableName: tableName
398
+ })
399
+ .then(
400
+ res => {
401
+ return res
402
+ },
403
+ err => {
404
+ console.log(err)
405
+ }
406
+ )
407
+ },
408
+ // 插入临时表数据sql生成
409
+ insertTempTableData (defineJson) {
410
+ const tableName = defineJson.tableName
411
+ const params = {}
412
+ params.define = defineJson.column
413
+ params.applyId = defineJson.applyId
414
+ params.stepName = defineJson.stepName
415
+ params.tableName = tableName
416
+ return post(ApplyInstallApi.insertDataToTempTable, {
417
+ tempTableData: params
418
+ })
419
+ .then(
420
+ res => {
421
+ return res
422
+ }
423
+ )
424
+ },
425
+ // 初始化临时表
426
+ async initTempTable (json) {
427
+ await this.createTempTable(this.queryParamsJson)
428
+ await this.insertTempTableData(this.queryParamsJson)
429
+ let result = {}
430
+ await post(ApplyInstallApi.initApplySubTable, {
431
+ define: json
432
+ })
433
+ .then(
434
+ res => {
435
+ console.log('子表临时表已创建')
436
+ result = res
437
+ }
438
+ )
439
+ return result
440
+ }
441
+ }
442
+ }
443
+ </script>
444
+ <style lang="less" scoped>
445
+ .btn-success {
446
+ color: #ffffff;
447
+ }
448
+ .btn-success:hover {
449
+ color: #ffffff !important;
450
+ }
451
+ .btn-success:focus {
452
+ color: #ffffff !important;
453
+ }
454
+ .btn-success:enabled:hover {
455
+ background-color: #85CE61 !important;
456
+ border-color: #85CE61 !important;
457
+ }
458
+ .btn-success:enabled {
459
+ background-color: #67c23a;
460
+ border-color: #67c23a;
461
+ }
462
+ .btn-success:disabled {
463
+ color: rgba(0, 0, 0, 0.25);
464
+ }
465
+ .btn-warn {
466
+ color: #ffffff;
467
+ }
468
+ .btn-warn:hover {
469
+ color: #ffffff !important;
470
+ }
471
+ .btn-warn:focus {
472
+ color: #ffffff !important;
473
+ }
474
+ .btn-warn:enabled:hover {
475
+ background-color: #ffc833 !important;
476
+ border-color: #ffc833 !important;
477
+ }
478
+ .btn-warn:enabled {
479
+ background-color: #ffba00;
480
+ border-color: #ffba00;
481
+ }
482
+ .btn-warn:disabled {
483
+ color: rgba(0, 0, 0, 0.25);
484
+ }
485
+ </style>