web-component-gallery 2.2.32 → 2.2.34

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.
@@ -0,0 +1,21 @@
1
+ /* stylelint-disable at-rule-empty-line-before,at-rule-name-space-after,at-rule-no-unknown */
2
+ /* stylelint-disable no-duplicate-selectors */
3
+ /* stylelint-disable */
4
+ /* stylelint-disable declaration-bang-space-before,no-duplicate-selectors,string-no-newline */
5
+ .TransferTable {
6
+ flex: 1;
7
+ display: flex;
8
+ gap: 8px 0;
9
+ flex-direction: column;
10
+ }
11
+ .TransferTable__Content {
12
+ flex: 1;
13
+ display: flex;
14
+ gap: 0 8px;
15
+ flex-direction: row;
16
+ }
17
+ .TransferTable__Left,
18
+ .TransferTable__Right {
19
+ height: 100%;
20
+ }
21
+
@@ -0,0 +1 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.rui=t():e.rui=t()}(self,function(){return function(){var e={73472:function(e,t,o){"use strict";o.r(t)}},t={};function o(r){var n=t[r];if(void 0!==n)return n.exports;var u=t[r]={exports:{}};return e[r](u,u.exports,o),u.exports}o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};return o(73472),{}}()});
@@ -1,4 +1,3 @@
1
-
2
1
  import PropTypes from 'ant-design-vue/es/_util/vue-types'
3
2
  import Descriptions from 'ant-design-vue/es/descriptions'
4
3
  import Browse from '../browse/index.jsx'
