sadais-piui 1.2.7-beta15 → 1.2.7-beta151

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 (75) hide show
  1. package/.prettierrc +8 -0
  2. package/components/pi-action-sheet/index.vue +260 -247
  3. package/components/pi-badge/index.vue +11 -1
  4. package/components/pi-bottom-bar/index.vue +1 -1
  5. package/components/pi-calendar/index.vue +207 -182
  6. package/components/pi-calendar-input/index.vue +61 -30
  7. package/components/pi-calendar-panel/components/calendar-days/index.vue +91 -52
  8. package/components/pi-calendar-panel/index.vue +28 -12
  9. package/components/pi-canvas/index.vue +8 -1
  10. package/components/pi-cascader/index.vue +601 -0
  11. package/components/pi-checkbox/index.vue +8 -4
  12. package/components/pi-checkbox-group/index.vue +12 -11
  13. package/components/pi-circle-progress/index.vue +53 -16
  14. package/components/pi-code-input/index.vue +11 -3
  15. package/components/pi-collapse/index.vue +16 -6
  16. package/components/pi-collapse-item/index.vue +35 -22
  17. package/components/pi-date-picker/index.vue +512 -391
  18. package/components/pi-date-picker-input/index.vue +61 -30
  19. package/components/pi-dropdown/components/dropdown-tab.vue +33 -23
  20. package/components/pi-dropdown/index.vue +34 -19
  21. package/components/pi-dropdown-item/index.vue +70 -58
  22. package/components/pi-form-item/index.vue +98 -20
  23. package/components/pi-grid/index.vue +1 -1
  24. package/components/pi-grid-item/index.vue +4 -4
  25. package/components/pi-img/index.vue +275 -267
  26. package/components/pi-img-cropper/index.vue +6 -3
  27. package/components/pi-input/index.vue +97 -36
  28. package/components/pi-list-item/index.vue +1 -1
  29. package/components/pi-marquee/index.vue +322 -310
  30. package/components/pi-marquee-pure-css/index.vue +267 -0
  31. package/components/pi-mask/index.vue +3 -1
  32. package/components/pi-modal/index.vue +311 -303
  33. package/components/pi-pagination/index.vue +13 -0
  34. package/components/pi-picker/index.vue +332 -317
  35. package/components/pi-popup/index.vue +4 -1
  36. package/components/pi-popup-select/index.vue +13 -4
  37. package/components/pi-radio/index.vue +12 -11
  38. package/components/pi-radio-group/index.vue +25 -5
  39. package/components/pi-regions-select/index.vue +6 -1
  40. package/components/pi-regions-select-input/index.vue +69 -31
  41. package/components/pi-search/index.vue +37 -2
  42. package/components/pi-section/index.vue +1 -1
  43. package/components/pi-select/index.vue +237 -22
  44. package/components/pi-select-input/index.vue +106 -41
  45. package/components/pi-stepper/index.vue +135 -121
  46. package/components/pi-steps/index.vue +115 -36
  47. package/components/pi-swiper/index.vue +22 -7
  48. package/components/pi-switch/index.vue +5 -1
  49. package/components/pi-table/index.vue +351 -0
  50. package/components/pi-tabs/index.vue +46 -10
  51. package/components/pi-upload-img/index.vue +895 -44
  52. package/components/pi-webview/index.vue +95 -82
  53. package/config/actionSheet.js +0 -1
  54. package/config/calendarInput.js +2 -1
  55. package/config/calendarPanel.js +2 -1
  56. package/config/cascader.js +22 -0
  57. package/config/circleProgress.js +12 -4
  58. package/config/codeInput.js +2 -1
  59. package/config/datePicker.js +29 -24
  60. package/config/datePickerInput.js +2 -1
  61. package/config/dropdown.js +3 -1
  62. package/config/input.js +5 -3
  63. package/config/marqueePureCss.js +18 -0
  64. package/config/regionsSelectInput.js +2 -1
  65. package/config/select.js +13 -1
  66. package/config/selectInput.js +2 -1
  67. package/config/steps.js +1 -1
  68. package/config/table.js +9 -0
  69. package/config/uploadImg.js +33 -11
  70. package/mixin/emitter.js +8 -1
  71. package/mixin/value-sync.js +5 -0
  72. package/package.json +5 -2
  73. package/scss/common.scss +11 -14
  74. package/scss/icon/icon.scss +2 -1
  75. package/scss/mixin.scss +5 -5
