mirror of
http://112.124.100.131/GFRS/ebiz-h5.git
synced 2025-12-22 22:16:44 +08:00
添加校验
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<van-cell-group @click.native="showPopup">
|
<van-cell-group @click.native="showPopup">
|
||||||
<van-field v-bind="$attrs" right-icon="arrow" v-model="value" :required="required" :readonly="readonly" />
|
<van-field v-bind="$attrs" right-icon="arrow" :value="value" :required="required" :readonly="readonly" />
|
||||||
</van-cell-group>
|
</van-cell-group>
|
||||||
<van-popup id="popup" :value="isShow" :position="position" @click-overlay="closePopup">
|
<van-popup id="popup" :value="isShow" :position="position" @click-overlay="closePopup">
|
||||||
<slot :closePopup="closePopup">
|
<slot :closePopup="closePopup">
|
||||||
<van-picker id="picker" show-toolbar :columns="columns" />
|
<van-picker id="picker" show-toolbar :columns="columns" @confirm="onPickerConfirm" @cancel="closePopup" />
|
||||||
</slot>
|
</slot>
|
||||||
</van-popup>
|
</van-popup>
|
||||||
</div>
|
</div>
|
||||||
@@ -13,8 +13,11 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'PopupSelectorq',
|
name: 'PopupSelector',
|
||||||
props: {
|
props: {
|
||||||
|
value: {
|
||||||
|
type: String
|
||||||
|
},
|
||||||
position: {
|
position: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'bottom'
|
default: 'bottom'
|
||||||
@@ -36,17 +39,19 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
value: '',
|
|
||||||
isShow: false
|
isShow: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {},
|
|
||||||
methods: {
|
methods: {
|
||||||
showPopup() {
|
showPopup() {
|
||||||
this.isShow = true
|
this.isShow = true
|
||||||
},
|
},
|
||||||
closePopup() {
|
closePopup() {
|
||||||
this.isShow = false
|
this.isShow = false
|
||||||
|
},
|
||||||
|
onPickerConfirm(pickedValue) {
|
||||||
|
this.$emit('input', String(pickedValue))
|
||||||
|
this.closePopup()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +1,66 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="full-page bg-white">
|
<div class="full-page bg-white">
|
||||||
<div class="form m10">
|
<div class="form ml10 mr10">
|
||||||
<van-cell-group>
|
<van-cell-group>
|
||||||
<van-field right-icon="arrow" v-model="accompanyingName" label="陪访新人姓名" placeholder="请选择" required readonly />
|
<van-field v-model="accompanyingName" label="陪访人" readonly />
|
||||||
</van-cell-group>
|
</van-cell-group>
|
||||||
<PopupSelector label="陪访类型" placeholder="请选择" readonly required :columns="visitType" />
|
<van-cell-group>
|
||||||
<PopupSelector label="日期" placeholder="请选择" readonly required>
|
<van-field
|
||||||
|
right-icon="arrow"
|
||||||
|
v-model="newcomerName"
|
||||||
|
label="陪访新人姓名"
|
||||||
|
placeholder="请选择"
|
||||||
|
required
|
||||||
|
readonly
|
||||||
|
name="陪访新人姓名"
|
||||||
|
v-validate="'required'"
|
||||||
|
/>
|
||||||
|
</van-cell-group>
|
||||||
|
<PopupSelector
|
||||||
|
v-model="visitType"
|
||||||
|
label="陪访类型"
|
||||||
|
placeholder="请选择"
|
||||||
|
readonly
|
||||||
|
required
|
||||||
|
:columns="visitTypes"
|
||||||
|
name="陪访类型"
|
||||||
|
v-validate="'required'"
|
||||||
|
/>
|
||||||
|
<PopupSelector v-model="visitDate" label="日期" placeholder="请选择" readonly required name="日期" v-validate="'required'">
|
||||||
<template v-slot:default="{ closePopup }">
|
<template v-slot:default="{ closePopup }">
|
||||||
<van-datetime-picker v-model="currentDate" type="date" @confirm="onDateConfirm($event, closePopup)" @cancel="closePopup" />
|
<van-datetime-picker v-model="currentDate" type="date" @confirm="onDateConfirm($event, closePopup)" @cancel="closePopup" />
|
||||||
</template>
|
</template>
|
||||||
</PopupSelector>
|
</PopupSelector>
|
||||||
<PopupSelector label="时长(h)" placeholder="请选择" readonly required :columns="duration" />
|
<PopupSelector v-model="visitDuration" label="时长(h)" placeholder="请选择" readonly required name="时长" v-validate="'required'">
|
||||||
|
<template v-slot:default="{ closePopup }">
|
||||||
|
<van-picker show-toolbar :columns="duration" @confirm="onDurationConfirm($event, closePopup)" @cancel="closePopup" />
|
||||||
|
</template>
|
||||||
|
</PopupSelector>
|
||||||
<van-cell-group>
|
<van-cell-group>
|
||||||
<van-field v-model="customerName" label="客户姓名" placeholder="请输入" required />
|
<van-field v-model="customerName" label="客户姓名" placeholder="请输入" required name="客户姓名" v-validate="'required'" />
|
||||||
</van-cell-group>
|
</van-cell-group>
|
||||||
<PopupSelector label="客户年龄" placeholder="请选择" readonly required />
|
<PopupSelector v-model="customerAge" :columns="ages" label="客户年龄" placeholder="请选择" readonly required name="客户年龄" v-validate="'required'" />
|
||||||
<PopupSelector label="地点" placeholder="请选择" readonly required>
|
<PopupSelector v-model="areaName" label="地点" placeholder="请选择" readonly required name="地点" v-validate="'required'">
|
||||||
<template v-slot:default="{ closePopup }">
|
<template v-slot:default="{ closePopup }">
|
||||||
<van-area :area-list="areaList" value="450000" @confirm="onAreaConfirm($event, closePopup)" @cancel="closePopup" />
|
<van-area :area-list="areaList" value="450000" @confirm="onAreaConfirm($event, closePopup)" @cancel="closePopup" />
|
||||||
</template>
|
</template>
|
||||||
</PopupSelector>
|
</PopupSelector>
|
||||||
<van-cell-group>
|
<van-cell-group>
|
||||||
<van-field v-model="homeAddress" label="详细地址" placeholder="请输入" required />
|
<van-field v-model="homeAddress" label="详细地址" placeholder="请输入" required clearable name="详细地址" v-validate="'required'" maxlength="200" />
|
||||||
</van-cell-group>
|
</van-cell-group>
|
||||||
<p class="m10">现场照片(最多9张)</p>
|
<p class="m10">现场照片(最多9张)</p>
|
||||||
<van-uploader class="m10" v-model="fileList" :after-read="afterRead" :max-count="9" />
|
<van-uploader class="m10" v-model="fileList" :after-read="afterRead" :max-count="9" />
|
||||||
</div>
|
</div>
|
||||||
<van-button type="info" block>提交</van-button>
|
<van-button type="info" block @click="submitInfo">提交</van-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import PopupSelector from '@/components/common/PopupSelector.vue'
|
import PopupSelector from '@/components/common/PopupSelector.vue'
|
||||||
import areaList from '@/assets/js/utils/areaForSale'
|
import areaList from '@/assets/js/utils/areaForSale'
|
||||||
|
import getAreaName from '@/assets/js/utils/getAreaNameForSale'
|
||||||
import { uploadImg } from '@/api/ebiz/sale/sale'
|
import { uploadImg } from '@/api/ebiz/sale/sale'
|
||||||
|
import timeUtil from '@/assets/js/utils/date-utils'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'VisitInfoRegister',
|
name: 'VisitInfoRegister',
|
||||||
@@ -44,21 +71,39 @@ export default {
|
|||||||
return {
|
return {
|
||||||
fileList: [],
|
fileList: [],
|
||||||
areaList,
|
areaList,
|
||||||
accompanyingName: '',
|
accompanyingName: '张三',
|
||||||
|
newcomerName: '',
|
||||||
customerName: '',
|
customerName: '',
|
||||||
|
customerAge: '',
|
||||||
|
areaName: '',
|
||||||
|
homeProvince: '',
|
||||||
|
homeCity: '',
|
||||||
|
homeArea: '',
|
||||||
homeAddress: '',
|
homeAddress: '',
|
||||||
visitType: ['入职前陪访', '新人首单', '冲刺挑战', '参与衔训'],
|
visitType: '',
|
||||||
|
visitTypes: ['入职前陪访', '新人首单', '冲刺挑战', '参与衔训'],
|
||||||
|
visitDate: '',
|
||||||
|
visitDuration: '',
|
||||||
show: false,
|
show: false,
|
||||||
currentDate: new Date()
|
currentDate: new Date()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
// 陪访时长0.5-24
|
||||||
duration() {
|
duration() {
|
||||||
let duration = []
|
let duration = []
|
||||||
for (let i = 0; i < 48; i++) {
|
for (let i = 0; i < 48; i++) {
|
||||||
duration.push(0.5 + i * 0.5)
|
duration.push(0.5 + i * 0.5)
|
||||||
}
|
}
|
||||||
return duration
|
return duration
|
||||||
|
},
|
||||||
|
// 客户年龄18-60
|
||||||
|
ages() {
|
||||||
|
let age = []
|
||||||
|
for (let i = 18; i <= 80; i++) {
|
||||||
|
age.push(i)
|
||||||
|
}
|
||||||
|
return age
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -66,7 +111,8 @@ export default {
|
|||||||
let data = new FormData()
|
let data = new FormData()
|
||||||
data.append('imgPath', file.file)
|
data.append('imgPath', file.file)
|
||||||
this.$toast.loading({
|
this.$toast.loading({
|
||||||
duration: 0
|
duration: 0,
|
||||||
|
loadingType: 'spinner'
|
||||||
})
|
})
|
||||||
let res = await uploadImg(data)
|
let res = await uploadImg(data)
|
||||||
console.log('res :>> ', res)
|
console.log('res :>> ', res)
|
||||||
@@ -75,12 +121,25 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDateConfirm(data, fun) {
|
onDateConfirm(data, fun) {
|
||||||
console.log('date :>> ', data)
|
this.visitDate = timeUtil.formatDate(data, 'yyyy-MM-dd')
|
||||||
fun()
|
fun()
|
||||||
},
|
},
|
||||||
onAreaConfirm(data, fun) {
|
onAreaConfirm(data, fun) {
|
||||||
console.log('data :>> ', data)
|
let [province, city, area] = [data[0], data[1], data[2]]
|
||||||
|
;[this.homeProvince, this.homeCity, this.homeArea] = [province.code, city.code, area.code]
|
||||||
|
this.areaName = getAreaName(data)
|
||||||
fun()
|
fun()
|
||||||
|
},
|
||||||
|
onDurationConfirm(data, fun) {
|
||||||
|
this.visitDuration = String(data)
|
||||||
|
fun()
|
||||||
|
},
|
||||||
|
async submitInfo() {
|
||||||
|
let res = await this.$validator.validate()
|
||||||
|
if (!res) {
|
||||||
|
return this.$toast(this.$validator.errors.all()[0])
|
||||||
|
}
|
||||||
|
console.log('res :>> ', res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user