sadais-piui 1.2.7-beta64 → 1.2.7-beta66

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.
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <view class="table-wrap">
2
+ <view class="table-wrap" :class="{ bounce }">
3
3
  <view class="table">
4
4
  <view class="row">
5
5
  <view
@@ -7,7 +7,13 @@
7
7
  :key="idx"
8
8
  class="head"
9
9
  :class="{ fixed: !!col.fixed }"
10
- :style="[col.style, cellStyle, leftMap[idx], rightMap[idx]]"
10
+ :style="[
11
+ col.style,
12
+ cellPaddingStyle,
13
+ headStyle,
14
+ leftMap[idx],
15
+ rightMap[idx],
16
+ ]"
11
17
  >
12
18
  {{ col.name }}
13
19
  </view>
@@ -25,7 +31,7 @@
25
31
  :key="colIdx"
26
32
  class="cell"
27
33
  :class="{ fixed: !!col.fixed }"
28
- :style="[leftMap[colIdx], rightMap[colIdx]]"
34
+ :style="[cellStyle, leftMap[colIdx], rightMap[colIdx]]"
29
35
  >
30
36
  <view
31
37
  class="cell-content-wrap-ph"
@@ -50,16 +56,49 @@
50
56
  :src="row[col.prop]"
51
57
  :style="[col.slot.style]"
52
58
  />
53
- <view v-else-if="col.slot && col.slot.type === 'link'" class="pi-align-center">
54
- <text v-for="(link, linkIdx) in col.slot.links" :key="linkIdx" class="link" :style="[link.style]">{{ link.name }}</text>
59
+ <view
60
+ v-else-if="col.slot && col.slot.type === 'link'"
61
+ class="pi-align-center"
62
+ >
63
+ <text
64
+ v-for="(link, linkIdx) in col.slot.links"
65
+ :key="linkIdx"
66
+ class="link"
67
+ :style="[link.style]"
68
+ >{{ link.name }}</text
69
+ >
55
70
  </view>
56
71
  <block v-else>{{ row[col.prop] }}</block>
57
72
  </view>
58
73
  <view class="cell-content-wrap" :style="[cellContentWrapStyle]">
59
- <image v-if="col.slot && col.slot.type === 'img'" :src="row[col.prop]" :style="[col.slot.style]" />
60
- <image v-else-if="col.slot && col.slot.type === 'rank' && idx < col.slot.condition" :src="row[col.prop]" :style="[col.slot.style]" />
61
- <view v-else-if="col.slot && col.slot.type === 'link'" class="pi-align-center">
62
- <text v-for="(link, linkIdx) in col.slot.links" :key="linkIdx" class="link" :style="[link.style]" @click="handleClickLink({ row, link, linkIdx, rowIdx: idx })">{{ link.name }}</text>
74
+ <image
75
+ v-if="col.slot && col.slot.type === 'img'"
76
+ :src="row[col.prop]"
77
+ :style="[col.slot.style]"
78
+ />
79
+ <image
80
+ v-else-if="
81
+ col.slot &&
82
+ col.slot.type === 'rank' &&
83
+ idx < col.slot.condition
84
+ "
85
+ :src="row[col.prop]"
86
+ :style="[col.slot.style]"
87
+ />
88
+ <view
89
+ v-else-if="col.slot && col.slot.type === 'link'"
90
+ class="pi-align-center"
91
+ >
92
+ <text
93
+ v-for="(link, linkIdx) in col.slot.links"
94
+ :key="linkIdx"
95
+ class="link"
96
+ :style="[link.style]"
97
+ @click="
98
+ handleClickLink({ row, link, linkIdx, rowIdx: idx })
99
+ "
100
+ >{{ link.name }}</text
101
+ >
63
102
  </view>
64
103
  <block v-else>{{ row[col.prop] }}</block>
65
104
  </view>
@@ -77,6 +116,13 @@ const { table: tableConfig } = getConfig();
77
116
  export default {
78
117
  name: "PiTable",
79
118
  props: {
119
+ // 是否开启滚动反弹效果
120
+ bounce: {
121
+ // `Boolean`
122
+ type: Boolean,
123
+ // `false`
124
+ default: tableConfig.bounce,
125
+ },
80
126
  // 列配置项
81
127
  columns: {
82
128
  type: Array,
@@ -99,6 +145,18 @@ export default {
99
145
  // `true`
100
146
  default: tableConfig.stripe,
101
147
  },
148
+ // 头部样式
149
+ headStyle: {
150
+ type: Object,
151
+ // `{}`
152
+ default: () => tableConfig.headStyle,
153
+ },
154
+ // 单元格样式
155
+ cellStyle: {
156
+ type: Object,
157
+ // `{}`
158
+ default: () => tableConfig.cellStyle,
159
+ },
102
160
  },
103
161
  data() {
104
162
  return {
@@ -108,7 +166,7 @@ export default {
108
166
  };
109
167
  },
110
168
  computed: {
111
- cellStyle() {
169
+ cellPaddingStyle() {
112
170
  return {
113
171
  padding: `${this.cellPadding}rpx`,
114
172
  };
@@ -165,15 +223,15 @@ export default {
165
223
  rightMap[i] = { right: isRight(col) ? `${right}px` : "auto" };
166
224
  right += isRight(col) ? list[i].width : 0;
167
225
  }
168
- this.leftMap = leftMap
169
- this.rightMap = rightMap
170
- })
226
+ this.leftMap = leftMap;
227
+ this.rightMap = rightMap;
228
+ });
171
229
  },
172
230
  handleClickLink(info) {
173
- this.$emit('link', info)
174
- }
175
- }
176
- }
231
+ this.$emit("link", info);
232
+ },
233
+ },
234
+ };
177
235
  </script>
178
236
 
179
237
  <style lang="scss" scoped>
@@ -181,6 +239,10 @@ export default {
181
239
  position: relative;
182
240
  width: 100%;
183
241
  overflow: auto hidden;
242
+ overscroll-behavior: none;
243
+ &.bounce {
244
+ overscroll-behavior: auto;
245
+ }
184
246
  }
185
247
  .table {
186
248
  display: table;
package/config/table.js CHANGED
@@ -2,5 +2,8 @@ export default {
2
2
  columns: [],
3
3
  data: [],
4
4
  emptyText: '暂无数据',
5
- stripe: true
5
+ stripe: true,
6
+ headStyle: {},
7
+ cellStyle: {},
8
+ bounce: false
6
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sadais-piui",
3
- "version": "1.2.7-beta64",
3
+ "version": "1.2.7-beta66",
4
4
  "description": "piui组件库",
5
5
  "main": "index.js",
6
6
  "scripts": {