vue2-client 1.3.0 → 1.3.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 (106) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/index.js +30 -28
  3. package/package.json +1 -1
  4. package/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox.vue +225 -225
  5. package/src/base-client/components/common/CreateQuery/CreateQueryItem.vue +777 -777
  6. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQueryItem.vue +553 -553
  7. package/src/base-client/components/common/FormGroupQuery/FormGroupQuery.vue +165 -163
  8. package/src/base-client/components/common/Upload/Upload.vue +161 -158
  9. package/src/base-client/components/common/XAddForm/XAddForm.vue +349 -349
  10. package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +321 -322
  11. package/src/base-client/components/common/XForm/XForm.vue +273 -268
  12. package/src/base-client/components/common/XForm/XFormItem.vue +387 -371
  13. package/src/base-client/components/common/XFormTable/XFormTable.vue +8 -7
  14. package/src/base-client/components/common/XTable/XTable.vue +278 -274
  15. package/src/base-client/components/{iot → system}/LogDetailsView/LogDetailsView.vue +0 -0
  16. package/src/base-client/components/{iot → system}/LogDetailsView/index.js +0 -0
  17. package/src/base-client/components/{iot → system}/LogDetailsView/index.md +0 -0
  18. package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +281 -280
  19. package/src/base-client/components/ticket/TicketDetailsView/TicketDetailsView.vue +806 -804
  20. package/src/base-client/components/ticket/TicketSubmitSuccessView/TicketSubmitSuccessView.vue +24 -24
  21. package/src/base-client/plugins/PagedList.js +177 -176
  22. package/src/components/STable/index.js +318 -316
  23. package/src/components/index.js +36 -36
  24. package/src/components/table/StandardTable.vue +141 -142
  25. package/src/components/tool/TagSelect.vue +83 -83
  26. package/src/layouts/header/AdminHeader.vue +104 -109
  27. package/src/layouts/header/HeaderNotice.vue +167 -199
  28. package/src/layouts/header/InstitutionDetail.vue +181 -182
  29. package/src/pages/CreateQueryPage.vue +65 -59
  30. package/src/pages/system/dictionary/index.vue +43 -41
  31. package/src/pages/system/file/Info.vue +56 -0
  32. package/src/pages/system/file/index.vue +317 -0
  33. package/src/pages/system/queryParams/index.vue +43 -41
  34. package/src/pages/system/ticket/index.vue +458 -452
  35. package/src/pages/system/ticket/submitTicketSuccess.vue +206 -203
  36. package/src/router/async/config.async.js +2 -1
  37. package/src/router/async/router.map.js +56 -60
  38. package/src/services/api/DictionaryDetailsViewApi.js +6 -6
  39. package/src/services/api/LogDetailsViewApi.js +10 -10
  40. package/src/services/api/QueryParamsDetailsViewApi.js +6 -6
  41. package/src/services/api/TicketDetailsViewApi.js +42 -40
  42. package/src/services/api/commonTempTable.js +10 -0
  43. package/src/services/api/index.js +2 -24
  44. package/src/services/api/manage.js +8 -16
  45. package/src/utils/excel/Blob.js +181 -181
  46. package/src/utils/excel/Export2Excel.js +141 -142
  47. package/src/utils/i18n.js +80 -80
  48. package/src/utils/request.js +4 -4
  49. package/src/utils/routerUtil.js +358 -350
  50. package/src/utils/theme-color-replacer-extend.js +91 -92
  51. package/vue.config.js +109 -163
  52. package/src/base-client/all.js +0 -62
  53. package/src/base-client/components/iot/CustomerDetailsView/CustomerDetailsView.vue +0 -225
  54. package/src/base-client/components/iot/CustomerDetailsView/index.js +0 -3
  55. package/src/base-client/components/iot/CustomerDetailsView/index.md +0 -40
  56. package/src/base-client/components/iot/DataAnalysisUser/DataAnalysisUser.vue +0 -127
  57. package/src/base-client/components/iot/DataAnalysisUser/index.js +0 -3
  58. package/src/base-client/components/iot/DeviceBrandDetailsView/DeviceBrandDetailsView.vue +0 -452
  59. package/src/base-client/components/iot/DeviceBrandDetailsView/index.js +0 -3
  60. package/src/base-client/components/iot/DeviceDetailsView/DeviceDetailsView.vue +0 -232
  61. package/src/base-client/components/iot/DeviceDetailsView/index.js +0 -3
  62. package/src/base-client/components/iot/DeviceDetailsView/index.md +0 -41
  63. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsCount.vue +0 -678
  64. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsException.vue +0 -57
  65. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsInstruct.vue +0 -122
  66. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsInstructOperate.vue +0 -121
  67. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsMain.vue +0 -269
  68. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsRead.vue +0 -131
  69. package/src/base-client/components/iot/DeviceDetailsView/part/index.js +0 -8
  70. package/src/base-client/components/iot/DeviceTypeDetailsView/DeviceTypeDetailsView.vue +0 -300
  71. package/src/base-client/components/iot/DeviceTypeDetailsView/index.js +0 -3
  72. package/src/base-client/components/iot/InstructDetailsView/InstructDetailsView.vue +0 -464
  73. package/src/base-client/components/iot/InstructDetailsView/index.js +0 -3
  74. package/src/base-client/components/iot/InstructDetailsView/index.md +0 -43
  75. package/src/base-client/components/iot/MeterDetailsView/MeterDetailsView.vue +0 -352
  76. package/src/base-client/components/iot/MeterDetailsView/index.js +0 -3
  77. package/src/base-client/components/iot/MeterDetailsView/index.md +0 -41
  78. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsCount.vue +0 -330
  79. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsException.vue +0 -179
  80. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsHandPlan.vue +0 -285
  81. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsInstruct.vue +0 -230
  82. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsMain.vue +0 -251
  83. package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsSellGas.vue +0 -184
  84. package/src/base-client/components/iot/MeterDetailsView/part/index.js +0 -9
  85. package/src/base-client/components/iot/WebmeterAnalysisView/WebmeterAnalysisView.vue +0 -960
  86. package/src/base-client/components/iot/WebmeterAnalysisView/index.js +0 -3
  87. package/src/base-client/components/iot/WebmeterAnalysisView/index.md +0 -42
  88. package/src/base-client/components/ticket/EmployeeDetailsView/EmployeeDetailsView.vue +0 -370
  89. package/src/base-client/components/ticket/EmployeeDetailsView/index.js +0 -3
  90. package/src/base-client/components/ticket/EmployeeDetailsView/index.md +0 -28
  91. package/src/components/Charts/DataUserOrderSituation.vue +0 -77
  92. package/src/components/Charts/DataUserReporting.vue +0 -74
  93. package/src/components/Charts/DataUserSituation.vue +0 -107
  94. package/src/services/api/CustomerDetailsViewApi.js +0 -6
  95. package/src/services/api/DeviceBrandDetailsViewApi.js +0 -14
  96. package/src/services/api/DeviceDetailsViewApi.js +0 -10
  97. package/src/services/api/DeviceTypeDetailsViewApi.js +0 -6
  98. package/src/services/api/EmployeeDetailsViewApi.js +0 -12
  99. package/src/services/api/FormGroupEditApi.js +0 -6
  100. package/src/services/api/InstructDetailsViewApi.js +0 -12
  101. package/src/services/api/MeterDetailsViewApi.js +0 -24
  102. package/src/services/api/WebmeterAnalysisViewApi.js +0 -24
  103. package/src/services/api/applyInstallApi.js +0 -14
  104. package/src/services/api/iot/DeviceDetailsView/DeviceDetailsCountApi.js +0 -18
  105. package/src/services/api/iot.js +0 -7
  106. package/src/services/api/service.js +0 -12
