vue2-client 1.8.11 → 1.8.13

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,384 +1,347 @@
1
- <template>
2
- <div>
3
- <a-skeleton :loading="loading" :paragraph="{ rows: 4 }" />
4
- <div v-show="!loading">
5
- <template v-if="!loadError">
6
- <x-add-form
7
- ref="xAddForm"
8
- @afterSubmit="onAddOrEditSubmitAfterSubmit"
9
- />
10
- <x-form
11
- ref="xForm"
12
- style="margin-bottom: 14px;"
13
- @onSubmit="onSearchSubmit">
14
- <slot name="formBtnExpand"></slot>
15
- </x-form>
16
- <x-table
17
- ref="xTable"
18
- :fixedQueryForm="fixedQueryForm"
19
- :queryParamsName="queryParamsName"
20
- :query-params-json="queryParamsJson"
21
- :show-pagination="showPagination"
22
- @add="add"
23
- @edit="edit"
24
- @afterDelete="afterDelete"
25
- @action="action"
26
- @selectRow="selectRow"
27
- @afterQuery="afterQuery"
28
- @tempTableEdit="tempTableEdit">
29
- <template slot="leftButton" slot-scope="{selectedRowKeys, selectedRows}">
30
- <slot name="leftButton" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
31
- </template>
32
- <template slot="button" slot-scope="{selectedRowKeys, selectedRows}">
33
- <slot name="button" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
34
- </template>
35
- <template slot="rightBtnExpand" slot-scope="{selectedRowKeys, selectedRows}">
36
- <slot name="rightBtnExpand" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
37
- <a-button @click="toggleIsFormShow">
38
- <a-icon :style="iconStyle" type="vertical-align-top"/>
39
- </a-button>
40
- </template>
41
- <!-- 底部插槽 -->
42
- <template slot="footer" slot-scope="{selectedRowKeys, selectedRows}">
43
- <slot name="footer" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
44
- </template>
45
- </x-table>
46
- </template>
47
- <template v-else>
48
- <a-empty>
49
- <span slot="description"> 页面配置不存在,请联系系统管理员 </span>
50
- </a-empty>
51
- </template>
52
- </div>
53
- </div>
54
- </template>
55
- <script>
56
- import XForm from '@vue2-client/base-client/components/common/XForm'
57
- import XAddForm from '@vue2-client/base-client/components/common/XAddForm'
58
- import XTable from '@vue2-client/base-client/components/common/XTable'
59
- import XImportExcel from '@vue2-client/base-client/components/common/XImportExcel'
60
- import { getConfigByName, getConfigByLogic, parseConfig } from '@vue2-client/services/api/common'
61
- import { mapState } from 'vuex'
62
-
63
- export default {
64
- name: 'XFormTable',
65
- components: {
66
- XTable,
67
- XForm,
68
- XAddForm,
69
- XImportExcel
70
- },
71
- data () {
72
- return {
73
- // 加载状态
74
- loading: false,
75
- // 图标样式
76
- iconStyle: {
77
- position: 'relative',
78
- top: '1px'
79
- },
80
- loadError: false,
81
- // 实际查询配置内容
82
- realQueryConfig: {}
83
- }
84
- },
85
- computed: {
86
- ...mapState('setting', ['isMobile'])
87
- },
88
- props: {
89
- // 业务名称
90
- title: {
91
- type: String,
92
- default: ''
93
- },
94
- // 查询配置文件名
95
- queryParamsName: {
96
- type: String,
97
- default: null
98
- },
99
- // 配置所属命名空间
100
- serviceName: {
101
- type: String,
102
- default: undefined
103
- },
104
- // 查询配置文件Json,用于查询配置生成器的预览
105
- queryParamsJson: {
106
- type: Object,
107
- default: null
108
- },
109
- // 业务逻辑名称, 通过logic获取表单表格配置
110
- logicName: {
111
- type: String,
112
- default: null
113
- },
114
- // 执行logic传递的参数
115
- logicParam: {
116
- type: Object,
117
- default: () => {}
118
- },
119
- // 固定新增表单
120
- fixedAddForm: {
121
- type: Object,
122
- default: () => {
123
- return {}
124
- }
125
- },
126
- // 固定查询表单
127
- fixedQueryForm: {
128
- type: Object,
129
- default: () => {
130
- return {}
131
- }
132
- },
133
- // 预览模式
134
- viewMode: {
135
- type: Boolean,
136
- default: () => {
137
- return false
138
- }
139
- },
140
- // 数据只有一页时是否展示分页,true:展示,auto:隐藏
141
- showPagination: {
142
- type: Boolean,
143
- default: true
144
- },
145
- // 调用logic获取数据源的追加参数
146
- getDataParams: {
147
- type: Object,
148
- default: undefined
149
- }
150
- },
151
- watch: {
152
- logicParam: {
153
- handler () {
154
- this.initConfig()
155
- },
156
- deep: true
157
- },
158
- queryParamsJson: {
159
- handler () {
160
- this.initConfig()
161
- },
162
- deep: true
163
- },
164
- queryParamsName: {
165
- handler () {
166
- this.initConfig()
167
- }
168
- }
169
- },
170
- created () {
171
- this.initConfig()
172
- },
173
- methods: {
174
- initConfig () {
175
- this.loading = true
176
- this.loadError = false
177
- if (this.queryParamsName) {
178
- this.getConfig()
179
- } else if (this.queryParamsJson) {
180
- this.getConfigBySource()
181
- } else if (this.logicName && this.logicParam) {
182
- this.getColumnJsonByLogic()
183
- } else {
184
- this.loading = false
185
- this.loadError = true
186
- }
187
- },
188
- getConfig () {
189
- getConfigByName(this.queryParamsName, this.serviceName, (res) => {
190
- console.warn('getConfigBySource', res)
191
- this.updateComponents(res)
192
- })
193
- },
194
- getConfigBySource () {
195
- parseConfig(this.queryParamsJson, 'CRUD_FORM', this.serviceName).then(res => {
196
- this.updateComponents(res, true)
197
- })
198
- },
199
- getColumnJsonByLogic () {
200
- getConfigByLogic(this.logicName, this.logicParam, this.serviceName, (res) => {
201
- this.updateComponents(res, true)
202
- })
203
- },
204
- /**
205
- * 更新子组件
206
- * @param res 参数
207
- * @param setQueryParams 是否设置queryParams参数
208
- */
209
- updateComponents (res, setQueryParams) {
210
- this.realQueryConfig = res
211
- if (this.$refs.xTable && this.$refs.xForm && this.$refs.xAddForm) {
212
- this.$refs.xTable.init({
213
- queryParams: setQueryParams ? res : null,
214
- tableColumns: res.columnJson,
215
- buttonState: res.buttonState,
216
- title: this.title,
217
- viewMode: this.viewMode,
218
- isTableTemp: this.isTableTemp,
219
- serviceName: this.serviceName
220
- })
221
- this.$refs.xForm.init({
222
- formItems: res.formJson,
223
- serviceName: this.serviceName,
224
- getDataParams: this.getDataParams
225
- })
226
- }
227
- this.loading = false
228
- },
229
- /**
230
- * 提交查询表单事件
231
- * @param res 参数
232
- */
233
- onSearchSubmit (res) {
234
- if (res.valid) {
235
- // 表单赋值
236
- this.$refs.xTable.setQueryForm(res.form)
237
- // commit
238
- this.$emit('afterSearchSubmit', res)
239
- } else {
240
- return false
241
- }
242
- },
243
- active (props) {
244
- let num = false
245
- for (const key in props) {
246
- // eslint-disable-next-line no-prototype-builtins
247
- if (this.$props.hasOwnProperty(key)) {
248
- console.log('key', this.$props[key] instanceof Object)
249
- if (this.$props[key] instanceof Object) {
250
- this.$props[key] = JSON.parse(props[key])
251
- } else {
252
- this.$props[key] = props[key]
253
- }
254
- num = true
255
- }
256
- console.log(key, props[key])
257
- }
258
- console.warn('activeProps', this.$props)
259
- if (num) {
260
- this.initConfig()
261
- }
262
- },
263
- /**
264
- * 提交新增/修改表单后事件
265
- */
266
- onAddOrEditSubmitAfterSubmit (res) {
267
- this.refreshTable(res.businessType === '新增')
268
- // commit
269
- this.$emit('afterSubmit', res)
270
- },
271
- /**
272
- * 表格查询后事件
273
- * @param res 参数
274
- * @param conditionParams 查询条件
275
- */
276
- afterQuery (res, conditionParams) {
277
- this.$emit('afterQuery', res, conditionParams)
278
- },
279
- /**
280
- * 详情按钮事件
281
- * @param record 本条数据
282
- * @param id 数据标识
283
- * @param actionType 操作类型
284
- */
285
- action (record, id, actionType) {
286
- this.$emit('action', record, id, actionType)
287
- },
288
- /**
289
- * 新增按钮事件
290
- */
291
- add () {
292
- const res = this.realQueryConfig
293
- this.$refs.xAddForm.init({
294
- businessType: '新增',
295
- title: this.title,
296
- isShow: !res.buttonState || res.buttonState.add || res.buttonState.edit,
297
- configName: this.queryParamsName,
298
- configContent: this.queryParamsJson,
299
- formItems: res.formJson,
300
- viewMode: this.viewMode,
301
- isTableTemp: this.isTableTemp,
302
- serviceName: this.serviceName,
303
- fixedAddForm: this.fixedAddForm,
304
- getDataParams: this.getDataParams
305
- })
306
- },
307
- /**
308
- * 修改按钮事件
309
- * @param modifyModelData 修改表单数据
310
- */
311
- edit (modifyModelData) {
312
- const res = this.realQueryConfig
313
- this.$refs.xAddForm.init({
314
- businessType: '修改',
315
- title: this.title,
316
- isShow: !res.buttonState || res.buttonState.add || res.buttonState.edit,
317
- configName: this.queryParamsName,
318
- configContent: this.queryParamsJson,
319
- formItems: res.formJson,
320
- viewMode: this.viewMode,
321
- isTableTemp: this.isTableTemp,
322
- serviceName: this.serviceName,
323
- fixedAddForm: this.fixedAddForm,
324
- getDataParams: this.getDataParams,
325
- modifyModelData: modifyModelData
326
- })
327
- },
328
- /**
329
- * 删除后事件
330
- * @param res
331
- */
332
- afterDelete (res) {
333
- this.$emit('afterDelete', res)
334
- },
335
- /**
336
- * 查询表单部分显示/隐藏切换
337
- */
338
- toggleIsFormShow () {
339
- this.$refs.xForm.toggleVisible()
340
- },
341
- /**
342
- * 选择列事件
343
- * @param selectedRowKeys 选中列Key集合
344
- * @param selectedRows 选中列
345
- */
346
- selectRow (selectedRowKeys, selectedRows) {
347
- this.$emit('selectRow', selectedRowKeys, selectedRows)
348
- },
349
- /**
350
- * 临时表修改
351
- * @param res 参数
352
- */
353
- tempTableEdit (res) {
354
- this.$emit('tempTableEdit', res)
355
- },
356
- /**
357
- * 刷新表格
358
- * @param toFirstPage 是否到第一页
359
- */
360
- refreshTable (toFirstPage = true) {
361
- this.$refs.xTable.refresh(toFirstPage)
362
- },
363
- },
364
- action: {
365
- /**
366
- * 实现doAction方法
367
- */
368
- doAction (actionType, args, data) {
369
- switch (actionType) {
370
- case 'refreshTable':
371
- for (const item in args) {
372
- console.log('item', item)
373
- }
374
- break
375
- default:
376
- break
377
- }
378
- }
379
- }
380
- }
381
- </script>
382
- <style lang="less" scoped>
383
-
384
- </style>
1
+ <template>
2
+ <div>
3
+ <a-skeleton :loading="loading" :paragraph="{ rows: 4 }" />
4
+ <div v-show="!loading">
5
+ <template v-if="!loadError">
6
+ <x-add-form
7
+ ref="xAddForm"
8
+ @afterSubmit="onAddOrEditSubmitAfterSubmit"
9
+ />
10
+ <x-form
11
+ ref="xForm"
12
+ style="margin-bottom: 14px;"
13
+ @onSubmit="onSearchSubmit">
14
+ <slot name="formBtnExpand"></slot>
15
+ </x-form>
16
+ <x-table
17
+ ref="xTable"
18
+ :fixedQueryForm="fixedQueryForm"
19
+ :queryParamsName="queryParamsName"
20
+ :query-params-json="queryParamsJson"
21
+ :show-pagination="showPagination"
22
+ @add="add"
23
+ @edit="edit"
24
+ @afterDelete="afterDelete"
25
+ @action="action"
26
+ @selectRow="selectRow"
27
+ @afterQuery="afterQuery"
28
+ @tempTableEdit="tempTableEdit">
29
+ <template slot="leftButton" slot-scope="{selectedRowKeys, selectedRows}">
30
+ <slot name="leftButton" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
31
+ </template>
32
+ <template slot="button" slot-scope="{selectedRowKeys, selectedRows}">
33
+ <slot name="button" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
34
+ </template>
35
+ <template slot="rightBtnExpand" slot-scope="{selectedRowKeys, selectedRows}">
36
+ <slot name="rightBtnExpand" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
37
+ <a-button @click="toggleIsFormShow">
38
+ <a-icon :style="iconStyle" type="vertical-align-top"/>
39
+ </a-button>
40
+ </template>
41
+ <!-- 底部插槽 -->
42
+ <template slot="footer" slot-scope="{selectedRowKeys, selectedRows}">
43
+ <slot name="footer" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
44
+ </template>
45
+ </x-table>
46
+ </template>
47
+ <template v-else>
48
+ <a-empty>
49
+ <span slot="description"> 页面配置不存在,请联系系统管理员 </span>
50
+ </a-empty>
51
+ </template>
52
+ </div>
53
+ </div>
54
+ </template>
55
+ <script>
56
+ import XForm from '@vue2-client/base-client/components/common/XForm'
57
+ import XAddForm from '@vue2-client/base-client/components/common/XAddForm'
58
+ import XTable from '@vue2-client/base-client/components/common/XTable'
59
+ import XImportExcel from '@vue2-client/base-client/components/common/XImportExcel'
60
+ import { getConfigByName, getConfigByLogic, parseConfig } from '@vue2-client/services/api/common'
61
+ import { mapState } from 'vuex'
62
+
63
+ export default {
64
+ name: 'XFormTable',
65
+ components: {
66
+ XTable,
67
+ XForm,
68
+ XAddForm,
69
+ XImportExcel
70
+ },
71
+ data () {
72
+ return {
73
+ // 加载状态
74
+ loading: false,
75
+ // 图标样式
76
+ iconStyle: {
77
+ position: 'relative',
78
+ top: '1px'
79
+ },
80
+ loadError: false,
81
+ // 实际查询配置内容
82
+ realQueryConfig: {}
83
+ }
84
+ },
85
+ computed: {
86
+ ...mapState('setting', ['isMobile'])
87
+ },
88
+ props: {
89
+ // 业务名称
90
+ title: {
91
+ type: String,
92
+ default: ''
93
+ },
94
+ // 查询配置文件名
95
+ queryParamsName: {
96
+ type: String,
97
+ default: null
98
+ },
99
+ // 配置所属命名空间
100
+ serviceName: {
101
+ type: String,
102
+ default: undefined
103
+ },
104
+ // 查询配置文件Json,用于查询配置生成器的预览
105
+ queryParamsJson: {
106
+ type: Object,
107
+ default: null
108
+ },
109
+ // 业务逻辑名称, 通过logic获取表单表格配置
110
+ logicName: {
111
+ type: String,
112
+ default: null
113
+ },
114
+ // 执行logic传递的参数
115
+ logicParam: {
116
+ type: Object,
117
+ default: () => {}
118
+ },
119
+ // 固定新增表单
120
+ fixedAddForm: {
121
+ type: Object,
122
+ default: () => {
123
+ return {}
124
+ }
125
+ },
126
+ // 固定查询表单
127
+ fixedQueryForm: {
128
+ type: Object,
129
+ default: () => {
130
+ return {}
131
+ }
132
+ },
133
+ // 预览模式
134
+ viewMode: {
135
+ type: Boolean,
136
+ default: () => {
137
+ return false
138
+ }
139
+ },
140
+ // 数据只有一页时是否展示分页,true:展示,auto:隐藏
141
+ showPagination: {
142
+ type: Boolean,
143
+ default: true
144
+ },
145
+ // 调用logic获取数据源的追加参数
146
+ getDataParams: {
147
+ type: Object,
148
+ default: undefined
149
+ }
150
+ },
151
+ watch: {
152
+ logicParam: {
153
+ handler () {
154
+ this.initConfig()
155
+ },
156
+ deep: true
157
+ },
158
+ queryParamsJson: {
159
+ handler () {
160
+ this.initConfig()
161
+ },
162
+ deep: true
163
+ },
164
+ queryParamsName: {
165
+ handler () {
166
+ this.initConfig()
167
+ }
168
+ }
169
+ },
170
+ created () {
171
+ this.initConfig()
172
+ },
173
+ methods: {
174
+ initConfig () {
175
+ this.loading = true
176
+ this.loadError = false
177
+ if (this.queryParamsName) {
178
+ this.getConfig()
179
+ } else if (this.queryParamsJson) {
180
+ this.getConfigBySource()
181
+ } else if (this.logicName && this.logicParam) {
182
+ this.getColumnJsonByLogic()
183
+ } else {
184
+ this.loading = false
185
+ this.loadError = true
186
+ }
187
+ },
188
+ getConfig () {
189
+ getConfigByName(this.queryParamsName, this.serviceName, (res) => {
190
+ this.updateComponents(res)
191
+ })
192
+ },
193
+ getConfigBySource () {
194
+ parseConfig(this.queryParamsJson, 'CRUD_FORM', this.serviceName).then(res => {
195
+ this.updateComponents(res, true)
196
+ })
197
+ },
198
+ getColumnJsonByLogic () {
199
+ getConfigByLogic(this.logicName, this.logicParam, this.serviceName, (res) => {
200
+ this.updateComponents(res, true)
201
+ })
202
+ },
203
+ /**
204
+ * 更新子组件
205
+ * @param res 参数
206
+ * @param setQueryParams 是否设置queryParams参数
207
+ */
208
+ updateComponents (res, setQueryParams) {
209
+ this.realQueryConfig = res
210
+ if (this.$refs.xTable && this.$refs.xForm && this.$refs.xAddForm) {
211
+ this.$refs.xTable.init({
212
+ queryParams: setQueryParams ? res : null,
213
+ tableColumns: res.columnJson,
214
+ buttonState: res.buttonState,
215
+ title: this.title,
216
+ viewMode: this.viewMode,
217
+ isTableTemp: this.isTableTemp,
218
+ serviceName: this.serviceName
219
+ })
220
+ this.$refs.xForm.init({
221
+ formItems: res.formJson,
222
+ serviceName: this.serviceName,
223
+ getDataParams: this.getDataParams
224
+ })
225
+ }
226
+ this.loading = false
227
+ },
228
+ /**
229
+ * 提交查询表单事件
230
+ * @param res 参数
231
+ */
232
+ onSearchSubmit (res) {
233
+ if (res.valid) {
234
+ // 表单赋值
235
+ this.$refs.xTable.setQueryForm(res.form)
236
+ // commit
237
+ this.$emit('afterSearchSubmit', res)
238
+ } else {
239
+ return false
240
+ }
241
+ },
242
+ /**
243
+ * 提交新增/修改表单后事件
244
+ */
245
+ onAddOrEditSubmitAfterSubmit (res) {
246
+ this.refreshTable(res.businessType === '新增')
247
+ // commit
248
+ this.$emit('afterSubmit', res)
249
+ },
250
+ /**
251
+ * 表格查询后事件
252
+ * @param res 参数
253
+ * @param conditionParams 查询条件
254
+ */
255
+ afterQuery (res, conditionParams) {
256
+ this.$emit('afterQuery', res, conditionParams)
257
+ },
258
+ /**
259
+ * 详情按钮事件
260
+ * @param record 本条数据
261
+ * @param id 数据标识
262
+ * @param actionType 操作类型
263
+ */
264
+ action (record, id, actionType) {
265
+ this.$emit('action', record, id, actionType)
266
+ },
267
+ /**
268
+ * 新增按钮事件
269
+ */
270
+ add () {
271
+ const res = this.realQueryConfig
272
+ this.$refs.xAddForm.init({
273
+ businessType: '新增',
274
+ title: this.title,
275
+ isShow: !res.buttonState || res.buttonState.add || res.buttonState.edit,
276
+ configName: this.queryParamsName,
277
+ configContent: this.queryParamsJson,
278
+ formItems: res.formJson,
279
+ viewMode: this.viewMode,
280
+ isTableTemp: this.isTableTemp,
281
+ serviceName: this.serviceName,
282
+ fixedAddForm: this.fixedAddForm,
283
+ getDataParams: this.getDataParams
284
+ })
285
+ },
286
+ /**
287
+ * 修改按钮事件
288
+ * @param modifyModelData 修改表单数据
289
+ */
290
+ edit (modifyModelData) {
291
+ const res = this.realQueryConfig
292
+ this.$refs.xAddForm.init({
293
+ businessType: '修改',
294
+ title: this.title,
295
+ isShow: !res.buttonState || res.buttonState.add || res.buttonState.edit,
296
+ configName: this.queryParamsName,
297
+ configContent: this.queryParamsJson,
298
+ formItems: res.formJson,
299
+ viewMode: this.viewMode,
300
+ isTableTemp: this.isTableTemp,
301
+ serviceName: this.serviceName,
302
+ fixedAddForm: this.fixedAddForm,
303
+ getDataParams: this.getDataParams,
304
+ modifyModelData: modifyModelData
305
+ })
306
+ },
307
+ /**
308
+ * 删除后事件
309
+ * @param res
310
+ */
311
+ afterDelete (res) {
312
+ this.$emit('afterDelete', res)
313
+ },
314
+ /**
315
+ * 查询表单部分显示/隐藏切换
316
+ */
317
+ toggleIsFormShow () {
318
+ this.$refs.xForm.toggleVisible()
319
+ },
320
+ /**
321
+ * 选择列事件
322
+ * @param selectedRowKeys 选中列Key集合
323
+ * @param selectedRows 选中列
324
+ */
325
+ selectRow (selectedRowKeys, selectedRows) {
326
+ this.$emit('selectRow', selectedRowKeys, selectedRows)
327
+ },
328
+ /**
329
+ * 临时表修改
330
+ * @param res 参数
331
+ */
332
+ tempTableEdit (res) {
333
+ this.$emit('tempTableEdit', res)
334
+ },
335
+ /**
336
+ * 刷新表格
337
+ * @param toFirstPage 是否到第一页
338
+ */
339
+ refreshTable (toFirstPage = true) {
340
+ this.$refs.xTable.refresh(toFirstPage)
341
+ }
342
+ }
343
+ }
344
+ </script>
345
+ <style lang="less" scoped>
346
+
347
+ </style>