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

228 lines
6.5 KiB
Vue
Raw Normal View History

2021-12-08 17:10:41 +08:00
<template>
<div class="add">
2021-12-09 17:44:57 +08:00
<div v-if="addList">
2021-12-10 18:20:55 +08:00
<div class="header-description">
2021-12-09 17:44:57 +08:00
<u-form :model="forms" ref="uForm" label-width="auto">
2021-12-10 18:20:55 +08:00
<u-form-item label="区域选择" prop="areaId" style="position: relative">
2021-12-16 17:13:18 +08:00
<AiAreaPicker v-model="forms.areaId" ref="areaIds" :areaId="areaIdProps" @select="areaSelect" style="color: #333"></AiAreaPicker>
2021-12-09 17:44:57 +08:00
</u-form-item>
2021-12-08 17:10:41 +08:00
2021-12-14 17:59:01 +08:00
<u-form-item label="走访对象" prop="create_user_name" required style="position: relative">
2021-12-16 17:13:18 +08:00
<u-input v-model="forms.create_user_name" disabled placeholder="请选择走访对象" @click="toWalkObject" />
2021-12-08 17:10:41 +08:00
2021-12-09 17:44:57 +08:00
<u-icon name="arrow-right" color="#CCCCCC" style="position: absolute; top: 25px; right: 30px"></u-icon>
</u-form-item>
2021-12-08 17:10:41 +08:00
2021-12-10 18:20:55 +08:00
<u-form-item label="现实状态" prop="reality" style="position: relative">
2021-12-16 17:13:18 +08:00
<u-input v-model="forms.reality" disabled placeholder="请选择走访慰问对象" @click="showStstus = true" />
2021-12-08 17:10:41 +08:00
2021-12-16 17:13:18 +08:00
<u-select v-model="showStstus" :list="$dict.getDict('realityStatus')" value-name="dictValue" label-name="dictName" @confirm="realityStstus"></u-select>
2021-12-08 17:10:41 +08:00
2021-12-09 17:44:57 +08:00
<u-icon name="arrow-right" color="#CCCCCC" style="position: absolute; top: 25px; right: 30px"></u-icon>
</u-form-item>
2021-12-08 17:10:41 +08:00
2021-12-10 18:20:55 +08:00
<u-form-item label="入户走访事项" prop="title" required label-position="top">
2021-12-16 17:13:18 +08:00
<u-input v-model="forms.title" placeholder="请输入入户走访事项(30字以内)" type="textarea" auto-height height="60" maxlength="30" />
2021-12-10 18:20:55 +08:00
<div>{{ forms.title.length }}/30</div>
2021-12-09 17:44:57 +08:00
</u-form-item>
2021-12-08 17:10:41 +08:00
2021-12-10 18:20:55 +08:00
<u-form-item label="入户走访内容" prop="description" label-position="top">
2021-12-16 17:13:18 +08:00
<u-input v-model="forms.description" placeholder="请输入入户走访事项(500字以内)" type="textarea" auto-height height="60" maxlength="500" />
2021-12-10 18:20:55 +08:00
<div>{{ forms.description.length }}/500</div>
2021-12-09 17:44:57 +08:00
</u-form-item>
2021-12-08 17:10:41 +08:00
2021-12-13 18:55:01 +08:00
<u-form-item label="图片(最多9张)" prop="images" class="avatars" label-position="top">
<AiUploader :def.sync="forms.images" multiple placeholder="上传图片" :limit="9"></AiUploader>
2021-12-09 17:44:57 +08:00
</u-form-item>
</u-form>
</div>
<div class="btn" @click="submit">保存</div>
2021-12-08 17:10:41 +08:00
2021-12-09 17:44:57 +08:00
<AiBack></AiBack>
</div>
2021-12-08 18:33:21 +08:00
2021-12-14 17:59:01 +08:00
<component v-else :is="comp" :paramss="params" @back="backlist"></component>
2021-12-08 17:10:41 +08:00
</div>
</template>
<script>
2021-12-16 17:13:18 +08:00
import { mapState } from 'vuex'
2021-12-13 18:55:01 +08:00
import walkObject from './walkObject'
2021-12-08 17:10:41 +08:00
export default {
name: 'add',
2021-12-13 11:50:28 +08:00
components: {
2021-12-13 18:55:01 +08:00
walkObject,
2021-12-13 11:50:28 +08:00
},
2021-12-14 15:51:00 +08:00
props: {
params: {},
},
2021-12-08 17:10:41 +08:00
data() {
return {
2021-12-14 15:51:00 +08:00
show: false,
2021-12-08 17:10:41 +08:00
forms: {
areaId: '',
2021-12-14 17:59:01 +08:00
optionId: '',
create_user_name: '',
2021-12-10 16:47:42 +08:00
reality: '',
2021-12-10 18:20:55 +08:00
realityValue: '',
title: '',
description: '',
images: [],
2021-12-08 17:10:41 +08:00
},
showAreaId: false,
showStstus: false,
flag: false,
2021-12-09 17:44:57 +08:00
addList: true,
2021-12-10 16:47:42 +08:00
areaIdProps: '',
2021-12-13 10:28:46 +08:00
clickedUserSelect: false,
2021-12-08 17:10:41 +08:00
}
},
2021-12-16 17:13:18 +08:00
computed: { ...mapState(['user']) },
2021-12-10 16:47:42 +08:00
created() {
this.areaIdProps = this.user.areaId
2021-12-14 15:51:00 +08:00
this.$dict.load('realityStatus').then(() => {
this.getDetail()
})
2021-12-10 16:47:42 +08:00
},
2021-12-14 17:59:01 +08:00
mounted() {},
2021-12-08 17:10:41 +08:00
methods: {
2021-12-14 15:51:00 +08:00
getDetail() {
this.$http.post(`/app/appvisitvondolence/queryDetailById?id=${this.params.id}`).then((res) => {
if (res?.data) {
this.forms = res.data
this.forms.realityValue = res.data.reality
this.forms.reality = this.$dict.getLabel('realityStatus', res.data.reality)
if (res.data.images) {
this.forms.images = JSON.parse(res.data.images || '[]')
}
}
})
},
2021-12-08 17:10:41 +08:00
submit() {
if (this.flag) return
this.$refs.uForm.validate((valid) => {
if (valid) {
2021-12-14 17:59:01 +08:00
if (!this.forms.create_user_name) {
return this.$u.toast('请选择走访慰问对象')
}
2021-12-10 18:20:55 +08:00
if (!this.forms.title) {
2021-12-08 17:10:41 +08:00
return this.$u.toast('请输入入户走访事项')
}
2021-12-10 18:20:55 +08:00
const imgs = []
if (this.forms.images) {
this.forms.images.map((e) => {
2021-12-16 17:13:18 +08:00
imgs.push({ url: e.url, id: e.id })
2021-12-10 18:20:55 +08:00
})
}
2021-12-08 17:10:41 +08:00
this.flag = true
2021-12-13 18:55:01 +08:00
this.$http
2021-12-16 17:13:18 +08:00
.post(`/app/appvisitvondolence/addOrUpdate`, {
areaId: this.forms.areaId,
applicationId: this.forms.applicationId,
name: this.forms.create_user_name,
optionId: this.forms.applicationId,
reality: this.forms.realityValue ? this.forms.realityValue : this.forms.reality,
title: this.forms.title,
description: this.forms.description,
createUserId: this.user.id,
createUserName: this.user.name,
images: JSON.stringify(imgs) || [],
id: this.id,
})
.then((res) => {
if (res.code == 0) {
this.$u.toast('保存成功')
this.flag = false
uni.navigateTo({ url: `./AppWalkask` })
}
})
2021-12-08 17:10:41 +08:00
} else {
this.$u.toast('保存失败')
}
})
},
2021-12-10 16:47:42 +08:00
areaSelect(e) {
if (e.type == 5) {
this.forms.areaId = e.id
} else {
return this.$u.toast('请选择到村')
}
2021-12-08 17:10:41 +08:00
},
2021-12-14 17:59:01 +08:00
backlist(e) {
console.log(e.item)
this.forms.create_user_name = e.item.create_user_name
this.forms.applicationId = e.appId
this.forms.optionId = e.item.id
this.addList = true
},
2021-12-10 18:20:55 +08:00
realityStstus(e) {
this.forms.reality = e[0].label
this.forms.realityValue = e[0].value
2021-12-08 17:10:41 +08:00
},
2021-12-13 18:55:01 +08:00
toWalkObject() {
this.addList = false
this.comp = 'walkObject'
2021-12-14 17:59:01 +08:00
this.paramss = 111
2021-12-08 17:10:41 +08:00
},
},
}
</script>
<style lang="scss" scoped>
.add {
height: 100%;
padding-bottom: 112px;
2021-12-15 14:37:20 +08:00
2021-12-10 18:20:55 +08:00
.header-description {
2021-12-08 17:10:41 +08:00
::v-deep .u-form {
.u-form-item {
margin-bottom: 16px;
2021-12-15 14:37:20 +08:00
2021-12-10 18:20:55 +08:00
.u-form-item__body {
.u-form-item--right__content__slot {
padding-bottom: 0;
}
}
2021-12-08 17:10:41 +08:00
}
2021-12-15 14:37:20 +08:00
2021-12-08 17:10:41 +08:00
.u-form-item:last-child {
margin-bottom: 0;
2021-12-10 18:20:55 +08:00
padding-bottom: 20px !important;
}
2021-12-15 14:37:20 +08:00
2021-12-10 18:20:55 +08:00
.avatars {
.u-form-item__body {
.default {
width: 160px;
height: 160px;
}
}
2021-12-08 17:10:41 +08:00
}
}
}
.btn {
position: fixed;
bottom: 0;
width: 100%;
height: 112px;
line-height: 112px;
background: #1365dd;
text-align: center;
font-size: 32px;
font-weight: 500;
color: #ffffff;
}
}
</style>