sadais-piui 1.2.6-beta6 → 1.2.6

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,174 @@
1
+ <template>
2
+ <view
3
+ class="pi-bubble pi-rela pi-flex pi-align-center pi-justify-center"
4
+ :style="[customStyle]"
5
+ :class="customClass"
6
+ @longpress.stop="handleLongpress"
7
+ >
8
+ <slot />
9
+ <view v-show="showBubble" class="pi-bubble-wrapper" :class="[bubbleClass]">
10
+ <view
11
+ ref="bubble"
12
+ class="pi-bubble-content pi-abso pi-bg-white pi-radius-4 pi-pd-20"
13
+ :style="[bubbleStyle]"
14
+ >
15
+ <slot name="bubble" />
16
+ <view class="pi-bubble-angle pi-abso" />
17
+ </view>
18
+ </view>
19
+ <pi-mask v-model="showMaks" background="transparent" @close="showBubble = false" />
20
+ </view>
21
+ </template>
22
+
23
+ <script>
24
+ /**
25
+ * bubble 气泡弹窗
26
+ */
27
+ import { getConfig } from '../../config'
28
+ const TAG = 'PiBubble'
29
+ const { bubble } = getConfig()
30
+
31
+ // 底部栏
32
+ export default {
33
+ name: 'PiBubble',
34
+ props: {
35
+ // 自定义样式,对象形式
36
+ customStyle: {
37
+ type: Object,
38
+ // {}
39
+ default() {
40
+ return bubble.customStyle
41
+ }
42
+ },
43
+ customClass: {
44
+ type: String,
45
+ // ''
46
+ default() {
47
+ return bubble.customClass
48
+ }
49
+ },
50
+ position: {
51
+ type: String,
52
+ default() {
53
+ return bubble.position
54
+ }
55
+ },
56
+ zIndex: {
57
+ type: Number,
58
+ default() {
59
+ return bubble.zIndex
60
+ }
61
+ }
62
+ },
63
+ data() {
64
+ return {
65
+ showBubble: false,
66
+ showMaks: false,
67
+ bubleWidth: 0,
68
+ sysInfo: {},
69
+ bublePosition: {
70
+ top: 0,
71
+ left: 0
72
+ }
73
+ }
74
+ },
75
+ computed: {
76
+ rpxRatio() {
77
+ return 750 / this.screenWidth
78
+ },
79
+ screenWidth() {
80
+ return this.sysInfo.screenWidth
81
+ },
82
+ bubblePosition() {
83
+ return this.position === 'bottom' ? 'top' : 'bottom'
84
+ },
85
+ bubbleStyle() {
86
+ return {
87
+ zIndex: this.zIndex,
88
+ ...this.bublePosition
89
+ }
90
+ },
91
+ bubbleClass() {
92
+ return this.position === 'top' ? 'isTop' : ''
93
+ }
94
+ },
95
+ mounted() {
96
+ this.init()
97
+ },
98
+ methods: {
99
+ init() {
100
+ this.sysInfo = uni.getSystemInfoSync()
101
+ },
102
+ async handleLongpress(e) {
103
+ await this.calcBubblePosition()
104
+ this.showBubble = true
105
+ this.showMaks = true
106
+ },
107
+ getBubbleWidth() {
108
+ return new Promise(reslove => {
109
+ this.$set(this, 'bublePosition', { top: '-9999vh', left: 0 })
110
+ this.showBubble = true
111
+ setTimeout(() => {
112
+ reslove(this.$refs.bubble ? this.$refs.bubble.$el.getBoundingClientRect().width : 0)
113
+ this.showBubble = false
114
+ }, 500)
115
+ })
116
+ },
117
+ async calcBubblePosition() {
118
+ let bublePosition = this.$el.getBoundingClientRect()
119
+ this.bubleWidth = await this.getBubbleWidth()
120
+ const lengthGap = (this.bubleWidth - bublePosition.width) / 2
121
+ const compRight = this.screenWidth - bublePosition.x - bublePosition.width
122
+ const posRes = {}
123
+ if (lengthGap <= 0 || (lengthGap < bublePosition.x && lengthGap < compRight)) {
124
+ posRes.left = -Math.abs(lengthGap) + 'px'
125
+ } else {
126
+ posRes.right = 4 - Math.min(bublePosition.x, compRight) + 'px'
127
+ }
128
+ posRes[this.bubblePosition] = 'calc(100% + 18rpx)'
129
+ this.$set(this, 'bublePosition', posRes)
130
+ }
131
+ }
132
+ }
133
+ </script>
134
+
135
+ <style lang="scss" scoped>
136
+ .pi-bubble {
137
+ width: fit-content;
138
+ height: fit-content;
139
+ .pi-bubble-wrapper {
140
+ filter: drop-shadow(0 0 2rpx #000);
141
+ z-index: 9999;
142
+ position: absolute;
143
+ width: 100%;
144
+ height: 0;
145
+ top: 100%;
146
+ &.isTop {
147
+ top: 0;
148
+ .pi-bubble-content {
149
+ .pi-bubble-angle {
150
+ top: initial;
151
+ bottom: -10rpx;
152
+ }
153
+ }
154
+ }
155
+ .pi-bubble-content {
156
+ max-width: 98vw;
157
+ line-height: 30rpx;
158
+ color: #fff;
159
+ z-index: 9999;
160
+ background-color: #000;
161
+ .pi-bubble-angle {
162
+ top: -10rpx;
163
+ left: 50%;
164
+ z-index: 9999;
165
+ width: 0rpx;
166
+ height: 0rpx;
167
+ border: 12rpx solid #000;
168
+ transform: translateX(-50%) rotate(45deg);
169
+ transform-origin: center;
170
+ }
171
+ }
172
+ }
173
+ }
174
+ </style>
@@ -0,0 +1,199 @@
1
+ <!--
2
+ * @Author: zhangzhenfei
3
+ * @Date: 2022-05-18 11:08:49
4
+ * @LastEditTime: 2022-05-21 15:00:48
5
+ * @LastEditors: zhangzhenfei
6
+ * @Description: 日历输入
7
+ * @FilePath: /hfmp-checkin-front/Users/feilin/workspace/piui/piui-awesome/src/piui/components/pi-calendar-input/index.vue
8
+ -->
9
+
10
+ <template>
11
+ <view class="pi-calendar-input">
12
+ <!-- 输入框 -->
13
+ <view v-if="$slots.default || $slots.$default" class="pi-w-100P" @click="show = true">
14
+ <slot />
15
+ </view>
16
+ <pi-input
17
+ v-else
18
+ type="text"
19
+ :value="getInputValue"
20
+ :custom-class="input.customClass"
21
+ :custom-style="input.customStyle"
22
+ :placeholder="input.placeholder"
23
+ :placeholder-style="input.placeholderStyle"
24
+ :placeholder-class="input.placeholderClass"
25
+ :disabled="input.disabled"
26
+ :border="input.border"
27
+ :maxlength="input.maxlength"
28
+ :password="input.password"
29
+ :cursor-spacing="input.cursorSpacing"
30
+ :focus="input.focus"
31
+ :confirm-type="input.confirmType"
32
+ :confirm-hold="input.confirmHold"
33
+ :cursor="input.cursor"
34
+ :selection-start="input.selectionStart"
35
+ :selection-end="input.selectionEnd"
36
+ :adjust-position="input.adjustPosition"
37
+ :hold-keyboard="input.holdKeyboard"
38
+ :auto-blur="input.autoBlur"
39
+ :show-confirmbar="input.showConfirmbar"
40
+ :auto-height="input.autoHeight"
41
+ :fixed="input.fixed"
42
+ :disable-default-padding="input.disableDefaultPadding"
43
+ :clearable="input.clearable"
44
+ :clear-icon="input.clearIcon"
45
+ @click="show = true"
46
+ />
47
+
48
+ <!-- 日历弹出框 -->
49
+ <pi-calendar
50
+ v-model="show"
51
+ :custom-class="getCalendar.customClass"
52
+ :custom-style="getCalendar.customStyle"
53
+ :show-title="getCalendar.showTitle"
54
+ :title="getCalendar.title"
55
+ :title-padding="getCalendar.titlePadding"
56
+ :type="getCalendar.type"
57
+ :calendar-panel="{
58
+ ...getCalendar.calendarPanel,
59
+ dateFormat: getCalendar.dateFormat,
60
+ value: val
61
+ }"
62
+ :popup="getCalendar.popup"
63
+ @confirm="handleCalendarConfirm"
64
+ />
65
+ </view>
66
+ </template>
67
+
68
+ <script>
69
+ import ValueSync from '../../mixin/value-sync'
70
+ import { getConfig } from '../../config'
71
+
72
+ const TAG = 'PiCalendarInput'
73
+ const { calendarInput } = getConfig()
74
+
75
+ const PI_DEFAULT_FN_FLAG = 'PI_DEFAULT_FN_FLAG'
76
+
77
+ export default {
78
+ name: 'PiCalendar',
79
+ // 混入v-model
80
+ mixins: [ValueSync],
81
+ props: {
82
+ // 初始值
83
+ value: {
84
+ required: false
85
+ },
86
+ // 自定义样式,对象形式
87
+ customStyle: {
88
+ type: Object,
89
+ // {}
90
+ default() {
91
+ return calendarInput.customStyle
92
+ }
93
+ },
94
+ // 自定义样式类,字符串形式
95
+ customClass: {
96
+ type: String,
97
+ // ''
98
+ default() {
99
+ return calendarInput.customClass
100
+ }
101
+ },
102
+ // input输入设置
103
+ input: {
104
+ type: Object,
105
+ default() {
106
+ // 参照calendar
107
+ return calendarInput.input
108
+ }
109
+ },
110
+ // 日历弹窗参数设置
111
+ calendar: {
112
+ type: Object,
113
+ default() {
114
+ // 参照calendar
115
+ return calendarInput.calendar
116
+ }
117
+ },
118
+ // 已选择的时间格式化显示规则,默认('YYYY-MM-DD')
119
+ dateFormat: {
120
+ type: String,
121
+ // 'YYYY-MM-DD'
122
+ default: calendarInput.dateFormat
123
+ },
124
+ // 范围选择时间分隔符,默认('至')
125
+ rangeSplit: {
126
+ type: String,
127
+ // '至'
128
+ default: calendarInput.rangeSplit
129
+ },
130
+ // 解析值的方法,如果配置了,则读取该函数的返回值作为显示的内容
131
+ parseValueFn: {
132
+ type: [Object, Function],
133
+ default() {
134
+ return {
135
+ [PI_DEFAULT_FN_FLAG]: true,
136
+ fn: calendarInput.parseValueFn
137
+ }
138
+ }
139
+ }
140
+ },
141
+ data() {
142
+ return {
143
+ show: false
144
+ }
145
+ },
146
+ computed: {
147
+ getCalendar() {
148
+ return this.$pi.lang.mergeDeep(calendarInput.calendar, this.calendar)
149
+ },
150
+ getInputValue() {
151
+ const parseValueFn = this.parseValueFn[PI_DEFAULT_FN_FLAG]
152
+ ? this.parseValueFn.fn
153
+ : this.parseValueFn
154
+ if (this.$pi.lang.isFunction(parseValueFn)) {
155
+ const parseValue = parseValueFn(this.val)
156
+ return parseValue
157
+ }
158
+ if (!this.dateFormat) {
159
+ console.warn('使用pi-calendar-input组件,请设置.dateFormat,否则无法正常显示')
160
+ }
161
+ if (this.$pi.lang.isEmpty(this.val)) return ''
162
+ // 常规字段正常返回
163
+ if (this.$pi.lang.isString(this.val) || this.$pi.lang.isNumber(this.val)) {
164
+ return this.val
165
+ }
166
+ // 如果是日期对象,返回格式化后的日期
167
+ if (this.calendar.calendarPanel.type === 'date') {
168
+ return this.$pi.date.formatDate(new Date(this.val), this.dateFormat)
169
+ }
170
+ if (this.calendar.calendarPanel.type === 'range') {
171
+ return this.val
172
+ .map(date => {
173
+ return this.$pi.date.formatDate(new Date(date), this.dateFormat)
174
+ })
175
+ .join(this.rangeSplit)
176
+ }
177
+ return ''
178
+ }
179
+ },
180
+ methods: {
181
+ handlePopupClose() {
182
+ this.val = false
183
+ // 关闭
184
+ this.$emit('close')
185
+ this.handleEmitChange()
186
+ },
187
+ handleCalendarConfirm(value) {
188
+ this.val = value
189
+ this.handleEmitChange()
190
+ }
191
+ }
192
+ }
193
+ </script>
194
+
195
+ <style lang="scss" scoped>
196
+ .pi-calendar-input {
197
+ width: 100%;
198
+ }
199
+ </style>
@@ -58,7 +58,6 @@
58
58
  <view
