Files
dvcp_v2_wxcp_app/src/saas/AppCountryAlbum/WatermarkConfig.vue
2022-05-19 14:43:54 +08:00

149 lines
3.3 KiB
Vue

<template>
<div class="AttendanceFiexdTime">
<div class="form-group">
<div class="form-group__item" hover-class="bg-hover" v-for="(item, index) in config" :key="index">
<div class="left">
<switch color="#1088F9" :checked="item.status === '1'" :disabled="item.editEnable === '0'" @change="e => onChange(e, index)" />
<div class="left-right" @click="toInput(item)">
<h2>{{ mapFieldLable(item.type) }}</h2>
<p>{{ item.defaultValue || '' }}</p>
</div>
</div>
<div class="right" @click="toInput(item)">
<u-icon name="arrow-right" color="#E1E2E3" size="#E1E2E3"></u-icon>
</div>
</div>
</div>
<div class="form-btn" hover-class="text-hover" @click="save">保存</div>
</div>
</template>
<script>
import { mapFieldLable } from './config'
export default {
data () {
return {
config: [],
mapFieldLable
}
},
onLoad () {
this.config = uni.getStorageSync('waterConfig')
uni.$on('change', e => {
this.config.forEach((v, index) => {
if (v.type === e.type) {
this.$set(this.config[index], 'defaultValue', e.defaultValue)
}
})
})
},
methods: {
linkTo (url) {
uni.navigateTo({
url
})
},
onChange (e, index) {
this.$set(this.config[index], 'status', e.detail.value ? '1' : '0')
},
toInput (e) {
if (e.editEnable === '0') return
if (e.fieldType === '2') return
uni.setStorageSync('formConfig', e)
this.linkTo('./Form')
},
save () {
for (let i = 0; i < this.config.length; i ++) {
if ((this.config[i].fieldType === '0' || this.config[i].fieldType === '1') && !this.config[i].defaultValue && this.config[i].status === '1') {
return this.$u.toast(`请输入${this.mapFieldLable(this.config[i].type)}`)
}
}
uni.$emit('change', this.config)
uni.navigateBack({
delta: 1
})
}
}
}
</script>
<style lang="scss" scoped>
.AttendanceFiexdTime {
padding-bottom: 130px;
* {
line-height: 1;
box-sizing: border-box;
}
.form-btn {
position: fixed;
bottom: 0;
left: 0;
z-index: 1;
width: 100%;
height: 112px;
line-height: 112px;
text-align: center;
color: #fff;
font-size: 32px;
background: #1365DD;
&:active {
opacity: 0.8;
}
}
.form-group {
margin-bottom: 16px;
padding: 0 32px;
background: #fff;
.form-group__item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 32rpx 0;
font-size: 32px;
color: #333333;
border-bottom: 1px solid #DDDDDD;
&:last-child {
border: none;
}
.left {
display: flex;
align-items: center;
flex: 1;
margin-right: 10px;
.left-right {
flex: 1;
margin-left: 36px;
h2 {
margin-bottom: 12px;
color: #999999;
font-size: 28px;
}
p {
font-size: 34px;
color: #333;
}
}
}
}
}
}
</style>