Files
dvcp_v2_wechat_app/src/mods/AppIntegralApply/add.vue
花有清香月有阴 8b0751dd8f 27609
2022-02-24 17:06:18 +08:00

229 lines
6.4 KiB
Vue

<template>
<div class="add">
<div class="u-forms">
<u-form class="u-form" :model="forms" ref="uForm" label-width="auto" :border-bottom="false">
<u-form-item label="申请人" prop="realName" required :border-bottom="false">
<u-input v-model="user.realName" disabled maxlength="30" />
</u-form-item>
<u-form-item label="申请时间" prop="auditTime" required :border-bottom="false">
<u-input v-model="toDay" disabled placeholder="请选择申请时间" />
</u-form-item>
<u-form-item label="联系电话" prop="phone" required :border-bottom="false">
<u-input v-model="forms.phone" placeholder="请输入联系电话" maxlength="11" />
</u-form-item>
<div class="line"></div>
<u-form-item label="积分类型" prop="applyIntegralType" required :border-bottom="false" right-icon="arrow-right">
<u-input v-model="forms.applyIntegralType" disabled placeholder="请选择积分类型" @click="showStstus = true" />
<u-select v-model="showStstus" :list="$dict.getDict('atWillReportType')" value-name="dictValue" label-name="dictName" @confirm="selectStatus"></u-select>
</u-form-item>
<u-form-item label="申请描述" prop="description" required :border-bottom="false" label-position="top" class="contents">
<u-input v-model="forms.description" placeholder="请输入描述信息" type="textarea" :auto-height="true" maxlength="500" />
</u-form-item>
<div class="wordLength">{{ forms.description.length }}/500</div>
<div class="line"></div>
<u-form-item label="图片上传 (最多9张)" prop="applyFiles" :border-bottom="false" class="avatars" label-position="top">
<AiUploader v-model="forms.applyFiles" multiple placeholder="上传图片" :limit="9" action="/admin/file/add2"></AiUploader>
</u-form-item>
<div class="line"></div>
</u-form>
</div>
<div class="btn" @click="submit">提交</div>
</div>
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'add',
components: {},
props: {},
data() {
return {
forms: {
phone: '',
auditTime: '',
applyIntegralType: '',
applyIntegralTypeValue: '',
description: '',
applyFiles: [],
},
showStstus: false,
flag: false,
toDay: '',
}
},
computed: { ...mapState(['user']) },
onLoad() {
this.$dict.load('atWillReportType').then(() => {
var toDay = new Date()
var year = toDay.getFullYear()
var month = toDay.getMonth() + 1 < 10 ? '0' + (toDay.getMonth() + 1) : toDay.getMonth() + 1
var data = toDay.getDate() < 10 ? '0' + toDay.getDate() : toDay.getDate()
this.toDay = year + '-' + month + '-' + data
this.forms.phone = this.user.phone
})
},
onShow() {},
mounted() {},
methods: {
submit() {
if (this.flag) return
this.$refs.uForm.validate((valid) => {
if (valid) {
if (!this.forms.phone) {
return this.$u.toast('请输入联系电话')
}
const regPhone = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/
if (this.forms.phone && !regPhone.test(this.forms.phone)) {
return this.$u.toast('请输入正确的手机号')
}
if (!this.forms.applyIntegralType) {
return this.$u.toast('请选择积分类型')
}
if (!this.forms.description) {
return this.$u.toast('请输入描述信息')
}
const imgs = []
if (this.forms.applyFiles) {
this.forms.applyFiles.map((e) => {
imgs.push({ url: e.url, id: e.id })
})
}
this.flag = true
this.$instance
.post(`/app/appvillagerintegraldeclare/addOrUpdate`, {
name: this.user.realName,
residentPhone: this.forms.phone,
applyIntegralType: this.forms.applyIntegralTypeValue,
description: this.forms.description,
applyFiles: imgs || [],
residentId: this.user.residentId,
})
.then((res) => {
if (res.code == 0) {
this.flag = false
this.$u.toast('提交成功')
uni.$emit('updateList')
setTimeout(() => {
uni.navigateBack()
}, 600)
}
})
.catch(() => {
this.$u.toast('提交失败')
})
.finally(() => {
this.flag = false
})
}
})
},
selectStatus(e) {
this.forms.applyIntegralType = e[0].label
this.forms.applyIntegralTypeValue = e[0].value
},
changeCalendar(e) {
this.forms.auditTime = e.result
},
},
}
</script>
<style lang="scss" scoped>
.add {
height: 100%;
.u-forms {
padding-bottom: 112px;
::v-deep .u-form {
background: #fff;
.u-form-item {
padding: 0;
.u-form-item__body {
padding: 40px 0 !important;
margin: 0 45px;
box-shadow: inset 0px -1px 0px 0px #dddddd;
.u-form-item--right__content__slot {
padding-bottom: 0;
.u-input {
text-align: right !important;
}
}
}
}
.contents {
padding-bottom: 20px !important;
.u-form-item__body {
box-shadow: none;
.u-form-item--right__content__slot {
.u-input {
text-align: left !important;
}
}
.default {
width: 160px;
height: 160px;
}
}
}
.avatars {
.u-form-item__body {
margin: 0 !important;
padding: 32px 32px 48px 32px !important;
.u-form-item--left {
margin-bottom: 32px;
}
}
}
.line {
height: 24px;
background: #f3f6f9;
}
}
}
.wordLength {
color: #999;
text-align: right;
padding: 10px 40px;
background-color: #ffffff;
}
.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;
z-index: 999;
}
}
</style>