59
59
  class="pi-abso-center pi-fw-500 pi-light-gray"
60
60
  style="
61
-
62
61
  z-index: 1;
63
62
  font-size: 300rpx;
64
63
  pointer-events: none;
@@ -267,6 +266,11 @@ export default {
267
266
  const inRange =
268
267
  start && end && day.timestamp > start.timestamp && day.timestamp < end.timestamp
269
268
  const activeStyle = {}
269
+ // 处理中间范围的样式
270
+ if (inRange) {
271
+ activeStyle.color = this.rangeColor
272
+ activeStyle.background = this.rangeBg
273
+ }
270
274
  // 处理两端
271
275
  if (isBegin || isEnd) {
272
276
  activeStyle.color = this.activeColor
@@ -275,11 +279,6 @@ export default {
275
279
  : `0 ${this.getActiveBorderRadius} ${this.getActiveBorderRadius} 0`
276
280
  if (this.activeBg) activeStyle.background = this.activeBg
277
281
  }
278
- // 处理中间范围的样式
279
- if (inRange) {
280
- activeStyle.color = this.rangeColor
281
- activeStyle.background = this.rangeBg
282
- }
283
282
  day.activeStyle = activeStyle
284
283
  // type 为 range 开始和结束的提示
285
284
  if (isBegin) day.tip = this.startText
@@ -3,9 +3,14 @@
3
3
  class="pi-check-wrap"
4
4
  :style="[customStyle]"
5
5
  :class="[getShape, getActiveMode, { disabled: getDisable }, { active: val }, customClass]"
6
- @tap="handleCheckboxToggle"
6
+ @tap="handleCheckboxToggle(true)"
7
7
  >
8
- <view v-if="getShape !== 'text'" class="check-icon" :style="[checkStyle]">
8
+ <view
9
+ v-if="getShape !== 'text'"
10
+ class="check-icon"
11
+ :style="[checkStyle]"
12
+ @tap.stop="handleCheckboxToggle(false)"
13
+ >
9
14
  <view v-if="getShape === 'dot'" class="dot" :style="[dotStyle]" />
10
15
  <pi-icon v-else name="blod-check" :size="getIconSize" />
11
16
  </view>
@@ -124,6 +129,12 @@ export default {
124
129
  validator: function(value) {
125
130
  return ['line', 'line-circle', 'fill', 'fill-circle'].includes(value)
126
131
  }
132
+ },
133
+ // 是否点击图标才能选中,默认点击整行都能选中
134
+ onlyIconSelect: {
135
+ type: [Boolean],
136
+ // null
137
+ default: checkbox.onlyIconSelect
127
138
  }
128
139
  },
129
140
  data() {
@@ -162,6 +173,11 @@ export default {
162
173
  ? this.$pi.common.addUnit(this.inheritProps.iconSize)
163
174
  : this.$pi.common.addUnit(this.iconSize)
164
175
  },
176
+ getOnlyIconSelect() {
177
+ return this.inheritProps.onlyIconSelect !== null
178
+ ? this.inheritProps.onlyIconSelect
179
+ : this.onlyIconSelect
180
+ },
165
181
  checkStyle() {
166
182
  const style = {
167
183
  width: this.getSize,
@@ -218,7 +234,8 @@ export default {
218
234
  this.val = true
219
235
  }
220
236
  },
221
- handleCheckboxToggle() {
237
+ handleCheckboxToggle(isTapRow) {
238
+ if (this.getOnlyIconSelect && isTapRow) return
222
239
  if (this.getDisable) return
223
240
  if (this.readonly) return
224
241
  // 如果父组件做了可选数量限制
@@ -242,6 +259,8 @@ $unactive-color: #cccccc;
242
259
  .pi-check-wrap {
243
260
  display: inline-flex;
244
261
  align-items: center;
262
+ cursor: pointer;
263
+
245
264
  .check-icon {
246
265
  position: relative;
247
266
  display: inline-flex;
@@ -33,7 +33,8 @@ export default {
33
33
  'size',
34
34
  'iconSize',
35
35
  'activeColor',
36
- 'activeMode'
36
+ 'activeMode',
37
+ 'onlyIconSelect'
37
38
  ])
38
39
  ], // 注入value与val,进行双向绑定
39
40
  options: {
@@ -125,6 +126,12 @@ export default {
125
126
  validator: function(value) {
126
127
  return ['', 'line', 'line-circle', 'fill', 'fill-circle'].includes(value)
127
128
  }
129
+ },
130
+ // 是否点击图标才能选中,默认点击整行都能选中
131
+ onlyIconSelect: {
132
+ type: [Boolean, null],
133
+ // null
134
+ default: checkboxGroup.onlyIconSelect
128
135
  }
129
136
  },
130
137
  computed: {
@@ -137,11 +144,6 @@ export default {
137
144
  handler(value) {
138
145
  this.handleValChange()
139
146
  }
140
- },
141
- value: {
142
- handler(val) {
143
- console.warn('val', val)
144
- }
145
147
  }
146
148
  },
147
149
  methods: {