@@ -13,7 +12,7 @@ const descDefaultAttrs = {
13
12
 
14
13
  const DescriptionsProps = {
15
14
  title: PropTypes.string,
16
- column: PropTypes.oneOfType([PropTypes.number, PropTypes.object]).def(3),
15
+ column: PropTypes.oneOfType([PropTypes.number, PropTypes.object]).def(4),
17
16
  descDetails: PropTypes.object,
18
17
  descSettings: PropTypes.array,
19
18
  descAttrs: PropTypes.object,
@@ -45,41 +44,33 @@ const renderContent = (h, item, details) => {
45
44
  const DescriptionsList = {
46
45
  name: 'DescriptionsList',
47
46
  props: DescriptionsProps,
48
- computed: {
49
- responsiveColumn() {
50
- return {
51
- xxl: 4,
52
- xl: 3,
53
- lg: 3,
54
- md: 3,
55
- sm: 2,
56
- xs: 1
57
- }
47
+ data() {
48
+ return {
49
+ responsiveColumn: 1
58
50
  }
59
51
  },
60
52
  mounted() {
61
- // this.setDescContentWidth()
62
- // this.$bus.$onWindow(this, 'resize', this.setDescContentWidth)
53
+ this.setDescContentWidth()
54
+ this.$bus.$onWindow(this, 'resize', this.setDescContentWidth)
63
55
  },
64
56
  methods: {
65
57
  getCurrentColumn(width) {
66
- if (width >= 1600) return this.responsiveColumn.xxl
67
- if (width >= 1200) return this.responsiveColumn.xl
68
- if (width >= 992) return this.responsiveColumn.lg
69
- if (width >= 768) return this.responsiveColumn.md
70
- if (width >= 576) return this.responsiveColumn.sm
71
- return this.responsiveColumn.xs
58
+ if (width >= 1600) return this.column || 4
59
+ if (width >= 1200) return Math.min(4, this.column)
60
+ if (width >= 992) return Math.min(3, this.column)
61
+ if (width >= 576) return Math.min(2, this.column)
62
+ return 1
72
63
  },
73
64
 
74
- calculateItemWidth(totalWidth, column, itemSpan) {
75
- const effectiveSpan = itemSpan && column > itemSpan ? itemSpan : 1
76
- return totalWidth * (effectiveSpan / column)
65
+ calculateItemWidth(totalWidth, itemSpan) {
66
+ const effectiveSpan = itemSpan && this.responsiveColumn > itemSpan ? itemSpan : 1
67
+ return totalWidth * (effectiveSpan / this.responsiveColumn)
77
68
  },
78
69
 
79
70
  setDescContentWidth() {
80
71
  const retry = () => {
81
72
  const container = this.$refs.Descriptions
82
- if (!container) return
73
+ if (!container) return
83
74
 
84
75
  const viewElement = container.querySelector('.ant-descriptions-view')
85
76
  if (!viewElement) return
@@ -90,39 +81,42 @@ const DescriptionsList = {
90
81
  return
91
82
  }
92
83
 
93
- const column = Math.max(1, this.getCurrentColumn(width))
94
- const labelElements = container.querySelectorAll('.ant-descriptions-item-label')
95
- const contentElements = container.querySelectorAll('.ant-descriptions-item-content')
96
-
97
- for (let i = 0; i < contentElements.length; i++) {
98
- const itemSpan = this.descSettings[i]?.span || 1
99
- let eachWidth = this.calculateItemWidth(width, column, itemSpan)
100
-
101
- let labelWidth, contentWidth
102
- if (eachWidth / 2 > 160) {
103
- labelWidth = 160
104
- contentWidth = eachWidth - 160
105
- } else {
106
- labelWidth = Math.floor(eachWidth * 0.4)
107
- contentWidth = Math.floor(eachWidth * 0.6)
108
- }
109
-
110
- if (labelElements[i]) {
111
- labelElements[i].style.cssText = `
112
- width: 160px;
113
- min-width: 160px;
114
- max-width: 160px;
115
- `
116
- }
117
-
118
- if (contentElements[i]) {
119
- contentElements[i].style.cssText = `
120
- width: calc(100% - 160px);
121
- min-width: calc(100% - 160px);
122
- max-width: calc(100% - 160px);
123
- `
84
+ this.responsiveColumn = this.getCurrentColumn(width)
85
+
86
+ setTimeout(() => {
87
+ const rowElements = container.querySelectorAll('.ant-descriptions-row')
88
+ // 记录数量
89
+ let count = 0
90
+
91
+ for (let i = 0; i < rowElements.length; i++) {
92
+ const labelElements = rowElements[i].querySelectorAll('.ant-descriptions-item-label')
93
+ const contentElements = rowElements[i].querySelectorAll('.ant-descriptions-item-content')
94
+ // 计算平均宽度
95
+ const meanWidth = width / labelElements.length
96
+
97
+ for (let j = 0; j < labelElements.length; j++) {
98
+ const itemSpan = this.descSettings[count]?.span || 1
99
+ const eachWidth = width / this.responsiveColumn * itemSpan
100
+
101
+ // 设置标签固定宽度
102
+ labelElements[j].style = `
103
+ width: 160px;
104
+ min-width: 160px;
105
+ max-width: 160px;
106
+ `
107
+
108
+ // 设置内容区域默认宽度
109
+ contentElements[j].style = `
110
+ width: ${eachWidth - 160}px;
111
+ min-width: ${eachWidth - 160}px;
112
+ max-width: ${eachWidth - 160}px;
113
+ `
114
+
115
+ count++
116
+ }
124
117
  }
125
- }
118
+ }, 0)
119
+
126
120
  }
127
121
  retry()
128
122
  }
@@ -161,4 +155,4 @@ DescriptionsList.install = function(Vue) {
161
155
  Vue.component('DescriptionsList', DescriptionsList)
162
156
  }
163
157
 
164
- export default DescriptionsList
158
+ export default DescriptionsList
@@ -4,18 +4,17 @@
4
4
  .scrollbarStyle();
5
5
 
6
6
  .ant-descriptions-bordered {
7
+
8
+ .ant-descriptions-view > table {
9
+ table-layout: fixed;
10
+ }
11
+
7
12
  .ant-descriptions-item-label {
8
- width: 160px;
9
- min-width: 160px;
10
- max-width: 160px;
11
13
  text-align: left;
12
14
  word-wrap: break-word;
13
15
  }
14
16
 
15
17
  .ant-descriptions-item-content {
16
- width: calc(100% - 160px);
17
- min-width: calc(100% - 160px);
18
- max-width: calc(100% - 160px);
19
18
  word-wrap: break-word;
20
19
 
21
20
  .Browse {
@@ -62,7 +62,7 @@ export default {
62
62
  watch: {
63
63
  value: {
64
64
  handler(newVal, oldVal) {
65
- if (newVal.toString() === oldVal.toString()) return
65
+ if (newVal.toString() === oldVal?.toString()) return
66
66
  this.date = [...newVal]
67
67
  },
68
68
  immediate: true
@@ -148,6 +148,7 @@ export default {
148
148
  block: "center"
149
149
  })
150
150
  })
151
+ reject()
151
152
  })
152
153
  })
153
154
  }
@@ -1,51 +1,72 @@
1
1
  <template>
2
+ <!-- 表格容器,根据tableStyle动态设置样式类 -->
2
3
  <div :class="[tableStyle, 'WebComponentTable']" ref="Table">
3
-
4
- <div class="WebComponentTable__Head" ref="TableHead">
5
- <slot name="ATableHead" />
6
- </div>
4
+ <!-- 表格头部插槽 -->
5
+ <div v-if="$slots.ATableHead" class="WebComponentTable__Head" ref="TableHead">
6
+ <slot name="ATableHead" />
7
+ </div>
7
8
 
8
- <Table
9
- ref="TableList"
10
- :size="tableSize"
11
- :data-source="tableDatas"
12
- v-on="$listeners"
13
- v-bind="setAttrs"
14
- class="WebComponentTable__List"
15
- >
16
- <!-- 下次更改一下title的传递方式 -->
17
- <div class="WebComponentTable__List__Title" ref="TableListTitle" slot="title">
18
- <slot name="ATableTitle" />
19
- </div>
9
+ <!-- 主表格组件 -->
10
+ <Table
11
+ ref="TableList"
12
+ :size="tableSize"
13
+ :data-source="tableDatas"
14
+ v-on="$listeners"
15
+ v-bind="setAttrs"
16
+ class="WebComponentTable__List"
17
+ >
18
+ <!-- 表格标题插槽 -->
19
+ <div v-if="$slots.ATableTitle" class="WebComponentTable__List__Title" ref="TableListTitle" slot="title">
20
+ <slot name="ATableTitle" />
21
+ </div>
20
22
 
21
- <template v-for="{ dataIndex } in $attrs.columns" #[dataIndex]>
22
- <!-- 自定义头部渲染 -->
23
- <slot :name="dataIndex" />
24
- </template>
25
-
26
- <template #customRender="text, record, i, column">
27
- <slot :name="column.dataIndex" :customProps="record" :text="text" :index="i" />
28
- </template>
29
- </Table>
23
+ <!-- 自定义头部渲染 -->
24
+ <template v-for="{ dataIndex } in $attrs.columns" #[dataIndex]>
25
+ <slot :name="dataIndex" />
26
+ </template>
30
27
 
31
- <div class="WebComponentTable__Pagination" ref="TablePagination">
32
- <slot name="ATablePagination">
33
- <Pagination
34
- size="small"
35
- :pageSizeOptions="pageSizeOptions"
36
- :show-total="total => `共 ${total} 条记录`"
37
- show-size-changer
38
- show-quick-jumper
39
- :defaultCurrent="1"
40
- :pageSize.sync="pagination.size"
41
- :current="pagination.current"
42
- @showSizeChange="paginationChange"
43
- @change="paginationChange"
44
- :total="pagination.total"
45
- />
46
- </slot>
47
- </div>
28
+ <!-- 新增:查看文件 -->
29
+ <template #checkFile="text, record, i, column">
30
+ <Button type="link" @click="handleCheckFile(record, column.props)">查看</Button>
31
+ </template>
32
+
33
+ <!-- 新增:携带自定义操作 -->
34
+ <template #viewOperate="text, record, i, column">
35
+ <Button type="link" @click="handleViewOperate(record, column)">
36
+ {{ column.customRender(record) || record[column.props] }}
37
+ </Button>
38
+ </template>
39
+
40
+ <!-- 自定义渲染插槽 -->
41
+ <template #customRender="text, record, i, column">
42
+ <slot
43
+ :name="column.dataIndex"
44
+ :customProps="record"
45
+ :text="text"
46
+ :index="i"
47
+ :column="column"
48
+ />
49
+ </template>
50
+ </Table>
48
51
 
52
+ <!-- 分页组件容器 -->
53
+ <div class="WebComponentTable__Pagination" ref="TablePagination">
54
+ <slot name="ATablePagination">
55
+ <Pagination
56
+ size="small"
57
+ :pageSizeOptions="pageSizeOptions"
58
+ :show-total="total => `共 ${total} 条记录`"
59
+ show-size-changer
60
+ show-quick-jumper
61
+ :defaultCurrent="1"
62
+ :pageSize.sync="pagination.size"
63
+ :current="pagination.current"
64
+ @showSizeChange="handlePaginationChange"
65
+ @change="handlePaginationChange"
66
+ :total="pagination.total"
67
+ />
68
+ </slot>
69
+ </div>
49
70
  </div>
50
71
  </template>
51
72
 
@@ -55,39 +76,24 @@ import IconFont from '../icon-font'
55
76
  import { Table, Pagination } from 'ant-design-vue/es'
56
77
 
57
78
  export default {
79
+ name: 'WTable',
58
80
  components: {
59
81
  Table,
60
82
  Pagination
61
- },
62
- name: 'WTable',
63
- data() {
64
- return {
65
- pagination: {
66
- total: 0,
67
- size: 10,
68
- current: 1
69
- },
70
- // 尺寸观察器
71
- resizeObserver: null,
72
- tableScrollBody: 600,
73
- /** 跨分页记录选中数据 */
74
- selectedRecords: []
75
- }
76
83
  },
77
84
  props: {
78
- // 紧凑型和宽松型
79
- // relax 宽松型
80
- // compact 紧凑型
81
85
  tableStyle: {
82
86
  type: String,
83
87
  default: 'compact'
84
88
  },
85
- // compact 紧凑型情况下是否有分割线
86
89
  tableSplit: {
87
90
  type: Boolean,
88
91
  default: true
89
92
  },
90
- // 表格数据
93
+ rowKey: {
94
+ type: String,
95
+ default: 'id'
96
+ },
91
97
  datas: {
92
98
  type: Array,
93
99
  default: () => []
@@ -96,12 +102,10 @@ export default {
96
102
  type: String,
97
103
  default: '-'
98
104
  },
99
- // 选中数据项
100
105
  selectedRowKeys: {
101
106
  type: Array,
102
107
  default: () => []
103
108
  },
104
- // 分页默认值
105
109
  paginationParams: {
106
110
  type: Object,
107
111
  default: () => ({
@@ -110,36 +114,54 @@ export default {
110
114
  current: 1
111
115
  })
112
116
  },
113
- // 配置分页数据
114
117
  pageSizeOptions: {
115
118
  type: Array,
116
119
  default: () => ['10', '15', '20', '30', '50']
117
120
  }
118
121
  },
122
+ data() {
123
+ return {
124
+ pagination: {
125
+ total: 0,
126
+ size: 10,
127
+ current: 1
128
+ },
129
+ resizeObserver: null,
130
+ tableScrollBody: 600,
131
+ selectedRecords: []
132
+ }
133
+ },
119
134
  computed: {
120
135
  setAttrs() {
121
136
  return {
122
137
  pagination: false,
123
- rowKey: (record, i) => record.id ?? `${this.pagination.current}${i}`,
124
- rowSelection: { selectedRowKeys: this.selectedRowKeys, onChange: this.onSelectChange },
138
+ rowKey: (record, i) => record[this.rowKey] ?? `${this.pagination.current}${i}`,
139
+ rowSelection: {
140
+ selectedRowKeys: this.selectedRowKeys,
141
+ onChange: this.handleSelectChange
142
+ },
125
143
  locale: {
126
- emptyText: <div class="WebComponentTable__List__Empty">
127
- <IconFont type="noData_data" />
128
- <span>暂无数据</span>
129
- </div>
144
+ emptyText: (
145
+ <div class="WebComponentTable__List__Empty">
146
+ <IconFont type="noData_data" />
147
+ <span>暂无数据</span>
148
+ </div>
149
+ )
150
+ },
151
+ scroll: {
152
+ y: this.tableScrollBody,
153
+ x: this.$attrs.scrollX
130
154
  },
131
- scroll: { y: this.tableScrollBody, x: this.$attrs.scrollX },
132
155
  ...this.$attrs
133
156
  }
134
157
  },
135
158
  tableSize() {
136
- return this.tableStyle == 'compact' ? 'middle' : 'default'
159
+ return this.tableStyle === 'compact' ? 'middle' : 'default'
137
160
  },
138
161
  tableDatas() {
139
- /** 字段数据为空则添加默认占位符 */
140
- const dataKeys = this.$attrs.columns.map(column => column.dataIndex)
162
+ const dataKeys = this.$attrs?.columns?.map(column => column.dataIndex) || []
141
163
  return this.datas.map(dataItem => {
142
- const cloneItem = {...dataItem}
164
+ const cloneItem = { ...dataItem }
143
165
  dataKeys.forEach(key => {
144
166
  const value = cloneItem[key]
145
167
  if (value === null || value === undefined ||
@@ -150,39 +172,42 @@ export default {
150
172
  return cloneItem
151
173
  })
152
174
  }
153
- },
175
+ },
154
176
  watch: {
155
- paginationParams(newValue) {
156
- this.pagination = { ...this.pagination, ...newValue }
177
+ paginationParams: {
178
+ handler(newValue) {
179
+ this.pagination = { ...this.pagination, ...newValue }
180
+ },
181
+ immediate: true
157
182
  }
158
183
  },
159
184
  mounted() {
160
- this.pagination = { ...this.pagination, ...this.paginationParams }
161
- // 监听父级高度
162
185
  this.initResizeObserver()
163
- setTimeout(this.getScrollBodyH, 300)
164
- this.$bus.$onWindow(this, 'resize', this.getScrollBodyH)
165
- this.removeDomElement()
166
- },
167
- destroyed() {
168
- if (this.resizeObserver) this.resizeObserver.disconnect()
186
+ this.$nextTick(() => {
187
+ setTimeout(this.getTableBodyHeight, 100)
188
+ })
189
+ this.$bus.$onWindow(this, 'resize', this.getTableBodyHeight)
190
+ },
191
+ beforeDestroy() {
192
+ if (this.resizeObserver) {
193
+ this.resizeObserver.disconnect()
194
+ this.resizeObserver = null
195
+ }
169
196
  },
170
197
  methods: {
171
- // 初始化尺寸观察器
172
198
  initResizeObserver() {
173
- if (typeof ResizeObserver !== 'undefined') {
199
+ if (typeof ResizeObserver !== 'undefined' && this.$refs.Table) {
174
200
  this.resizeObserver = new ResizeObserver(() => {
175
- this.getScrollBodyH()
201
+ this.getTableBodyHeight()
176
202
  })
177
203
  this.resizeObserver.observe(this.$refs.Table)
178
204
  }
179
205
  },
180
- /** 根据内容高度计算滚动长度 */
181
- getScrollBodyH() {
206
+ getTableBodyHeight() {
182
207
  if (!this.$refs.Table || !this.$refs.TableHead || !this.$refs.TablePagination) return
183
208
 
184
209
  const tableTitleHeight = this.$refs.TableListTitle ? this.$refs.TableListTitle.offsetHeight : 0
185
- const tableHeader = document.querySelector('.ant-table-thead')
210
+ const tableHeader = this.$refs.TableList.querySelector('.ant-table-thead')
186
211
  const headerHeight = tableHeader ? tableHeader.offsetHeight : 0
187
212
 
188
213
  this.tableScrollBody =
@@ -193,37 +218,49 @@ export default {
193
218
  tableTitleHeight -
194
219
  headerHeight -
195
220
  24 // 浮动空间缓冲
196
- /** 24为获取高度时抹掉的小数点后两位的浮动空间(存在叠加多个获取错误的情况) */
197
221
  },
198
- /** 根据高度判断dom元素是否加载 进行删除 */
199
- removeDomElement() {
200
- let domElement
201
- this.$refs.Table.querySelectorAll('div').forEach( node => {
202
- node.className == 'ant-table-title' && (domElement = node)
203
- } )
204
- !this.$scopedSlots.ATableHead && this.$refs.TableHead.remove()
205
- !this.$scopedSlots.ATableTitle && ( domElement.style.padding = '0' )
222
+ handleCheckFile(record, props) {
223
+ this.$postM({
224
+ type: 'customModal',
225
+ name: 'browse',
226
+ params: {
227
+ data: record[props]
228
+ }
229
+ })
206
230
  },
207
- onSelectChange(selectedKey, selectedRecord) {
208
- const currentIds = new Set(this.selectedRecords.map(r => r.id))
231
+ handleViewOperate(record, column) {
232
+ const { customOperate, customView } = column
233
+
234
+ if (typeof customOperate === 'function') return customOperate(record)
235
+ if (!customView || !customView.code) return
236
+
237
+ this.$postM({
238
+ name: customView.code,
239
+ method: 'modalOpen',
240
+ params: record
241
+ })
242
+ },
243
+ handleSelectChange(selectedKey, selectedRecord) {
244
+ const currentIds = new Set(this.selectedRecords.map(r => r[this.rowKey]))
209
245
  const newIds = new Set(selectedKey)
210
246
 
211
247
  this.selectedRecords = newIds.size > currentIds.size
212
- ? [...this.selectedRecords, ...selectedRecord.filter(r =>
213
- newIds.has(r.id) && !currentIds.has(r.id)
214
- )]
215
- : this.selectedRecords.filter(r => newIds.has(r.id))
248
+ ? [
249
+ ...this.selectedRecords,
250
+ ...selectedRecord.filter(r => newIds.has(r[this.rowKey]) && !currentIds.has(r[this.rowKey]))
251
+ ]
252
+ : this.selectedRecords.filter(r => newIds.has(r[this.rowKey]))
216
253
 
217
254
  this.$emit('selectedRecords', selectedKey, this.selectedRecords)
218
255
  },
219
- paginationChange(current, pageSize) {
256
+ handlePaginationChange(current, pageSize) {
220
257
  this.pagination = {
221
258
  ...this.pagination,
222
259
  size: pageSize,
223
260
  current
224
261
  }
225
262
  this.$emit('pageSizeChange', this.pagination)
226
- }
263
+ }
227
264
  }
228
265
  }
229
- </script>
266
+ </script>