vue2-client 1.2.0 → 1.2.3

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 (134) hide show
  1. package/README.md +65 -65
  2. package/babel.config.js +1 -0
  3. package/docs/notice.md +22 -0
  4. package/index.js +28 -28
  5. package/package.json +1 -1
  6. package/src/App.vue +93 -93
  7. package/src/assets/img/SunClientDownload.png +0 -0
  8. package/src/assets/img/SunClientManual/1.png +0 -0
  9. package/src/assets/img/SunClientManual/2.png +0 -0
  10. package/src/assets/img/SunClientManual/3.png +0 -0
  11. package/src/assets/img/SunClientManual/4.png +0 -0
  12. package/src/assets/img/ToDeskDownload.png +0 -0
  13. package/src/assets/img/ToDeskManual/1.png +0 -0
  14. package/src/assets/img/ToDeskManual/2.png +0 -0
  15. package/src/assets/img/ToDeskManual/3.png +0 -0
  16. package/src/assets/img/ToDeskManual/4.png +0 -0
  17. package/src/assets/sound/newNote.mp3 +0 -0
  18. package/src/base-client/all.js +57 -57
  19. package/src/base-client/components/common/CreateQuery/CreateQuery.vue +1157 -1159
  20. package/src/base-client/components/common/CreateQuery/index.md +42 -42
  21. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQuery.vue +540 -540
  22. package/src/base-client/components/common/CreateSimpleFormQuery/index.md +42 -42
  23. package/src/base-client/components/common/CustomColumnsDrawer/index.md +46 -46
  24. package/src/base-client/components/common/FormGroupEdit/FormGroupEdit.vue +150 -150
  25. package/src/base-client/components/common/FormGroupEdit/index.md +43 -43
  26. package/src/base-client/components/common/FormGroupQuery/index.md +43 -43
  27. package/src/base-client/components/common/XAddForm/XAddForm.vue +323 -323
  28. package/src/base-client/components/common/XAddForm/index.md +60 -60
  29. package/src/base-client/components/common/XBadge/index.md +39 -39
  30. package/src/base-client/components/common/XCard/index.md +43 -43
  31. package/src/base-client/components/common/XForm/XForm.vue +275 -275
  32. package/src/base-client/components/common/XForm/XFormItem.vue +217 -217
  33. package/src/base-client/components/common/XForm/index.md +196 -196
  34. package/src/base-client/components/common/XFormCol/index.md +35 -35
  35. package/src/base-client/components/common/XFormTable/XFormTable.vue +407 -405
  36. package/src/base-client/components/common/XFormTable/index.md +89 -89
  37. package/src/base-client/components/common/XTable/XTable.vue +262 -262
  38. package/src/base-client/components/common/XTable/index.md +255 -255
  39. package/src/base-client/components/common/XTreeOne/XTreeOne.vue +105 -105
  40. package/src/base-client/components/iot/CustomerDetailsView/CustomerDetailsView.vue +226 -226
  41. package/src/base-client/components/iot/CustomerDetailsView/index.md +41 -41
  42. package/src/base-client/components/iot/DataAnalysisUser/DataAnalysisUser.vue +127 -127
  43. package/src/base-client/components/iot/DataAnalysisView/DataAnalysisView.vue +244 -250
  44. package/src/base-client/components/iot/DataAnalysisViewGD/DataAnalysisViewGD.vue +548 -548
  45. package/src/base-client/components/iot/DeviceBrandDetailsView/DeviceBrandDetailsView.vue +453 -453
  46. package/src/base-client/components/iot/DeviceDetailsView/DeviceDetailsView.vue +231 -231
  47. package/src/base-client/components/iot/DeviceDetailsView/index.md +43 -43
  48. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsCount.vue +330 -330
  49. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsException.vue +57 -57
  50. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsInstruct.vue +122 -122
  51. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsInstructOperate.vue +122 -122
  52. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsMain.vue +225 -225
  53. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsRead.vue +135 -135
  54. package/src/base-client/components/iot/DeviceTypeDetailsView/DeviceTypeDetailsView.vue +277 -277
  55. package/src/base-client/components/iot/InstructDetailsView/InstructDetailsView.vue +472 -472
  56. package/src/base-client/components/iot/InstructDetailsView/index.md +45 -45
  57. package/src/base-client/components/iot/LogDetailsView/LogDetailsView.vue +380 -380
  58. package/src/base-client/components/iot/LogDetailsView/index.md +43 -43
  59. package/src/base-client/components/iot/MeterDetailsView/MeterDetailsView.vue +360 -360
  60. package/src/base-client/components/iot/MeterDetailsView/index.md +43 -43
  61. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsCount.vue +335 -335
  62. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsException.vue +185 -185
  63. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsHandPlan.vue +292 -292
  64. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsInstruct.vue +237 -237
  65. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsMain.vue +257 -257
  66. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsSellGas.vue +190 -190
  67. package/src/base-client/components/iot/WebmeterAnalysisView/WebmeterAnalysisView.vue +723 -723
  68. package/src/base-client/components/iot/WebmeterAnalysisView/index.md +48 -48
  69. package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +232 -232
  70. package/src/base-client/components/system/DictionaryDetailsView/index.md +41 -41
  71. package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +248 -248
  72. package/src/base-client/components/ticket/EmployeeDetailsView/EmployeeDetailsView.vue +371 -406
  73. package/src/base-client/components/ticket/TicketDetailsView/TicketDetailsView.vue +838 -486
  74. package/src/base-client/components/ticket/TicketDetailsView/part/TicketDetailsFlow.vue +261 -184
  75. package/src/base-client/components/ticket/TicketSubmitSuccessView/TicketSubmitSuccessView.vue +528 -303
  76. package/src/base-client/plugins/AppData.js +69 -69
  77. package/src/base-client/plugins/GetLoginInfoService.js +221 -221
  78. package/src/base-client/plugins/index.js +21 -21
  79. package/src/bootstrap.js +27 -27
  80. package/src/components/Ellipsis/Ellipsis.vue +64 -64
  81. package/src/components/Ellipsis/index.md +38 -38
  82. package/src/components/NumberInfo/index.md +43 -43
  83. package/src/components/STable/README.md +341 -341
  84. package/src/components/Trend/index.md +45 -45
  85. package/src/components/cache/AKeepAlive.js +172 -172
  86. package/src/components/checkbox/index.js +7 -7
  87. package/src/components/index.js +36 -36
  88. package/src/components/menu/menu.js +273 -273
  89. package/src/components/setting/Setting.vue +237 -237
  90. package/src/components/table/advance/AdvanceTable.vue +275 -275
  91. package/src/components/transition/PageToggleTransition.vue +97 -97
  92. package/src/layouts/CommonLayout.vue +42 -42
  93. package/src/layouts/PageLayout.vue +151 -151
  94. package/src/layouts/SinglePageView.vue +74 -74
  95. package/src/layouts/header/AdminHeader.vue +109 -109
  96. package/src/layouts/header/HeaderAvatar.vue +60 -60
  97. package/src/layouts/header/HeaderNotice.vue +97 -97
  98. package/src/layouts/tabs/TabsHead.vue +190 -190
  99. package/src/layouts/tabs/TabsView.vue +355 -355
  100. package/src/main.js +20 -20
  101. package/src/mock/goods/index.js +108 -108
  102. package/src/mock/index.js +12 -12
  103. package/src/mock/project/index.js +17 -17
  104. package/src/mock/user/current.js +13 -13
  105. package/src/mock/user/login.js +39 -39
  106. package/src/mock/workplace/index.js +15 -15
  107. package/src/pages/exception/403.vue +25 -25
  108. package/src/pages/exception/404.vue +25 -25
  109. package/src/pages/exception/500.vue +25 -25
  110. package/src/pages/login/Login.vue +194 -194
  111. package/src/pages/report/ReportTableHome.vue +28 -28
  112. package/src/pages/resourceManage/resourceManageMain.vue +55 -55
  113. package/src/pages/system/applyInstallView/Core.vue +570 -570
  114. package/src/pages/system/applyInstallView/index.vue +34 -34
  115. package/src/pages/system/dictionary/index.vue +41 -41
  116. package/src/pages/system/queryParams/index.vue +41 -41
  117. package/src/router/async/config.async.js +25 -25
  118. package/src/router/async/router.map.js +59 -59
  119. package/src/router/guards.js +104 -104
  120. package/src/router/index.js +27 -27
  121. package/src/services/api/EmployeeDetailsViewApi.js +3 -1
  122. package/src/services/api/TicketDetailsViewApi.js +9 -1
  123. package/src/services/api/common.js +37 -39
  124. package/src/services/api/restTools.js +23 -23
  125. package/src/services/dataSource.js +12 -12
  126. package/src/services/user.js +34 -34
  127. package/src/store/modules/setting.js +114 -114
  128. package/src/utils/i18n.js +80 -80
  129. package/src/utils/indexedDB.js +146 -146
  130. package/src/utils/request.js +197 -197
  131. package/src/utils/routerUtil.js +15 -2
  132. package/tests/unit/ReportTable.spec.js +15 -15
  133. package/vue.config.js +153 -153
  134. package/webpack.config.js +12 -12
