vue2-client 1.2.0 → 1.2.1

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.
Files changed (120) hide show
  1. package/README.md +65 -65
  2. package/babel.config.js +1 -0
  3. package/docs/notice.md +24 -0
  4. package/index.js +28 -28
  5. package/package.json +1 -1
  6. package/src/App.vue +93 -93
  7. package/src/base-client/all.js +57 -57
  8. package/src/base-client/components/common/CreateQuery/CreateQuery.vue +1159 -1159
  9. package/src/base-client/components/common/CreateQuery/index.md +42 -42
  10. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQuery.vue +540 -540
  11. package/src/base-client/components/common/CreateSimpleFormQuery/index.md +42 -42
  12. package/src/base-client/components/common/CustomColumnsDrawer/index.md +46 -46
  13. package/src/base-client/components/common/FormGroupEdit/FormGroupEdit.vue +150 -150
  14. package/src/base-client/components/common/FormGroupEdit/index.md +43 -43
  15. package/src/base-client/components/common/FormGroupQuery/index.md +43 -43
  16. package/src/base-client/components/common/XAddForm/XAddForm.vue +323 -323
  17. package/src/base-client/components/common/XAddForm/index.md +60 -60
  18. package/src/base-client/components/common/XBadge/index.md +39 -39
  19. package/src/base-client/components/common/XCard/index.md +43 -43
  20. package/src/base-client/components/common/XForm/XForm.vue +275 -275
  21. package/src/base-client/components/common/XForm/XFormItem.vue +217 -217
  22. package/src/base-client/components/common/XForm/index.md +196 -196
  23. package/src/base-client/components/common/XFormCol/index.md +35 -35
  24. package/src/base-client/components/common/XFormTable/XFormTable.vue +405 -405
  25. package/src/base-client/components/common/XFormTable/index.md +89 -89
  26. package/src/base-client/components/common/XTable/XTable.vue +262 -262
  27. package/src/base-client/components/common/XTable/index.md +255 -255
  28. package/src/base-client/components/common/XTreeOne/XTreeOne.vue +105 -105
  29. package/src/base-client/components/iot/CustomerDetailsView/CustomerDetailsView.vue +226 -226
  30. package/src/base-client/components/iot/CustomerDetailsView/index.md +41 -41
  31. package/src/base-client/components/iot/DataAnalysisUser/DataAnalysisUser.vue +127 -127
  32. package/src/base-client/components/iot/DataAnalysisViewGD/DataAnalysisViewGD.vue +548 -548
  33. package/src/base-client/components/iot/DeviceBrandDetailsView/DeviceBrandDetailsView.vue +453 -453
  34. package/src/base-client/components/iot/DeviceDetailsView/DeviceDetailsView.vue +231 -231
  35. package/src/base-client/components/iot/DeviceDetailsView/index.md +43 -43
  36. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsCount.vue +330 -330
  37. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsException.vue +57 -57
  38. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsInstruct.vue +122 -122
  39. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsInstructOperate.vue +122 -122
  40. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsMain.vue +225 -225
  41. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsRead.vue +135 -135
  42. package/src/base-client/components/iot/DeviceTypeDetailsView/DeviceTypeDetailsView.vue +277 -277
  43. package/src/base-client/components/iot/InstructDetailsView/InstructDetailsView.vue +472 -472
  44. package/src/base-client/components/iot/InstructDetailsView/index.md +45 -45
  45. package/src/base-client/components/iot/LogDetailsView/LogDetailsView.vue +380 -380
  46. package/src/base-client/components/iot/LogDetailsView/index.md +43 -43
  47. package/src/base-client/components/iot/MeterDetailsView/MeterDetailsView.vue +360 -360
  48. package/src/base-client/components/iot/MeterDetailsView/index.md +43 -43
  49. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsCount.vue +335 -335
  50. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsException.vue +185 -185
  51. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsHandPlan.vue +292 -292
  52. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsInstruct.vue +237 -237
  53. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsMain.vue +257 -257
  54. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsSellGas.vue +190 -190
  55. package/src/base-client/components/iot/WebmeterAnalysisView/WebmeterAnalysisView.vue +723 -723
  56. package/src/base-client/components/iot/WebmeterAnalysisView/index.md +48 -48
  57. package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +232 -232
  58. package/src/base-client/components/system/DictionaryDetailsView/index.md +41 -41
  59. package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +248 -248
  60. package/src/base-client/components/ticket/EmployeeDetailsView/EmployeeDetailsView.vue +406 -406
  61. package/src/base-client/components/ticket/TicketDetailsView/TicketDetailsView.vue +486 -486
  62. package/src/base-client/components/ticket/TicketDetailsView/part/TicketDetailsFlow.vue +184 -184
  63. package/src/base-client/components/ticket/TicketSubmitSuccessView/TicketSubmitSuccessView.vue +303 -303
  64. package/src/base-client/plugins/AppData.js +69 -69
  65. package/src/base-client/plugins/GetLoginInfoService.js +221 -221
  66. package/src/base-client/plugins/index.js +21 -21
  67. package/src/bootstrap.js +27 -27
  68. package/src/components/Ellipsis/Ellipsis.vue +64 -64
  69. package/src/components/Ellipsis/index.md +38 -38
  70. package/src/components/NumberInfo/index.md +43 -43
  71. package/src/components/STable/README.md +341 -341
  72. package/src/components/Trend/index.md +45 -45
  73. package/src/components/cache/AKeepAlive.js +172 -172
  74. package/src/components/checkbox/index.js +7 -7
  75. package/src/components/index.js +36 -36
  76. package/src/components/menu/menu.js +273 -273
  77. package/src/components/setting/Setting.vue +237 -237
  78. package/src/components/table/advance/AdvanceTable.vue +275 -275
  79. package/src/components/transition/PageToggleTransition.vue +97 -97
  80. package/src/layouts/CommonLayout.vue +42 -42
  81. package/src/layouts/PageLayout.vue +151 -151
  82. package/src/layouts/SinglePageView.vue +74 -74
  83. package/src/layouts/header/AdminHeader.vue +109 -109
  84. package/src/layouts/header/HeaderAvatar.vue +60 -60
  85. package/src/layouts/header/HeaderNotice.vue +97 -97
  86. package/src/layouts/tabs/TabsHead.vue +190 -190
  87. package/src/layouts/tabs/TabsView.vue +355 -355
  88. package/src/main.js +20 -20
  89. package/src/mock/goods/index.js +108 -108
  90. package/src/mock/index.js +12 -12
  91. package/src/mock/project/index.js +17 -17
  92. package/src/mock/user/current.js +13 -13
  93. package/src/mock/user/login.js +39 -39
  94. package/src/mock/workplace/index.js +15 -15
  95. package/src/pages/exception/403.vue +25 -25
  96. package/src/pages/exception/404.vue +25 -25
  97. package/src/pages/exception/500.vue +25 -25
  98. package/src/pages/login/Login.vue +194 -194
  99. package/src/pages/report/ReportTableHome.vue +28 -28
  100. package/src/pages/resourceManage/resourceManageMain.vue +55 -55
  101. package/src/pages/system/applyInstallView/Core.vue +570 -570
  102. package/src/pages/system/applyInstallView/index.vue +34 -34
  103. package/src/pages/system/dictionary/index.vue +41 -41
  104. package/src/pages/system/queryParams/index.vue +41 -41
  105. package/src/router/async/config.async.js +25 -25
  106. package/src/router/async/router.map.js +59 -59
  107. package/src/router/guards.js +104 -104
  108. package/src/router/index.js +27 -27
  109. package/src/services/api/common.js +39 -39
  110. package/src/services/api/restTools.js +23 -23
  111. package/src/services/dataSource.js +12 -12
  112. package/src/services/user.js +34 -34
  113. package/src/store/modules/setting.js +114 -114
  114. package/src/utils/i18n.js +80 -80
  115. package/src/utils/indexedDB.js +146 -146
  116. package/src/utils/request.js +197 -197
  117. package/src/utils/routerUtil.js +15 -2
  118. package/tests/unit/ReportTable.spec.js +15 -15
  119. package/vue.config.js +153 -153
  120. package/webpack.config.js +12 -12
