sadais-piui 1.2.7-beta2 → 1.2.7-beta20

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.
@@ -4,17 +4,21 @@
4
4
  <view
5
5
  v-for="item in options"
6
6
  :key="item[getKeyField]"
7
- class="item-wrap pi-pd-tb-24 pi-pd-lr-32 pi-w-100P pi-justify-between pi-align-center"
8
- :class="[customClass, item[getDisabledField] ? 'disabled' : '']"
7
+ class="item-wrap pi-pd-tb-24 pi-pd-lr-32 pi-w-100P pi-align-center"
8
+ :class="[
9
+ customClass,
10
+ item[getDisabledField] ? 'disabled' : '',
11
+ getSelectedCheckbox === 'none' ? 'pi-justify-center' : 'pi-justify-between'
12
+ ]"
9
13
  :style="[customStyle, getItemStyle]"
10
14
  @tap="handleSelectItem(item)"
11
15
  >
12
- <view>
16
+ <view :class="[{ 'pi-primary': item[keyField] === val }]">
13
17
  {{ item[getDisplayField] }}
14
18
  </view>
15
19
  <!-- 如果配置了图片地址,使用图片 -->
16
20
  <pi-img
17
- v-if="getSelectedImg.src && item.id === val"
21
+ v-if="getSelectedImg.src && item[keyField] === val"
18
22
  :src="getSelectedImg.src"
19
23
  :mode="getSelectedImg.mode"
20
24
  :width="getSelectedImg.width"
@@ -34,9 +38,9 @@
34
38
  />
35
39
  <!-- 默认使用复选框 -->
36
40
  <pi-checkbox
37
- v-if="!getSelectedImg.src"
41
+ v-if="!getSelectedImg.src && getSelectedCheckbox !== 'none'"
38
42
  readonly
39
- :value="item.id === val"
43
+ :value="item[keyField] === val"
40
44
  :name="getSelectedCheckbox.name"
41
45
  :shape="getSelectedCheckbox.shape"
42
46
  :border-radius="getSelectedCheckbox.borderRadius"
@@ -148,7 +152,7 @@ export default {
148
152
  },
149
153
  // 选中checkbox配置