@@ -1,405 +1,407 @@
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
+ const result = query(requestParameters)
287
+ this.$emit('afterQuery', result)
288
+ callback(result)
289
+ },
290
+ // 详情按钮事件
291
+ action (record, id) {
292
+ this.$emit('action', record, id)
293
+ },
294
+ // 新增业务
295
+ addItem () {
296
+ this.businessType = '新增'
297
+ this.modifyModelData = {}
298
+ this.modelVisible = true
299
+ },
300
+ // 修改业务
301
+ editItem () {
302
+ this.businessType = '修改'
303
+ if (!this.viewMode) {
304
+ const requestParameters = {
305
+ queryParamsName: this.queryParamsName,
306
+ conditionParams: {},
307
+ pageNo: 1,
308
+ pageSize: 1
309
+ }
310
+ requestParameters.conditionParams[this.tableColumns[0].dataIndex] = this.selectedRowKeys[0]
311
+ this.editDataLoading = true
312
+ query(requestParameters).then(res => {
313
+ this.modifyModelData = res.data[0]
314
+ this.modelVisible = true
315
+ this.editDataLoading = false
316
+ })
317
+ } else {
318
+ this.$message.info('预览模式禁止修改')
319
+ }
320
+ },
321
+ // 删除业务
322
+ deleteItem () {
323
+ if (this.viewMode) {
324
+ this.$message.info('预览模式禁止删除')
325
+ return
326
+ }
327
+ Modal.confirm({
328
+ title: '提示',
329
+ content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
330
+ confirmLoading: this.loading,
331
+ zIndex: 1001,
332
+ onOk: () => {
333
+ this.loading = true
334
+ const requestParameters = {
335
+ queryParamsName: this.queryParamsName,
336
+ idList: this.selectedRowKeys
337
+ }
338
+ remove(requestParameters).then(res => {
339
+ this.loading = false
340
+ this.$message.success('删除成功!')
341
+ this.$refs.xTable.clearRowKeys()
342
+ this.$refs.xTable.refresh(true)
343
+ // commit
344
+ this.$emit('afterSubmit', res)
345
+ }).catch(e => {
346
+ this.loading = false
347
+ this.$message.error('删除失败!')
348
+ })
349
+ },
350
+ onCancel () {}
351
+ })
352
+ },
353
+ // 查询表单部分显示/隐藏切换
354
+ toggleIsFormShow () {
355
+ this.isFormShow = !this.isFormShow
356
+ },
357
+ // 控制业务操作按钮组的显示
358
+ selectRow (rowKeys) {
359
+ this.selectedRowKeys = rowKeys
360
+ this.isModify = this.selectedRowKeys.length === 1
361
+ this.isDelete = this.selectedRowKeys.length > 0
362
+ }
363
+ }
364
+ }
365
+ </script>
366
+ <style lang="less" scoped>
367
+ .btn-success {
368
+ color: #ffffff;
369
+ }
370
+ .btn-success:hover {
371
+ color: #ffffff !important;
372
+ }
373
+ .btn-success:focus {
374
+ color: #ffffff !important;
375
+ }
376
+ .btn-success:enabled:hover {
377
+ background-color: #85CE61 !important;
378
+ border-color: #85CE61 !important;
379
+ }
380
+ .btn-success:enabled {
381
+ background-color: #67c23a;
382
+ border-color: #67c23a;
383
+ }
384
+ .btn-success:disabled {
385
+ color: rgba(0, 0, 0, 0.25);
386
+ }
387
+ .btn-warn {
388
+ color: #ffffff;
389
+ }
390
+ .btn-warn:hover {
391
+ color: #ffffff !important;
392
+ }
393
+ .btn-warn:focus {
394
+ color: #ffffff !important;
395
+ }
396
+ .btn-warn:enabled:hover {
397
+ background-color: #ffc833 !important;
398
+ border-color: #ffc833 !important;
399
+ }
400
+ .btn-warn:enabled {
401
+ background-color: #ffba00;
402
+ border-color: #ffba00;
403
+ }
404
+ .btn-warn:disabled {
405
+ color: rgba(0, 0, 0, 0.25);
406
+ }
407
+ </style>