@@ -1,405 +1,405 @@
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
-
66
- export default {
67
- name: 'XFormTable',
68
- components: {
69
- XTable,
70
- XForm,
71
- XAddForm
72
- },
73
- data () {
74
- return {
75
- // Query参数文件内容加载中
76
- mainLoading: false,
77
- // Query参数文件内容加载完成
78
- loaded: false,
79
- // 是否展示表单
80
- isFormShow: true,
81
- // 当使用logic获取到表单表格配置时, 将配置对象直接传入到x-table用于查询
82
- queryParams: null,
83
- // 表格列集合
84
- tableColumns: [],
85
- // 操作按钮集合
86
- buttonState: {},
87
- // 表格选择列Key集合
88
- selectedRowKeys: [],
89
- // 表单项集合
90
- formItems: [],
91
- // 表单
92
- form: {},
93
- // 图标样式
94
- iconStyle: {
95
- position: 'relative',
96
- top: '1px'
97
- },
98
- // 当前业务类型:新增,修改
99
- businessType: '',
100
- // 是否显示新增/修改模态框
101
- modelVisible: false,
102
- // 修改业务时查询的单条业务数据
103
- modifyModelData: {},
104
- // 是否允许修改
105
- isModify: false,
106
- // 是否允许删除
107
- isDelete: false,
108
- // 新增,修改业务执行状态
109
- loading: false,
110
- // 被修改数据加载状态
111
- editDataLoading: false
112
- }
113
- },
114
- computed: {
115
- ...mapState('setting', ['isMobile']),
116
- businessTitle () {
117
- return this.businessType + this.title
118
- }
119
- },
120
- props: {
121
- // 业务名称
122
- title: {
123
- type: String,
124
- default: ''
125
- },
126
- // 查询配置文件名
127
- queryParamsName: {
128
- type: String,
129
- default: null
130
- },
131
- // 查询配置文件Json,用于查询配置生成器的预览
132
- queryParamsJson: {
133
- type: Object,
134
- default: null
135
- },
136
- // 业务逻辑名称, 通过logic获取表单表格配置
137
- logicName: {
138
- type: String,
139
- default: null
140
- },
141
- // 执行logic传递的参数
142
- logicParam: {
143
- type: Object,
144
- default: () => {}
145
- },
146
- // 固定新增表单
147
- fixedAddForm: {
148
- type: Object,
149
- default: () => {
150
- return {}
151
- }
152
- },
153
- // 固定查询表单
154
- fixedQueryForm: {
155
- type: Object,
156
- default: () => {
157
- return {}
158
- }
159
- },
160
- // 预览模式
161
- viewMode: {
162
- type: Boolean,
163
- default: () => {
164
- return false
165
- }
166
- }
167
- },
168
- watch: {
169
- logicParam: {
170
- handler () {
171
- this.mainLoading = true
172
- this.form = {}
173
- indexedDB.getByWeb(`${this.logicName}_${JSON.stringify(this.logicParam)}`, commonApi.getColumnsJson, { logic: this.logicName, logicParam: this.logicParam }, (ret) => {
174
- this.queryParams = ret
175
- this.tableColumns = ret.columnJson
176
- this.formItems = ret.formJson
177
- this.mainLoading = false
178
- this.loaded = true
179
- })
180
- },
181
- deep: true
182
- },
183
- fixedQueryForm: {
184
- handler () {
185
- this.mainLoading = true
186
- this.form = {}
187
- indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
188
- this.tableColumns = ret.columnJson
189
- this.formItems = ret.formJson
190
- this.buttonState = ret.buttonState
191
- this.mainLoading = false
192
- this.loaded = true
193
- })
194
- },
195
- deep: true
196
- },
197
- queryParamsJson: {
198
- handler () {
199
- this.getColumnsJsonBySource()
200
- },
201
- deep: true
202
- }
203
- },
204
- created () {
205
- if (this.queryParamsName) {
206
- this.getColumnsJson()
207
- } else if (this.queryParamsJson) {
208
- this.getColumnsJsonBySource()
209
- }
210
- },
211
- methods: {
212
- getColumnsJsonBySource () {
213
- this.mainLoading = true
214
- post(commonApi.getColumnsJson, { queryObject: this.queryParamsJson }).then(res => {
215
- this.queryParams = res
216
- this.tableColumns = this.queryParams.columnJson
217
- this.formItems = this.queryParams.formJson
218
- this.buttonState = this.queryParams.buttonState
219
- this.mainLoading = false
220
- this.loaded = true
221
- })
222
- },
223
- getColumnsJson () {
224
- this.mainLoading = true
225
- indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
226
- this.tableColumns = ret.columnJson
227
- this.formItems = ret.formJson
228
- this.buttonState = ret.buttonState
229
- this.mainLoading = false
230
- this.loaded = true
231
- })
232
- },
233
- // 查询表单提交
234
- onSubmit (res) {
235
- if (res.valid) {
236
- // 设置当前燃气公司
237
- this.$emit('update:selectOrgName', res.form.orgName)
238
- // 表单赋值
239
- this.form = res.form
240
- // commit
241
- this.$emit('afterSearchSubmit', res)
242
- } else {
243
- return false
244
- }
245
- },
246
- // 新增/修改数据表单提交
247
- onAddOrModify (res) {
248
- if (this.viewMode) {
249
- this.$message.info('预览模式禁止新增')
250
- return false
251
- }
252
- if (res.valid) {
253
- this.loading = true
254
- const requestParameters = {
255
- queryParamsName: this.queryParamsName,
256
- form: {}
257
- }
258
- if (this.businessType === '修改') {
259
- const rowKeyValue = this.selectedRowKeys[0]
260
- const key = this.tableColumns[0].dataIndex
261
- const realKey = key.substring(key.indexOf('_') + 1)
262
- requestParameters.form[realKey] = rowKeyValue
263
- }
264
- for (const key of Object.keys(res.form)) {
265
- const realKey = key.substring(key.indexOf('_') + 1)
266
- requestParameters.form[realKey] = res.form[key]
267
- }
268
- addOrModify(requestParameters).then(res => {
269
- this.$message.success(this.businessType + '成功!')
270
- this.loading = false
271
- this.modelVisible = false
272
- this.$refs.xTable.refresh(true)
273
- // commit
274
- this.$emit('afterSubmit', res)
275
- }).catch(e => {
276
- this.loading = false
277
- this.modelVisible = false
278
- this.$message.error(this.businessType + '失败!')
279
- })
280
- } else {
281
- return false
282
- }
283
- },
284
- // 刷新加载表格数据
285
- loadData (requestParameters, callback) {
286
- callback(query(requestParameters))
287
- },
288
- // 详情按钮事件
289
- action (record, id) {
290
- this.$emit('action', record, id)
291
- },
292
- // 新增业务
293
- addItem () {
294
- this.businessType = '新增'
295
- this.modifyModelData = {}
296
- this.modelVisible = true
297
- },
298
- // 修改业务
299
- editItem () {
300
- this.businessType = '修改'
301
- if (!this.viewMode) {
302
- const requestParameters = {
303
- queryParamsName: this.queryParamsName,
304
- conditionParams: {},
305
- pageNo: 1,
306
- pageSize: 1
307
- }
308
- requestParameters.conditionParams[this.tableColumns[0].dataIndex] = this.selectedRowKeys[0]
309
- this.editDataLoading = true
310
- query(requestParameters).then(res => {
311
- this.modifyModelData = res.data[0]
312
- this.modelVisible = true
313
- this.editDataLoading = false
314
- })
315
- } else {
316
- this.$message.info('预览模式禁止修改')
317
- }
318
- },
319
- // 删除业务
320
- deleteItem () {
321
- if (this.viewMode) {
322
- this.$message.info('预览模式禁止删除')
323
- return
324
- }
325
- Modal.confirm({
326
- title: '提示',
327
- content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
328
- confirmLoading: this.loading,
329
- zIndex: 1001,
330
- onOk: () => {
331
- this.loading = true
332
- const requestParameters = {
333
- queryParamsName: this.queryParamsName,
334
- idList: this.selectedRowKeys
335
- }
336
- remove(requestParameters).then(res => {
337
- this.loading = false
338
- this.$message.success('删除成功!')
339
- this.$refs.xTable.clearRowKeys()
340
- this.$refs.xTable.refresh(true)
341
- // commit
342
- this.$emit('afterSubmit', res)
343
- }).catch(e => {
344
- this.loading = false
345
- this.$message.error('删除失败!')
346
- })
347
- },
348
- onCancel () {}
349
- })
350
- },
351
- // 查询表单部分显示/隐藏切换
352
- toggleIsFormShow () {
353
- this.isFormShow = !this.isFormShow
354
- },
355
- // 控制业务操作按钮组的显示
356
- selectRow (rowKeys) {
357
- this.selectedRowKeys = rowKeys
358
- this.isModify = this.selectedRowKeys.length === 1
359
- this.isDelete = this.selectedRowKeys.length > 0
360
- }
361
- }
362
- }
363
- </script>
364
- <style lang="less" scoped>
365
- .btn-success {
366
- color: #ffffff;
367
- }
368
- .btn-success:hover {
369
- color: #ffffff !important;
370
- }
371
- .btn-success:focus {
372
- color: #ffffff !important;
373
- }
374
- .btn-success:enabled:hover {
375
- background-color: #85CE61 !important;
376
- border-color: #85CE61 !important;
377
- }
378
- .btn-success:enabled {
379
- background-color: #67c23a;
380
- border-color: #67c23a;
381
- }
382
- .btn-success:disabled {
383
- color: rgba(0, 0, 0, 0.25);
384
- }
385
- .btn-warn {
386
- color: #ffffff;
387
- }
388
- .btn-warn:hover {
389
- color: #ffffff !important;
390
- }
391
- .btn-warn:focus {
392
- color: #ffffff !important;
393
- }
394
- .btn-warn:enabled:hover {
395
- background-color: #ffc833 !important;
396
- border-color: #ffc833 !important;
397
- }
398
- .btn-warn:enabled {
399
- background-color: #ffba00;
400
- border-color: #ffba00;
401
- }
402
- .btn-warn:disabled {
403
- color: rgba(0, 0, 0, 0.25);
404
- }
405
- </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
+
66
+ export default {
67
+ name: 'XFormTable',
68
+ components: {
69
+ XTable,
70
+ XForm,
71
+ XAddForm
72
+ },
73
+ data () {
74
+ return {
75
+ // Query参数文件内容加载中
76
+ mainLoading: false,
77
+ // Query参数文件内容加载完成
78
+ loaded: false,
79
+ // 是否展示表单
80
+ isFormShow: true,
81
+ // 当使用logic获取到表单表格配置时, 将配置对象直接传入到x-table用于查询
82
+ queryParams: null,
83
+ // 表格列集合
84
+ tableColumns: [],
85
+ // 操作按钮集合
86
+ buttonState: {},
87
+ // 表格选择列Key集合
88
+ selectedRowKeys: [],
89
+ // 表单项集合
90
+ formItems: [],
91
+ // 表单
92
+ form: {},
93
+ // 图标样式
94
+ iconStyle: {
95
+ position: 'relative',
96
+ top: '1px'
97
+ },
98
+ // 当前业务类型:新增,修改
99
+ businessType: '',
100
+ // 是否显示新增/修改模态框
101
+ modelVisible: false,
102
+ // 修改业务时查询的单条业务数据
103
+ modifyModelData: {},
104
+ // 是否允许修改
105
+ isModify: false,
106
+ // 是否允许删除
107
+ isDelete: false,
108
+ // 新增,修改业务执行状态
109
+ loading: false,
110
+ // 被修改数据加载状态
111
+ editDataLoading: false
112
+ }
113
+ },
114
+ computed: {
115
+ ...mapState('setting', ['isMobile']),
116
+ businessTitle () {
117
+ return this.businessType + this.title
118
+ }
119
+ },
120
+ props: {
121
+ // 业务名称
122
+ title: {
123
+ type: String,
124
+ default: ''
125
+ },
126
+ // 查询配置文件名
127
+ queryParamsName: {
128
+ type: String,
129
+ default: null
130
+ },
131
+ // 查询配置文件Json,用于查询配置生成器的预览
132
+ queryParamsJson: {
133
+ type: Object,
134
+ default: null
135
+ },
136
+ // 业务逻辑名称, 通过logic获取表单表格配置
137
+ logicName: {
138
+ type: String,
139
+ default: null
140
+ },
141
+ // 执行logic传递的参数
142
+ logicParam: {
143
+ type: Object,
144
+ default: () => {}
145
+ },
146
+ // 固定新增表单
147
+ fixedAddForm: {
148
+ type: Object,
149
+ default: () => {
150
+ return {}
151
+ }
152
+ },
153
+ // 固定查询表单
154
+ fixedQueryForm: {
155
+ type: Object,
156
+ default: () => {
157
+ return {}
158
+ }
159
+ },
160
+ // 预览模式
161
+ viewMode: {
162
+ type: Boolean,
163
+ default: () => {
164
+ return false
165
+ }
166
+ }
167
+ },
168
+ watch: {
169
+ logicParam: {
170
+ handler () {
171
+ this.mainLoading = true
172
+ this.form = {}
173
+ indexedDB.getByWeb(`${this.logicName}_${JSON.stringify(this.logicParam)}`, commonApi.getColumnsJson, { logic: this.logicName, logicParam: this.logicParam }, (ret) => {
174
+ this.queryParams = ret
175
+ this.tableColumns = ret.columnJson
176
+ this.formItems = ret.formJson
177
+ this.mainLoading = false
178
+ this.loaded = true
179
+ })
180
+ },
181
+ deep: true
182
+ },
183
+ fixedQueryForm: {
184
+ handler () {
185
+ this.mainLoading = true
186
+ this.form = {}
187
+ indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
188
+ this.tableColumns = ret.columnJson
189
+ this.formItems = ret.formJson
190
+ this.buttonState = ret.buttonState
191
+ this.mainLoading = false
192
+ this.loaded = true
193
+ })
194
+ },
195
+ deep: true
196
+ },
197
+ queryParamsJson: {
198
+ handler () {
199
+ this.getColumnsJsonBySource()
200
+ },
201
+ deep: true
202
+ }
203
+ },
204
+ created () {
205
+ if (this.queryParamsName) {
206
+ this.getColumnsJson()
207
+ } else if (this.queryParamsJson) {
208
+ this.getColumnsJsonBySource()
209
+ }
210
+ },
211
+ methods: {
212
+ getColumnsJsonBySource () {
213
+ this.mainLoading = true
214
+ post(commonApi.getColumnsJson, { queryObject: this.queryParamsJson }).then(res => {
215
+ this.queryParams = res
216
+ this.tableColumns = this.queryParams.columnJson
217
+ this.formItems = this.queryParams.formJson
218
+ this.buttonState = this.queryParams.buttonState
219
+ this.mainLoading = false
220
+ this.loaded = true
221
+ })
222
+ },
223
+ getColumnsJson () {
224
+ this.mainLoading = true
225
+ indexedDB.getByWeb(this.queryParamsName, commonApi.getColumnsJson, { str: this.queryParamsName }, (ret) => {
226
+ this.tableColumns = ret.columnJson
227
+ this.formItems = ret.formJson
228
+ this.buttonState = ret.buttonState
229
+ this.mainLoading = false
230
+ this.loaded = true
231
+ })
232
+ },
233
+ // 查询表单提交
234
+ onSubmit (res) {
235
+ if (res.valid) {
236
+ // 设置当前燃气公司
237
+ this.$emit('update:selectOrgName', res.form.orgName)
238
+ // 表单赋值
239
+ this.form = res.form
240
+ // commit
241
+ this.$emit('afterSearchSubmit', res)
242
+ } else {
243
+ return false
244
+ }
245
+ },
246
+ // 新增/修改数据表单提交
247
+ onAddOrModify (res) {
248
+ if (this.viewMode) {
249
+ this.$message.info('预览模式禁止新增')
250
+ return false
251
+ }
252
+ if (res.valid) {
253
+ this.loading = true
254
+ const requestParameters = {
255
+ queryParamsName: this.queryParamsName,
256
+ form: {}
257
+ }
258
+ if (this.businessType === '修改') {
259
+ const rowKeyValue = this.selectedRowKeys[0]
260
+ const key = this.tableColumns[0].dataIndex
261
+ const realKey = key.substring(key.indexOf('_') + 1)
262
+ requestParameters.form[realKey] = rowKeyValue
263
+ }
264
+ for (const key of Object.keys(res.form)) {
265
+ const realKey = key.substring(key.indexOf('_') + 1)
266
+ requestParameters.form[realKey] = res.form[key]
267
+ }
268
+ addOrModify(requestParameters).then(res => {
269
+ this.$message.success(this.businessType + '成功!')
270
+ this.loading = false
271
+ this.modelVisible = false
272
+ this.$refs.xTable.refresh(true)
273
+ // commit
274
+ this.$emit('afterSubmit', res)
275
+ }).catch(e => {
276
+ this.loading = false
277
+ this.modelVisible = false
278
+ this.$message.error(this.businessType + '失败!')
279
+ })
280
+ } else {
281
+ return false
282
+ }
283
+ },
284
+ // 刷新加载表格数据
285
+ loadData (requestParameters, callback) {
286
+ callback(query(requestParameters))
287
+ },
288
+ // 详情按钮事件
289
+ action (record, id) {
290
+ this.$emit('action', record, id)
291
+ },
292
+ // 新增业务
293
+ addItem () {
294
+ this.businessType = '新增'
295
+ this.modifyModelData = {}
296
+ this.modelVisible = true
297
+ },
298
+ // 修改业务
299
+ editItem () {
300
+ this.businessType = '修改'
301
+ if (!this.viewMode) {
302
+ const requestParameters = {
303
+ queryParamsName: this.queryParamsName,
304
+ conditionParams: {},
305
+ pageNo: 1,
306
+ pageSize: 1
307
+ }
308
+ requestParameters.conditionParams[this.tableColumns[0].dataIndex] = this.selectedRowKeys[0]
309
+ this.editDataLoading = true
310
+ query(requestParameters).then(res => {
311
+ this.modifyModelData = res.data[0]
312
+ this.modelVisible = true
313
+ this.editDataLoading = false
314
+ })
315
+ } else {
316
+ this.$message.info('预览模式禁止修改')
317
+ }
318
+ },
319
+ // 删除业务
320
+ deleteItem () {
321
+ if (this.viewMode) {
322
+ this.$message.info('预览模式禁止删除')
323
+ return
324
+ }
325
+ Modal.confirm({
326
+ title: '提示',
327
+ content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
328
+ confirmLoading: this.loading,
329
+ zIndex: 1001,
330
+ onOk: () => {
331
+ this.loading = true
332
+ const requestParameters = {
333
+ queryParamsName: this.queryParamsName,
334
+ idList: this.selectedRowKeys
335
+ }
336
+ remove(requestParameters).then(res => {
337
+ this.loading = false
338
+ this.$message.success('删除成功!')
339
+ this.$refs.xTable.clearRowKeys()
340
+ this.$refs.xTable.refresh(true)
341
+ // commit
342
+ this.$emit('afterSubmit', res)
343
+ }).catch(e => {
344
+ this.loading = false
345
+ this.$message.error('删除失败!')
346
+ })
347
+ },
348
+ onCancel () {}
349
+ })
350
+ },
351
+ // 查询表单部分显示/隐藏切换
352
+ toggleIsFormShow () {
353
+ this.isFormShow = !this.isFormShow
354
+ },
355
+ // 控制业务操作按钮组的显示
356
+ selectRow (rowKeys) {
357
+ this.selectedRowKeys = rowKeys
358
+ this.isModify = this.selectedRowKeys.length === 1
359
+ this.isDelete = this.selectedRowKeys.length > 0
360
+ }
361
+ }
362
+ }
363
+ </script>
364
+ <style lang="less" scoped>
365
+ .btn-success {
366
+ color: #ffffff;
367
+ }
368
+ .btn-success:hover {
369
+ color: #ffffff !important;
370
+ }
371
+ .btn-success:focus {
372
+ color: #ffffff !important;
373
+ }
374
+ .btn-success:enabled:hover {
375
+ background-color: #85CE61 !important;
376
+ border-color: #85CE61 !important;
377
+ }
378
+ .btn-success:enabled {
379
+ background-color: #67c23a;
380
+ border-color: #67c23a;
381
+ }
382
+ .btn-success:disabled {
383
+ color: rgba(0, 0, 0, 0.25);
384
+ }
385
+ .btn-warn {
386
+ color: #ffffff;
387
+ }
388
+ .btn-warn:hover {
389
+ color: #ffffff !important;
390
+ }
391
+ .btn-warn:focus {
392
+ color: #ffffff !important;
393
+ }
394
+ .btn-warn:enabled:hover {
395
+ background-color: #ffc833 !important;
396
+ border-color: #ffc833 !important;
397
+ }
398
+ .btn-warn:enabled {
399
+ background-color: #ffba00;
400
+ border-color: #ffba00;
401
+ }
402
+ .btn-warn:disabled {
403
+ color: rgba(0, 0, 0, 0.25);
404
+ }
405
+ </style>