150
154
  selectedCheckbox: {
151
- type: Object,
155
+ type: [Object, String],
152
156
  default() {
153
157
  // 参照checkbox
154
158
  return dropdownItem.selectedCheckbox
@@ -185,6 +189,9 @@ export default {
185
189
  return this.$pi.lang.mergeDeep(selectedImg, this.selectedImg)
186
190
  },
187
191
  getSelectedCheckbox() {
192
+ if (this.inheritProps.selectedCheckbox === 'none') {
193
+ return this.inheritProps.selectedCheckbox
194
+ }
188
195
  const selectedCheckbox = this.inheritProps.selectedCheckbox || dropdownItem.selectedCheckbox
189
196
  return this.$pi.lang.mergeDeep(selectedCheckbox, this.selectedCheckbox)
190
197
  },
@@ -203,7 +210,7 @@ export default {
203
210
  if (item[this.getDisabledField]) {
204
211
  return
205
212
  }
206
- this.emitChange(item.id)
213
+ this.emitChange(item[this.getKeyField])
207
214
  setTimeout(() => {
208
215
  this._parent.submit()
209
216
  }, 300) // 延迟 可见按钮点击动画
@@ -234,10 +234,11 @@ export default {
234
234
  },
235
235
  watch: {
236
236
  rules: {
237
- handler(val) {
238
- this.validRules = val
239
- },
240
- deep: true
237
+ deep: true,
238
+ immediate: true,
239
+ handler(value) {
240
+ this.setRules(value)
241
+ }
241
242
  }
242
243
  },
243
244
  methods: {
@@ -449,7 +449,10 @@ export default {
449
449
  resolve(_getResolve())
450
450
  })
451
451
  .catch(({ errors, fields }) => {
452
- console.log(TAG, '表单校验失败', this.prop, errors, fields)
452
+ console.log(TAG, '表单校验失败', `字段名:${this.prop},字段值:${fieldValue}`)
453
+ console.log(TAG, '字段值:', fieldValue)
454
+ console.log(TAG, '错误信息', errors)
455
+ console.log(TAG, '校验规则', fields)
453
456
  // 记录状态和报错信息
454
457
  this.validateState = 'error'
455
458
  this.validateMessage = errors ? errors[0].message : ''
@@ -328,8 +328,8 @@ export default {
328
328
  handleChange(value) {
329
329
  this.val = value
330
330
  this.handleEmitChange()
331
- this.dispatch('PiForm', 'form-change', value)
332
- this.dispatch('PiFormItem', 'form-change', value)
331
+ this.dispatch('PiForm', 'form-change', this.val)
332
+ this.dispatch('PiFormItem', 'form-change', this.val)
333
333
  }
334
334
  }
335
335
  }
@@ -10,13 +10,12 @@
10
10
  { stretch: getStretch },
11
11
  customClass
12
12
  ]"
13
- @tap="handleRadioToggle(true)"
14
13
  >
15
14
  <view
16
15
  v-if="!['text', 'button'].includes(getShape)"
17
16
  class="radio-icon"
18
17
  :style="[radioStyle]"
19
- @tap.stop="handleRadioToggle(false)"
18
+ @tap="handleRadioToggle(false)"
20
19
  >
21
20
  <view v-if="getShape === 'dot'" class="dot" />
22
21
  <pi-icon v-else name="blod-check" :size="getIconSize" />
@@ -26,6 +25,7 @@
26
25
  class="radio-label"
27
26
  :class="[getShape]"
28
27
  :style="[textStyle]"
28
+ @tap="handleRadioToggle(true)"
29
29
  >
30
30
  <slot />
31
31
  </view>
@@ -15,6 +15,7 @@
15
15
  </template>
16
16
 
17
17
  <script>
18
+ import Emitter from '../../mixin/emitter'
18
19
  import ValueSync from '../../mixin/value-sync'
19
20
  import { parentInit } from '../../mixin/props-sync'
20
21
  import { getConfig } from '../../config'
@@ -26,6 +27,7 @@ export default {
26
27
  name: 'PiRadioGroup',
27
28
  // 混入自定义样式customStyle和customClass
28
29
  mixins: [
30
+ Emitter,
29
31
  ValueSync,
30
32
  // parentInit 混入子组件要继承的属性
31
33
  parentInit([
@@ -181,6 +183,8 @@ export default {
181
183
  this.val = childName
182
184
  }
183
185
  this.handleEmitChange()
186
+ this.dispatch('PiForm', 'form-change', this.val)
187
+ this.dispatch('PiFormItem', 'form-change', this.val)
184
188
  }
185
189
  }
186
190
  }
@@ -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 {
@@ -13,7 +13,7 @@
13
13
  activeIndex === index && activeTextColor ? { color: activeTextColor } : {},
14
14
  activeIndex === index && activeItemStyle ? activeItemStyle : {}
15
15
  ]"
16
- class="pi-tab pi-align-center"
16
+ class="pi-tab pi-justify-center pi-align-center "
17
17
  :class="[
18
18
  {
19
19
  disabled: item[disabledField],
@@ -283,7 +283,8 @@ export default {
283
283
  width: this.getSliderBarWidth,
284
284
  height: this.getSliderBarHeight,
285
285
  borderRadius: this.getSliderBarRadius,
286
- transitionDuration: duration.css
286
+ transitionDuration: duration.css,
287
+ ...this.sliderBarStyle
287
288
  }
288
289
  let sliderScrollLeft = this.activeRect.left
289
290
  if (style.width !== 'auto') {
@@ -355,7 +356,7 @@ export default {
355
356
  white-space: nowrap;
356
357
  .pi-tab {
357
358
  position: relative;
358
- display: inline-block;
359
+ display: inline-flex;
359
360
  font-size: 30rpx;
360
361
  text-align: center;
361
362
  transition: all $pi-animation-duration $pi-animation-timing-function;