sadais-piui 1.2.7-beta90 → 1.2.7-beta92

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,10 +1,10 @@
1
1
  <!--
2
2
  * @Author: zhangzhenfei
3
3
  * @Date: 2022-05-18 11:08:49
4
- * @LastEditTime: 2023-12-05 09:41:08
4
+ * @LastEditTime: 2024-01-12 11:09:10
5
5
  * @LastEditors: zhangzhenfei
6
6
  * @Description: 选择输入
7
- * @FilePath: /piui-awesome/src/piui/components/pi-select-input/index.vue
7
+ * @FilePath: /piui/components/pi-select-input/index.vue
8
8
  -->
9
9
 
10
10
  <template>
@@ -168,7 +168,7 @@ export default {
168
168
  return parseValue
169
169
  }
170
170
  if (this.$pi.lang.isEmpty(this.val)) return ''
171
- const getItems = this.$refs['pi-select']?.getItems || this.getSelect.items
171
+ const getItems = this.$refs['pi-select']?.getItems || this.getSelect.items || []
172
172
  if (this.getSelect.keyDefaultValue) {
173
173
  if (this.getSelect.isMulti) {
174
174
  return getItems
@@ -197,7 +197,19 @@ export default {
197
197
  }
198
198
  }
199
199
  },
200
+ created() {
201
+ this.initRemoteSelectData()
202
+ },
200
203
  methods: {
204
+ initRemoteSelectData() {
205
+ // 如果开启了远程搜索 则在创建之初 先触发一次搜索 让代码触发到用户自定义的parseRemoteSearchResult方法中
206
+ // 目的为了回显数据
207
+ if (this.getSelect.remoteSearchConfig.enable && this.getSelect.parseRemoteSearchResult) {
208
+ this.$nextTick(() => {
209
+ this.$refs['pi-select'].handleRemoteSearch()
210
+ })
211
+ }
212
+ },
201
213
  handlePopupClose() {
202
214
  this.val = false
203
215
  // 关闭
@@ -15,7 +15,7 @@
15
15
  @tap="handleChange(-1)"
16
16
  />
17
17
  <input
18
- :value="value"
18
+ :value="val"
19
19
  type="digit"
20
20
  class="step-input"
21
21
  :disabled="disabled || disableInput"
@@ -49,6 +49,9 @@ import { parseDuration } from '@sadais/piui-tool/tools/common'
49
49
  const TAG = 'PiTabs'
50
50
  const { tabs } = getConfig()
51
51
 
52
+ let MAX_RETRY = 10
53
+ let timer = null
54
+
52
55
  export default {
53
56
  name: 'PiTabs',
54
57
  // 混入v-model
@@ -263,13 +266,14 @@ export default {
263
266
  left: 0,
264
267
  width: 0
265
268
  }
266
- if (!this.tabRects.length) return rect
267
- const activeIndex =
268
- this.activeIndex >= this.tabRects.length ? this.tabRects.length - 1 : this.activeIndex
269
- rect.left = this.tabRects.slice(0, activeIndex).reduce((previous, current) => {
270
- return previous + current.width
271
- }, 0)
272
- rect.width = this.tabRects[activeIndex].width
269
+ if (this.tabRects.length) {
270
+ const activeIndex =
271
+ this.activeIndex >= this.tabRects.length ? this.tabRects.length - 1 : this.activeIndex
272
+ rect.left = this.tabRects.slice(0, activeIndex).reduce((previous, current) => {
273
+ return previous + current.width
274
+ }, 0)
275
+ rect.width = this.tabRects[activeIndex].width
276
+ }
273
277
  return rect
274
278
  },
275
279
  scrollLeft() {
@@ -284,6 +288,7 @@ export default {
284
288
  height: this.getSliderBarHeight,
285
289
  borderRadius: this.getSliderBarRadius,
286
290
  transitionDuration: duration.css,
291
+ transform: `translate(${this.activeRect.left}px, -25%)`,
287
292
  ...this.sliderBarStyle
288
293
  }
289
294
  let sliderScrollLeft = this.activeRect.left
@@ -328,14 +333,39 @@ export default {
328
333
  mounted() {
329
334
  this.init()
330
335
  },
336
+ beforeDestroy() {
337
+ this.clearTimer()
338
+ },
331
339
  methods: {
340
+ clearTimer() {
341
+ if (timer) {
342
+ clearInterval(timer)
343
+ timer = null
344
+ MAX_RETRY = 10
345
+ }
346
+ },
332
347
  async init() {
333
348
  const srollWrapRect = await this.$pi.common.queryRect(this, '.pi-tabs', false)
334
349
  if (srollWrapRect) {
335
350
  this.tabsWidth = srollWrapRect.width
336
351
  }
337
- this.tabRects = await this.$pi.common.queryRect(this, '.pi-tab', true)
338
- console.log(TAG, '计算.pi-tab布局', this.tabRects)
352
+ this.initTabRects()
353
+ this.clearTimer()
354
+ timer = setInterval(() => {
355
+ this.initTabRects()
356
+ }, 200)
357
+ },
358
+ async initTabRects() {
359
+ MAX_RETRY--
360
+ const tabRects = await this.$pi.common.queryRect(this, '.pi-tab', true)
361
+ const tabWidth = this.tabRects.reduce((previous, current) => {
362
+ return previous + current.width
363
+ }, 0)
364
+ this.tabRects = tabRects
365
+ this.$forceUpdate()
366
+ if (tabWidth || MAX_RETRY <= 0) {
367
+ this.clearTimer()
368
+ }
339
369
  },
340
370
  handleSelectItem(item) {
341
371
  if (item[this.disabledField]) return
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sadais-piui",
3
- "version": "1.2.7-beta90",
3
+ "version": "1.2.7-beta92",
4
4
  "description": "piui组件库",
5
5
  "main": "index.js",
6
6
  "scripts": {