Files
dvcp_v2_wxcp_app/library/apps/AppFourNeighbor/Add.vue
2024-10-31 14:34:57 +08:00

211 lines
5.2 KiB
Vue

<template>
<div class="Add">
<div class="flex mar-b16">
<div class="label">
<span class="tips">*</span>党员信息
</div>
<div class="value">
<AiPagePicker type="party" @select="handlePartySelect" single :isFourParty="true">
<AiMore v-model="form.partyName" placeholder="请选择"/>
</AiPagePicker>
</div>
</div>
<div class="flex mar-b16">
<div class="label">
<span class="tips">*</span>四邻对象
</div>
<div class="value" @click="selectUser">
<span :class="form.residentName ? '' : 'color-999'">{{form.residentName || '请选择'}}</span>
<u-icon name="arrow-right" color="#ddd" size="28"></u-icon>
</div>
</div>
<div class="flex mar-b16">
<div class="label">
<span class="tips">*</span>事件日期
</div>
<div class="value" @click="showTimeSelect=true">
<span :class="form.linksageDate ? '' : 'color-999'">{{form.linksageDate || '请选择'}}</span>
<u-icon name="arrow-right" color="#ddd" size="28"></u-icon>
</div>
</div>
<div class="flex">
<div class="label">
<span class="tips">*</span>事件描述
</div>
</div>
<div class="text-area">
<u-input v-model="form.description" type="textarea" :height="150" :auto-height="true" maxlength="200" placeholder="请输入事件内容描述" placeholder-style="font-size:16px;" />
<div class="hint">{{ form.description.length }}/200</div>
</div>
<div class="footer" @click="confirm">
<div class="btn">确认提交</div>
</div>
<u-picker v-model="showTimeSelect" mode="time" :params="params" @confirm="confirmSelectTime"></u-picker>
<u-select :list="userList" value-name="id" label-name="name" v-model="showUserSelect" @confirm="confirmSelectUser"></u-select>
</div>
</template>
<script>
import {mapState} from "vuex";
export default {
name: 'Add',
data() {
return {
value: '',
form: {
partyName: '',
partyId: '',
residentName: '',
residentId: '',
linksageDate: '',
description: ''
},
showTimeSelect: false,
userList: [],
showUserSelect: false,
params: {year: true, month: true, day: true, hour: false, minute: false, second: false},
isFlag: true
}
},
computed: {
...mapState(['user']),
},
created() {
this.$dict.load('appSpecialTypeFive')
},
onShow() {
document.title = '新增'
},
methods: {
rules() {
return {
partyId: '请选择党员信息',
residentId: '请选择四邻对象',
linksageDate: '请选择事件日期',
description: '请输入事件描述',
}
},
confirm() {
const rules = this.rules()
for (let v of Object.keys(rules)) {
if (!this.form[v]) {
return this.$u.toast(rules[v])
}
}
if(!this.isFlag) {
return
}
this.$http.post('/app/apppartyfourlinkage/addOrUpdate', {...this.form}).then(res => {
if (res.code == 0) {
this.isFlag = false
this.$u.toast('提交成功')
uni.$emit('reload')
setTimeout(() => {
uni.navigateBack({
delta: 1
})
}, 600)
}
}).catch((err) => {
this.$u.toast(err)
})
},
confirmSelectTime(e) {
this.form.linksageDate = e.year + '-' + e.month + '-' + e.day
},
selectUser() {
if(!this.form.partyId) {
return this.$u.toast('请先选择党员信息')
}
this.showUserSelect = true
},
confirmSelectUser(e) {
this.form.residentId = e[0].value
this.form.residentName = e[0].label
},
handlePartySelect(e) {
this.form.partyId = e[0].id
this.form.partyName = e[0].name
this.getUserList()
},
getUserList() {
this.$http.post('/app/apppartyfourresident/listFourResident', null, {
params: {
size: 10,
partyId: this.form.partyId,
},
}).then((res) => {
if (res.code == 0) {
this.userList = res.data.records
}
})
}
},
}
</script>
<style lang="scss" scoped>
.Add {
.flex{
display: flex;
justify-content: space-between;
padding: 34px 32px 34px 12px;
font-size: 32px;
font-family: PingFangSC-Regular, PingFang SC;
color: #333;
line-height: 44px;
background-color: #fff;
.label{
width: 150px;
.tips{
font-size: 32px;
font-family: PingFangSC-Regular, PingFang SC;
color: #F46;
}
}
.value{
span{
display: inline-block;
margin-right: 12px;
}
.color-999{
color: #999;
}
}
}
.mar-b16{
margin-bottom: 16px;
}
.text-area{
width: 100%;
padding: 0 32px 32px;
background-color: #fff;
box-sizing: border-box;
.hint{
width: 100%;
color: #999;
text-align: right;
}
}
.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;
}
}
</style>