vue2-client 1.6.6 → 1.6.8

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