Files
dvcp_v2_wechat_app/project/sanjianxi/AppNeighborLinkage/addLinkage.vue
shijingjing 29cb1e4448 四邻
2022-04-19 14:38:12 +08:00

146 lines
3.2 KiB
Vue

<template>
<div class="addLinkage">
<div class="item">
<div><span>*</span>四邻对象</div>
<AiSelect class="right" v-model="form.id" :list="userList"/>
</div>
<div class="item">
<div><span>*</span>事件日期</div>
<div @click="isShowDate = true">
<span v-if="form.linksageDate" >{{ form.linksageDate }}</span>
<span v-else style="color: #999;">请选择</span>
<u-icon name="arrow-right" color="#ddd"/>
</div>
</div>
<u-picker mode="time" :params="params" v-model="isShowDate" @confirm="onDateChange"></u-picker>
<div>
<div class="title"><span style="color: #FF4466">*</span>事件描述</div>
<div>
<u-input type="textarea" v-model="form.description" placeholder="请输入事件内容描述" height="200" maxlength="500"/>
</div>
<div class="tips">{{form.description.length}}/500</div>
</div>
<div class="btn">
<div class="addBtn" @click="confirm">提交</div>
</div>
</div>
</template>
<script>
export default {
name: "addLinkage",
appName: "添加联动记录",
data() {
return {
params: {
year: true,
month: true,
day: true,
},
isShowDate: false,
form: {
id: '',
linksageDate: '',
description: '',
},
userList: []
}
},
onShow() {
this.$dict.load('agriculturalType')
this.getUserList()
},
methods: {
onDateChange(e) {
this.form.linksageDate = `${e.year}-${e.month}-${e.day}`
},
getUserList() {
this.$instance.post('/app/apppartyfourresident/listFourResidentByApplet').then((res) => {
if(res?.data) {
res.data.map((item) => {
this.userList.push({
label: item.name,
value: item.id,
})
})
}
})
},
confirm() {
if(!this.form.id) {
return this.$u.toast('请选择四邻对象')
}
if(!this.form.linksageDate) {
return this.$u.toast('请选择事件日期')
}
if(!this.form.description) {
return this.$u.toast('请输入事件描述')
}
this.$instance.post('/app/apppartyfourlinkage/addOrUpdate',{
...this.form
}).then(res => {
if(res.code == 0) {
this.$u.toast('添加联动记录成功')
uni.$emit('update')
setTimeout(() => {
uni.navigateBack()
},600)
}
})
}
}
}
</script>
<style lang="scss" scoped>
.addLinkage {
padding: 0 32px;
box-sizing: border-box;
background: #FFF;
.item {
display: flex;
justify-content: space-between;
padding: 32px 0;
border-bottom: 1px solid #DDDDDD;
div:first-child {
span {
color: #FF4466;
}
}
}
.title {
padding: 32px 0
}
.tips {
text-align: right;
color: #999;
padding: 15px 0;
}
.btn {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 120px;
padding: 16px 32px;
box-sizing: border-box;
background: #F3F6F9;
.addBtn {
width: 100%;
height: 88px;
line-height: 88px;
text-align: center;
background: #4181FF;
border-radius: 16px;
color: #FFF;
}
}
}
</style>