@@ -1,7 +1,7 @@
1
1
  <!--
2
2
  * @Author: zhouxianpan
3
3
  * @Date: 2021-09-06 10:07:33
4
- * @LastEditTime: 2021-11-23 16:45:30
4
+ * @LastEditTime: 2023-04-20 17:11:04
5
5
  * @LastEditors: zhangzhenfei
6
6
  * @Description:
7
7
  * @FilePath: \piui-awesome\src\piui\components\pi-circle-progress\index.vue
@@ -10,9 +10,10 @@
10
10
  <view
11
11
  class="circle-progress"
12
12
  :style="{
13
- width: widthPx + 'px',
14
- height: widthPx + 'px',
15
- backgroundColor: bgColor
13
+ width: parentWidthPx + 'px',
14
+ height: parentWidthPx + 'px',
15
+ backgroundColor: getType.bgColor,
16
+ borderRadius: '50%'
16
17
  }"
17
18
  >
18
19
  <canvas
@@ -84,7 +85,17 @@ export default {
84
85
  // 主题类型
85
86
  type: {
86
87
  type: String,
87
- default: circleProgress.type
88
+ default: circleProgress.type,
89
+ validator: function(value) {
90
+ return ['success', 'error', 'info', 'primary', 'warning'].includes(value)
91
+ }
92
+ },
93
+ // 主题列表
94
+ typeList: {
95
+ type: Object,
96
+ default() {
97
+ return circleProgress.typeList
98
+ }
88
99
  },
89
100
 
90
101
  // 字体大小
@@ -106,13 +117,18 @@ export default {
106
117
  },
107
118
  data() {
108
119
  return {
109
- // elBgId: 'pCircleProgressBgId', // 微信小程序中不能使用this.$pi形式动态生成id值,否则会报错
110
- // elId: 'pCircleProgressElId',
120
+ // #ifdef MP-WEIXIN
121
+ elBgId: 'pCircleProgressBgId', // 微信小程序中不能使用this.$pi形式动态生成id值,否则会报错
122
+ elId: 'pCircleProgressElId',
123
+ // #endif
124
+ // #ifndef MP-WEIXIN
111
125
  elBgId: this.$pi.guid(), // 支付宝等小程序 动态生产ID
112
126
  elId: this.$pi.guid(),
127
+ // #endif
113
128
  progressContext: null,
114
129
  // 开始的角度
115
130
  widthPx: uni.upx2px(this.width), // 转成px后的整个组件的背景宽度
131
+ parentWidthPx: uni.upx2px(this.width - this.borderWidth), // 转成px后容器的宽度
116
132
  borderWidthPx: uni.upx2px(this.borderWidth), // 转成px后的圆环的宽度
117
133
  startAngle: -Math.PI / 2, // canvas画圆的起始角度,默认为3点钟方向,定位到12点钟方向
118
134
  newPercent: 0, // 当动态修改进度值的时候,保存进度值的变化前后值,用于比较用
@@ -120,12 +136,29 @@ export default {
120
136
  }
121
137
  },
122
138
  computed: {
123
- // 有type主题时,优先起作用
124
- circleColor() {
125
- if (['success', 'error', 'info', 'primary', 'warning'].indexOf(this.type) >= 0)
126
- return this.$u.color[this.type]
127
- else return this.activeColor
139
+ /**
140
+ * 默认使用type配套样式success
141
+ * 如果有传入 进度条底部颜色、进度条颜色、背景颜色时就使用它们的
142
+ */
143
+ getType() {
144
+ const { type, inactiveColor, activeColor, bgColor } = this
145
+ // const typeData = this.$pi.lang.mergeDeep(this.typeList[type], {
146
+ // inactiveColor,
147
+ // activeColor,
148
+ // bgColor
149
+ // })
150
+ return {
151
+ inactiveColor: inactiveColor || this.typeList[type]['inactiveColor'],
152
+ activeColor: activeColor || this.typeList[type]['activeColor'],
153
+ bgColor: bgColor || this.typeList[type]['bgColor']
154
+ }
128
155
  }
156
+ // 有type主题时,优先起作用(弃用)
157
+ // circleColor() {
158
+ // if (['success', 'error', 'info', 'primary', 'warning'].indexOf(this.type) >= 0)
159
+ // return this.$u.color[this.type]
160
+ // else return this.activeColor
161
+ // }
129
162
  },
130
163
  watch: {
131
164
  // 深度监听进度
@@ -156,10 +189,11 @@ export default {
156
189
  },
157
190
  methods: {
158
191
  drawProgressBg() {
159
- console.log(this)
192
+ // console.log(this)
160
193
  let ctx = uni.createCanvasContext(this.elBgId, this)
161
194
  ctx.setLineWidth(this.borderWidthPx) // 设置圆环宽度
162
- ctx.setStrokeStyle(this.inactiveColor) // 线条颜色
195
+ // ctx.setStrokeStyle(this.inactiveColor) // 线条颜色
196
+ ctx.setStrokeStyle(this.getType.inactiveColor) // 线条颜色
163
197
  ctx.beginPath() // 开描绘路径
164
198
  // 设置一个原点(110,110),半径为100的圆的路径到当前路径
165
199
  let radius = this.widthPx / 2
@@ -201,7 +235,8 @@ export default {
201
235
  ctx.stroke()
202
236
  }
203
237
  } else {
204
- ctx.setStrokeStyle(this.circleColor)
238
+ // ctx.setStrokeStyle(this.circleColor)
239
+ ctx.setStrokeStyle(this.getType.activeColor)
205
240
  // 结束角的计算依据为:将2π分为100份,乘以当前的进度值,得出终止点的弧度值,加起始角,为整个圆从默认的
206
241
  // 3点钟方向开始画图,转为更好理解的12点钟方向开始作图,这需要起始角和终止角同时加上this.startAngle值
207
242
  let endAngle = ((2 * Math.PI) / 100) * progress + this.startAngle
@@ -238,14 +273,16 @@ export default {
238
273
  },
239
274
  createColorData() {
240
275
  let canvas
276
+ let ctx
241
277
  // #ifndef MP-WEIXIN
242
278
  canvas = document.createElement('canvas')
243
279
  canvas.width = 256
244
280
  canvas.height = 1
245
- let ctx = canvas.getContext('2d')
281
+ ctx = canvas.getContext('2d')
246
282
  // #endif
247
283
  // #ifdef MP-WEIXIN
248
284
  canvas = uni.createOffscreenCanvas({ type: '2d', width: 256, height: 1 })
285
+ ctx = canvas.getContext('2d')
249
286
  // #endif
250
287
  const linearGradient = ctx.createLinearGradient(0, 0, 256, 1)
251
288
  this.linearGradient.colorStop.forEach(color => {
@@ -5,7 +5,7 @@
5
5
  type="number"
6
6
  :value="val"
7
7
  :focus="focus"
8
- :disabled="disabled"
8
+ :disabled="getDisabled"
9
9
  :maxlength="getLength"
10
10
  @focus="focus = true"
11
11
  @blur="focus = false"
@@ -137,12 +137,15 @@ export default {
137
137
  default() {
138
138
  return codeInput.codeFormat
139
139
  }
140
+ },
141
+ disabled: {
142
+ type: Boolean,
143
+ default: codeInput.disabled
140
144
  }
141
145
  },
142
146
  data() {
143
147
  return {
144
148
  focus: false,
145
- disabled: false,
146
149
  data() {
147
150
  return {
148
151
  val: this.value
@@ -165,7 +168,12 @@ export default {
165
168
  },
166
169
  getAlign() {
167
170
  return ALIGN_MAP[this.align]
168
- }
171
+ },
172
+ getDisabled() {
173
+ const parentFormItem = this.$pi.parent(this, 'PiFormItem')
174
+ const disabled = this.disabled || (parentFormItem && parentFormItem.getDisabled)
175
+ return disabled
176
+ },
169
177
  },
170
178
  mounted() {
171
179
  if (this.autoFocus) {
@@ -6,6 +6,7 @@
6
6
  </template>
7
7
 
8
8
  <script>
9
+ import ValueSync from '../../mixin/value-sync'
9
10
  import { getConfig } from '../../config'
10
11
  const { collapse } = getConfig()
11
12
  /**
@@ -17,6 +18,8 @@ const { collapse } = getConfig()
17
18
  */
18
19
  export default {
19
20
  name: 'PiCollapse',
21
+ // 混入v-model
22
+ mixins: [ValueSync],
20
23
  props: {
21
24
  // 当前展开面板的name,非手风琴模式:[<string | number>],手风琴模式:string | number
22
25
  value: {
@@ -56,8 +59,12 @@ export default {
56
59
  }
57
60
  },
58
61
  watch: {
59
- needInit() {
60
- this.init()
62
+ needInit: {
63
+ deep: true,
64
+ immediate: false,
65
+ handler(value) {
66
+ this.init()
67
+ }
61
68
  },
62
69
  // 当父组件需要子组件需要共享的参数发生了变化,手动通知子组件
63
70
  parentData() {
@@ -75,9 +82,11 @@ export default {
75
82
  methods: {
76
83
  // 重新初始化一次内部的所有子元素
77
84
  init() {
78
- this.children.map(child => {
79
- child.init()
80
- })
85
+ console.log('折叠面板初始化')
86
+ this.children &&
87
+ this.children.map(child => {
88
+ child.init()
89
+ })
81
90
  },
82
91
  /**
83
92
  * collapse-item被点击时触发,由collapse统一处理各子组件的状态
@@ -104,7 +113,8 @@ export default {
104
113
  })
105
114
  })
106
115
  // 触发change事件
107
- this.$emit('change', changeArr)
116
+ this.val = changeArr
117
+ this.handleEmitChange()
108
118
  this.$emit(target.expanded ? 'open' : 'close', target.name)
109
119
  }
110
120
  }
@@ -1,14 +1,10 @@
1
1
  <template>
2
- <view
3
- class="pi-collapse-item"
4
- :class="[customClass]"
5
- :style="[customStyle]"
6
- @click="clickHandler"
7
- >
2
+ <view class="pi-collapse-item" :class="[customClass]" :style="[customStyle]">
8
3
  <!-- 标题 -->
9
4
  <view
10
5
  class="pi-collapse-item__title pi-justify-between pi-align-center"
11
6
  :class="{ disabled: disabled, border: border }"
7
+ @tap="handleCollapseItemClick"
12
8
  >
13
9
  <!-- 左侧 -->
14
10
  <view class="pi-flex-column pi-lh-44">
@@ -32,8 +28,17 @@
32
28
  </view>
33
29
  </view>
34
30
  <!-- 内容 -->
35
- <view ref="animation" class="pi-collapse-item__content" :animation="animationData">
36
- <view :id="elId" :ref="elId" class="pi-collapse-item__content__text content-class">
31
+ <view
32
+ ref="animation"
33
+ class="pi-collapse-item__content"
34
+ :animation="animationData"
35
+ @tap="handleContentClick"
36
+ >
37
+ <view
38
+ :id="elId"
39
+ :ref="elId"
40
+ class="pi-collapse-item__content__text content-class"
41
+ >
37
42
  <slot />
38
43
  </view>
39
44
  </view>
@@ -113,7 +118,7 @@ export default {
113
118
  // uni.createAnimation的导出数据
114
119
  animationData: {},
115
120
  // 是否展开状态
116
- expanded: false,
121
+ expanded: true,
117
122
  // 根据expanded确定是否显示border,为了控制展开时,cell的下划线更好的显示效果,进行一定时间的延时
118
123
  showBorder: false,
119
124
  // 是否动画中,如果是则不允许继续触发点击
@@ -163,22 +168,27 @@ export default {
163
168
  if (!this.parent) {
164
169
  return console.error('pi-collapse-item必须要搭配pi-collapse组件使用')
165
170
  }
166
- const { value, accordion } = this.parent
171
+ const { val, accordion } = this.parent
167
172
  if (accordion) {
168
- if (this.$pi.lang.isArray(value)) {
169
- return console.error('手风琴模式下,pi-collapse组件的value参数不能为数组')
173
+ if (this.$pi.lang.isArray(val)) {
174
+ return console.error(
175
+ '手风琴模式下,pi-collapse组件的value参数不能为数组'
176
+ )
170
177
  }
171
- this.expanded = this.name == value
178
+ this.expanded = this.name == val
172
179
  } else {
173
- if (!this.$pi.lang.isArray(value) && value !== null) {
174
- return console.error('非手风琴模式下,pi-collapse组件的value参数必须为数组')
180
+ if (!this.$pi.lang.isArray(val) && val !== null) {
181
+ return console.error(
182
+ '非手风琴模式下,pi-collapse组件的value参数必须为数组'
183
+ )
175
184
  }
176
- this.expanded = (value || []).some(item => item == this.name)
185
+ this.expanded = (val || []).some(item => item == this.name)
177
186
  }
187
+ console.log('折叠面板item初始化', val, accordion, this.expanded)
178
188
  // 设置组件的展开或收起状态
179
- this.$nextTick(function () {
189
+ setTimeout(() => {
180
190
  this.setContentAnimate()
181
- })
191
+ }, 200)
182
192
  },
183
193
  updateParentData() {
184
194
  // 传组件Name给父组件,用于组件展开或收起时,改变父组件的值
@@ -227,8 +237,11 @@ export default {
227
237
  })
228
238
  // #endif
229
239
  },
240
+ handleContentClick() {
241
+ this.$emit('content-click')
242
+ },
230
243
  // 点击collapsehead头部
231
- clickHandler() {
244
+ handleCollapseItemClick() {
232
245
  if (this.disabled || this.animating) return
233
246
  // 设置本组件为相反的状态
234
247
  this.parent && this.parent.onChange(this)
@@ -269,7 +282,8 @@ export default {
269
282
  this.parent = this.$pi.parent(this, parentName)
270
283
  if (this.parent.children) {
271
284
  // 如果父组件的children不存在本组件的实例,才将本实例添加到父组件的children中
272
- this.parent.children.indexOf(this) === -1 && this.parent.children.push(this)
285
+ this.parent.children.indexOf(this) === -1 &&
286
+ this.parent.children.push(this)
273
287
  }
274
288
  if (this.parent && this.parentData) {
275
289
  // 历遍parentData中的属性,将parent中的同名属性赋值给parentData
@@ -326,7 +340,6 @@ export default {
326
340
  }
327
341
  }
328
342
  &.disabled {
329
- cursor: not-allowed;
330
343
  .text,
331
344
  .icon {
332
345
  color: #cccccc;
@@ -335,7 +348,7 @@ export default {
335
348
  }
336
349
  &__content {
337
350
  overflow: hidden;
338
- height: 0;
351
+ height: auto;
339
352
 
340
353
  &__text {
341
354
  padding: 24rpx 30rpx;