Files
dvcp_v2_wxcp_app/src/apps/AppMailList/add.vue

189 lines
5.2 KiB
Vue
Raw Normal View History

2021-12-21 15:41:51 +08:00
<template>
<div class="add">
<div class="pad-l32">
<div class="item border">
<span class="label"><span class="tips">*</span>名称</span>
<div class="value">
2021-12-22 18:56:44 +08:00
<u-input type="text" placeholder="请输入" v-model="userInfo.name" input-align="right" placeholder-style="color:#999;font-size:16px;" height="48" :maxlength="30" :clearable="false" />
2021-12-21 15:41:51 +08:00
</div>
</div>
<div class="item border">
<span class="label"><span class="tips">*</span>类型</span>
<div class="value">
2021-12-22 18:56:44 +08:00
<u-input type="text" placeholder="请输入" v-model="userInfo.type" input-align="right" placeholder-style="color:#999;font-size:16px;" height="48" :maxlength="30" :clearable="false" />
2021-12-21 15:41:51 +08:00
</div>
</div>
<div class="item border">
<span class="label"><span class="tips">*</span>电话</span>
<div class="value">
2021-12-22 18:56:44 +08:00
<u-input type="number" placeholder="请输入" v-model="userInfo.phone" input-align="right" placeholder-style="color:#999;font-size:16px;" height="48" :maxlength="11" :clearable="false" />
2021-12-21 15:41:51 +08:00
</div>
</div>
<div class="item border">
<span class="label"><span class="tips">*</span>是否公开</span>
<div class="value" @click="showSelect=true">
2021-12-22 15:18:32 +08:00
<span v-if="userInfo.isPublic !== ''">{{$dict.getLabel('yesOrNo', userInfo.isPublic)}}</span>
<span v-else class="color-999">请选择</span>
2021-12-21 15:41:51 +08:00
<u-icon name="arrow-right" color="#cccccc" size="14"></u-icon>
</div>
</div>
<div class="item">
<span class="label"><span class="tips">*</span>地区</span>
2021-12-22 16:42:38 +08:00
<div class="value">
2021-12-21 15:41:51 +08:00
<AiAreaPicker :areaId="user.areaId" v-model="userInfo.areaId" @select="areaSelect">
<span class="label" v-if="userInfo.areaName">{{ userInfo.areaName }}</span>
<span v-else class="color-999">请选择</span>
<u-icon name="arrow-right" color="#cccccc" size="14"></u-icon>
</AiAreaPicker>
</div>
</div>
</div>
<div class="footer" @click="submit">
<div class="btn">保存</div>
</div>
<u-select v-model="showSelect" :list="$dict.getDict('yesOrNo')" label-name="dictName" value-name="dictValue" @confirm="confirmSelect"></u-select>
</div>
</template>
<script>
import { mapState } from 'vuex'
export default {
props: ['params'],
data() {
return {
id: '',
userInfo: {
id: '',
name: '',
phone: '',
type: '',
isPublic: '',
areaId: '',
areaName: ''
},
showSelect: false,
2021-12-21 17:08:53 +08:00
flag: true
2021-12-21 15:41:51 +08:00
}
},
computed: { ...mapState(['user']) },
2021-12-22 19:11:23 +08:00
onLoad(option) {
2021-12-22 16:45:16 +08:00
this.userInfo.areaId = this.user.areaId
this.userInfo.areaName = this.user.areaName
2021-12-21 15:41:51 +08:00
this.$dict.load('yesOrNo').then(() => {
2021-12-22 19:11:23 +08:00
if(option.id) {
this.userInfo.id = option.id
2021-12-21 15:41:51 +08:00
this.getDetail()
}
})
2021-12-23 16:56:41 +08:00
uni.setNavigationBarTitle({title: '新增'})
2021-12-21 15:41:51 +08:00
},
methods: {
areaSelect(e) {
this.userInfo.areaId = e.id
this.userInfo.areaName = e.name
},
confirmSelect(e) {
this.userInfo.isPublic = e[0].value
},
getDetail() {
this.$http.post(`/app/appconvenientaddressbook/queryDetailById?id=${this.userInfo.id}`).then(res => {
if (res.code == 0) {
this.userInfo = res.data
}
})
},
submit() {
if(!this.userInfo.name) {
return this.$u.toast('请输入名称')
}
if(!this.userInfo.type) {
return this.$u.toast('请输入类型')
}
if(!this.userInfo.phone) {
return this.$u.toast('请输入电话')
}
if(this.userInfo.isPublic === '') {
return this.$u.toast('请选择是否公开')
}
if(!this.userInfo.areaId) {
return this.$u.toast('请选择地区')
}
2021-12-21 17:08:53 +08:00
if(!this.flag) return
2021-12-21 15:41:51 +08:00
this.$http.post(`/app/appconvenientaddressbook/addOrUpdate`, this.userInfo).then(res => {
if (res.code == 0) {
2021-12-21 17:08:53 +08:00
this.flag = false
2021-12-21 15:41:51 +08:00
this.$u.toast('提交成功')
setTimeout(() => {
uni.navigateBack()
}, 600)
}
})
},
}
}
</script>
<style lang="scss" scoped>
.add {
padding-bottom: 112px;
.border{
border-bottom: 1px solid #ddd;
}
.item{
width: 100%;
padding: 40px 32px 40px 0;
background: #FFFFFF;
display: flex;
justify-content: space-between;
font-size: 34px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #666;
line-height: 48px;
box-sizing: border-box;
.color-999{
color: #999;
}
.value{
color: #333;
.u-icon{
margin-left: 16px;
}
}
.tips{
display: inline-block;
width: 16px;
font-size: 32px;
font-family: PingFangSC-Regular, PingFang SC;
color: #FF4466;
line-height: 44px;
margin-right: 4px;
}
}
.footer{
width: 100%;
position: fixed;
bottom: 0;
left: 0;
}
.btn{
width: 100%;
height: 112px;
line-height: 112px;
text-align: center;
background: #3975C6;
font-size: 32px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FFF;
}
.pad-l32{
padding-left: 32px;
background-color: #fff;
}
}
</style>