Files
dvcp_v2_wechat_app/src/mods/AppIntegralApply/add.vue

229 lines
6.4 KiB
Vue
Raw Normal View History

2022-02-15 17:05:29 +08:00
<template>
2022-02-15 18:08:33 +08:00
<div class="add">
<div class="u-forms">
<u-form class="u-form" :model="forms" ref="uForm" label-width="auto" :border-bottom="false">
2022-02-24 16:38:44 +08:00
<u-form-item label="申请人" prop="realName" required :border-bottom="false">
<u-input v-model="user.realName" disabled maxlength="30" />
2022-02-15 18:08:33 +08:00
</u-form-item>
2022-02-24 16:38:44 +08:00
<u-form-item label="申请时间" prop="auditTime" required :border-bottom="false">
<u-input v-model="toDay" disabled placeholder="请选择申请时间" />
2022-02-15 18:08:33 +08:00
</u-form-item>
2022-02-24 17:06:18 +08:00
<u-form-item label="联系电话" prop="phone" required :border-bottom="false">
<u-input v-model="forms.phone" placeholder="请输入联系电话" maxlength="11" />
</u-form-item>
2022-02-15 18:08:33 +08:00
<div class="line"></div>
2022-02-16 17:54:40 +08:00
<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" />
2022-02-15 18:08:33 +08:00
2022-02-16 17:54:40 +08:00
<u-select v-model="showStstus" :list="$dict.getDict('atWillReportType')" value-name="dictValue" label-name="dictName" @confirm="selectStatus"></u-select>
2022-02-15 18:08:33 +08:00
</u-form-item>
2022-02-16 17:54:40 +08:00
<u-form-item label="申请描述" prop="description" required :border-bottom="false" label-position="top" class="contents">
2022-02-24 16:38:44 +08:00
<u-input v-model="forms.description" placeholder="请输入描述信息" type="textarea" :auto-height="true" maxlength="500" />
2022-02-15 18:08:33 +08:00
</u-form-item>
2022-02-16 17:54:40 +08:00
<div class="wordLength">{{ forms.description.length }}/500</div>
2022-02-15 18:08:33 +08:00
<div class="line"></div>
2022-02-16 17:54:40 +08:00
<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>
2022-02-15 18:08:33 +08:00
</u-form-item>
<div class="line"></div>
</u-form>
</div>
<div class="btn" @click="submit">提交</div>
</div>
2022-02-15 17:05:29 +08:00
</template>
<script>
2022-02-15 18:08:33 +08:00
import { mapState } from 'vuex'
2022-02-15 17:05:29 +08:00
export default {
2022-02-16 20:37:46 +08:00
name: 'add',
2022-02-15 17:05:29 +08:00
components: {},
props: {},
data() {
2022-02-15 18:08:33 +08:00
return {
forms: {
2022-02-24 17:06:18 +08:00
phone: '',
2022-02-16 17:54:40 +08:00
auditTime: '',
applyIntegralType: '',
applyIntegralTypeValue: '',
description: '',
applyFiles: [],
2022-02-15 18:08:33 +08:00
},
showStstus: false,
flag: false,
2022-02-24 16:38:44 +08:00
toDay: '',
2022-02-15 18:08:33 +08:00
}
},
computed: { ...mapState(['user']) },
onLoad() {
2022-02-24 16:38:44 +08:00
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
2022-02-24 17:06:18 +08:00
this.forms.phone = this.user.phone
2022-02-24 16:38:44 +08:00
})
2022-02-15 17:05:29 +08:00
},
onShow() {},
2022-02-15 18:08:33 +08:00
mounted() {},
methods: {
submit() {
if (this.flag) return
this.$refs.uForm.validate((valid) => {
if (valid) {
2022-02-24 17:06:18 +08:00
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('请输入正确的手机号')
2022-02-15 18:08:33 +08:00
}
2022-02-16 17:54:40 +08:00
if (!this.forms.applyIntegralType) {
2022-02-15 18:08:33 +08:00
return this.$u.toast('请选择积分类型')
}
2022-02-16 17:54:40 +08:00
if (!this.forms.description) {
2022-02-15 18:08:33 +08:00
return this.$u.toast('请输入描述信息')
}
const imgs = []
2022-02-16 17:54:40 +08:00
if (this.forms.applyFiles) {
this.forms.applyFiles.map((e) => {
2022-02-15 18:08:33 +08:00
imgs.push({ url: e.url, id: e.id })
})
}
this.flag = true
this.$instance
2022-02-16 17:54:40 +08:00
.post(`/app/appvillagerintegraldeclare/addOrUpdate`, {
2022-02-24 16:38:44 +08:00
name: this.user.realName,
2022-02-24 17:06:18 +08:00
residentPhone: this.forms.phone,
2022-02-16 17:54:40 +08:00
applyIntegralType: this.forms.applyIntegralTypeValue,
description: this.forms.description,
applyFiles: imgs || [],
residentId: this.user.residentId,
2022-02-15 18:08:33 +08:00
})
.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) {
2022-02-16 17:54:40 +08:00
this.forms.applyIntegralType = e[0].label
this.forms.applyIntegralTypeValue = e[0].value
2022-02-15 18:08:33 +08:00
},
changeCalendar(e) {
2022-02-16 17:54:40 +08:00
this.forms.auditTime = e.result
2022-02-15 18:08:33 +08:00
},
},
2022-02-15 17:05:29 +08:00
}
</script>
2022-02-15 18:08:33 +08:00
<style lang="scss" scoped>
.add {
2022-02-15 17:05:29 +08:00
height: 100%;
2022-02-15 18:08:33 +08:00
.u-forms {
padding-bottom: 112px;
::v-deep .u-form {
background: #fff;
.u-form-item {
2022-02-24 16:38:44 +08:00
padding: 0;
2022-02-15 18:08:33 +08:00
.u-form-item__body {
2022-02-24 16:38:44 +08:00
padding: 40px 0 !important;
margin: 0 45px;
box-shadow: inset 0px -1px 0px 0px #dddddd;
2022-02-15 18:08:33 +08:00
.u-form-item--right__content__slot {
padding-bottom: 0;
.u-input {
text-align: right !important;
}
}
}
}
.contents {
padding-bottom: 20px !important;
.u-form-item__body {
2022-02-24 16:38:44 +08:00
box-shadow: none;
2022-02-15 18:08:33 +08:00
.u-form-item--right__content__slot {
.u-input {
text-align: left !important;
}
}
.default {
width: 160px;
height: 160px;
}
}
}
.avatars {
2022-02-24 16:57:47 +08:00
.u-form-item__body {
margin: 0 !important;
padding: 32px 32px 48px 32px !important;
.u-form-item--left {
margin-bottom: 32px;
2022-02-15 18:08:33 +08:00
}
}
}
.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;
2022-02-24 16:38:44 +08:00
z-index: 999;
2022-02-15 18:08:33 +08:00
}
2022-02-15 17:05:29 +08:00
}
</style>