@@ -1,316 +1,318 @@
1
- import T from 'ant-design-vue/es/table/Table'
2
- import get from 'lodash.get'
3
-
4
- export default {
5
- data () {
6
- return {
7
- needTotalList: [],
8
-
9
- selectedRows: [],
10
- selectedRowKeys: [],
11
-
12
- localLoading: false,
13
- localDataSource: [],
14
- localPagination: Object.assign({}, this.pagination)
15
- }
16
- },
17
- props: Object.assign({}, T.props, {
18
- rowKey: {
19
- type: [String, Function],
20
- default: 'key'
21
- },
22
- data: {
23
- type: Function,
24
- required: true
25
- },
26
- pageNum: {
27
- type: Number,
28
- default: 1
29
- },
30
- pageSize: {
31
- type: Number,
32
- default: 10
33
- },
34
- showSizeChanger: {
35
- type: Boolean,
36
- default: true
37
- },
38
- size: {
39
- type: String,
40
- default: 'default'
41
- },
42
- /**
43
- * alert: {
44
- * show: true,
45
- * clear: Function
46
- * }
47
- */
48
- alert: {
49
- type: [Object, Boolean],
50
- default: null
51
- },
52
- rowSelection: {
53
- type: Object,
54
- default: null
55
- },
56
- /** @Deprecated */
57
- showAlertInfo: {
58
- type: Boolean,
59
- default: false
60
- },
61
- showPagination: {
62
- type: String | Boolean,
63
- default: 'auto'
64
- },
65
- /**
66
- * enable page URI mode
67
- *
68
- * e.g:
69
- * /users/1
70
- * /users/2
71
- * /users/3?queryParam=test
72
- * ...
73
- */
74
- pageURI: {
75
- type: Boolean,
76
- default: false
77
- }
78
- }),
79
- watch: {
80
- 'localPagination.current' (val) {
81
- this.pageURI && this.$router.push({
82
- ...this.$route,
83
- name: this.$route.name,
84
- params: Object.assign({}, this.$route.params, {
85
- pageNo: val
86
- })
87
- })
88
- // change pagination, reset total data
89
- this.needTotalList = this.initTotalList(this.columns)
90
- this.selectedRowKeys = []
91
- this.selectedRows = []
92
- },
93
- pageNum (val) {
94
- Object.assign(this.localPagination, {
95
- current: val
96
- })
97
- },
98
- pageSize (val) {
99
- Object.assign(this.localPagination, {
100
- pageSize: val
101
- })
102
- },
103
- showSizeChanger (val) {
104
- Object.assign(this.localPagination, {
105
- showSizeChanger: val
106
- })
107
- }
108
- },
109
- created () {
110
- const { pageNo } = this.$route.params
111
- const localPageNum = this.pageURI && (pageNo && parseInt(pageNo)) || this.pageNum
112
- this.localPagination = ['auto', true].includes(this.showPagination) && Object.assign({}, this.localPagination, {
113
- current: localPageNum,
114
- pageSize: this.pageSize,
115
- showSizeChanger: this.showSizeChanger
116
- }) || false
117
- this.needTotalList = this.initTotalList(this.columns)
118
- this.loadData()
119
- },
120
- methods: {
121
- /**
122
- * 表格重新加载方法
123
- * 如果参数为 true, 则强制刷新到第一页
124
- * @param Boolean bool
125
- */
126
- refresh (bool = false) {
127
- bool && (this.localPagination = Object.assign({}, {
128
- current: 1, pageSize: this.pageSize
129
- }))
130
- this.loadData()
131
- },
132
- /**
133
- * 加载数据方法
134
- * @param {Object} pagination 分页选项器
135
- * @param {Object} filters 过滤条件
136
- * @param {Object} sorter 排序条件
137
- */
138
- loadData (pagination, filters, sorter) {
139
- this.localLoading = true
140
- const parameter = Object.assign({
141
- pageNo: (pagination && pagination.current) ||
142
- this.showPagination && this.localPagination.current || this.pageNum,
143
- pageSize: (pagination && pagination.pageSize) ||
144
- this.showPagination && this.localPagination.pageSize || this.pageSize
145
- },
146
- (sorter && sorter.field && {
147
- sortField: sorter.field
148
- }) || {},
149
- (sorter && sorter.order && {
150
- sortOrder: sorter.order
151
- }) || {}, {
152
- ...filters
153
- }
154
- )
155
- const result = this.data(parameter)
156
- // 对接自己的通用数据接口需要修改下方代码中的 r.pageNo, r.totalCount, r.data
157
- // eslint-disable-next-line
158
- if ((typeof result === 'object' || typeof result === 'function') && typeof result.then === 'function') {
159
- result.then(r => {
160
- this.localPagination = this.showPagination && Object.assign({}, this.localPagination, {
161
- current: r.pageNo, // 返回结果中的当前分页数
162
- total: r.totalCount, // 返回结果中的总记录数
163
- showSizeChanger: this.showSizeChanger,
164
- showTotal: (total, range) => range[0] === range[1] ? `第 ${range[0]} / 共 ${total} 条, 合计 ${r.totalPage} 页` : `第 ${range[0]} ~ ${range[1]} / 共 ${total} 条, 合计 ${r.totalPage} 页`,
165
- pageSize: (pagination && pagination.pageSize) || this.localPagination.pageSize
166
- }) || false
167
- // 为防止删除数据后导致页面当前页面数据长度为 0 ,自动翻页到上一页
168
- if (r.data.length === 0 && this.showPagination && this.localPagination.current > 1) {
169
- this.localPagination.current--
170
- this.loadData()
171
- return
172
- }
173
-
174
- // 这里用于判断接口是否有返回 r.totalCount 且 this.showPagination = 'auto' 且 pageNo 和 pageSize 存在 且 totalCount 小于等于 pageNo * pageSize 的大小
175
- // 当情况满足时,表示数据不满足分页大小,关闭 table 分页功能
176
- try {
177
- if ((['auto'].includes(this.showPagination) && r.totalCount <= (r.pageNo * this.localPagination.pageSize))) {
178
- this.localPagination.hideOnSinglePage = true
179
- }
180
- } catch (e) {
181
- this.localPagination = false
182
- }
183
- this.localDataSource = r.data // 返回结果中的数组数据
184
- this.localLoading = false
185
- })
186
- }
187
- },
188
- initTotalList (columns) {
189
- const totalList = []
190
- columns && columns instanceof Array && columns.forEach(column => {
191
- if (column.needTotal) {
192
- totalList.push({
193
- ...column,
194
- total: 0
195
- })
196
- }
197
- })
198
- return totalList
199
- },
200
- /**
201
- * 用于更新已选中的列表数据 total 统计
202
- * @param selectedRowKeys
203
- * @param selectedRows
204
- */
205
- updateSelect (selectedRowKeys, selectedRows) {
206
- this.selectedRows = selectedRows
207
- this.selectedRowKeys = selectedRowKeys
208
- const list = this.needTotalList
209
- this.needTotalList = list.map(item => {
210
- return {
211
- ...item,
212
- total: selectedRows.reduce((sum, val) => {
213
- const total = sum + parseInt(get(val, item.dataIndex))
214
- return isNaN(total) ? 0 : total
215
- }, 0)
216
- }
217
- })
218
- },
219
- /**
220
- * 清空 table 已选中项
221
- */
222
- clearSelected () {
223
- if (this.rowSelection) {
224
- this.rowSelection.onChange([], [])
225
- this.updateSelect([], [])
226
- }
227
- },
228
- /**
229
- * 处理交给 table 使用者去处理 clear 事件时,内部选中统计同时调用
230
- * @param callback
231
- * @returns {*}
232
- */
233
- renderClear (callback) {
234
- if (this.selectedRowKeys.length <= 0) return null
235
- return (
236
- <a style="margin-left: 24px" onClick={() => {
237
- callback()
238
- this.clearSelected()
239
- }}>清空</a>
240
- )
241
- },
242
- renderAlert () {
243
- // 绘制统计列数据
244
- const needTotalItems = this.needTotalList.map((item) => {
245
- return (<span style="margin-right: 12px">
246
- {item.title}总计 <a style="font-weight: 600">{!item.customRender ? item.total : item.customRender(item.total)}</a>
247
- </span>)
248
- })
249
-
250
- // 绘制 清空 按钮
251
- const clearItem = (typeof this.alert.clear === 'boolean' && this.alert.clear) ? (
252
- this.renderClear(this.clearSelected)
253
- ) : (this.alert !== null && typeof this.alert.clear === 'function') ? (
254
- this.renderClear(this.alert.clear)
255
- ) : null
256
-
257
- // 绘制 alert 组件
258
- return (
259
- <a-alert showIcon={true} style="margin-bottom: 16px">
260
- <template slot="message">
261
- <span style="margin-right: 12px">已选择: <a style="font-weight: 600">{this.selectedRows.length}</a></span>
262
- {needTotalItems}
263
- {clearItem}
264
- </template>
265
- </a-alert>
266
- )
267
- }
268
- },
269
-
270
- render () {
271
- const props = {}
272
- const localKeys = Object.keys(this.$data)
273
- const showAlert = (typeof this.alert === 'object' && this.alert !== null && this.alert.show) && typeof this.rowSelection.selectedRowKeys !== 'undefined' || this.alert
274
-
275
- Object.keys(T.props).forEach(k => {
276
- const localKey = `local${k.substring(0, 1).toUpperCase()}${k.substring(1)}`
277
- if (localKeys.includes(localKey)) {
278
- props[k] = this[localKey]
279
- return props[k]
280
- }
281
- if (k === 'rowSelection') {
282
- if (showAlert && this.rowSelection) {
283
- // 如果需要使用alert,则重新绑定 rowSelection 事件
284
- props[k] = {
285
- ...this.rowSelection,
286
- selectedRows: this.selectedRows,
287
- selectedRowKeys: this.selectedRowKeys,
288
- onChange: (selectedRowKeys, selectedRows) => {
289
- this.updateSelect(selectedRowKeys, selectedRows)
290
- typeof this[k].onChange !== 'undefined' && this[k].onChange(selectedRowKeys, selectedRows)
291
- }
292
- }
293
- return props[k]
294
- } else if (!this.rowSelection) {
295
- // 如果没打算开启 rowSelection 则清空默认的选择项
296
- props[k] = null
297
- return props[k]
298
- }
299
- }
300
- this[k] && (props[k] = this[k])
301
- return props[k]
302
- })
303
- const table = (
304
- <a-table {...{ props, scopedSlots: { ...this.$scopedSlots } }} onChange={this.loadData} onExpand={ (expanded, record) => { this.$emit('expand', expanded, record) } }>
305
- { Object.keys(this.$slots).map(name => (<template slot={name}>{this.$slots[name]}</template>)) }
306
- </a-table>
307
- )
308
-
309
- return (
310
- <div class="table-wrapper">
311
- { showAlert ? this.renderAlert() : null }
312
- { table }
313
- </div>
314
- )
315
- }
316
- }
1
+ import T from 'ant-design-vue/es/table/Table'
2
+ import get from 'lodash.get'
3
+
4
+ export default {
5
+ data () {
6
+ return {
7
+ needTotalList: [],
8
+
9
+ selectedRows: [],
10
+ selectedRowKeys: [],
11
+
12
+ localLoading: false,
13
+ localDataSource: [],
14
+ localPagination: Object.assign({}, this.pagination)
15
+ }
16
+ },
17
+ props: Object.assign({}, T.props, {
18
+ rowKey: {
19
+ type: [String, Function],
20
+ default: 'key'
21
+ },
22
+ data: {
23
+ type: Function,
24
+ required: true
25
+ },
26
+ pageNum: {
27
+ type: Number,
28
+ default: 1
29
+ },
30
+ pageSize: {
31
+ type: Number,
32
+ default: 10
33
+ },
34
+ showSizeChanger: {
35
+ type: Boolean,
36
+ default: true
37
+ },
38
+ size: {
39
+ type: String,
40
+ default: 'default'
41
+ },
42
+ /**
43
+ * alert: {
44
+ * show: true,
45
+ * clear: Function
46
+ * }
47
+ */
48
+ alert: {
49
+ type: [Object, Boolean],
50
+ default: null
51
+ },
52
+ rowSelection: {
53
+ type: Object,
54
+ default: null
55
+ },
56
+ /** @Deprecated */
57
+ showAlertInfo: {
58
+ type: Boolean,
59
+ default: false
60
+ },
61
+ showPagination: {
62
+ type: String | Boolean,
63
+ default: 'auto'
64
+ },
65
+ /**
66
+ * enable page URI mode
67
+ *
68
+ * e.g:
69
+ * /users/1
70
+ * /users/2
71
+ * /users/3?queryParam=test
72
+ * ...
73
+ */
74
+ pageURI: {
75
+ type: Boolean,
76
+ default: false
77
+ }
78
+ }),
79
+ watch: {
80
+ 'localPagination.current' (val) {
81
+ this.pageURI && this.$router.push({
82
+ ...this.$route,
83
+ name: this.$route.name,
84
+ params: Object.assign({}, this.$route.params, {
85
+ pageNo: val
86
+ })
87
+ })
88
+ // change pagination, reset total data
89
+ this.needTotalList = this.initTotalList(this.columns)
90
+ this.selectedRowKeys = []
91
+ this.selectedRows = []
92
+ },
93
+ pageNum (val) {
94
+ Object.assign(this.localPagination, {
95
+ current: val
96
+ })
97
+ },
98
+ pageSize (val) {
99
+ Object.assign(this.localPagination, {
100
+ pageSize: val
101
+ })
102
+ },
103
+ showSizeChanger (val) {
104
+ Object.assign(this.localPagination, {
105
+ showSizeChanger: val
106
+ })
107
+ }
108
+ },
109
+ created () {
110
+ const { pageNo } = this.$route.params
111
+ const localPageNum = this.pageURI && (pageNo && parseInt(pageNo)) || this.pageNum
112
+ this.localPagination = ['auto', true].includes(this.showPagination) && Object.assign({}, this.localPagination, {
113
+ current: localPageNum,
114
+ pageSize: this.pageSize,
115
+ showSizeChanger: this.showSizeChanger
116
+ }) || false
117
+ this.needTotalList = this.initTotalList(this.columns)
118
+ this.loadData()
119
+ },
120
+ methods: {
121
+ /**
122
+ * 表格重新加载方法
123
+ * 如果参数为 true, 则强制刷新到第一页
124
+ * @param Boolean bool
125
+ */
126
+ refresh (bool = false) {
127
+ bool && (this.localPagination = Object.assign({}, {
128
+ current: 1, pageSize: this.pageSize
129
+ }))
130
+ this.loadData()
131
+ },
132
+ /**
133
+ * 加载数据方法
134
+ * @param {Object} pagination 分页选项器
135
+ * @param {Object} filters 过滤条件
136
+ * @param {Object} sorter 排序条件
137
+ */
138
+ loadData (pagination, filters, sorter) {
139
+ this.localLoading = true
140
+ const parameter = Object.assign({
141
+ pageNo: (pagination && pagination.current) ||
142
+ this.showPagination && this.localPagination.current || this.pageNum,
143
+ pageSize: (pagination && pagination.pageSize) ||
144
+ this.showPagination && this.localPagination.pageSize || this.pageSize
145
+ },
146
+ (sorter && sorter.field && {
147
+ sortField: sorter.field
148
+ }) || {},
149
+ (sorter && sorter.order && {
150
+ sortOrder: sorter.order
151
+ }) || {}, {
152
+ ...filters
153
+ }
154
+ )
155
+ const result = this.data(parameter)
156
+ // 对接自己的通用数据接口需要修改下方代码中的 r.pageNo, r.totalCount, r.data
157
+ // eslint-disable-next-line
158
+ if ((typeof result === 'object' || typeof result === 'function') && typeof result.then === 'function') {
159
+ result.then(r => {
160
+ this.localPagination = this.showPagination && Object.assign({}, this.localPagination, {
161
+ current: r.pageNo, // 返回结果中的当前分页数
162
+ total: r.totalCount, // 返回结果中的总记录数
163
+ showSizeChanger: this.showSizeChanger,
164
+ showTotal: (total, range) => range[0] === range[1] ? `第 ${range[0]} / 共 ${total} 条, 合计 ${r.totalPage} 页` : `第 ${range[0]} ~ ${range[1]} / 共 ${total} 条, 合计 ${r.totalPage} 页`,
165
+ pageSize: (pagination && pagination.pageSize) || this.localPagination.pageSize
166
+ }) || false
167
+ // 为防止删除数据后导致页面当前页面数据长度为 0 ,自动翻页到上一页
168
+ if (r.data.length === 0 && this.showPagination && this.localPagination.current > 1) {
169
+ this.localPagination.current--
170
+ this.loadData()
171
+ return
172
+ }
173
+
174
+ // 这里用于判断接口是否有返回 r.totalCount 且 this.showPagination = 'auto' 且 pageNo 和 pageSize 存在 且 totalCount 小于等于 pageNo * pageSize 的大小
175
+ // 当情况满足时,表示数据不满足分页大小,关闭 table 分页功能
176
+ try {
177
+ if ((['auto'].includes(this.showPagination) && r.totalCount <= (r.pageNo * this.localPagination.pageSize))) {
178
+ this.localPagination.hideOnSinglePage = true
179
+ }
180
+ } catch (e) {
181
+ this.localPagination = false
182
+ }
183
+ this.localDataSource = r.data // 返回结果中的数组数据
184
+ this.localLoading = false
185
+ }, () => {
186
+ this.localLoading = false
187
+ })
188
+ }
189
+ },
190
+ initTotalList (columns) {
191
+ const totalList = []
192
+ columns && columns instanceof Array && columns.forEach(column => {
193
+ if (column.needTotal) {
194
+ totalList.push({
195
+ ...column,
196
+ total: 0
197
+ })
198
+ }
199
+ })
200
+ return totalList
201
+ },
202
+ /**
203
+ * 用于更新已选中的列表数据 total 统计
204
+ * @param selectedRowKeys
205
+ * @param selectedRows
206
+ */
207
+ updateSelect (selectedRowKeys, selectedRows) {
208
+ this.selectedRows = selectedRows
209
+ this.selectedRowKeys = selectedRowKeys
210
+ const list = this.needTotalList
211
+ this.needTotalList = list.map(item => {
212
+ return {
213
+ ...item,
214
+ total: selectedRows.reduce((sum, val) => {
215
+ const total = sum + parseInt(get(val, item.dataIndex))
216
+ return isNaN(total) ? 0 : total
217
+ }, 0)
218
+ }
219
+ })
220
+ },
221
+ /**
222
+ * 清空 table 已选中项
223
+ */
224
+ clearSelected () {
225
+ if (this.rowSelection) {
226
+ this.rowSelection.onChange([], [])
227
+ this.updateSelect([], [])
228
+ }
229
+ },
230
+ /**
231
+ * 处理交给 table 使用者去处理 clear 事件时,内部选中统计同时调用
232
+ * @param callback
233
+ * @returns {*}
234
+ */
235
+ renderClear (callback) {
236
+ if (this.selectedRowKeys.length <= 0) return null
237
+ return (
238
+ <a style="margin-left: 24px" onClick={() => {
239
+ callback()
240
+ this.clearSelected()
241
+ }}>清空</a>
242
+ )
243
+ },
244
+ renderAlert () {
245
+ // 绘制统计列数据
246
+ const needTotalItems = this.needTotalList.map((item) => {
247
+ return (<span style="margin-right: 12px">
248
+ {item.title}总计 <a style="font-weight: 600">{!item.customRender ? item.total : item.customRender(item.total)}</a>
249
+ </span>)
250
+ })
251
+
252
+ // 绘制 清空 按钮
253
+ const clearItem = (typeof this.alert.clear === 'boolean' && this.alert.clear) ? (
254
+ this.renderClear(this.clearSelected)
255
+ ) : (typeof this.alert.clear === 'function') ? (
256
+ this.renderClear(this.alert.clear)
257
+ ) : null
258
+
259
+ // 绘制 alert 组件
260
+ return (
261
+ <a-alert showIcon={true} style="margin-bottom: 16px">
262
+ <template slot="message">
263
+ <span style="margin-right: 12px">已选择: <a style="font-weight: 600">{this.selectedRows.length}</a></span>
264
+ {needTotalItems}
265
+ {clearItem}
266
+ </template>
267
+ </a-alert>
268
+ )
269
+ }
270
+ },
271
+
272
+ render () {
273
+ const props = {}
274
+ const localKeys = Object.keys(this.$data)
275
+ const showAlert = (typeof this.alert === 'object' && this.alert !== null && this.alert.show) && typeof this.rowSelection.selectedRowKeys !== 'undefined' || this.alert
276
+
277
+ Object.keys(T.props).forEach(k => {
278
+ const localKey = `local${k.substring(0, 1).toUpperCase()}${k.substring(1)}`
279
+ if (localKeys.includes(localKey)) {
280
+ props[k] = this[localKey]
281
+ return props[k]
282
+ }
283
+ if (k === 'rowSelection') {
284
+ if (showAlert && this.rowSelection) {
285
+ // 如果需要使用alert,则重新绑定 rowSelection 事件
286
+ props[k] = {
287
+ ...this.rowSelection,
288
+ selectedRows: this.selectedRows,
289
+ selectedRowKeys: this.selectedRowKeys,
290
+ onChange: (selectedRowKeys, selectedRows) => {
291
+ this.updateSelect(selectedRowKeys, selectedRows)
292
+ typeof this[k].onChange !== 'undefined' && this[k].onChange(selectedRowKeys, selectedRows)
293
+ }
294
+ }
295
+ return props[k]
296
+ } else if (!this.rowSelection) {
297
+ // 如果没打算开启 rowSelection 则清空默认的选择项
298
+ props[k] = null
299
+ return props[k]
300
+ }
301
+ }
302
+ this[k] && (props[k] = this[k])
303
+ return props[k]
304
+ })
305
+ const table = (
306
+ <a-table {...{ props, scopedSlots: { ...this.$scopedSlots } }} onChange={this.loadData} onExpand={ (expanded, record) => { this.$emit('expand', expanded, record) } }>
307
+ { Object.keys(this.$slots).map(name => (<template slot={name}>{this.$slots[name]}</template>)) }
308
+ </a-table>
309
+ )
310
+
311
+ return (
312
+ <div class="table-wrapper">
313
+ { showAlert ? this.renderAlert() : null }
314
+ { table }
315
+ </div>
316
+ )
317
+ }
318
+ }