Browse Source

Merge pull request 'zq-slider-menu' (#49) from zq-slider-menu into master

Reviewed-on: #49
pull/52/head
zhangqi 2 weeks ago
parent
commit
35b0f8450c
  1. 106
      src/components/GlobalLoading1.vue
  2. 4
      src/components/GuipInput.vue
  3. 162
      src/components/GuipRadio.vue
  4. 3
      src/components/GuipSelect.vue
  5. 14
      src/views/elementGroups.vue

106
src/components/GlobalLoading1.vue

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

4
src/components/GuipInput.vue

@ -1,5 +1,5 @@
<template>
<el-form-item :style="{ height: height, ...styleObject }"
<el-form-item :style="{ ...styleObject }" :required="required"
:class="[{ 'column': column }, { 'w510': addClass == 'w510' }, { 'w388': addClass == 'w388' }, 'form-item']" :label="label"
:prop="prop" :rules="rules">
<p v-if="desc" class="desc_right">{{ desc }}</p>
@ -36,7 +36,7 @@
<script>
export default {
name: 'GuipInput',
props: ['value', 'styleObject', 'disabled', 'defaultValue', 'placeholder',
props: ['value', 'styleObject', 'disabled', 'defaultValue', 'placeholder','required',
'maxlength', 'minLength', 'clear', 'width', 'height', 'showWordLimit',
'label', 'type', 'prop', 'rules', 'column', 'addClass', 'desc', 'unit'],
data() {

162
src/components/GuipRadio.vue

@ -1,88 +1,88 @@
<template>
<el-form-item
:class="[{'column':column},'form-item']"
:label="label" :prop="prop" :rules="rules">
<el-radio-group
v-model="selectedValue"
v-bind="$attrs"
@change="handleChange"
<template>
<el-form-item
:class="[{'column':column},'form-item']"
:label="label" :prop="prop" :rules="rules" :required="required">
<el-radio-group
v-model="selectedValue"
v-bind="$attrs"
@change="handleChange"
>
<el-radio
v-for="option in options"
:key="option.value"
:label="option.value"
:disabled="option.disabled"
>
<el-radio
v-for="option in options"
:key="option.value"
:label="option.value"
:disabled="option.disabled"
>
<!-- 默认展示和选中显示 不同文案 -->
{{ selectedValue === option.value ? option.selectedLabel : 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-group>
</el-form-item>
</template>
<!-- 默认展示和选中显示 不同文案 -->
{{( selectedValue === option.value ) ? (option.selectedLabel ? option.selectedLabel : option.label) :option.label }}
</el-radio>
</el-radio-group>
</el-form-item>
</template>
<script>
export default {
name: 'MyRadioGroup',
props: {
//
column:{
type:Boolean,
default:false
},
// [{ label: '', value: '', disabled: false }]
options: {
type: Array,
required: true,
},
// 使 v-model
value: {
type: [String, Number, Boolean],
default: '',
},
// label
label: {
type: String,
default: '',
},
// prop
prop: {
type: String,
default: '',
},
//
rules: {
type: Array,
default: () => [],
},
<script>
export default {
name: 'MyRadioGroup',
props: {
//
column:{
type:String,
default:''
},
data() {
return {
selectedValue: this.value, //
};
required:{
type:Boolean,
default:false
},
watch: {
// value selectedValue
value(newVal) {
this.selectedValue = newVal;
},
// [{ label: '', value: '', disabled: false }]
options: {
type: Array,
required: true,
},
methods: {
//
handleChange(value) {
this.$emit('input', value); // v-model
this.$emit('change', value); // change
},
// 使 v-model
value: {
type: [String, Number, Boolean],
default: '',
},
};
</script>
// label
label: {
type: String,
default: '',
},
// prop
prop: {
type: String,
default: '',
},
//
rules: {
type: Array,
default: () => [],
},
},
data() {
return {
selectedValue: this.value, //
};
},
watch: {
// value selectedValue
value(newVal) {
this.selectedValue = newVal;
},
},
methods: {
//
handleChange(value) {
this.$emit('input', value); // v-model
this.$emit('change', value); // change
},
},
};
</script>
<style scoped>
/* 自定义样式 */
.el-radio-group {
margin: 10px 0;
}
</style>
<style scoped>
/* 自定义样式 */
.el-radio-group {
margin: 10px 0;
}
</style>

3
src/components/GuipSelect.vue

@ -1,5 +1,5 @@
<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']"
:label="label" :prop="prop" :rules="rules">
<p v-if="desc" class="desc_right">{{ desc }}</p>
@ -32,6 +32,7 @@ export default {
},
styleObject: Object,
disabled: Boolean,
required: Boolean,
defaultValue: [String, Number, Array],
placeholder: String,
width: String,

14
src/views/elementGroups.vue

@ -11,7 +11,7 @@
</div>
<div class="ele-item">
<label for="">下拉框</label>
<GuipSelect width="600px" v-model="form.card" label="卡片" prop="card" :options="options"
<GuipSelect width="600px" v-model="form.card" label="卡片" :default-value="form.card" prop="card" :options="options" valueKey="id1" labelKey="id2"
defaultValue="选项1" />
</div>
<div>
@ -263,7 +263,7 @@
<div style="width: 800px;height: 150px;">
<h3>表单上下布局 (宽度 510 388 用的最多 已有这2种宽度类名设置)</h3>
<GuipInput ref="GuipInput" column="column" addClass="w510" label="age" desc="这是是右侧文案"
<GuipInput ref="GuipInput" column="column" addClass="w510" required label="age" desc="这是是右侧文案"
v-model="form.age" prop="age" placeholder="这是自定义默认提示语" />
</div>
@ -640,21 +640,31 @@ export default {
options: [{
value: '选项1',
label1: '黄金hhhhhh',
id1:'1',
id2:'啊11哈哈',
label: '黄金糕'
}, {
value: '选项2',
id1:'12',
id2:'啊22哈哈',
label1: '双皮奶hhhhhhhhh',
label: '双皮奶'
}, {
value: '选项3',
id1:'13',
id2:'啊33哈哈',
label1: '蚵仔煎hhhhhhhhh',
label: '蚵仔煎'
}, {
value: '选项4',
id1:'14',
id2:'啊444哈哈',
label1: '双皮奶hhhhhhhhh',
label: '龙须面'
}, {
value: '选项5',
id1:'155',
id2:'啊55哈哈',
label1: '双皮奶hhhhhhhhh',
label: '北京烤鸭'
}],

Loading…
Cancel
Save