sh-view 2.1.0 → 2.3.0

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 (128) hide show
  1. package/package.json +9 -13
  2. package/packages/components/global-components/sh-alert/index.vue +175 -173
  3. package/packages/components/global-components/sh-badge/index.vue +57 -43
  4. package/packages/components/global-components/sh-card/index.vue +24 -16
  5. package/packages/components/global-components/sh-code-editor/index.vue +250 -260
  6. package/packages/components/global-components/sh-col/index.vue +44 -36
  7. package/packages/components/global-components/sh-corner/index.vue +230 -228
  8. package/packages/components/global-components/sh-count-to/index.vue +60 -51
  9. package/packages/components/global-components/sh-drawer/index.vue +209 -182
  10. package/packages/components/global-components/sh-drawer/scrollbar.js +44 -42
  11. package/packages/components/global-components/sh-empty/index.vue +0 -1
  12. package/packages/components/global-components/sh-form/form.vue +110 -0
  13. package/packages/components/global-components/sh-form/js/props.js +76 -63
  14. package/packages/components/global-components/sh-form/js/useForm.js +236 -0
  15. package/packages/components/global-components/sh-form/query.vue +70 -0
  16. package/packages/components/global-components/sh-header/index.vue +35 -50
  17. package/packages/components/global-components/sh-icon/css/index.scss +44 -0
  18. package/packages/components/global-components/sh-icon/index.vue +24 -11
  19. package/packages/components/global-components/sh-image/index.vue +47 -38
  20. package/packages/components/global-components/sh-list/index.vue +42 -37
  21. package/packages/components/global-components/sh-loading/index.vue +12 -8
  22. package/packages/components/global-components/sh-modal/index.vue +49 -40
  23. package/packages/components/global-components/sh-noticebar/index.vue +68 -54
  24. package/packages/components/global-components/sh-poptip/index.vue +247 -130
  25. package/packages/components/global-components/sh-progress/index.vue +71 -69
  26. package/packages/components/global-components/sh-pull-refresh/index.vue +156 -157
  27. package/packages/components/global-components/sh-result/index.vue +37 -28
  28. package/packages/components/global-components/sh-row/index.vue +21 -18
  29. package/packages/components/global-components/sh-split/index.vue +115 -109
  30. package/packages/components/global-components/sh-table/components/importModal.vue +95 -86
  31. package/packages/components/global-components/sh-table/components/sh-column.vue +62 -0
  32. package/packages/components/global-components/sh-table/{index.vue → grid.vue} +34 -145
  33. package/packages/components/global-components/sh-table/js/tableMethods.js +175 -0
  34. package/packages/components/global-components/sh-table/js/useTable.js +592 -0
  35. package/packages/components/global-components/sh-table/table.vue +266 -0
  36. package/packages/components/global-components/sh-tabs/index.vue +118 -93
  37. package/packages/components/global-components/sh-tag/index.vue +52 -51
  38. package/packages/components/global-components/sh-toolbar/index.vue +53 -47
  39. package/packages/components/global-components/sh-tree/components/table-tree.vue +152 -139
  40. package/packages/components/global-components/sh-tree/index.vue +218 -195
  41. package/packages/components/global-components/sh-tree/mixin/treeProps.js +118 -120
  42. package/packages/components/global-components/sh-upload/index.vue +308 -51
  43. package/packages/components/global-components/sh-water-fall/index.vue +4 -11
  44. package/packages/components/index.js +5 -3
  45. package/packages/components/other-components/sh-cron-modal/components/cron-content.vue +140 -129
  46. package/packages/components/other-components/sh-cron-modal/css/index.scss +0 -5
  47. package/packages/components/other-components/sh-cron-modal/index.vue +81 -67
  48. package/packages/components/other-components/sh-cron-modal/mixin/cron-emits.js +1 -0
  49. package/packages/components/other-components/sh-cron-modal/mixin/cron-hooks.js +179 -0
  50. package/packages/components/other-components/sh-cron-modal/mixin/cron-props.js +9 -0
  51. package/packages/components/other-components/sh-cron-modal/tabs/cron-day-box.vue +101 -92
  52. package/packages/components/other-components/sh-cron-modal/tabs/cron-hour-box.vue +68 -56
  53. package/packages/components/other-components/sh-cron-modal/tabs/cron-minute-box.vue +68 -56
  54. package/packages/components/other-components/sh-cron-modal/tabs/cron-month-box.vue +68 -56
  55. package/packages/components/other-components/sh-cron-modal/tabs/cron-second-box.vue +68 -56
  56. package/packages/components/other-components/sh-cron-modal/tabs/cron-week-box.vue +126 -115
  57. package/packages/components/other-components/sh-cron-modal/tabs/cron-year-box.vue +59 -46
  58. package/packages/components/other-components/sh-menu/index.vue +73 -60
  59. package/packages/components/other-components/sh-menu/menu-group-content.vue +71 -59
  60. package/packages/components/other-components/sh-menu/menu-item-content.vue +40 -30
  61. package/packages/components/other-components/sh-menu-card/index.vue +70 -64
  62. package/packages/components/other-components/sh-menu-card/menu-box.vue +50 -44
  63. package/packages/components/other-components/sh-preview/components/sh-excel.vue +182 -0
  64. package/packages/components/other-components/sh-preview/components/sh-word.vue +73 -0
  65. package/packages/components/other-components/sh-preview/index.vue +86 -85
  66. package/packages/components/other-components/sh-preview/js/data-hook.js +37 -0
  67. package/packages/components/other-components/sh-preview/js/data-props.js +11 -0
  68. package/packages/components/other-components/sh-system-tip/index.vue +28 -24
  69. package/packages/css/index.js +4 -4
  70. package/packages/directive/module/prevent-click.js +1 -1
  71. package/packages/directive/module/resize.js +11 -154
  72. package/packages/index.js +39 -39
  73. package/packages/mixin/index.js +86 -87
  74. package/packages/vxeTable/render/cell/vxe-render-checkbox.vue +14 -5
  75. package/packages/vxeTable/render/cell/vxe-render-checkgroup.vue +43 -36
  76. package/packages/vxeTable/render/cell/vxe-render-code.vue +14 -5
  77. package/packages/vxeTable/render/cell/vxe-render-goption.vue +34 -24
  78. package/packages/vxeTable/render/cell/vxe-render-href.vue +21 -11
  79. package/packages/vxeTable/render/cell/vxe-render-img.vue +16 -10
  80. package/packages/vxeTable/render/cell/vxe-render-input.vue +83 -79
  81. package/packages/vxeTable/render/cell/vxe-render-money.vue +14 -6
  82. package/packages/vxeTable/render/cell/vxe-render-progress.vue +28 -19
  83. package/packages/vxeTable/render/cell/vxe-render-radio.vue +14 -5
  84. package/packages/vxeTable/render/cell/vxe-render-radiogroup.vue +43 -36
  85. package/packages/vxeTable/render/cell/vxe-render-select.vue +44 -36
  86. package/packages/vxeTable/render/cell/vxe-render-switch.vue +14 -5
  87. package/packages/vxeTable/render/cell/vxe-render-table.vue +51 -78
  88. package/packages/vxeTable/render/cell/vxe-render-textarea.vue +14 -5
  89. package/packages/vxeTable/render/cell/vxe-render-time.vue +23 -13
  90. package/packages/vxeTable/render/cell/vxe-render-tree.vue +23 -27
  91. package/packages/vxeTable/render/cell/vxe-render-upload.vue +11 -7
  92. package/packages/vxeTable/render/filters/vxe-filter-input.vue +25 -43
  93. package/packages/vxeTable/render/footer/vxe-footer-input.vue +23 -13
  94. package/packages/vxeTable/render/footer/vxe-footer-money.vue +30 -20
  95. package/packages/vxeTable/render/globalRenders.jsx +1 -1
  96. package/packages/vxeTable/render/header/vxe-header-money.vue +31 -21
  97. package/packages/vxeTable/render/mixin/cell-hooks.js +162 -0
  98. package/packages/vxeTable/render/mixin/cell-props.js +23 -0
  99. package/packages/vxeTable/render/mixin/filter-hooks.js +28 -0
  100. package/packages/components/global-components/sh-form/components/form-item.vue +0 -25
  101. package/packages/components/global-components/sh-form/css/index.scss +0 -55
  102. package/packages/components/global-components/sh-form/index.vue +0 -114
  103. package/packages/components/global-components/sh-form/js/methods.js +0 -146
  104. package/packages/components/global-components/sh-form/mixin/defaultData.js +0 -32
  105. package/packages/components/global-components/sh-icon/css/default/index.scss +0 -27
  106. package/packages/components/global-components/sh-icon/css/font/index.scss +0 -16
  107. package/packages/components/global-components/sh-icon/icon-default.vue +0 -32
  108. package/packages/components/global-components/sh-icon/icon-font.vue +0 -32
  109. package/packages/components/global-components/sh-poptip/popper.js +0 -115
  110. package/packages/components/global-components/sh-query/index.vue +0 -317
  111. package/packages/components/global-components/sh-table/js/methods.js +0 -549
  112. package/packages/components/global-components/sh-table/mixin/defaultData.js +0 -94
  113. package/packages/components/global-components/sh-upload/js/mixin.js +0 -257
  114. package/packages/components/other-components/sh-cron-modal/mixin/cron-box.js +0 -169
  115. package/packages/vxeTable/render/mixin/cell-mixin.js +0 -195
  116. /package/packages/components/global-components/sh-icon/css/default/{fonts/ionicons.svg → ionicons.svg} +0 -0
  117. /package/packages/components/global-components/sh-icon/css/default/{fonts/ionicons.ttf → ionicons.ttf} +0 -0
  118. /package/packages/components/global-components/sh-icon/css/default/{fonts/ionicons.woff → ionicons.woff} +0 -0
  119. /package/packages/components/global-components/sh-icon/css/default/{fonts/ionicons.woff2 → ionicons.woff2} +0 -0
  120. /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.js → iconfont.js} +0 -0
  121. /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.json → iconfont.json} +0 -0
  122. /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.ttf → iconfont.ttf} +0 -0
  123. /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.woff → iconfont.woff} +0 -0
  124. /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.woff2 → iconfont.woff2} +0 -0
  125. /package/packages/{assets/css → css}/animated.scss +0 -0
  126. /package/packages/{assets/css → css}/loader.scss +0 -0
  127. /package/packages/{assets/css → css}/main.scss +0 -0
  128. /package/packages/{assets/css → css}/theme.scss +0 -0
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div ref="scroller" class="sh-pull-refresh" :class="classes" @touchstart="touchStart" @touchmove="touchMove" @touchend="touchEnd">
2
+ <div ref="scroller" class="sh-pull-refresh" @touchstart="touchStart" @touchmove="touchMove" @touchend="touchEnd">
3
3
  <div class="sh-pull-refresh-container" :style="getStyle">
