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

330 lines
8.9 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-22 15:35:01 +08:00
<u-form-item label="区域选择" prop="areaId" class="areaIds" style="position: relative">
2022-03-16 20:10:17 +08:00
<AiAreaPicker :value="forms.areaId" :areaId="areaIdProps" @select="areaSelect" isForm/>
2021-12-09 17:44:57 +08:00
</u-form-item>
2021-12-08 17:10:41 +08:00
2021-12-22 15:35:01 +08:00
<div class="line"></div>
2021-12-08 17:10:41 +08:00
2022-03-16 20:10:17 +08:00
<u-form-item label="走访对象" prop="name" required :right-icon="id ? '' : 'arrow-right'"
class="create_user_names">
<u-input v-model="forms.name" disabled placeholder="请选择走访对象" @click="toWalkObject"/>
2021-12-09 17:44:57 +08:00
</u-form-item>
2021-12-08 17:10:41 +08:00
2021-12-22 15:35:01 +08:00
<div class="line"></div>
2021-12-08 17:10:41 +08:00
2022-03-15 09:48:51 +08:00
<u-form-item label="走访时间" prop="visitTime" required :right-icon="id ? '' : 'arrow-right'" class="realitys">
2022-03-16 20:10:17 +08:00
<u-input v-model="forms.visitTime" disabled placeholder="请选择走访时间" @click="showVisitTime = true"/>
2022-03-15 09:48:51 +08:00
2022-03-15 14:54:39 +08:00
<u-picker v-model="showVisitTime" :params="params" mode="time" @confirm="change"></u-picker>
2022-03-15 09:48:51 +08:00
</u-form-item>
<div class="line"></div>
2021-12-30 20:51:37 +08:00
<u-form-item label="现实状态" prop="reality" :right-icon="id ? '' : 'arrow-right'" class="realitys">
2022-03-16 20:10:17 +08:00
<u-input v-model="forms.reality" disabled placeholder="请选择现实状态" @click="realityClick"/>
2021-12-08 17:10:41 +08:00
2022-03-16 20:10:17 +08:00
<u-select v-model="showStstus" :list="$dict.getDict('realityStatus')" value-name="dictValue"
label-name="dictName" @confirm="realityStstus"></u-select>
2021-12-09 17:44:57 +08:00
</u-form-item>
2021-12-08 17:10:41 +08:00
2021-12-22 15:35:01 +08:00
<div class="line"></div>
2021-12-31 11:28:45 +08:00
<u-form-item label="入户走访事项" prop="title" required label-position="top" :border-bottom="false">
2022-03-16 20:10:17 +08:00
<u-input v-model="forms.title" placeholder="请输入入户走访事项(30字以内)" type="textarea" auto-height height="60"
:maxlength="30"/>
2021-12-09 17:44:57 +08:00
</u-form-item>
2021-12-31 11:28:45 +08:00
<div class="hint">{{ forms.title.length }}/30</div>
2021-12-08 17:10:41 +08:00
2021-12-22 15:35:01 +08:00
<div class="line"></div>
2021-12-31 11:28:45 +08:00
<u-form-item label="入户走访内容" prop="description" label-position="top" :border-bottom="false">
2022-03-16 20:10:17 +08:00
<u-input v-model="forms.description" placeholder="请输入入户走访事项(500字以内)" type="textarea" auto-height height="60"
:maxlength="500"/>
2021-12-09 17:44:57 +08:00
</u-form-item>
2021-12-31 11:28:45 +08:00
<div class="hint">{{ forms.description.length }}/500</div>
2021-12-08 17:10:41 +08:00
2021-12-22 15:35:01 +08:00
<div class="line"></div>
<u-form-item label="图片(最多9张)" prop="images" class="avatars" label-position="top" :border-bottom="false">
2022-03-16 20:10:17 +08:00
<AiUploader :def.sync="forms.images" multiple placeholder="上传图片" :limit="9" action="/admin/file/add2"
sourceType="camera"></AiUploader>
2021-12-09 17:44:57 +08:00
</u-form-item>
</u-form>
</div>
<div class="btn" @click="submit">保存</div>
</div>
2021-12-08 17:10:41 +08:00
</div>
</template>
<script>
2022-03-16 20:10:17 +08:00
import {mapState} from 'vuex'
2021-12-08 17:10:41 +08:00
export default {
name: 'add',
2021-12-24 13:58:52 +08:00
props: {},
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-30 17:26:15 +08:00
areaName: '',
2021-12-31 10:19:09 +08:00
2021-12-14 17:59:01 +08:00
optionId: '',
2021-12-31 10:19:09 +08:00
name: '',
2021-12-10 16:47:42 +08:00
reality: '',
2021-12-10 18:20:55 +08:00
realityValue: '',
2021-12-22 15:35:01 +08:00
menuLevel3Name: '',
2021-12-31 10:59:00 +08:00
applicationId: '',
2021-12-10 18:20:55 +08:00
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-24 13:58:52 +08:00
id: '',
2021-12-31 10:19:09 +08:00
name: '',
optionId: '',
2022-03-15 09:48:51 +08:00
showVisitTime: false,
2022-03-15 14:54:39 +08:00
params: {
year: true,
month: true,
day: true,
hour: true,
minute: true,
second: true,
},
2021-12-08 17:10:41 +08:00
}
},
2022-03-16 20:10:17 +08:00
computed: {...mapState(['user'])},
2021-12-24 13:58:52 +08:00
onLoad(o) {
2021-12-31 10:19:09 +08:00
this.id = o.id ? o.id : ''
2021-12-10 16:47:42 +08:00
this.areaIdProps = this.user.areaId
2021-12-30 20:51:37 +08:00
if (!this.id) {
2021-12-30 18:38:44 +08:00
this.forms.areaId = this.user.areaId
}
2021-12-14 15:51:00 +08:00
this.$dict.load('realityStatus').then(() => {
this.getDetail()
})
2021-12-31 10:19:09 +08:00
uni.$on('goBack', (data) => {
this.forms.menuLevel3Name = data.applicationName
2021-12-31 10:59:00 +08:00
this.forms.applicationId = data.applicationId
2021-12-31 10:19:09 +08:00
this.forms.name = data.selectUser.name
this.forms.optionId = data.selectUser.id
})
2021-12-10 16:47:42 +08:00
},
2021-12-24 15:27:36 +08:00
onShow() {
document.title = '新建走访'
},
2021-12-08 17:10:41 +08:00
methods: {
2021-12-30 17:41:08 +08:00
realityClick() {
2021-12-30 20:51:37 +08:00
if (this.id) return
2021-12-31 10:19:09 +08:00
if (!this.forms.name) {
2021-12-30 19:20:11 +08:00
return this.$u.toast('请选择走访对象')
2021-12-30 17:41:08 +08:00
}
this.showStstus = true
},
2021-12-31 10:19:09 +08:00
2021-12-14 15:51:00 +08:00
getDetail() {
2021-12-24 13:58:52 +08:00
if (this.id) {
this.$http.post(`/app/appvisitvondolence/queryDetailById?id=${this.id}`).then((res) => {
2021-12-22 16:36:28 +08:00
if (res?.data) {
this.forms = res.data
2021-12-24 13:58:52 +08:00
this.forms.create_user_name = res.data.name
2021-12-22 16:36:28 +08:00
this.forms.realityValue = res.data.reality
2022-01-18 17:16:18 +08:00
this.forms.areaId = res.data.areaId
this.forms.areaName = res.data.areaName
2021-12-22 16:36:28 +08:00
this.forms.reality = this.$dict.getLabel('realityStatus', res.data.reality)
if (res.data.images) {
this.forms.images = JSON.parse(res.data.images || '[]')
}
2021-12-14 15:51:00 +08:00
}
2021-12-22 16:36:28 +08:00
})
}
2021-12-14 15:51:00 +08:00
},
2021-12-08 17:10:41 +08:00
submit() {
if (this.flag) return
this.$refs.uForm.validate((valid) => {
if (valid) {
2021-12-31 10:19:09 +08:00
if (!this.forms.name) {
2021-12-30 19:20:11 +08:00
return this.$u.toast('请选择走访对象')
2021-12-14 17:59:01 +08:00
}
2022-03-15 09:48:51 +08:00
if (!this.forms.visitTime) {
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) => {
2022-03-16 20:10:17 +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
2022-03-16 20:10:17 +08:00
.post(`/app/appvisitvondolence/addOrUpdate`, {
areaId: this.forms.areaId,
name: this.forms.name,
visitTime: this.forms.visitTime,
optionId: this.forms.optionId,
// menuLevel3Name: this.forms.menuLevel3Name,
applicationId: 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.$emit('updateList')
setTimeout(() => {
uni.navigateBack()
}, 600)
}
})
2021-12-08 17:10:41 +08:00
} else {
this.$u.toast('保存失败')
}
})
},
2021-12-10 16:47:42 +08:00
areaSelect(e) {
2021-12-30 17:26:15 +08:00
this.forms.areaId = e
2021-12-08 17:10:41 +08:00
},
2022-03-15 09:48:51 +08:00
change(e) {
2022-03-15 15:10:11 +08:00
this.forms.visitTime = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute + ':' + e.second
2022-03-15 09:48:51 +08:00
},
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() {
2022-03-16 20:10:17 +08:00
uni.navigateTo({url: `./selectType`})
2021-12-08 17:10:41 +08:00
},
},
}
</script>
<style lang="scss" scoped>
.add {
height: 100%;
2021-12-22 15:35:01 +08:00
background: #f3f6f9;
2021-12-15 14:37:20 +08:00
2021-12-10 18:20:55 +08:00
.header-description {
2021-12-22 15:35:01 +08:00
padding-bottom: 162px;
background: #f3f6f9;
2022-03-16 20:10:17 +08:00
2021-12-08 17:10:41 +08:00
::v-deep .u-form {
2021-12-22 15:35:01 +08:00
background: #fff;
2022-03-16 20:10:17 +08:00
2021-12-08 17:10:41 +08:00
.u-form-item {
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-22 15:35:01 +08:00
.areaIds {
.u-form-item__body {
.u-form-item--right {
.u-form-item--right__content {
.u-form-item--right__content__slot {
.AiAreaPicker {
width: 100%;
2021-12-22 16:36:28 +08:00
display: flex;
2021-12-23 09:07:47 +08:00
justify-content: flex-end;
2021-12-22 16:36:28 +08:00
2021-12-22 15:35:01 +08:00
.AiSearchPopup {
.areaSelector {
.location {
opacity: 0;
}
}
}
}
}
}
}
}
}
.create_user_names,
.realitys {
.u-form-item__body {
.u-form-item--right__content__slot {
.u-input {
text-align: right !important;
}
}
}
}
.line {
height: 16px;
background: #f3f6f9;
}
2021-12-31 11:28:45 +08:00
.hint {
padding: 4px 32px 8px 0;
text-align: right;
color: #999;
}
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;
2021-12-30 17:26:15 +08:00
z-index: 999;
2021-12-08 17:10:41 +08:00
}
}
</style>