Files
dvcp_v2_wxcp_app/src/apps/AppHelpEffect/addLog.vue

217 lines
4.9 KiB
Vue
Raw Normal View History

2022-07-21 10:19:50 +08:00
<template>
<div class="addLog">
2022-08-15 18:39:33 +08:00
<AiGroup v-if="isBangFu">
<AiItem label="帮扶类型" required>
<AiSelect dict="fpAssistanceMeasures" v-model="form.operationDesc"/>
</AiItem>
</AiGroup>
<AiGroup v-else-if="isNormalFarmer">
<AiItem label="走访对象" required>
<input v-model="form.name"/>
</AiItem>
<AiItem label="现住址" required>
2022-08-17 09:11:08 +08:00
<AiAreaPicker v-model="form.areaId" :name.sync="form.areaName">
2022-08-15 18:39:33 +08:00
<AiMore v-model="form.areaName"/>
</AiAreaPicker>
</AiItem>
<AiItem label="走访日期" required>
<AiDate v-model="form.visitDate"/>
</AiItem>
</AiGroup>
<!--走访日志-->
<AiGroup v-else>
<AiItem label="走访日期" required>
<AiDate v-model="form.visitDate"/>
</AiItem>
</AiGroup>
<AiGroup>
<AiItem :label="isBangFu ? '帮扶内容' : '走访内容'" required topLabel>
<textarea maxlength="500" v-model="form.detail" :placeholder="isBangFu ? '请输入帮扶内容' : '请输入走访内容'"></textarea>
<div class="hint">{{ form.detail.length || 0 }}/500</div>
</AiItem>
</AiGroup>
<AiGroup>
<AiItem label="图片" topLabel>
<span slot="sub" class="color-999" v-text="`最多9张`"/>
2022-08-16 09:28:41 +08:00
<AiUploader :def.sync="form.files" multiple placeholder="上传图片" :limit="9"
action="/admin/file/add2"></AiUploader>
2022-08-15 18:39:33 +08:00
</AiItem>
</AiGroup>
2022-07-21 10:19:50 +08:00
<div class="btn" @click="submit">提交</div>
</div>
</template>
<script>
export default {
data() {
return {
2022-08-15 18:39:33 +08:00
name: null,
areaId: null,
areaName: null,
2022-07-21 10:19:50 +08:00
detail: '',
pid: '',
files: [],
id: '',
type: '',
operationDesc: '',
flag: false,
2022-08-15 18:39:33 +08:00
form: {detail: ""}
2022-07-21 10:19:50 +08:00
}
},
2022-08-15 18:39:33 +08:00
computed: {
isBangFu: v => v.type == 1,
isNormalFarmer: v => v.type == 2
},
2022-07-21 10:19:50 +08:00
onLoad(query) {
this.$dict.load('fpAssistanceMeasures')
this.pid = query.pid
this.type = query.type
2022-08-15 18:39:33 +08:00
this.visitDate = this.$dateFormat(this.$dayjs())
if (query.id) {
2022-07-21 10:19:50 +08:00
this.id = query.id
this.getInfo()
}
},
onShow() {
2022-08-15 18:39:33 +08:00
this.pageTitle()
2022-07-21 10:19:50 +08:00
},
methods: {
2022-08-15 18:39:33 +08:00
pageTitle() {
const action = this.id ? '编辑' : '添加', app = this.type == 1 ? '帮扶措施' : this.type == 2 ? '一般农户走访日志' : '走访日志'
document.title = action + app
},
2022-07-21 10:19:50 +08:00
getInfo() {
this.$http.post(`/app/apppreventionreturntopovertylog/queryDetailById?id=${this.id}`).then(res => {
2022-08-15 18:39:33 +08:00
if (res?.data) {
this.form = res.data
2022-07-21 10:19:50 +08:00
}
})
},
submit() {
2022-08-15 18:39:33 +08:00
if (this.flag) return
if (this.type == 1) {
if (!this.form.operationDesc) {
2022-07-21 10:19:50 +08:00
return this.$u.toast('请选择帮扶类型')
}
2022-08-15 18:39:33 +08:00
} else if (this.type == 2) {
if (!this.form.areaId) {
return this.$u.toast('请选择现住址')
}
if (!this.form.name) {
return this.$u.toast('请输入走访对象')
}
2022-07-21 10:19:50 +08:00
} else {
2022-08-15 18:39:33 +08:00
if (!this.form.detail) {
2022-07-21 10:19:50 +08:00
return this.$u.toast('请输入走访内容')
}
}
this.flag = true
2022-08-17 14:46:27 +08:00
const {form, type, pid} = this
this.$http.post('/app/apppreventionreturntopovertylog/addOrUpdate', {...form, type, pid}).then(res => {
2022-08-15 18:39:33 +08:00
if (res.code == 0) {
2022-07-21 10:19:50 +08:00
this.$u.toast('提交成功')
uni.$emit('reload')
setTimeout(() => {
uni.navigateBack({
delta: 1
})
}, 300)
}
})
}
}
}
</script>
<style lang="scss" scoped>
.addLog {
padding-bottom: 120px;
.help {
padding: 32px;
box-sizing: border-box;
display: flex;
justify-content: space-between;
background: #fff;
margin-bottom: 16px;
}
.form-item {
padding: 32px;
background: #fff;
margin-bottom: 16px;
.form-item__title {
display: flex;
align-items: center;
margin-bottom: 34px;
em {
margin-right: 4px;
font-style: normal;
color: #FF4466;
}
h2 {
color: #333333;
font-weight: normal;
font-size: 32px;
}
i {
color: #999999;
font-size: 28px;
font-style: normal;
}
}
textarea {
width: 100%;
}
}
.form-type {
display: flex;
align-items: center;
justify-content: space-between;
height: 112px;
padding: 0 32px;
h2 {
font-weight: normal;
color: #333333;
font-size: 32px;
}
span {
color: #999999;
font-size: 28px;
}
}
.btn {
position: fixed;
left: 0;
bottom: 0;
z-index: 11;
width: 100%;
height: 112px;
line-height: 112px;
margin: 0;
text-align: center;
color: #FFFFFF;
font-size: 32px;
background: #3192F4;
}
2022-08-15 18:39:33 +08:00
.hint {
2022-07-21 10:19:50 +08:00
text-align: right;
color: #999;
}
2022-08-17 09:10:17 +08:00
::v-deep uni-textarea {
width: 100%;
}
2022-07-21 10:19:50 +08:00
}
</style>