4
4
  <div class="sh-pull-refresh-container-topbox" :style="getHeightStyle">
5
5
  <div class="sh-pull-refresh-container-topbox-text">
@@ -17,7 +17,8 @@
17
17
  </template>
18
18
 
19
19
  <script>
20
- export default {
20
+ import { defineComponent, computed, onMounted, getCurrentInstance, ref, reactive, watch } from 'vue'
21
+ export default defineComponent({
21
22
  name: 'ShPullRefresh',
22
23
  props: {
23
24
  modelValue: {
@@ -54,111 +55,88 @@ export default {
54
55
  }
55
56
  },
56
57
  emits: ['change', 'refresh', 'update:modelValue'],
57
- data() {
58
- return {
59
- touch: {
60
- startX: 0,
61
- startY: 0,
62
- moveX: 0,
63
- moveY: 0,
64
- deltaX: 0,
65
- deltaY: 0,
66
- offsetX: 0,
67
- offsetY: 0,
68
- direction: ''
69
- },
70
- scrollParent: null,
71
- isPullRefresh: false,
72
- distance: 0,
73
- status: 'normal'
74
- }
75
- },
76
- computed: {
77
- classes() {
78
- const prefixCls = 'pull-refresh'
79
- return {
80
- [prefixCls]: true
81
- }
82
- },
83
- getPullStatus() {
84
- if (this.status === 'pulling') {
85
- return !this.slots.pulling ? this.pullingTxt : ''
86
- } else if (this.status === 'loosing') {
87
- return !this.slots.loosing ? this.loosingTxt : ''
88
- } else if (this.status === 'loading') {
89
- return !this.slots.loading ? this.loadingTxt : ''
90
- } else {
91
- return ''
58
+ setup(props, context) {
59
+ const { emit, slots } = context
60
+ const touch = reactive({
61
+ startX: 0,
62
+ startY: 0,
63
+ moveX: 0,
64
+ moveY: 0,
65
+ deltaX: 0,
66
+ deltaY: 0,
67
+ offsetX: 0,
68
+ offsetY: 0,
69
+ direction: ''
70
+ })
71
+ let scrollParent = null
72
+ const isPullRefresh = ref(false)
73
+ const distance = ref(0)
74
+ const status = ref('normal')
75
+
76
+ const getPullStatus = computed(() => {
77
+ if (status.value === 'pulling') {
78
+ return !slots.pulling ? props.pullingTxt : ''
79
+ } else if (status.value === 'loosing') {
80
+ return !slots.loosing ? props.loosingTxt : ''
81
+ } else if (status.value === 'loading') {
82
+ return !slots.loading ? props.loadingTxt : ''
92
83
  }
93
- },
94
- getStyle() {
84
+ return ''
85
+ })
86
+ const getStyle = computed(() => {
95
87
  return {
96
- transitionDuration: `${this.duration}s`,
97
- transform: this.distance ? `translate3d(0,${this.distance}px, 0)` : ''
88
+ transitionDuration: `${props.duration}s`,
89
+ transform: distance.value ? `translate3d(0,${distance.value}px, 0)` : ''
98
90
  }
99
- },
100
- getHeightStyle() {
101
- const styles = {}
102
- if (this.headHeight !== 40) styles.height = this.pxCheck(this.headHeight)
91
+ })
92
+ const getHeightStyle = computed(() => {
93
+ let styles = {}
94
+ if (props.headHeight !== 40) styles.height = pxCheck(props.headHeight)
103
95
  return styles
96
+ })
97
+
98
+ const initMounted = () => {
99
+ scrollParent = getScrollParent()
104
100
  }
105
- },
106
- watch: {
107
- modelValue(val) {
108
- if (val) {
109
- this.setPullStatus(+this.headHeight, true)
110
- this.$nextTick(() => this.$emit('refresh'))
111
- } else {
112
- this.setPullStatus(0)
113
- }
114
- }
115
- },
116
- mounted() {
117
- this.initMounted()
118
- },
119
- methods: {
120
- initMounted() {
121
- this.scrollParent = this.getScrollParent()
122
- },
123
- pxCheck(value) {
101
+ const pxCheck = value => {
124
102
  return isNaN(Number(value)) ? String(value) : `${value}px`
125
- },
126
- timing(distance) {
127
- const pullDistance = +(this.pullDistance || this.headHeight)
128
- let moveDistance = distance
129
- if (distance > pullDistance) {
130
- if (distance < pullDistance * 2) {
131
- moveDistance = (distance + pullDistance) / 2
103
+ }
104
+ const timing = distanceValue => {
105
+ const pullDistance = +(props.pullDistance || props.headHeight)
106
+ let moveDistance = distanceValue
107
+ if (distanceValue > pullDistance) {
108
+ if (distanceValue < pullDistance * 2) {
109
+ moveDistance = (distanceValue + pullDistance) / 2
132
110
  } else {
133
- moveDistance = pullDistance + distance / 4
111
+ moveDistance = pullDistance + distanceValue / 4
134
112
  }
135
113
  }
136
114
  return Math.round(moveDistance)
137
- },
138
- setPullStatus(distance, isLoading) {
139
- const pullDistance = +(this.pullDistance || this.headHeight)
140
- this.distance = distance
115
+ }
116
+ const setPullStatus = (distanceValue, isLoading) => {
117
+ const pullDistance = +(props.pullDistance || props.headHeight)
118
+ distance.value = distanceValue
141
119
  if (isLoading) {
142
- this.status = 'loading'
143
- } else if (distance === 0) {
144
- this.status = 'normal'
145
- } else if (distance < pullDistance) {
146
- this.status = 'pulling'
120
+ status.value = 'loading'
121
+ } else if (distanceValue === 0) {
122
+ status.value = 'normal'
123
+ } else if (distanceValue < pullDistance) {
124
+ status.value = 'pulling'
147
125
  } else {
148
- this.status = 'loosing'
126
+ status.value = 'loosing'
149
127
  }
150
- this.$emit('change', { status: this.status, distance })
151
- },
152
- isElement(node) {
128
+ emit('change', { status: status.value, distance: distanceValue })
129
+ }
130
+ const isElement = node => {
153
131
  return node.tagName !== 'HTML' && node.tagName !== 'BODY' && node.nodeType === 1
154
- },
155
- isVertical() {
156
- return this.touch.direction === 'vertical'
157
- },
158
- isHorizontal() {
159
- return this.touch.direction === 'horizontal'
160
- },
161
- getDirection(x, y) {
132
+ }
133
+ const isVertical = () => {
134
+ return touch.direction === 'vertical'
135
+ }
136
+ const isHorizontal = () => {
137
+ return touch.direction === 'horizontal'
138
+ }
139
+ const getDirection = (x, y) => {
162
140
  let MIN_DISTANCE = 10
163
141
  if (x > y && x > MIN_DISTANCE) {
164
142
  return 'horizontal'
@@ -167,35 +145,35 @@ export default {
167
145
  return 'vertical'
168
146
  }
169
147
  return ''
170
- },
171
- resetTouch() {
172
- this.touch.deltaX = 0
173
- this.touch.deltaY = 0
174
- this.touch.offsetX = 0
175
- this.touch.offsetY = 0
176
- this.touch.direction = ''
177
- },
178
- startTouch(event) {
179
- this.resetTouch()
180
- this.touch.startX = event.touches[0].clientX
181
- this.touch.startY = event.touches[0].clientY
182
- },
183
- moveTouch(event) {
148
+ }
149
+ const resetTouch = () => {
150
+ touch.deltaX = 0
151
+ touch.deltaY = 0
152
+ touch.offsetX = 0
153
+ touch.offsetY = 0
154
+ touch.direction = ''
155
+ }
156
+ const startTouch = event => {
157
+ resetTouch()
158
+ touch.startX = event.touches[0].clientX
159
+ touch.startY = event.touches[0].clientY
160
+ }
161
+ const moveTouch = event => {
184
162
  const touch = event.touches[0]
185
- this.touch.deltaX = touch.clientX - this.touch.startX
186
- this.touch.deltaY = touch.clientY - this.touch.startY
187
- this.touch.moveX = touch.clientX
188
- this.touch.moveY = touch.clientY
189
- this.touch.offsetX = Math.abs(this.touch.deltaX)
190
- this.touch.offsetY = Math.abs(this.touch.deltaY)
191
- if (!this.touch.direction) {
192
- this.touch.direction = this.getDirection(this.touch.offsetX, this.touch.offsetY)
163
+ touch.deltaX = touch.clientX - touch.startX
164
+ touch.deltaY = touch.clientY - touch.startY
165
+ touch.moveX = touch.clientX
166
+ touch.moveY = touch.clientY
167
+ touch.offsetX = Math.abs(touch.deltaX)
168
+ touch.offsetY = Math.abs(touch.deltaY)
169
+ if (!touch.direction) {
170
+ touch.direction = getDirection(touch.offsetX, touch.offsetY)
193
171
  }
194
- },
195
- getScrollParent(el, root = window) {
172
+ }
173
+ const getScrollParent = (el, root = window) => {
196
174
  let node = el
197
175
  const overflowScrollReg = /scroll|auto|overlay/i
198
- while (node && node !== root && this.isElement(node)) {
176
+ while (node && node !== root && isElement(node)) {
199
177
  const { overflowY } = window.getComputedStyle(node)
200
178
  if (overflowScrollReg.test(overflowY)) {
201
179
  return node
@@ -203,57 +181,78 @@ export default {
203
181
  node = node.parentNode
204
182
  }
205
183
  return root
206
- },
207
- getScrollTopRoot() {
184
+ }
185
+ const getScrollTopRoot = () => {
208
186
  return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0
209
- },
210
- isCanTouch() {
211
- return this.status !== 'loading' && this.status !== 'complete'
212
- },
213
- isScrollTop() {
214
- if (this.scrollParent === window) {
215
- return this.getScrollTopRoot() === 0
187
+ }
188
+ const isCanTouch = () => {
189
+ return !['loading', 'complete'].includes(status.value)
190
+ }
191
+ const isScrollTop = () => {
192
+ if (scrollParent === window) {
193
+ return getScrollTopRoot() === 0
216
194
  } else {
217
- return this.scrollParent && this.scrollParent.scrollTop === 0
195
+ return scrollParent && scrollParent.scrollTop === 0
218
196
  }
219
- },
220
- touchStart(event) {
221
- if (this.isCanTouch()) {
222
- if (this.isScrollTop()) {
223
- this.startTouch(event)
224
- this.isPullRefresh = true
225
- } else {
226
- this.distance = 0
227
- this.isPullRefresh = false
228
- }
197
+ }
198
+ const touchStart = event => {
199
+ if (!isCanTouch()) return
200
+ if (isScrollTop()) {
201
+ startTouch(event)
202
+ isPullRefresh.value = true
203
+ } else {
204
+ distance.value = 0
205
+ isPullRefresh.value = false
229
206
  }
230
- },
231
- touchMove(event) {
232
- if (this.isCanTouch()) {
233
- this.moveTouch(event)
234
- if (this.isVertical() && this.touch.deltaY > 0 && this.isPullRefresh) {
235
- event.preventDefault()
236
- this.setPullStatus(this.timing(this.touch.deltaY))
237
- }
207
+ }
208
+ const touchMove = event => {
209
+ if (!isCanTouch()) return
210
+ moveTouch(event)
211
+ if (isVertical() && touch.deltaY > 0 && isPullRefresh) {
212
+ event.preventDefault()
213
+ setPullStatus(timing(touch.deltaY))
238
214
  }
239
- },
240
- touchEnd() {
241
- const that = this
242
- if (that.isPullRefresh && that.isCanTouch() && that.touch.deltaY) {
243
- if (that.status === 'loosing') {
244
- that.setPullStatus(+that.headHeight, true)
245
- that.$emit('update:modelValue', true)
246
- that.$nextTick(() => that.$emit('refresh'))
215
+ }
216
+ const touchEnd = () => {
217
+ if (isPullRefresh.value && isCanTouch() && touch.deltaY) {
218
+ if (status.value === 'loosing') {
219
+ setPullStatus(+props.headHeight, true)
220
+ emit('update:modelValue', true)
221
+ nextTick(() => emit('refresh'))
247
222
  } else {
248
- that.setPullStatus(0)
223
+ setPullStatus(0)
249
224
  }
250
225
  }
251
226
  setTimeout(() => {
252
- that.resetTouch()
227
+ resetTouch()
253
228
  }, 0)
254
229
  }
230
+
231
+ watch(
232
+ () => props.modelValue,
233
+ val => {
234
+ if (val) {
235
+ setPullStatus(+props.headHeight, true)
236
+ nextTick(() => emit('refresh'))
237
+ } else {
238
+ setPullStatus(0)
239
+ }
240
+ }
241
+ )
242
+
243
+ onMounted(() => {
244
+ initMounted()
245
+ })
246
+
247
+ return {
248
+ getStyle,
249
+ getHeightStyle,
250
+ touchStart,
251
+ touchMove,
252
+ touchEnd
253
+ }
255
254
  }
256
- }
255
+ })
257
256
  </script>
258
257
 
259
258
  <style scoped lang="scss">
@@ -1,12 +1,12 @@
1
1
  <template>
2
2
  <div class="sh-result">
3
- <div v-if="isicon || $slots.icon" class="sh-result-icon" :class="resultType">
3
+ <div v-if="isicon || slots.icon" class="sh-result-icon" :class="resultType">
4
4
  <slot name="icon"><sh-icon :type="resultIcon" :size="iconSize" /></slot>
5
5
  </div>
6
- <div v-if="resultTitle || $slots.title" class="sh-result-title" :title="resultTitle">
6
+ <div v-if="resultTitle || slots.title" class="sh-result-title" :title="resultTitle">
7
7
  <slot name="title">{{ resultTitle }}</slot>
8
8
  </div>
9
- <div v-if="text || $slots.text" v-line-clamp="clamp" class="sh-result-text" :title="text">
9
+ <div v-if="text || slots.text" v-line-clamp="clamp" class="sh-result-text" :title="text">
10
10
  <slot name="text">{{ text }}</slot>
11
11
  </div>
12
12
  <slot name="default"></slot>
@@ -14,9 +14,9 @@
14
14
  </template>
15
15
 
16
16
  <script>
17
- export default {
17
+ import { defineComponent, computed } from 'vue'
18
+ export default defineComponent({
18
19
  name: 'ShResult',
19
- components: {},
20
20
  props: {
21
21
  type: {
22
22
  type: String,
@@ -47,31 +47,40 @@ export default {
47
47
  default: 2
48
48
  }
49
49
  },
50
- computed: {
51
- resultType() {
52
- let types = ['success', 'error', 'warning', 'info']
53
- return types.includes(this.type) ? this.type : 'info'
54
- },
55
- resultTitle() {
56
- let resultTitleMap = {
57
- success: '成功',
58
- error: '失败',
59
- warning: '警告',
60
- info: '提示'
61
- }
62
- return typeof this.title === 'string' ? this.title : resultTitleMap[this.resultType]
63
- },
64
- resultIcon() {
65
- let resultIconMap = {
66
- success: 'ios-checkmark-circle',
67
- error: 'ios-close-circle',
68
- warning: 'ios-alert',
69
- info: 'ios-information-circle'
70
- }
71
- return resultIconMap[this.resultType]
50
+ setup(props, context) {
51
+ const { emit, slots } = context
52
+ let types = ['success', 'error', 'warning', 'info']
53
+ let resultTitleMap = {
54
+ success: '成功',
55
+ error: '失败',
56
+ warning: '警告',
57
+ info: '提示'
58
+ }
59
+ let resultIconMap = {
60
+ success: 'ios-checkmark-circle',
61
+ error: 'ios-close-circle',
62
+ warning: 'ios-alert',
63
+ info: 'ios-information-circle'
64
+ }
65
+
66
+ const resultType = computed(() => {
67
+ return types.includes(props.type) ? props.type : 'info'
68
+ })
69
+ const resultTitle = computed(() => {
70
+ return typeof props.title === 'string' ? props.title : resultTitleMap[resultType.value]
71
+ })
72
+ const resultIcon = computed(() => {
73
+ return resultIconMap[resultType.value]
74
+ })
75
+
76
+ return {
77
+ slots,
78
+ resultType,
79
+ resultTitle,
80
+ resultIcon
72
81
  }
73
82
  }
74
- }
83
+ })
75
84
  </script>
76
85
 
77
86
  <style lang="scss" scoped>
@@ -5,15 +5,10 @@
5
5
  </template>
6
6
 
7
7
  <script>
8
+ import { defineComponent, computed, provide } from 'vue'
8
9
  import './css/index.scss'
9
- const prefixCls = 'sh-row'
10
- export default {
10
+ export default defineComponent({
11
11
  name: 'ShRow',
12
- provide() {
13
- return {
14
- RowInstance: this
15
- }
16
- },
17
12
  props: {
18
13
  align: {
19
14
  type: String,
@@ -35,29 +30,37 @@ export default {
35
30
  type: Boolean
36
31
  }
37
32
  },
38
- computed: {
39
- classes() {
33
+ setup(props, context) {
34
+ const prefixCls = 'sh-row'
35
+ provide('RowInstance', props)
36
+
37
+ const classes = computed(() => {
40
38
  return [
41
39
  `${prefixCls}`,
42
40
  {
43
- [`${prefixCls}-${this.align}`]: !!this.align,
44
- [`${prefixCls}-${this.justify}`]: !!this.justify,
45
- [`${prefixCls}-wrap`]: this.wrap
41
+ [`${prefixCls}-${props.align}`]: !!props.align,
42
+ [`${prefixCls}-${props.justify}`]: !!props.justify,
43
+ [`${prefixCls}-wrap`]: props.wrap
46
44
  }
47
45
  ]
48
- },
49
- styles() {
46
+ })
47
+ const styles = computed(() => {
50
48
  let style = {}
51
- if (this.gutter !== 0 && this.margin) {
49
+ if (props.gutter !== 0 && props.margin) {
52
50
  style = {
53
- marginLeft: this.gutter / -2 + 'px',
54
- marginRight: this.gutter / -2 + 'px'
51
+ marginLeft: props.gutter / -2 + 'px',
52
+ marginRight: props.gutter / -2 + 'px'
55
53
  }
56
54
  }
57
55
  return style
56
+ })
57
+
58
+ return {
59
+ classes,
60
+ styles
58
61
  }
59
62
  }
60
- }
63
+ })
61
64
  </script>
62
65
 
63
66
  <style scoped lang="scss"></style>