resolver-egretimp-plus 0.0.297 → 0.0.299

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.
@@ -7,6 +7,8 @@ import { getDomWidth } from '../../utils/dom.js';
7
7
  import { watch } from 'vue';
8
8
  import { nextTick } from 'vue';
9
9
  import { resolveComponent } from 'vue';
10
+ import { onUnmounted } from 'vue';
11
+ import { useToolTip } from '../helper/calcTooltip.jsx';
10
12
 
11
13
  export default {
12
14
  inheritAttrs: false,
@@ -17,28 +19,37 @@ export default {
17
19
  type: [Number, String],
18
20
  default: 2,
19
21
  },
22
+ // 是否在超出的时候展示tooltip
23
+ showTooltip: {
24
+ type: [String, Number],
25
+ default: ''
26
+ },
27
+ // 是否使用金额显示
20
28
  showMoney: {
21
29
  type: [String, Number],
22
30
  default: ''
23
31
  },
32
+ // 金额显示的分割,默认‘,’
24
33
  moneySeg: {
25
34
  type: [String],
26
35
  default: ','
27
36
  },
37
+ // 金额显示的最小值
28
38
  min: {
29
39
  type: Number,
30
40
  default: -Infinity
31
41
  },
42
+ // 金额显示的最大值
32
43
  max: {
33
44
  type: Number,
34
45
  default: Infinity
35
46
  },
36
- // 小数位数
47
+ // 金额显示小数位数
37
48
  decimal: {
38
49
  type: Number,
39
50
  default: 2
40
51
  },
41
- // 保留小数点0后缀
52
+ // 金额显示时保留小数点0后缀
42
53
  decimalSuffix: {
43
54
  type: [Number, String],
44
55
  default: '0'
@@ -48,7 +59,7 @@ export default {
48
59
  type: Array,
49
60
  default: ['na', '-']
50
61
  },
51
- // 是否显示货币符号
62
+ // 金额显示是否显示货币符号
52
63
  showSymbol: {
53
64
  type: String,
54
65
  default: ''
@@ -67,9 +78,6 @@ export default {
67
78
  },
68
79
  emits: ['update:modelValue'],
69
80
  setup(props, { emit, attrs, expose, slots }) {
70
- const isOverflow = ref(false)
71
- const inputWrapRef = ref(null)
72
- const calcSpanRef = ref(null)
73
81
  const inputProps = computed(() => {
74
82
  const ret = Object.keys(ElInput.props).reduce((total, key) => {
75
83
  total[key] = props[key]
@@ -96,7 +104,7 @@ export default {
96
104
  return ret
97
105
  })
98
106
  const showTooltip = computed(() => {
99
- return props?.config?.showTooltip == '1' && props.disabled
107
+ return props?.showTooltip == '1'
100
108
  })
101
109
  // 这个是真实的值
102
110
  const modelValue = computed({
@@ -108,11 +116,22 @@ export default {
108
116
  }
109
117
  })
110
118
  // 开启金额展示的时候需要isFocus来控制格式的转换
111
- const isFocus = ref(false)
112
119
  const currentVal = ref('')
120
+ const isFocus = ref(false)
113
121
  const displayValue = computed(() => {
114
122
  return props.showMoney == '1' ? (isFocus.value ? currentVal.value : formatValue(modelValue.value)) : modelValue.value
115
123
  })
124
+ const { generateTooltipWrap } = useToolTip({
125
+ showTooltip,
126
+ offset: computed(() => {
127
+ let offset = 20
128
+ if (!props.disabled && props.clearable) {
129
+ offset = 50
130
+ }
131
+ return offset
132
+ }),
133
+ displayValue
134
+ })
116
135
  const isPagePopupAndSearch = computed(() => {
117
136
  return props.config?.lcpPagePopupMapVO && inputProps.value.suffixIcon == 'Search'
118
137
  })
@@ -138,12 +157,12 @@ export default {
138
157
  }
139
158
  if (props.showMoney == '1') {
140
159
  ret['onFocus'] = () => {
141
- currentVal.value = modelValue.value
142
160
  isFocus.value = true
161
+ currentVal.value = modelValue.value
143
162
  }
144
163
  ret['onBlur'] = () => {
145
- modelValue.value = parseValue(formatValue(currentVal.value))
146
164
  isFocus.value = false
165
+ modelValue.value = parseValue(formatValue(currentVal.value))
147
166
  }
148
167
  }
149
168
  } else {
@@ -154,17 +173,13 @@ export default {
154
173
  }
155
174
  return ret
156
175
  })
157
- const inputWrapAttrs = computed(() => {
158
- return {
159
- class: attrs?.class,
160
- style: attrs?.style
161
- }
162
- })
176
+
163
177
  const normalAttrs = computed(() => {
164
178
  const ret = {
165
179
  ...attrs
166
180
  }
167
181
  delete ret.class
182
+
168
183
  if (isPagePopupAndSearch.value && isOnlyIconClickFlag.value) {
169
184
  delete ret.onClick
170
185
  }
@@ -182,54 +197,6 @@ export default {
182
197
  return ret
183
198
  })
184
199
 
185
- const tooltipCalc = (() => {
186
- let unWatch = null
187
- let onResize = null
188
- return {
189
- clear: () => {
190
- unWatch && unWatch()
191
- onResize && window.removeEventListener('resize', onResize)
192
- },
193
- calc() {
194
- this.clear()
195
- let inputWrapWidth = getDomWidth(inputWrapRef.value, 0)
196
- let textLengthWidth = getDomWidth(calcSpanRef.value, -22)
197
- isOverflow.value = inputWrapWidth < textLengthWidth
198
- unWatch = watch(() => modelValue.value, (val) => {
199
- nextTick(() => {
200
- textLengthWidth = getDomWidth(calcSpanRef.value, -22)
201
- isOverflow.value = inputWrapWidth < textLengthWidth
202
- })
203
- })
204
- onResize = () => {
205
- inputWrapWidth = getDomWidth(inputWrapRef.value, 0)
206
- isOverflow.value = inputWrapWidth < textLengthWidth
207
- console.log('isOverflow==:', isOverflow.value, inputWrapWidth)
208
- }
209
- window.addEventListener('resize', onResize)
210
- }
211
- }
212
- })()
213
-
214
- onMounted(() => {
215
- watch(showTooltip, (val) => {
216
- if (val) {
217
- tooltipCalc?.calc()
218
- }
219
- }, {
220
- immediate: true
221
- })
222
- })
223
- const polyfillInputWrap = (node) => {
224
- if (isOverflow.value) {
225
- return (
226
- <el-tooltip content={modelValue.value} placement="top">
227
- { node }
228
- </el-tooltip>
229
- )
230
- }
231
- return node
232
- }
233
200
  const getInputSolts = () => {
234
201
  const ret = {
235
202
  ...slots
@@ -321,21 +288,12 @@ export default {
321
288
  }
322
289
  })
323
290
  return () => {
324
- return (
325
- <div class="input-contrainer" {...inputWrapAttrs.value}>
326
- <span ref={(e) => calcSpanRef.value = e} class="calc-span">{ displayValue.value }</span>
291
+ return generateTooltipWrap(
292
+ <ElInput {...vmodelProps.value} {...{...normalAttrs.value, ...normalInputProps.value}}>
327
293
  {
328
- polyfillInputWrap(
329
- <div class="input-wrap" ref={(e) => inputWrapRef.value = e}>
330
- <ElInput {...vmodelProps.value} {...{...normalAttrs.value, ...normalInputProps.value}}>
331
- {
332
- getInputSolts()
333
- }
334
- </ElInput>
335
- </div>
336
- )
294
+ getInputSolts()
337
295
  }
338
- </div>
296
+ </ElInput>
339
297
  )
340
298
  }
341
299
  }
@@ -3,6 +3,7 @@ import { computed, defineProps, inject, getCurrentInstance, useAttrs, useSlots }
3
3
  import { commonPropsType } from '../../utils/index.js'
4
4
  import { h, resolveComponent, withModifiers } from 'vue'
5
5
  import '../styles/text.scss'
6
+ import { useToolTip } from '../helper/calcTooltip.jsx'
6
7
 
7
8
  export default {
8
9
  inheritAttrs: false,
@@ -20,6 +21,15 @@ export default {
20
21
  },
21
22
  isPointer: {
22
23
  type: [String, Number]
24
+ },
25
+ // 是否在超出的时候展示tooltip
26
+ showTooltip: {
27
+ type: [String, Number],
28
+ default: '1'
29
+ },
30
+ truncated: {
31
+ type: [String, Number, Boolean],
32
+ default: '1'
23
33
  }
24
34
  },
25
35
  emits: ['update:modelValue'],
@@ -61,6 +71,9 @@ export default {
61
71
  ret[key] = props[key]
62
72
  return ret
63
73
  }, {})
74
+ if (typeof result.truncated !== 'boolean') {
75
+ result.truncated = result.truncated == '1'
76
+ }
64
77
  return result
65
78
  })
66
79
  const buttonActions = inject('buttonActions', {})
@@ -68,6 +81,27 @@ export default {
68
81
  const labelDesc = computed(() => {
69
82
  return normalVal.value
70
83
  })
84
+ const showTooltip = computed(() => {
85
+ return props?.showTooltip == '1'
86
+ })
87
+
88
+ const { generateTooltipWrap } = useToolTip({
89
+ showTooltip,
90
+ offset: computed(() => {
91
+ let offset = 0
92
+ if (props.needWrap == '1') {
93
+ offset = 22
94
+ if (props.suffixIcon) {
95
+ offset = 36
96
+ }
97
+ }
98
+ return offset
99
+ }),
100
+ displayValue: labelDesc,
101
+ calcFn(node) {
102
+ return node?.getBoundingClientRect?.()?.width
103
+ }
104
+ })
71
105
 
72
106
  const dynamicMapComp = inject('dynamicMapComp')
73
107
  const hireRelatMapRules = inject('hireRelatMapRules')
@@ -139,13 +173,15 @@ export default {
139
173
  }
140
174
  }
141
175
  return () => {
142
- return getWrap(
176
+ return generateTooltipWrap(getWrap(
143
177
  <ElText {...{...attrs, ...elTextProps.value}} onClickCapture={withModifiers((e) => {clickAction(e)}, [ 'stop', 'self' ])} class={{cursor: props.isPointer == '1'}}>
144
178
  {
145
179
  getSlots()
146
180
  }
147
181
  </ElText>
148
- )
182
+ ), {
183
+ maintain: true,
184
+ })
149
185
  }
150
186
  }
151
187
  }
@@ -20,16 +20,16 @@
20
20
  }
21
21
  }
22
22
 
23
- .input-contrainer {
24
- width: 100%;
25
- .calc-span {
26
- white-space: nowrap;
27
- position: absolute;
28
- visibility: hidden;
29
- padding: 0 11px;
30
- box-sizing: border-box;
31
- }
32
- .input-wrap{
33
- width: 100%;
34
- }
35
- }
23
+ // .input-contrainer {
24
+ // width: 100%;
25
+ // .calc-span {
26
+ // white-space: nowrap;
27
+ // position: absolute;
28
+ // visibility: hidden;
29
+ // padding: 0 11px;
30
+ // box-sizing: border-box;
31
+ // }
32
+ // .input-wrap{
33
+ // width: 100%;
34
+ // }
35
+ // }
@@ -34,3 +34,18 @@
34
34
  }
35
35
  }
36
36
  }
37
+
38
+
39
+ .resolver-calc-contrainer {
40
+ width: 100%;
41
+ .resolver-calc-span {
42
+ white-space: nowrap;
43
+ position: absolute;
44
+ visibility: hidden;
45
+ padding: 0 11px;
46
+ box-sizing: border-box;
47
+ }
48
+ .resolver-calc-wrap{
49
+ width: 100%;
50
+ }
51
+ }