vue2-client 1.6.21 → 1.6.22

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 (104) hide show
  1. package/CHANGELOG.md +569 -569
  2. package/index.js +30 -30
  3. package/package.json +1 -1
  4. package/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox.vue +226 -226
  5. package/src/base-client/components/common/AmapMarker/index.js +3 -3
  6. package/src/base-client/components/common/CitySelect/CitySelect.vue +247 -247
  7. package/src/base-client/components/common/CreateQuery/CreateQueryItem.vue +733 -733
  8. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQueryItem.vue +508 -508
  9. package/src/base-client/components/common/FormGroupEdit/FormGroupEdit.vue +140 -140
  10. package/src/base-client/components/common/FormGroupQuery/FormGroupQuery.vue +165 -165
  11. package/src/base-client/components/common/JSONToTree/jsontotree.vue +275 -275
  12. package/src/base-client/components/common/XAddForm/XAddForm.vue +326 -326
  13. package/src/base-client/components/common/XCard/XCard.vue +64 -64
  14. package/src/base-client/components/common/XForm/XForm.vue +180 -180
  15. package/src/base-client/components/common/XFormTable/XFormTable.vue +336 -336
  16. package/src/base-client/components/common/XFormTable/index.md +97 -97
  17. package/src/base-client/components/common/XTreeOne/XTreeOne.vue +109 -109
  18. package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +281 -281
  19. package/src/base-client/components/ticket/TicketDetailsView/TicketDetailsView.vue +807 -807
  20. package/src/base-client/components/ticket/TicketDetailsView/index.md +29 -29
  21. package/src/base-client/components/ticket/TicketDetailsView/part/TicketDetailsFlow.vue +260 -260
  22. package/src/base-client/components/ticket/TicketSubmitSuccessView/TicketSubmitSuccessView.vue +532 -532
  23. package/src/base-client/components/ticket/TicketSubmitSuccessView/index.md +29 -29
  24. package/src/base-client/plugins/AppData.js +76 -76
  25. package/src/base-client/plugins/GetLoginInfoService.js +179 -179
  26. package/src/base-client/plugins/PagedList.js +177 -177
  27. package/src/base-client/plugins/compatible/LoginServiceOA.js +20 -20
  28. package/src/base-client/plugins/i18n-extend.js +32 -32
  29. package/src/components/Ellipsis/Ellipsis.vue +65 -65
  30. package/src/components/Ellipsis/index.md +38 -38
  31. package/src/components/NumberInfo/index.md +43 -43
  32. package/src/components/STable/README.md +341 -341
  33. package/src/components/STable/index.js +318 -318
  34. package/src/components/Trend/index.md +45 -45
  35. package/src/components/checkbox/ColorCheckbox.vue +157 -157
  36. package/src/components/checkbox/ImgCheckbox.vue +163 -163
  37. package/src/components/exception/ExceptionPage.vue +70 -70
  38. package/src/components/form/FormRow.vue +52 -52
  39. package/src/components/index.js +36 -36
  40. package/src/components/menu/SideMenu.vue +62 -62
  41. package/src/components/menu/menu.js +273 -273
  42. package/src/components/page/header/index.less +40 -40
  43. package/src/components/setting/Setting.vue +235 -235
  44. package/src/components/table/StandardTable.vue +141 -141
  45. package/src/components/table/advance/ActionColumns.vue +158 -158
  46. package/src/components/table/advance/SearchArea.vue +355 -355
  47. package/src/components/tool/AStepItem.vue +60 -60
  48. package/src/components/tool/AvatarList.vue +68 -68
  49. package/src/components/tool/Drawer.vue +142 -142
  50. package/src/components/tool/TagSelect.vue +83 -83
  51. package/src/components/transition/PageToggleTransition.vue +97 -97
  52. package/src/config/default/admin.config.js +18 -18
  53. package/src/config/default/setting.config.js +46 -46
  54. package/src/config/replacer/resolve.config.js +67 -67
  55. package/src/layouts/CommonLayout.vue +42 -42
  56. package/src/layouts/ComponentLayoutOne.vue +47 -47
  57. package/src/layouts/PageLayout.vue +151 -151
  58. package/src/layouts/SinglePageView.vue +111 -111
  59. package/src/layouts/footer/PageFooter.vue +49 -49
  60. package/src/layouts/header/AdminHeader.vue +134 -134
  61. package/src/layouts/header/HeaderAvatar.vue +64 -64
  62. package/src/layouts/header/HeaderNotice.vue +176 -176
  63. package/src/layouts/header/HeaderSearch.vue +67 -67
  64. package/src/layouts/header/InstitutionDetail.vue +181 -181
  65. package/src/layouts/header/index.less +92 -92
  66. package/src/layouts/tabs/TabsHead.vue +190 -190
  67. package/src/layouts/tabs/TabsView.vue +379 -379
  68. package/src/mock/goods/index.js +108 -108
  69. package/src/pages/exception/404.vue +25 -25
  70. package/src/pages/login/Login.vue +363 -363
  71. package/src/pages/report/ReportTable.js +124 -124
  72. package/src/pages/report/ReportTableHome.vue +28 -28
  73. package/src/pages/resourceManage/orgListManage.vue +98 -98
  74. package/src/pages/system/file/index.vue +317 -317
  75. package/src/pages/system/settings/index.vue +126 -126
  76. package/src/pages/system/settings/modifyPassword.vue +109 -109
  77. package/src/router/async/config.async.js +28 -28
  78. package/src/router/async/router.map.js +68 -68
  79. package/src/router/index.js +27 -27
  80. package/src/services/api/DictionaryDetailsViewApi.js +6 -6
  81. package/src/services/api/LogDetailsViewApi.js +10 -10
  82. package/src/services/api/QueryParamsDetailsViewApi.js +6 -6
  83. package/src/services/api/TicketDetailsViewApi.js +34 -34
  84. package/src/services/api/cas.js +79 -79
  85. package/src/services/api/commonTempTable.js +10 -10
  86. package/src/services/api/index.js +17 -17
  87. package/src/services/api/logininfor/index.js +6 -6
  88. package/src/services/api/manage.js +8 -8
  89. package/src/services/apiService.js +14 -14
  90. package/src/services/user.js +64 -64
  91. package/src/store/modules/index.js +4 -4
  92. package/src/theme/default/nprogress.less +76 -76
  93. package/src/theme/default/style.less +47 -47
  94. package/src/utils/colors.js +107 -107
  95. package/src/utils/excel/Blob.js +180 -180
  96. package/src/utils/excel/Export2Excel.js +141 -141
  97. package/src/utils/formatter.js +68 -68
  98. package/src/utils/i18n.js +80 -80
  99. package/src/utils/map-utils.js +37 -37
  100. package/src/utils/request.js +311 -311
  101. package/src/utils/theme-color-replacer-extend.js +91 -91
  102. package/src/utils/themeUtil.js +100 -100
  103. package/src/utils/util.js +230 -230
  104. package/vue.config.js +106 -106
@@ -1,318 +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
- 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
- }
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
+ }