Browse Source

radio、select组件增加必输标识;loading组件修改

pull/49/head
zq 2 weeks ago
parent
commit
8c33b2b2f3
  1. 38
      src/components/GlobalLoading1.vue
  2. 12
      src/components/GuipRadio.vue
  3. 3
      src/components/GuipSelect.vue

38
src/components/GlobalLoading1.vue

@ -1,18 +1,19 @@
<template> <template>
<div class="content-loading-overlay" v-if="isLoading"> <div>
<div class="content-loading-overlay" v-show="isLoading">
<div class="loading-content"> <div class="loading-content">
<div ref="animationContainer" class="animation-container"></div> <div ref="animationContainer" class="animation-container"></div>
</div> </div>
</div> </div>
<div v-else style="height: 100%;"> <div v-show="!isLoading">
<slot></slot> <slot></slot>
</div> </div>
</div>
</template> </template>
<script> <script>
import lottie from 'lottie-web' import lottie from 'lottie-web'
import { mapState } from 'vuex' import { mapState } from 'vuex'
import defaultAnimation from '@/assets/loadingAni.json' // JSON import defaultAnimation from '@/assets/loadingAni.json'
export default { export default {
name: 'Loading', name: 'Loading',
@ -26,41 +27,42 @@ export default {
}, },
watch: { watch: {
isLoading(newVal) { isLoading(newVal) {
if (newVal) {
this.$nextTick(() => { this.$nextTick(() => {
if (newVal) {
this.playAnimation() this.playAnimation()
})
} else { } else {
this.stopAnimation() this.stopAnimation()
} }
})
} }
}, },
mounted() {
if (this.isLoading) {
this.playAnimation()
}
},
beforeDestroy() {
this.stopAnimation()
},
methods: { methods: {
playAnimation() { playAnimation() {
//
if (this.anim) {
this.anim.destroy()
this.anim = null
}
console.log('执行动画')
this.anim = lottie.loadAnimation({ this.anim = lottie.loadAnimation({
container: this.$refs.animationContainer, container: this.$refs.animationContainer,
renderer: 'svg', renderer: 'svg',
loop: true, loop: true,
autoplay: true, autoplay: true,
animationData: defaultAnimation // JSON animationData: defaultAnimation
}) })
if (this.anim) {
this.anim.play()
}
}, },
stopAnimation() { stopAnimation() {
if (this.anim) { if (this.anim) {
this.anim.stop() this.anim.stop()
} }
} }
},
beforeDestroy() {
if (this.anim) {
this.anim.destroy() //
}
} }
} }
</script> </script>

12
src/components/GuipRadio.vue

@ -1,7 +1,7 @@
<template> <template>
<el-form-item <el-form-item
:class="[{'column':column},'form-item']" :class="[{'column':column},'form-item']"
:label="label" :prop="prop" :rules="rules"> :label="label" :prop="prop" :rules="rules" :required="required">
<el-radio-group <el-radio-group
v-model="selectedValue" v-model="selectedValue"
v-bind="$attrs" v-bind="$attrs"
@ -14,11 +14,7 @@
:disabled="option.disabled" :disabled="option.disabled"
> >
<!-- 默认展示和选中显示 不同文案 --> <!-- 默认展示和选中显示 不同文案 -->
{{ selectedValue === option.value ? option.selectedLabel : option.label }} {{( selectedValue === option.value ) ? (option.selectedLabel ? option.selectedLabel : option.label) :option.label }}
<!-- 自定义 选中图标 -->
<!-- <template #label>
<span><img src="../assets/radio_checked.svg" alt="custom icon" style="width: 16px; height: 16px;"> {{ text }}</span>
</template> -->
</el-radio> </el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
@ -30,6 +26,10 @@
props: { props: {
// //
column:{ column:{
type:String,
default:''
},
required:{
type:Boolean, type:Boolean,
default:false default:false
}, },

3
src/components/GuipSelect.vue

@ -1,5 +1,5 @@
<template> <template>
<el-form-item :style="{ ...style, height: height, ...styleObject }" <el-form-item :style="{ ...style, height: height, ...styleObject }" :required="required"
:class="[{ 'column': column }, { 'w510': addClass == 'w510' }, { 'w388': addClass == 'w388' }, 'form-item']" :class="[{ 'column': column }, { 'w510': addClass == 'w510' }, { 'w388': addClass == 'w388' }, 'form-item']"
:label="label" :prop="prop" :rules="rules"> :label="label" :prop="prop" :rules="rules">
<p v-if="desc" class="desc_right">{{ desc }}</p> <p v-if="desc" class="desc_right">{{ desc }}</p>
@ -32,6 +32,7 @@ export default {
}, },
styleObject: Object, styleObject: Object,
disabled: Boolean, disabled: Boolean,
required: Boolean,
defaultValue: [String, Number, Array], defaultValue: [String, Number, Array],
placeholder: String, placeholder: String,
width: String, width: String,

Loading…
Cancel
Save