sadais-piui 1.2.7-beta15 → 1.2.7-beta16

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.
@@ -8,42 +8,56 @@
8
8
  :class="[itemClass, item.mode, direction, { active: index < val }]"
9
9
  >
10
10
  <view class="step-icon pi-flex-row-center" :style="[item.style]">
11
- <template v-if="item.mode === 'dot'">
12
- <view class="item-dot pi-radius-round" :style="[item.dotStyle]" />
13
- </template>
14
- <!-- 数字-->
15
- <template v-if="item.mode === 'number'">
16
- <text v-if="index >= val">
17
- {{ index + 1 }}
18
- </text>
19
- <pi-icon v-else name="check" color="#ffffff" />
20
- </template>
21
- <!-- 图标 -->
22
- <pi-icon
23
- v-if="item.mode === 'icon'"
24
- :custom-style="item.icon.customStyle"
25
- :custom-class="item.icon.customClass"
26
- :name="item.icon.name"
27
- :dot="item.icon.dot"
28
- :dot-radius="item.icon.dotRadius"
29
- :badge="item.icon.badge"
30
- :color="item.icon.color"
31
- :size="item.icon.size"
32
- :class-prefix="item.icon.classPrefix"
33
- />
11
+ <view class="step-icon-inner">
12
+ <template v-if="item.mode === 'dot'">
13
+ <view class="item-dot pi-radius-round" :style="[item.dotStyle]" />
14
+ </template>
15
+ <!-- 数字-->
16
+ <template v-if="item.mode === 'number'">
17
+ <text v-if="index >= val">
18
+ {{ index + 1 }}
19
+ </text>
20
+ <pi-icon v-else name="check" color="#ffffff" />
21
+ </template>
22
+ <!-- 图标 -->
23
+ <pi-icon
24
+ v-if="item.mode === 'icon'"
25
+ :custom-style="item.icon.customStyle"
26
+ :custom-class="item.icon.customClass"
27
+ :name="item.icon.name"
28
+ :dot="item.icon.dot"
29
+ :dot-radius="item.icon.dotRadius"
30
+ :badge="item.icon.badge"
31
+ :color="item.icon.color"
32
+ :size="item.icon.size"
33
+ :class-prefix="item.icon.classPrefix"
34
+ />
35
+ </view>
34
36
  </view>
35
37
 
36
38
  <!-- 文字 -->
37
39
  <view :class="['pi-steps-item-text']" :style="{ color: item.style.fontColor }">
38
40
  <slot name="item" :item="item" :index="index" :active="index < val">
39
41
  <view>{{ item.name }}</view>
40
- <text class="pi-fz-20" style="word-break:break-all">{{ item.desc }}</text>
42
+ <text v-if="item.desc" class="pi-fz-20 pi-mg-top-10" style="word-break:break-all">
43
+ {{ item.desc }}
44
+ </text>
41
45
  </slot>
42
46
  </view>
43
47
 
44
48
  <!-- 中线 -->
45
- <view v-if="index < items.length - 1" class="pi-steps-item-line" :style="[lineStyle]">
46
- <pi-line :direction="direction" length="100%" :hair-line="false" :color="color" />
49
+ <view
50
+ v-if="index < items.length - 1"
51
+ class="pi-steps-item-line"
52
+ :style="[lineStyle, item.lineStyle]"
53
+ >
54
+ <pi-line
55
+ :direction="direction"
56
+ length="100%"
57
+ :hair-line="false"
58
+ :color="item.icon.color"
59
+ border-style="dashed"
60
+ />
47
61
  </view>
48
62
  </view>
49
63
  </view>
@@ -138,7 +152,10 @@ export default {
138
152
  }
139
153
  },
140
154
  data() {
141
- return {}
155
+ return {
156
+ iconsRect: [],
157
+ itemsRect: []
158
+ }
142
159
  },
