vue2-client 1.7.0 → 1.7.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 (126) hide show
  1. package/.env +15 -15
  2. package/CHANGELOG.md +31 -1
  3. package/Components.md +60 -0
  4. package/index.js +39 -30
  5. package/package.json +4 -2
  6. package/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox.vue +316 -316
  7. package/src/base-client/components/common/CitySelect/CitySelect.vue +247 -247
  8. package/src/base-client/components/common/CreateQuery/CreateQuery.vue +669 -667
  9. package/src/base-client/components/common/CreateQuery/CreateQueryItem.vue +735 -733
  10. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQuery.vue +466 -468
  11. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQueryItem.vue +510 -508
  12. package/src/base-client/components/common/FormGroupEdit/FormGroupEdit.vue +144 -146
  13. package/src/base-client/components/common/FormGroupQuery/FormGroupQuery.vue +165 -165
  14. package/src/base-client/components/common/JSONToTree/jsontotree.vue +275 -275
  15. package/src/base-client/components/common/Upload/Upload.vue +168 -168
  16. package/src/base-client/components/common/XAddForm/XAddForm.vue +72 -325
  17. package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +365 -279
  18. package/src/base-client/components/common/XAddNativeForm/index.md +96 -56
  19. package/src/base-client/components/common/XCard/XCard.vue +64 -64
  20. package/src/base-client/components/common/XDataDrawer/XDataDrawer.vue +180 -0
  21. package/src/base-client/components/common/XDataDrawer/index.js +3 -0
  22. package/src/base-client/components/common/XDataDrawer/index.md +41 -0
  23. package/src/base-client/components/common/XForm/XForm.vue +178 -180
  24. package/src/base-client/components/common/XForm/XFormItem.vue +521 -513
  25. package/src/base-client/components/common/XForm/XTreeSelect.vue +184 -184
  26. package/src/base-client/components/common/XFormCol/XFormCol.vue +38 -38
  27. package/src/base-client/components/common/XFormTable/XFormTable.vue +356 -344
  28. package/src/base-client/components/common/XFormTable/index.md +97 -97
  29. package/src/base-client/components/common/XImportExcel/XImportExcel.vue +132 -132
  30. package/src/base-client/components/common/XTable/XTable.vue +519 -506
  31. package/src/base-client/components/common/XTreeOne/XTreeOne.vue +111 -111
  32. package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +231 -231
  33. package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +281 -281
  34. package/src/base-client/components/ticket/TicketDetailsView/TicketDetailsView.vue +807 -807
  35. package/src/base-client/components/ticket/TicketDetailsView/index.md +29 -29
  36. package/src/base-client/components/ticket/TicketDetailsView/part/TicketDetailsFlow.vue +260 -260
  37. package/src/base-client/components/ticket/TicketSubmitSuccessView/TicketSubmitSuccessView.vue +532 -532
  38. package/src/base-client/components/ticket/TicketSubmitSuccessView/index.md +29 -29
  39. package/src/base-client/plugins/AppData.js +76 -76
  40. package/src/base-client/plugins/GetLoginInfoService.js +179 -179
  41. package/src/base-client/plugins/PagedList.js +177 -177
  42. package/src/base-client/plugins/compatible/LoginServiceOA.js +20 -20
  43. package/src/base-client/plugins/i18n-extend.js +32 -32
  44. package/src/components/Ellipsis/Ellipsis.vue +65 -65
  45. package/src/components/Ellipsis/index.md +38 -38
  46. package/src/components/NumberInfo/index.md +43 -43
  47. package/src/components/STable/README.md +341 -341
  48. package/src/components/STable/index.js +318 -318
  49. package/src/components/Trend/index.md +45 -45
  50. package/src/components/checkbox/ColorCheckbox.vue +157 -157
  51. package/src/components/checkbox/ImgCheckbox.vue +163 -163
  52. package/src/components/exception/ExceptionPage.vue +70 -70
  53. package/src/components/form/FormRow.vue +52 -52
  54. package/src/components/index.js +36 -36
  55. package/src/components/menu/SideMenu.vue +62 -62
  56. package/src/components/menu/menu.js +273 -273
  57. package/src/components/page/header/index.less +40 -40
  58. package/src/components/setting/Setting.vue +235 -235
  59. package/src/components/table/StandardTable.vue +141 -141
  60. package/src/components/table/advance/ActionColumns.vue +158 -158
  61. package/src/components/table/advance/SearchArea.vue +355 -355
  62. package/src/components/tool/AStepItem.vue +60 -60
  63. package/src/components/tool/AvatarList.vue +68 -68
  64. package/src/components/tool/Drawer.vue +142 -142
  65. package/src/components/tool/TagSelect.vue +83 -83
  66. package/src/components/transition/PageToggleTransition.vue +97 -97
  67. package/src/config/CreateQueryConfig.js +307 -307
  68. package/src/config/default/admin.config.js +18 -18
  69. package/src/config/default/setting.config.js +3 -1
  70. package/src/config/replacer/resolve.config.js +67 -67
  71. package/src/layouts/CommonLayout.vue +42 -42
  72. package/src/layouts/ComponentLayoutOne.vue +47 -47
  73. package/src/layouts/PageLayout.vue +151 -151
  74. package/src/layouts/SinglePageView.vue +116 -116
  75. package/src/layouts/footer/PageFooter.vue +49 -49
  76. package/src/layouts/header/AdminHeader.vue +134 -134
  77. package/src/layouts/header/HeaderAvatar.vue +64 -64
  78. package/src/layouts/header/HeaderNotice.vue +176 -176
  79. package/src/layouts/header/HeaderSearch.vue +67 -67
  80. package/src/layouts/header/InstitutionDetail.vue +181 -181
  81. package/src/layouts/header/index.less +92 -92
  82. package/src/layouts/tabs/TabsHead.vue +190 -190
  83. package/src/layouts/tabs/TabsView.vue +379 -379
  84. package/src/mock/goods/index.js +108 -108
  85. package/src/pages/CreateQueryPage.vue +84 -84
  86. package/src/pages/login/Login.vue +369 -369
  87. package/src/pages/report/ReportTable.js +124 -124
  88. package/src/pages/report/ReportTableHome.vue +28 -28
  89. package/src/pages/resourceManage/orgListManage.vue +98 -98
  90. package/src/pages/system/dictionary/index.vue +43 -43
  91. package/src/pages/system/file/index.vue +317 -317
  92. package/src/pages/system/monitor/loginInfor/index.vue +36 -36
  93. package/src/pages/system/monitor/operLog/index.vue +36 -36
  94. package/src/pages/system/settings/index.vue +126 -126
  95. package/src/pages/system/settings/modifyPassword.vue +109 -109
  96. package/src/router/async/config.async.js +28 -28
  97. package/src/router/async/router.map.js +66 -66
  98. package/src/router/guards.js +52 -12
  99. package/src/router/index.js +27 -27
  100. package/src/services/api/DictionaryDetailsViewApi.js +6 -6
  101. package/src/services/api/LogDetailsViewApi.js +10 -10
  102. package/src/services/api/QueryParamsDetailsViewApi.js +6 -6
  103. package/src/services/api/TicketDetailsViewApi.js +34 -34
  104. package/src/services/api/cas.js +79 -79
  105. package/src/services/api/common.js +137 -137
  106. package/src/services/api/commonTempTable.js +10 -10
  107. package/src/services/api/index.js +17 -17
  108. package/src/services/api/logininfor/index.js +6 -6
  109. package/src/services/api/manage.js +8 -8
  110. package/src/services/apiService.js +14 -14
  111. package/src/services/user.js +67 -67
  112. package/src/store/modules/index.js +4 -4
  113. package/src/theme/default/nprogress.less +76 -76
  114. package/src/theme/default/style.less +58 -58
  115. package/src/utils/EncryptUtil.js +53 -53
  116. package/src/utils/colors.js +107 -107
  117. package/src/utils/excel/Blob.js +180 -180
  118. package/src/utils/excel/Export2Excel.js +141 -141
  119. package/src/utils/formatter.js +68 -68
  120. package/src/utils/i18n.js +80 -80
  121. package/src/utils/login.js +138 -0
  122. package/src/utils/map-utils.js +37 -37
  123. package/src/utils/theme-color-replacer-extend.js +91 -91
  124. package/src/utils/themeUtil.js +100 -100
  125. package/src/utils/util.js +230 -230
  126. 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
+ }