Files
dvcp_v2_wxcp_app/src/project/caw/AppCountryAlbum/WatermarkConfig.vue

213 lines
5.6 KiB
Vue
Raw Normal View History

2022-05-17 14:58:10 +08:00
<template>
<div class="AttendanceFiexdTime">
<div class="form-group">
2022-05-31 11:18:51 +08:00
<div class="form-group__item" @click.stop="onClick(item.editEnable)" hover-class="bg-hover" v-if="item.fieldType" v-for="(item, index) in config" :key="index">
2022-05-17 14:58:10 +08:00
<div class="left">
2022-05-31 11:18:51 +08:00
<switch @click.stop="onSwitchClick(item.editEnable)" :color="item.editEnable === '0' ? '#B7DBFD' : '#1088F9'" :checked="item.status === '1'" :disabled="item.editEnable === '0'" @change="e => onChange(e, index)" />
2022-05-23 18:00:28 +08:00
</div>
<div class="right" @click="toInput(item)" v-if="['6', '7'].indexOf(item.fieldType) === -1">
<div class="right-left">
2022-05-19 14:43:42 +08:00
<h2>{{ mapFieldLable(item.type) }}</h2>
2022-05-31 11:18:51 +08:00
<p :style="{color: item.defaultValue ? '#333' : '#999'}">{{ item.defaultValue || mapType(item.fieldType) }}</p>
2022-05-17 14:58:10 +08:00
</div>
2022-05-31 11:18:51 +08:00
<u-icon name="arrow-right" color="#E1E2E3" v-if="item.editEnable !== '0'"></u-icon>
2022-05-17 14:58:10 +08:00
</div>
2022-06-01 16:24:18 +08:00
<picker mode="date" :disabled="item.editEnable === '0'" style="flex: 1;" v-if="item.fieldType === '7'" :value="item.defaultValue" @change="e => onDateChange(e, index)">
2022-05-23 18:00:28 +08:00
<div class="right">
<div class="right-left">
<h2>{{ mapFieldLable(item.type) }}</h2>
<p>{{ item.defaultValue || '' }}</p>
</div>
2022-05-31 11:18:51 +08:00
<u-icon name="arrow-right" color="#E1E2E3" v-if="item.editEnable !== '0'"></u-icon>
2022-05-23 18:00:28 +08:00
</div>
</picker>
2022-06-01 16:24:18 +08:00
<picker mode="time" style="flex: 1;" :disabled="item.editEnable === '0'" v-if="item.fieldType === '6'" :value="item.defaultValue" @change="e => onDateChange(e, index)">
2022-05-23 18:00:28 +08:00
<div class="right">
<div class="right-left">
<h2>{{ mapFieldLable(item.type) }}</h2>
<p>{{ item.defaultValue || '' }}</p>
</div>
2022-05-31 11:18:51 +08:00
<u-icon name="arrow-right" color="#E1E2E3" v-if="item.editEnable !== '0'"></u-icon>
2022-05-23 18:00:28 +08:00
</div>
</picker>
2022-05-17 14:58:10 +08:00
</div>
</div>
2022-05-19 14:43:42 +08:00
<div class="form-btn" hover-class="text-hover" @click="save">保存</div>
2022-05-17 14:58:10 +08:00
</div>
</template>
<script>
2022-05-19 14:43:42 +08:00
import { mapFieldLable } from './config'
2022-05-17 14:58:10 +08:00
export default {
2022-05-27 15:51:58 +08:00
appName: '表单配置',
2022-05-17 14:58:10 +08:00
data () {
return {
2022-05-19 14:43:42 +08:00
config: [],
mapFieldLable
2022-05-17 14:58:10 +08:00
}
},
onLoad () {
2022-05-19 14:43:42 +08:00
this.config = uni.getStorageSync('waterConfig')
2022-05-17 14:58:10 +08:00
2022-05-25 18:14:07 +08:00
uni.$on('filedChange', e => {
2022-05-19 14:43:42 +08:00
this.config.forEach((v, index) => {
if (v.type === e.type) {
this.$set(this.config[index], 'defaultValue', e.defaultValue)
}
})
})
2022-05-17 14:58:10 +08:00
},
methods: {
linkTo (url) {
uni.navigateTo({
url
})
2022-05-19 14:43:42 +08:00
},
2022-05-31 11:18:51 +08:00
mapType (type) {
return {
'0': '请输入内容',
'1': '请输入内容',
'2': '请选择天气',
'3': '请选择地址',
'4': '请选择定位',
'5': '请选择经纬度',
'6': '请选择时间',
'7': '请选择日期'
}[type]
},
2022-05-23 18:00:28 +08:00
onDateChange (e, index) {
this.$set(this.config[index], 'defaultValue', e.detail.value)
},
2022-05-19 14:43:42 +08:00
onChange (e, index) {
this.$set(this.config[index], 'status', e.detail.value ? '1' : '0')
},
2022-05-31 11:18:51 +08:00
onSwitchClick (status) {
if (status === '0') {
return this.$u.toast('该选项不允许关闭')
}
},
onClick (status) {
if (status === '0') {
return this.$u.toast('该选项不允许修改内容')
}
},
2022-05-19 14:43:42 +08:00
toInput (e) {
if (e.editEnable === '0') return
if (e.fieldType === '2') return
2022-05-24 16:31:10 +08:00
if (e.fieldType === '3') {
uni.setStorageSync('formConfig', e)
this.linkTo('./ChooseAddess?type=address')
return false
}
2022-05-19 14:43:42 +08:00
uni.setStorageSync('formConfig', e)
this.linkTo('./Form')
},
save () {
for (let i = 0; i < this.config.length; i ++) {
2022-05-24 16:31:10 +08:00
if (['2', '3', '4', '5'].indexOf(this.config[i].fieldType) === -1 && this.config[i].fieldType && !this.config[i].defaultValue && this.config[i].status === '1') {
2022-05-19 14:43:42 +08:00
return this.$u.toast(`请输入${this.mapFieldLable(this.config[i].type)}`)
}
}
uni.$emit('change', this.config)
uni.navigateBack({
delta: 1
})
2022-05-17 14:58:10 +08:00
}
}
}
</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;
2022-05-19 14:43:42 +08:00
padding: 32rpx 0;
2022-05-17 14:58:10 +08:00
font-size: 32px;
color: #333333;
border-bottom: 1px solid #DDDDDD;
&:last-child {
border: none;
}
2022-05-23 18:00:28 +08:00
.right {
2022-05-17 14:58:10 +08:00
display: flex;
align-items: center;
2022-05-19 14:43:42 +08:00
flex: 1;
2022-05-23 18:00:28 +08:00
margin-left: 36px;
2022-05-17 14:58:10 +08:00
2022-05-23 18:00:28 +08:00
.right-left {
2022-05-19 14:43:42 +08:00
flex: 1;
2022-05-17 14:58:10 +08:00
h2 {
margin-bottom: 12px;
color: #999999;
font-size: 28px;
}
p {
2022-05-24 16:31:10 +08:00
line-height: 1.3;
2022-05-17 14:58:10 +08:00
font-size: 34px;
color: #333;
}
}
}
2022-05-23 18:00:28 +08:00
.left {
display: flex;
align-items: center;
margin-right: 10px;
}
2022-05-17 14:58:10 +08:00
}
}
}
</style>