143
160
  computed: {
144
161
  getDotMaxSize() {
@@ -191,16 +208,18 @@ export default {
191
208
  } else {
192
209
  style.backgroundColor = this.getCurrentColor
193
210
  }
211
+ item.icon.color = this.getCurrentColor
194
212
  } else if (index < this.val && this.activeColor) {
195
213
  // 已激活步骤
196
214
  style.fontColor = this.activeColor
197
215
  if (item.mode === 'icon') {
198
216
  style.color = this.activeColor
199
217
  } else if (item.mode === 'dot') {
200
- item.dotStyle.backgroundColor = this.getCurrentColor
218
+ item.dotStyle.backgroundColor = this.activeColor
201
219
  } else {
202
220
  style.backgroundColor = this.activeColor
203
221
  }
222
+ item.icon.color = this.activeColor
204
223
  } else if (index > this.val) {
205
224
  // 未激活步骤
206
225
  style.fontColor = this.color
@@ -213,14 +232,47 @@ export default {
213
232
  if (item.mode === 'number') {
214
233
  style.backgroundColor = this.color
215
234
  }
235
+ item.icon.color = this.color
216
236
  }
217
237
  item.style = style
238
+ item.lineStyle = {}
239
+ if (
240
+ this.direction === 'column' &&
241
+ this.itemsRect.length &&
242
+ this.iconsRect.length &&
243
+ index < this.itemsRect.length - 1
244
+ ) {
245
+ // 动态计算线的位置和高度
246
+ item.lineStyle.top = `${this.iconsRect[index].top -
247
+ this.itemsRect[index].top +
248
+ this.iconsRect[index].height +
249
+ 2}px`
250
+ item.lineStyle.height = `${this.itemsRect[index].height -
251
+ this.iconsRect[index + 1].height}px`
252
+ }
218
253
  return item
219
254
  })
220
255
  }
221
256
  },
222
- watch: {},
223
- methods: {}
257
+ watch: {
258
+ items: {
259
+ deep: true,
260
+ immediate: false,
261
+ handler(value) {
262
+ this.init()
263
+ }
264
+ }
265
+ },
266
+ mounted() {
267
+ this.init()
268
+ },
269
+ methods: {
270
+ async init() {
271
+ this.iconsRect = await this.$pi.common.queryRect(this, '.step-icon-inner', true)
272
+ this.itemsRect = await this.$pi.common.queryRect(this, '.pi-steps-item', true)
273
+ console.log(TAG, '计算.pi-steps布局', this.itemsRect, this.iconsRect)
274
+ }
275
+ }
224
276
  }
225
277
  </script>
226
278
 
@@ -256,7 +308,7 @@ export default {
256
308
  display: flex;
257
309
  flex-direction: row;
258
310
  justify-content: flex-start;
259
- align-items: center;
311
+ align-items: baseline;
260
312
  min-height: 120rpx;
261
313
  .pi-steps-item-text {
262
314
  width: 95%;
@@ -266,15 +318,15 @@ export default {
266
318
  }
267
319
  .pi-steps-item-line {
268
320
  position: absolute;
269
- top: 75%;
270
321
  z-index: 0;
271
- height: 50%;
272
322
  }
273
323
  }
274
324
  .item-dot,
275
325
  .step-icon {
276
326
  border-radius: 50%;
277
327
  overflow: hidden;
328
+ position: relative;
329
+ z-index: 2;
278
330
  }
279
331
 
280
332
  &.active {
package/config/steps.js CHANGED
@@ -5,7 +5,7 @@ export default {
5
5
  customStyle: {}, // 自定义样式,对象形式(默认值:{})
6
6
  items: [], // 选项列表,默认([])
7
7
  mode: 'dot', // 步骤条的类型,默认('dot')
8
- activeColor: '', // 激活步骤的颜色
8
+ activeColor: '#5a7dff', // 激活步骤的颜色
9
9
  color: '#cccccc', // 未激活的颜色
10
10
  currentColor: '#666666', // 当前步骤的颜色
11
11
  direction: 'row', // 排列方向
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sadais-piui",
3
- "version": "1.2.7beta15",
3
+ "version": "1.2.7beta16",
4
4
  "description": "piui组件库",
5
5
  "main": "index.js",
6
6
  "scripts": {