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

331 lines
8.3 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-24 18:11:09 +08:00
<div class="form-item form-item__textarea">
<div class="form-item__wrapper">
<div class="form-item__title">
<i>*</i>
<h2>事件描述</h2>
</div>
<div class="form-item__right">
<textarea v-model="forms.content" class="textareas" :maxlength="500" placeholder="请输入描述信息"></textarea>
</div>
</div>
</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">
2022-02-28 11:56:45 +08:00
<AiUploader v-model="forms.applyFiles" multiple placeholder="上传图片" :limit="9"></AiUploader>
<!-- action="/admin/file/add2" -->
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
},
2022-02-28 11:56:45 +08:00
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
},
2022-02-25 14:20:31 +08:00
onShow() {
uni.setNavigationBarTitle({
title: '我要申请',
})
},
2022-02-15 18:08:33 +08:00
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-25 14:18:45 +08:00
if (!this.forms.content) {
return this.$u.toast('请输入事件描述')
2022-02-15 18:08:33 +08:00
}
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,
2022-02-28 11:56:45 +08:00
description: this.forms.content,
2022-02-16 17:54:40 +08:00
applyFiles: imgs || [],
residentId: this.user.residentId,
2022-02-15 18:08:33 +08:00
})
.then((res) => {
if (res.code == 0) {
this.$u.toast('提交成功')
uni.$emit('updateList')
setTimeout(() => {
uni.navigateBack()
}, 600)
}
})
.catch(() => {
this.flag = false
2022-02-24 17:21:32 +08:00
this.$u.toast('提交失败')
2022-02-15 18:08:33 +08:00
})
}
})
},
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;
}
}
}
}
2022-02-24 18:11:09 +08:00
.form-item {
padding-left: 28px;
.form-item__wrapper {
display: flex;
align-items: center;
justify-content: space-between;
height: 128px;
padding-right: 28px;
input {
flex: 1;
height: 100%;
text-align: right;
padding-right: 10px;
}
.form-item__right {
display: flex;
align-items: center;
2022-03-03 17:02:40 +08:00
font-size: 28px;
2022-02-24 18:11:09 +08:00
span {
max-width: 400px;
margin-right: 8px;
color: #333333;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
i {
margin-right: 8px;
color: #999999;
}
}
}
&:last-child {
.form-item__wrapper {
border-bottom: none;
}
}
.form-item__title {
display: flex;
align-items: center;
i {
font-size: 32px;
color: #fa3534;
opacity: 0.65;
}
span {
font-size: 28px;
color: #999999;
}
h2 {
padding: 0 4px;
font-size: 28px;
color: #303133;
}
}
&.form-item__imgs,
&.form-item__textarea {
.form-item__wrapper {
display: block;
height: auto;
padding-bottom: 32px;
}
textarea {
width: 100%;
height: 160px;
}
.form-item__title {
padding: 32px 0;
}
.form-item__right {
padding-left: 18px;
.textareas {
color: #303133;
}
}
}
}
2022-02-15 18:08:33 +08:00
.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
}
}
2022-02-25 17:07:42 +08:00
.ai-uploader {
.item {
.info {
padding-left: 10px;
}
}
}
2022-02-15 18:08:33 +08:00
}
.line {
height: 24px;
background: #f3f6f9;
}
}
}
.btn {
position: fixed;
bottom: 0;
width: 100%;
2022-02-25 10:51:28 +08:00
box-sizing: border-box;
2022-02-15 18:08:33 +08:00
background: #1365dd;
2022-02-25 10:51:28 +08:00
padding: 20px 0;
2022-02-15 18:08:33 +08:00
text-align: center;
2022-02-25 10:51:28 +08:00
border-radius: 16px;
font-size: 34px;
2022-02-15 18:08:33 +08:00
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>