Commit 30c9091f by 胡悦

Merge branch 'SAAS+V5.5.0' of http://192.168.3.233:8090/glsx/gl_tape into SAAS+V5.5.0

2 parents 08e60f07 bbf2f1f9
...@@ -554,4 +554,13 @@ module.exports = { ...@@ -554,4 +554,13 @@ module.exports = {
...data ...data
}) })
}, },
// VIN车架号校验
checkVinValidate(data={}) {
console.log("调用接口checkVinValidate",data);
return http.post({
method: 'dj.pad.api.vin.validate',
projectName: 'pad',
...data,
})
},
} }
...@@ -2,7 +2,7 @@ import http from '../request/http' ...@@ -2,7 +2,7 @@ import http from '../request/http'
module.exports = { module.exports = {
/** 销售顾问/录单员 & 交付专员 */ /** 销售顾问/录单员 & 交付专员 */
getEmployeeList (data) { getEmployeeList(data) {
return http.post({ return http.post({
method: 'dj.api.smartcarlife.employee.onTheJob.getByMerchantId', method: 'dj.api.smartcarlife.employee.onTheJob.getByMerchantId',
projectName: 'boutique', projectName: 'boutique',
...@@ -13,7 +13,7 @@ module.exports = { ...@@ -13,7 +13,7 @@ module.exports = {
* 二级流量方 * 二级流量方
*/ */
getDiversionMerchantRef (data) { getDiversionMerchantRef(data) {
return http.post({ return http.post({
method: 'dj.api.smartcarlife.diversionMerchant.getDiversionMerchantRef', method: 'dj.api.smartcarlife.diversionMerchant.getDiversionMerchantRef',
projectName: 'boutique', projectName: 'boutique',
...@@ -24,7 +24,7 @@ module.exports = { ...@@ -24,7 +24,7 @@ module.exports = {
* 获取门店品牌车型 * 获取门店品牌车型
*/ */
getMerchantCarBrandList (data) { getMerchantCarBrandList(data) {
return http.post({ return http.post({
method: 'dj.api.get.car.brandList', method: 'dj.api.get.car.brandList',
projectName: 'boutique', projectName: 'boutique',
...@@ -36,7 +36,7 @@ module.exports = { ...@@ -36,7 +36,7 @@ module.exports = {
/*** /***
* 获取门店礼券列表 * 获取门店礼券列表
*/ */
getMerchantCouponList (data) { getMerchantCouponList(data) {
return http.post({ return http.post({
method: 'dj.api.smartCarLife.merchant.coupon.list', method: 'dj.api.smartCarLife.merchant.coupon.list',
projectName: 'boutique', projectName: 'boutique',
...@@ -46,7 +46,7 @@ module.exports = { ...@@ -46,7 +46,7 @@ module.exports = {
/** /**
* 获取客户礼券列表 * 获取客户礼券列表
*/ */
getCustomerCouponList (data) { getCustomerCouponList(data) {
return http.post({ return http.post({
method: 'dj.api.customer.coupon.list', method: 'dj.api.customer.coupon.list',
projectName: 'boutique', projectName: 'boutique',
...@@ -56,7 +56,7 @@ module.exports = { ...@@ -56,7 +56,7 @@ module.exports = {
/** /**
* 获取商品列表 * 获取商品列表
*/ */
getGoodsList (data) { getGoodsList(data) {
return http.post({ return http.post({
method: 'dj.api.smartcarlife.selectOrderGoods.list', method: 'dj.api.smartcarlife.selectOrderGoods.list',
projectName: 'boutique', projectName: 'boutique',
...@@ -65,7 +65,7 @@ module.exports = { ...@@ -65,7 +65,7 @@ module.exports = {
}, },
/**获取订单列表筛选转化人员&销售顾问 */ /**获取订单列表筛选转化人员&销售顾问 */
getOrderScreenEmployeeList (data) { getOrderScreenEmployeeList(data) {
return http.post({ return http.post({
method: 'dj.api.smartcarlife.employee.getByMerchantId', method: 'dj.api.smartcarlife.employee.getByMerchantId',
projectName: 'boutique', projectName: 'boutique',
...@@ -75,7 +75,7 @@ module.exports = { ...@@ -75,7 +75,7 @@ module.exports = {
/** /**
* 获取园区店配置 * 获取园区店配置
*/ */
getYqStoreConfig (data) { getYqStoreConfig(data) {
return http.get({ return http.get({
method: 'dj.api.smarcarlife.yqMerchantConfig.detail', method: 'dj.api.smarcarlife.yqMerchantConfig.detail',
projectName: 'boutique', projectName: 'boutique',
...@@ -86,7 +86,7 @@ module.exports = { ...@@ -86,7 +86,7 @@ module.exports = {
* 战败下单商品列表 * 战败下单商品列表
* *
*/ */
getOrderUpgradeGoodsList (data) { getOrderUpgradeGoodsList(data) {
return http.post({ return http.post({
method: 'dj.api.smartcarlife.orderUpgradeGoods.listByMerchantId', method: 'dj.api.smartcarlife.orderUpgradeGoods.listByMerchantId',
projectName: 'boutique', projectName: 'boutique',
...@@ -96,7 +96,7 @@ module.exports = { ...@@ -96,7 +96,7 @@ module.exports = {
/** /**
* 获取精品升级场景 太阳膜类商品部位数据 * 获取精品升级场景 太阳膜类商品部位数据
*/ */
getPositionList (data) { getPositionList(data) {
return http.post({ return http.post({
method: 'dj.api.smartcarlife.goodsPosition.list', method: 'dj.api.smartcarlife.goodsPosition.list',
projectName: 'boutique', projectName: 'boutique',
...@@ -107,11 +107,29 @@ module.exports = { ...@@ -107,11 +107,29 @@ module.exports = {
* 获取提单客户档案列表 * 获取提单客户档案列表
* *
*/ */
getQuotationCustomerList (data) { getQuotationCustomerList(data) {
return http.post({ return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.customer.page', method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.customer.page',
projectName: 'boutique', projectName: 'boutique',
...data ...data
}) })
},
/**搜索订单(含套餐) */
getWorkPackageGoodsList(data) {
let params = data || {}
params.sceneType = 1
return http.post(
{
method: 'dj.api.smartcarlife.order.search.containPackageGoods',
projectName: 'boutique',
...data,
pageSize: 10,
pageSize: 999999,
statusList: [1]
},
false,
'dj',
1000000
)
} }
} }
...@@ -11,8 +11,8 @@ class Request { ...@@ -11,8 +11,8 @@ class Request {
get(params, returnAll = false, hostType) { get(params, returnAll = false, hostType) {
return this.request('GET', params, returnAll, hostType) return this.request('GET', params, returnAll, hostType)
} }
post(params, returnAll = false, hostType) { post(params, returnAll = false, hostType, timeout) {
return this.request('POST', params, returnAll, hostType) return this.request('POST', params, returnAll, hostType, timeout)
} }
fetch(method, data, returnAll = true, hostType) { fetch(method, data, returnAll = true, hostType) {
return this.post( return this.post(
...@@ -24,7 +24,7 @@ class Request { ...@@ -24,7 +24,7 @@ class Request {
hostType hostType
) )
} }
request(RequestMethods, params, returnAll, hostType = 'dj') { request(RequestMethods, params, returnAll, hostType = 'dj', timeout) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let _this = this let _this = this
uni.getNetworkType({ uni.getNetworkType({
...@@ -57,6 +57,7 @@ class Request { ...@@ -57,6 +57,7 @@ class Request {
header, header,
dataType: 'json', dataType: 'json',
responseType: 'text', responseType: 'text',
timeout: timeout || 60000,
success(response) { success(response) {
/**业务代码 */ /**业务代码 */
let { data, statusCode } = response let { data, statusCode } = response
......

2.92 MB | W: | H:

2.92 MB | W: | H:

assets/images/sprite.png
assets/images/sprite.png
assets/images/sprite.png
assets/images/sprite.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -326,7 +326,7 @@ export default { ...@@ -326,7 +326,7 @@ export default {
} }
.uni-list-cell { .uni-list-cell {
margin-left: toRpx(57.2); margin-left: toRpx(48);
} }
.radio-name { .radio-name {
......
<template> <template>
<view class="customer-list"> <view class="customer-list">
<template v-for="(i, index) in listData"> <template v-for="(i, index) in listData">
<view <view :key="index" @click="choose(i)" :class="['item flex', { active: checkActive(i) }]">
:key="index"
@click="choose(i)"
:class="['item flex', { active: checkActive(i) }]"
>
<view class="sprite-icon icon-tag-checked"></view> <view class="sprite-icon icon-tag-checked"></view>
<template v-if="i.customerName"> <template v-if="i.customerName || (i.customer && i.customer.customerName)">
{{i.customerName}} {{ i.customerName || (i.customer && i.customer.customerName) }}
</template> </template>
<template v-if="i.carSeriesName"> <template v-if="i.carSeriesName || i.carType">
<view class="car-model">({{i.carChildsBrandName || ''}}-{{i.carSeriesName}})</view> <view class="car-model">({{ i.carType ? i.carType : i.carChildsBrandName + '-' + i.carSeriesName || '' }})</view>
</template> </template>
<template v-if="i.customerPhone"> <template v-if="i.customerPhone || i.customer.customerPhone">
<view class="phone">|{{i.customerPhone}}</view> <view class="phone">|{{ i.customerPhone || (i.customer && i.customer.customerPhone) }}</view>
</template> </template>
</view> </view>
</template> </template>
...@@ -27,14 +23,14 @@ export default { ...@@ -27,14 +23,14 @@ export default {
mixins: [popupmixin], mixins: [popupmixin],
name: 'Customer', name: 'Customer',
inject: ['userInfo'], inject: ['userInfo'],
data () { data() {
return { return {
} }
}, },
mounted () { mounted() {
}, },
methods: { methods: {
async getList (searchValue, search) { async getList(searchValue, search) {
const { userInfo, params } = this, const { userInfo, params } = this,
{ cacheData } = params { cacheData } = params
this.currentId = '' this.currentId = ''
...@@ -50,30 +46,48 @@ export default { ...@@ -50,30 +46,48 @@ export default {
currentPage: 1, currentPage: 1,
search: searchValue search: searchValue
} }
const { list } = await uni.$api.popupApi.getQuotationCustomerList(apiParams) let apiTargetName = !params.defeat ? 'getQuotationCustomerList' : 'getWorkPackageGoodsList'
this.updateParams(params, list || []) console.log(apiTargetName, 'apiTargetName')
const { list } = await uni.$api.popupApi[apiTargetName](apiParams)
let customerList = list
if (params.defeat) {
const listArray = list.map(item => {
if (item.customer && item.customer.carSeriesName) {
item.carType = `${item.customer.carBrand || ''}-${item.customer.carChildsBrandName || ''}-${item.customer.carSeriesName || ''}`
}
return item
})
customerList = listArray
}
console.log(customerList, 'customerList')
this.updateParams(params, customerList || [])
}, },
initData (list) { initData(list) {
const { params: { idKey }, data } = this const { params: { idKey, defeat }, data } = this
let key = defeat ? 'id' : 'customerPhone'
console.log(data, idKey)
if (data[idKey]) { if (data[idKey]) {
this.currentId = data[idKey] this.currentId = data[idKey]
let item = list.find(i => i.id == this.currentId) let item = list.find(i => i[key] == this.currentId)
this.$emit('choose', item) this.$emit('choose', item)
} }
this.list = list this.list = list
this.$emit('onComplete') this.$emit('onComplete')
}, },
handleSearch (searchValue) { handleSearch(searchValue) {
this.list = [] this.list = []
this.getList(searchValue, true) this.getList(searchValue, true)
}, },
choose (i) { choose(i) {
this.currentId = i.id let { params } = this
let key = params.defeat ? 'id' : 'customerPhone'
this.currentId = i[key]
this.$emit('choose', i) this.$emit('choose', i)
}, },
checkActive (i) { checkActive(i) {
let { currentId, data, params } = this let { currentId, data, params } = this
return currentId ? i.id == currentId : i.id == data[params.idKey] let key = params.defeat ? 'id' : 'customerPhone'
return currentId ? (i[key] == currentId) : (i[key]) == data[params.idKey]
} }
} }
} }
...@@ -85,6 +99,7 @@ export default { ...@@ -85,6 +99,7 @@ export default {
grid-template-columns: repeat(2, 1fr); grid-template-columns: repeat(2, 1fr);
gap: toRpx(32); gap: toRpx(32);
margin: 0 toRpx(48); margin: 0 toRpx(48);
.item { .item {
justify-content: center; justify-content: center;
height: toRpx(72); height: toRpx(72);
...@@ -94,6 +109,7 @@ export default { ...@@ -94,6 +109,7 @@ export default {
position: relative; position: relative;
color: #333333; color: #333333;
font-size: toRpx(32); font-size: toRpx(32);
.sprite-icon { .sprite-icon {
display: none; display: none;
position: absolute; position: absolute;
...@@ -101,10 +117,12 @@ export default { ...@@ -101,10 +117,12 @@ export default {
right: 0; right: 0;
} }
} }
.active { .active {
border-color: #2c66f7; border-color: #2c66f7;
background: #ecf1ff; background: #ecf1ff;
color: #2c66f7; color: #2c66f7;
.sprite-icon { .sprite-icon {
display: block; display: block;
} }
......
...@@ -127,6 +127,7 @@ export default { ...@@ -127,6 +127,7 @@ export default {
const { days } = this const { days } = this
const { value } = e.detail const { value } = e.detail
const index = value[0] const index = value[0]
console.log( days[index],days,index)
this.currentDate = days[index] this.currentDate = days[index]
// 选择过去时间需要重新初始化时分 // 选择过去时间需要重新初始化时分
const today = dayjs().format('YYYY/MM/DD') const today = dayjs().format('YYYY/MM/DD')
...@@ -175,6 +176,7 @@ export default { ...@@ -175,6 +176,7 @@ export default {
this.minutes = minutes this.minutes = minutes
}, },
getResult () { getResult () {
console.log(this.currentDate,this.currentHour,this.currentMinute)
let str = '' let str = ''
str = this.currentDate + ' ' + this.currentHour + ':' + this.currentMinute + ":00" str = this.currentDate + ' ' + this.currentHour + ':' + this.currentMinute + ":00"
const result = dayjs(str).format('YYYY/MM/DD HH:mm:ss') const result = dayjs(str).format('YYYY/MM/DD HH:mm:ss')
......
...@@ -50,7 +50,7 @@ export default { ...@@ -50,7 +50,7 @@ export default {
}, },
initData (list) { initData (list) {
const { idKey, data } = this const { idKey, data } = this
console.log(idKey) console.log(idKey,data)
if (data[idKey]) { if (data[idKey]) {
this.currentId = data[idKey] this.currentId = data[idKey]
let item = list.find(i => i.uuid == this.currentId) let item = list.find(i => i.uuid == this.currentId)
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
<text class="price">¥{{ i.goods.price }}</text> <text class="price">¥{{ i.goods.price }}</text>
</view> </view>
<template v-if="i.goods.serveName"> <template v-if="i.goods.serveName">
<view class="base-tips">(包含{{i.goods.serveName}})</view> <view class="base-tips">包含{{i.goods.serveName}}</view>
</template> </template>
</template> </template>
<template v-if="i.goodsFlag == 2"> <template v-if="i.goodsFlag == 2">
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
</template> </template>
</view> </view>
<template v-if="sceneType == 0 && i.multipleSpecificationsGoods.goods && i.multipleSpecificationsGoods.goods.serveName"> <template v-if="sceneType == 0 && i.multipleSpecificationsGoods.goods && i.multipleSpecificationsGoods.goods.serveName">
<view class="base-tips">(包含{{i.multipleSpecificationsGoods.goods.serveName}})</view> <view class="base-tips">包含{{i.multipleSpecificationsGoods.goods.serveName}}</view>
</template> </template>
<template v-if="i.multipleSpecificationsGoods.specificationList && i.multipleSpecificationsGoods.specificationList.length"> <template v-if="i.multipleSpecificationsGoods.specificationList && i.multipleSpecificationsGoods.specificationList.length">
<view class="package-list"> <view class="package-list">
...@@ -564,6 +564,7 @@ export default { ...@@ -564,6 +564,7 @@ export default {
.price { .price {
margin-left: auto; margin-left: auto;
flex-shrink: 0; flex-shrink: 0;
font-weight: 600;
} }
.title { .title {
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
* 17:所在城市 * 17:所在城市
* 18: 座位数 * 18: 座位数
* 19: 客户档案 * 19: 客户档案
* 20: 战败客户档案
*/ */
const componentConfig = { const componentConfig = {
...@@ -225,6 +226,19 @@ const componentConfig = { ...@@ -225,6 +226,19 @@ const componentConfig = {
loadComplete: false, loadComplete: false,
searchValue: '', searchValue: '',
noData: false noData: false
},
20: {
name: 'Customer',
title: '客户档案',
loadComplete: false,
placeholder: '查找',
nullTips: '请选择客户',
idKey: 'id',
cacheData: [],
loadComplete: false,
searchValue: '',
noData: false,
defeat: true
} }
} }
export default { componentConfig } export default { componentConfig }
<template> <template>
<view class="employee-list"> <view class="employee-list">
<view <view @click="currentIds = []" :class="['item flex', { active: !currentIds.length }]">
@click="currentIds = []"
:class="['item flex',{active:!currentIds.length}]"
>
<view class="sprite-icon icon-tag-checked"></view> <view class="sprite-icon icon-tag-checked"></view>
全部 全部
</view> </view>
<template v-for="(i, index) in list"> <template v-for="(i, index) in list">
<view <view :key="index" @click="choose(i)" :class="['item flex', { active: checkActive(i) }]">
:key="index"
@click="choose(i)"
:class="['item flex',{active:checkActive(i)}]"
>
<view class="sprite-icon icon-tag-checked"></view> <view class="sprite-icon icon-tag-checked"></view>
{{i.staffName}} {{ i.staffName }}
</view> </view>
</template> </template>
</view> </view>
</template> </template>
<script type='text/ecmascript-6'> <script type="text/ecmascript-6">
export default { export default {
name: 'EmployeeList', name: 'EmployeeList',
inject: ['userInfo'], inject: ['userInfo'],
...@@ -59,8 +52,8 @@ export default { ...@@ -59,8 +52,8 @@ export default {
} }
const { shopMerchantId, sceneType, merchantId } = userInfo, const { shopMerchantId, sceneType, merchantId } = userInfo,
data = await uni.$api.popupApi.getOrderScreenEmployeeList({ data = await uni.$api.popupApi.getOrderScreenEmployeeList({
merchantId: params.idKey == 'sellerUserIdList' ? merchantId : shopMerchantId, merchantId: params.idKey == 'transferIds' ? merchantId : shopMerchantId,
sceneList: params.idKey == 'sellerUserIdList' ? '' : [sceneType] sceneList: params.idKey == 'transferIds' ? '' : [sceneType]
}) })
if (data && data.length) { if (data && data.length) {
this.initList(data) this.initList(data)
...@@ -97,7 +90,7 @@ export default { ...@@ -97,7 +90,7 @@ export default {
} }
</script> </script>
<style scoped lang='scss'> <style scoped lang="scss">
.employee-list { .employee-list {
display: grid; display: grid;
grid-template-columns: repeat(6, 1fr); grid-template-columns: repeat(6, 1fr);
......
const target = ['ip', 'dev', 'uat', 'prod', 'beta'] const target = ['ip', 'dev', 'uat', 'prod', 'beta']
const index = 2 const index = 1
/** /**
* *
0本地 0本地
......
...@@ -52,6 +52,7 @@ import Package from './Package.vue' ...@@ -52,6 +52,7 @@ import Package from './Package.vue'
import SkuGoods from './SkuGoods.vue' import SkuGoods from './SkuGoods.vue'
import { FORM_LIST, popupTypeEnum, payTypeList } from '../contant' import { FORM_LIST, popupTypeEnum, payTypeList } from '../contant'
import { interceptionMixin } from '@/mixin/index' import { interceptionMixin } from '@/mixin/index'
import { validateVin, formatVinInput } from '@/utils/vinVaildate'
export default { export default {
name: 'CreateOrder', name: 'CreateOrder',
mixins: [interceptionMixin], mixins: [interceptionMixin],
...@@ -216,6 +217,7 @@ export default { ...@@ -216,6 +217,7 @@ export default {
positionTypeList: [], positionTypeList: [],
valueKey: '', valueKey: '',
totalPrice: 0, totalPrice: 0,
validateState:null,
// 产品槽位配置,用于循环渲染产品组件 // 产品槽位配置,用于循环渲染产品组件
productSlots: { productSlots: {
frontGear: true, frontGear: true,
...@@ -382,6 +384,21 @@ export default { ...@@ -382,6 +384,21 @@ export default {
inputBlur(e, val) { inputBlur(e, val) {
console.log(e, val) console.log(e, val)
this.orderObj.customer[val.value] = this.orderObj[val.value] this.orderObj.customer[val.value] = this.orderObj[val.value]
// VIN车架号动态校验:车架号字段,动态转换为大写
let standNoVal = this.orderObj.standNo;
if (val.value === 'standNo' && standNoVal) {
this.orderObj.standNo = formatVinInput(standNoVal)
validateVin(this.orderObj.standNo).then(result => {
console.log("validateVin",result);
let { valid } = result.data;
this.validateState = valid
// 校验成功,所有提示已在公共方法中处理
console.log('车架号校验成功:', result)
}).catch(err => {
console.log("validateVinErr",result);
})
}
}, },
// 校验必填等规则 // 校验必填等规则
checkRequired() { checkRequired() {
...@@ -430,9 +447,9 @@ export default { ...@@ -430,9 +447,9 @@ export default {
} }
} }
if (this.orderObj.standNo) { // if (this.orderObj.standNo) {
if (!utils.validateVIN(this.orderObj.standNo)) throw '车架号校验不匹配,请核对后重新输入' // if (!utils.validateVIN(this.orderObj.standNo)) throw '车架号校验不匹配,请核对后重新输入'
} // }
// 处理onlyLabel为true的特殊校验 // 处理onlyLabel为true的特殊校验
if (onlyLabelItem.length > 0) { if (onlyLabelItem.length > 0) {
...@@ -458,8 +475,22 @@ export default { ...@@ -458,8 +475,22 @@ export default {
// 提交 // 提交
async submit() { async submit() {
console.log(this.orderObj) // VIN车架号-动态校验
if (!this.checkRequired()) return const carVin = this.orderObj.standNo
console.log("validateState",this.validateState);
if (carVin) {
// 前置判断
if (carVin.length !== 17) {
uni.showToast({title:'请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)',icon:'none'})
return false
}
// 根据接口校验结果判断
if (carVin.length === 17 && !this.validateState) {
uni.showToast({title:'车架号校验不匹配,请核对后重新输入',icon:'none'})
return false
}
}
if (!(await this.checkDailyReport())) { if (!(await this.checkDailyReport())) {
const { orderCreateType } = this const { orderCreateType } = this
const obj = utils.deepClone(this.orderObj) const obj = utils.deepClone(this.orderObj)
......
...@@ -896,7 +896,7 @@ export default { ...@@ -896,7 +896,7 @@ export default {
} }
.info { .info {
display: flex; display: flex;
padding: toRpx(16) toRpx(32); padding: 0 toRpx(32) toRpx(16);
flex-wrap: wrap; flex-wrap: wrap;
&-item { &-item {
width: 25%; width: 25%;
...@@ -908,7 +908,10 @@ export default { ...@@ -908,7 +908,10 @@ export default {
color: #777777; color: #777777;
font-size: toRpx(24); font-size: toRpx(24);
line-height: toRpx(48); line-height: toRpx(48);
padding: toRpx(8) 0; padding: toRpx(24) 0 toRpx(8);
}
&-value {
padding-bottom: toRpx(8);
} }
} }
.block { .block {
......
...@@ -62,6 +62,7 @@ import SkuGoods from './SkuGoods.vue' ...@@ -62,6 +62,7 @@ import SkuGoods from './SkuGoods.vue'
import { checkDailyReport, showNextModal } from '@/utils/modalUtils' import { checkDailyReport, showNextModal } from '@/utils/modalUtils'
import { DEFEAT_FORM_LIST, popupTypeEnum, payTypeList } from '../contant' import { DEFEAT_FORM_LIST, popupTypeEnum, payTypeList } from '../contant'
import { debounce } from 'lodash' import { debounce } from 'lodash'
import { validateVin, formatVinInput } from '@/utils/vinVaildate'
export default { export default {
name: 'DefeatOrder', name: 'DefeatOrder',
components: { components: {
...@@ -182,6 +183,7 @@ export default { ...@@ -182,6 +183,7 @@ export default {
positionTypeList: [], positionTypeList: [],
valueKey: '', valueKey: '',
totalPrice: 0, totalPrice: 0,
validateState:null,
// 产品槽位配置,用于循环渲染产品组件 // 产品槽位配置,用于循环渲染产品组件
productSlots: { productSlots: {
frontGear: true, frontGear: true,
...@@ -333,6 +335,20 @@ export default { ...@@ -333,6 +335,20 @@ export default {
console.log(e, val) console.log(e, val)
console.log(this.orderObj) console.log(this.orderObj)
this.orderObj.customer[val.value] = this.orderObj[val.value] this.orderObj.customer[val.value] = this.orderObj[val.value]
// VIN车架号动态校验:车架号字段,动态转换为大写
let standNoVal = this.orderObj.standNo;
if (val.value === 'standNo' && standNoVal) {
this.orderObj.standNo = formatVinInput(standNoVal)
validateVin(this.orderObj.standNo).then(result => {
console.log("validateVin",result);
let { valid } = result.data;
this.validateState = valid
// 校验成功,所有提示已在公共方法中处理
console.log('车架号校验成功:', result)
}).catch(err => {
console.log("validateVinErr",result);
})
}
}, },
checkRequired() { checkRequired() {
const phoneRex = /^[1]([3-9])[0-9]{9}$/ const phoneRex = /^[1]([3-9])[0-9]{9}$/
...@@ -352,6 +368,21 @@ export default { ...@@ -352,6 +368,21 @@ export default {
}) })
}) })
// VIN车架号-动态校验
const carVin = this.orderObj.standNo
console.log("validateState",this.validateState);
if (carVin) {
// 前置判断
if (carVin.length !== 17) {
uni.showToast({title:'请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)',icon:'none'})
return false
}
// 根据接口校验结果判断
if (carVin.length === 17 && !this.validateState) {
uni.showToast({title:'车架号校验不匹配,请核对后重新输入',icon:'none'})
return false
}
}
// 遍历requiredArr,检查orderObj中是否有对应的值 // 遍历requiredArr,检查orderObj中是否有对应的值
for (let i = 0; i < requiredArr.length; i++) { for (let i = 0; i < requiredArr.length; i++) {
const item = requiredArr[i] const item = requiredArr[i]
...@@ -380,18 +411,17 @@ export default { ...@@ -380,18 +411,17 @@ export default {
} }
} }
if (this.orderObj.standNo) { // if (this.orderObj.standNo) {
const vinRex = /^(?=.*[A-Za-z])[A-Za-z0-9]{17}$/ // const vinRex = /^(?=.*[A-Za-z])[A-Za-z0-9]{17}$/
console.log(this.orderObj.standNo, vinRex.test(this.orderObj.standNo)) // console.log(this.orderObj.standNo, vinRex.test(this.orderObj.standNo))
if (!vinRex.test(this.orderObj.standNo)) { // if (!vinRex.test(this.orderObj.standNo)) {
uni.showToast({ // uni.showToast({
title: `请输入正确的VIN码`, // title: `请输入正确的VIN码`,
icon: 'none' // icon: 'none'
}) // })
return false // return false
} // }
} // }
// 处理onlyLabel为true的特殊校验 // 处理onlyLabel为true的特殊校验
if (onlyLabelItem.length > 0) { if (onlyLabelItem.length > 0) {
// 检查frontGear、frontWindow、rearGear、rearWindow、sunRoof和couponInfo字段中是否至少有一个不为空 // 检查frontGear、frontWindow、rearGear、rearWindow、sunRoof和couponInfo字段中是否至少有一个不为空
...@@ -419,6 +449,7 @@ export default { ...@@ -419,6 +449,7 @@ export default {
// 校验是否填写昨日日报 // 校验是否填写昨日日报
let staffCheck = await checkDailyReport() let staffCheck = await checkDailyReport()
if (staffCheck) return false if (staffCheck) return false
console.log("this.checkRequired()",this.checkRequired());
if (!this.checkRequired()) return if (!this.checkRequired()) return
const { orderCreateType } = this const { orderCreateType } = this
const obj = utils.deepClone(this.orderObj) const obj = utils.deepClone(this.orderObj)
......
...@@ -110,7 +110,7 @@ import UploadProofOfPayment from './UploadProofOfPayment.vue' ...@@ -110,7 +110,7 @@ import UploadProofOfPayment from './UploadProofOfPayment.vue'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import OrderPay from './OrderPay.vue' import OrderPay from './OrderPay.vue'
import NP from 'number-precision' import NP from 'number-precision'
import { validateVin, formatVinInput } from '@/utils/vinVaildate'
export default { export default {
name: 'CreateOrder', name: 'CreateOrder',
mixins: [interceptionMixin], mixins: [interceptionMixin],
...@@ -202,7 +202,8 @@ export default { ...@@ -202,7 +202,8 @@ export default {
valueKey: '', valueKey: '',
popupTitle: '', popupTitle: '',
pointsMultiRole: 'Y', pointsMultiRole: 'Y',
formKey: Date.now() formKey: Date.now(),
validateState:null
} }
...@@ -507,12 +508,27 @@ export default { ...@@ -507,12 +508,27 @@ export default {
}, },
// 输入框失去焦点事件 // 输入框失去焦点事件
inputBlur (e, val) { inputBlur (e, val) {
console.log("SSSSSS");
console.log(e, val) console.log(e, val)
if (val.value == 'price') { if (val.value == 'price') {
this.orderObj[val.value] = parseFloat(this.orderObj[val.value]) > 2000000 ? 2000000 : this.orderObj[val.value] this.orderObj[val.value] = parseFloat(this.orderObj[val.value]) > 2000000 ? 2000000 : this.orderObj[val.value]
return return
} }
this.orderObj[val.value] = this.orderObj[val.value] this.orderObj[val.value] = this.orderObj[val.value]
// VIN车架号动态校验:车架号字段,动态转换为大写
let carVinVal = this.orderObj.carVin;
if (val.value === 'carVin' && carVinVal) {
this.orderObj.carVin = formatVinInput(carVinVal)
validateVin(this.orderObj.carVin).then(result => {
console.log("validateVin",result);
let { valid } = result.data;
this.validateState = valid
// 校验成功,所有提示已在公共方法中处理
console.log('车架号校验成功:', result)
}).catch(err => {
console.log("validateVinErr",result);
})
}
}, },
// 校验必填等规则 // 校验必填等规则
checkRequired () { checkRequired () {
...@@ -530,6 +546,21 @@ export default { ...@@ -530,6 +546,21 @@ export default {
} }
}) })
}) })
// VIN车架号-动态校验
const carVin = this.orderObj.carVin
console.log("validateState",this.validateState);
if (carVin) {
// 前置判断
if (carVin.length !== 17) {
uni.showToast({title:'请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)',icon:'none'})
return false
}
// 根据接口校验结果判断
if (carVin.length === 17 && !this.validateState) {
uni.showToast({title:'车架号校验不匹配,请核对后重新输入',icon:'none'})
return false
}
}
// 遍历requiredArr,检查orderObj中是否有对应的值 // 遍历requiredArr,检查orderObj中是否有对应的值
for (let i = 0; i < requiredArr.length; i++) { for (let i = 0; i < requiredArr.length; i++) {
const item = requiredArr[i] const item = requiredArr[i]
...@@ -539,9 +570,9 @@ export default { ...@@ -539,9 +570,9 @@ export default {
// 如果是customerPhone,添加phoneRex校验 // 如果是customerPhone,添加phoneRex校验
if (item.value === 'phone' && !phoneRex.test(value)) throw `请输入正确的${item.label}` if (item.value === 'phone' && !phoneRex.test(value)) throw `请输入正确的${item.label}`
} }
if (orderObj.carVin) { // if (orderObj.carVin) {
if (!utils.validateVIN(orderObj.carVin)) throw '车架号校验不匹配,请核对后重新输入' // if (!utils.validateVIN(orderObj.carVin)) throw '车架号校验不匹配,请核对后重新输入'
} // }
if (onlyLabelItem.length) { if (onlyLabelItem.length) {
const labelFields = ['skuGoods'] const labelFields = ['skuGoods']
......
...@@ -724,7 +724,6 @@ export default { ...@@ -724,7 +724,6 @@ export default {
userInfo, userInfo,
carBandList carBandList
} = this } = this
console.log(carBandList,'===')
let { value } = e.detail let { value } = e.detail
if (value) { if (value) {
let { key, max } = i, let { key, max } = i,
...@@ -1043,7 +1042,7 @@ export default { ...@@ -1043,7 +1042,7 @@ export default {
} }
.info { .info {
display: flex; display: flex;
padding: toRpx(16) toRpx(32); padding: 0 toRpx(32) toRpx(16);
flex-wrap: wrap; flex-wrap: wrap;
&-item { &-item {
width: 25%; width: 25%;
...@@ -1055,7 +1054,10 @@ export default { ...@@ -1055,7 +1054,10 @@ export default {
color: #777777; color: #777777;
font-size: toRpx(24); font-size: toRpx(24);
line-height: toRpx(48); line-height: toRpx(48);
padding: toRpx(8) 0; padding: toRpx(24) 0 toRpx(8);
}
&-value {
padding-bottom: toRpx(8);
} }
} }
.block { .block {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
class="customer-file flex" class="customer-file flex"
@click=" @click="
handleCell({ handleCell({
key: 'customer' value: 'defeatCustomer'
}) })
" "
> >
...@@ -30,9 +30,13 @@ ...@@ -30,9 +30,13 @@
</template> </template>
</GlCell> </GlCell>
</view> </view>
<view @click.stop="submit" class="btn">战败下单</view>
</scroll-view> </scroll-view>
<view class="btns flex">
<view @click.stop="submit('reload')" class="btn save">提交后继续添加</view>
<view @click.stop="submit" class="btn">战败下单</view>
</view>
</view> </view>
<!-- 弹窗 --> <!-- 弹窗 -->
<order-popup ref="orderPopup" :data="orderObj" :dataKey="valueKey" :isDefeatOrder="true" @onConfirm="onConfirm" :externalData="externalData" :popupType="popupType" /> <order-popup ref="orderPopup" :data="orderObj" :dataKey="valueKey" :isDefeatOrder="true" @onConfirm="onConfirm" :externalData="externalData" :popupType="popupType" />
</view> </view>
...@@ -200,6 +204,19 @@ export default { ...@@ -200,6 +204,19 @@ export default {
this.initData() this.initData()
}, },
methods: { methods: {
resetParams() {
// 重置表单数据
this.orderObj = {
deafeatReason: '',
customerName: '',
customerPhone: '',
salesType: 0
}
// 重置表单列表
this.formList = utils.deepClone(DEFEAT_FORM_LIST)
this.initData()
},
async initData() { async initData() {
const { userInfo } = this const { userInfo } = this
console.log(this.orderObj, 'this.orderObj') console.log(this.orderObj, 'this.orderObj')
...@@ -236,7 +253,7 @@ export default { ...@@ -236,7 +253,7 @@ export default {
// 获取当前选中的popupType // 获取当前选中的popupType
console.log(val, 'val') console.log(val, 'val')
console.log(this.popupTypeEnum, 'this.popupTypeEnum') console.log(this.popupTypeEnum, 'this.popupTypeEnum')
this.popupType = Object.keys(this.popupTypeEnum).find(key => this.popupTypeEnum[key].key === val.key) * 1 this.popupType = Object.keys(this.popupTypeEnum).find(key => this.popupTypeEnum[key].key === val.value) * 1
// 获取对应的list字段 // 获取对应的list字段
const popupConfig = this.popupTypeEnum[this.popupType] const popupConfig = this.popupTypeEnum[this.popupType]
if (popupConfig && popupConfig.list) { if (popupConfig && popupConfig.list) {
...@@ -278,6 +295,7 @@ export default { ...@@ -278,6 +295,7 @@ export default {
console.log(res, '上一个订单的销售顾问信息') console.log(res, '上一个订单的销售顾问信息')
this.$set(this.orderObj, 'employeeName', res.employeeName) this.$set(this.orderObj, 'employeeName', res.employeeName)
this.orderObj.userId = res.userId this.orderObj.userId = res.userId
this.orderObj.referrerId = res.userId
console.log(res, '上一个订单的销售顾问信息') console.log(res, '上一个订单的销售顾问信息')
}, },
// 单选框change事件 // 单选框change事件
...@@ -303,11 +321,19 @@ export default { ...@@ -303,11 +321,19 @@ export default {
// 根据popupTypeEnum优化处理 // 根据popupTypeEnum优化处理
const _typeValue = this.popupTypeEnum[this.popupType] const _typeValue = this.popupTypeEnum[this.popupType]
console.log(_typeValue) console.log(_typeValue)
if (_typeValue.key == 'todayShow') {
const weeks = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
this.$set(this.orderObj, 'todayShow', dayjs(chooseContent).format('YYYY-MM-DD') + ' ' + weeks[dayjs(chooseContent).day()])
this.$set(this.orderObj, 'createDate', dayjs(chooseContent).format('YYYY-MM-DD'))
} else if (_typeValue.key) {
this.orderObj[_typeValue.targetIdKey] = chooseContent[_typeValue.sourceIdKey]
this.$set(this.orderObj, _typeValue.targetNameKey, chooseContent[_typeValue.sourceNameKey])
}
// 定义产品相关字段数组 // 定义产品相关字段数组
if (val.popupType == 19) { if (val.popupType == 20) {
console.log(chooseContent, 'chooseContent') console.log(chooseContent, 'chooseContent')
this.orderObj.customerName = chooseContent.customerName this.orderObj.customerName = chooseContent.customer.customerName
this.orderObj.customerPhone = chooseContent.customerPhone this.orderObj.customerPhone = chooseContent.customer.customerPhone
} }
if (val.popupType == 0) { if (val.popupType == 0) {
console.log(chooseContent, 'chooseContent') console.log(chooseContent, 'chooseContent')
...@@ -394,7 +420,7 @@ export default { ...@@ -394,7 +420,7 @@ export default {
}, },
// 提交 // 提交
submit: debounce(async function () { submit: debounce(async function (type) {
// 校验是否填写昨日日报 // 校验是否填写昨日日报
let staffCheck = await checkDailyReport() let staffCheck = await checkDailyReport()
if (staffCheck) return false if (staffCheck) return false
...@@ -424,8 +450,12 @@ export default { ...@@ -424,8 +450,12 @@ export default {
title: '保存成功', title: '保存成功',
icon: 'success' icon: 'success'
}) })
if (type == 'reload') {
this.resetParams()
} else {
this.$emit('jump', 'OrderManagement') this.$emit('jump', 'OrderManagement')
} }
}
}, 300), }, 300),
// 获取商品列表数据 // 获取商品列表数据
...@@ -651,7 +681,7 @@ export default { ...@@ -651,7 +681,7 @@ export default {
.box { .box {
height: calc(100% - #{toRpx(120)}); height: calc(100% - #{toRpx(120)});
padding-bottom: toRpx(24); padding-bottom: toRpx(24);
position: relative;
.scroll-view { .scroll-view {
height: 100%; height: 100%;
} }
...@@ -859,13 +889,26 @@ export default { ...@@ -859,13 +889,26 @@ export default {
} }
.defeat-order ::v-deep .cell-value .textarea { .defeat-order ::v-deep .cell-value .textarea {
margin-bottom: 0; margin-bottom: 0;
height: toRpx(192);
}
.btns {
padding: 24rpx 128rpx;
gap: 32rpx;
position: absolute;
bottom: 0;
width: 100%;
left: 0;
.save {
background: #3b73ff1a;
color: #4673ff;
font-size: 28rpx;
font-weight: 500;
}
} }
.btn { .btn {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin: toRpx(88) auto 0;
width: toRpx(1130); width: toRpx(1130);
height: toRpx(80); height: toRpx(80);
color: #fff; color: #fff;
......
<template> <template>
<view class="order"> <view class="order">
<view :class="['order-box', { hide: showUpload }]" :key="formKey"> <view :class="['order-box', { hide: showUpload }]">
<view class="common-title">修改客户信息</view> <view class="common-title">修改客户信息</view>
<view class="box"> <view class="box">
<scroll-view class="scroll-view" scroll-y="true"> <scroll-view class="scroll-view" scroll-y="true">
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</view> </view>
</view> </view>
<!-- 弹窗 --> <!-- 弹窗 -->
<order-popup ref="orderPopup" :data="orderObj" :dataKey="valueKey" @onConfirm="onConfirm" :externalData="externalData" :popupType="popupType" :popupTitle="popupTitle" /> <!-- <order-popup ref="orderPopup" :data="orderObj" :dataKey="valueKey" @onConfirm="onConfirm" :externalData="externalData" :popupType="popupType" :popupTitle="popupTitle" /> -->
<template v-if="showUpload"> <template v-if="showUpload">
<view class="upload-box"> <view class="upload-box">
<upload-proof-of-payment @back="showUpload = false" @confirm="uploadConfirm" /> <upload-proof-of-payment @back="showUpload = false" @confirm="uploadConfirm" />
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<script> <script>
import utils from '@/utils/utils' import utils from '@/utils/utils'
import OrderPopup from '@/components/OrderPopup/index.vue' // import OrderPopup from '@/components/OrderPopup/index.vue'
import GlCell from '../../../../components/Form/GlCell.vue' import GlCell from '../../../../components/Form/GlCell.vue'
import { UpdateOrderInfo, popupTypeEnum, payTypeList, titleList } from '../contant' import { UpdateOrderInfo, popupTypeEnum, payTypeList, titleList } from '../contant'
import { interceptionMixin } from '@/mixin/index' import { interceptionMixin } from '@/mixin/index'
...@@ -44,7 +44,7 @@ export default { ...@@ -44,7 +44,7 @@ export default {
mixins: [interceptionMixin], mixins: [interceptionMixin],
components: { components: {
GlCell, GlCell,
OrderPopup, // OrderPopup,
UploadProofOfPayment, UploadProofOfPayment,
OrderPay, OrderPay,
NoticePopup NoticePopup
...@@ -60,7 +60,9 @@ export default { ...@@ -60,7 +60,9 @@ export default {
showUpload: false, showUpload: false,
titleList, titleList,
formList: utils.deepClone(UpdateOrderInfo), formList: utils.deepClone(UpdateOrderInfo),
valueKey: '',
externalData: [],
popupType: 0,
baseConfigData: {}, baseConfigData: {},
requiredList: [], // 录单设置的必填项 requiredList: [], // 录单设置的必填项
orderObj: { orderObj: {
...@@ -163,7 +165,6 @@ export default { ...@@ -163,7 +165,6 @@ export default {
} }
}, },
// 提交 // 提交
async submit() { async submit() {
if (!this.checkRequired() || (await this.checkDailyReport())) return if (!this.checkRequired() || (await this.checkDailyReport())) return
let params = { let params = {
...@@ -216,6 +217,10 @@ export default { ...@@ -216,6 +217,10 @@ export default {
] ]
// 打开弹窗 // 打开弹窗
this.$refs.notice.open() this.$refs.notice.open()
},
radioChange(val) {
console.log(val)
this.orderObj.salesType = val.detail.value
} }
} }
} }
......
...@@ -387,6 +387,9 @@ const popupTypeEnum = { ...@@ -387,6 +387,9 @@ const popupTypeEnum = {
}, },
19: { 19: {
key: 'customer' key: 'customer'
},
20: {
key: 'defeatCustomer'
} }
} }
const titleList = [null, { addHtml: 'customer' }, { name: '车辆信息' }, { name: '增值车损险' }, { name: '其他信息' }] const titleList = [null, { addHtml: 'customer' }, { name: '车辆信息' }, { name: '增值车损险' }, { name: '其他信息' }]
......
...@@ -151,6 +151,7 @@ import dayjs from 'dayjs' ...@@ -151,6 +151,7 @@ import dayjs from 'dayjs'
import permision from '@/js_sdk/wa-permission/permission.js' import permision from '@/js_sdk/wa-permission/permission.js'
import { sign, md532, md516 } from 'utils/common' import { sign, md532, md516 } from 'utils/common'
import { signSecretKey } from '@/env.js' import { signSecretKey } from '@/env.js'
import { validateVin, formatVinInput } from '@/utils/vinVaildate'
export default { export default {
name: 'AddEvaluationFrom', name: 'AddEvaluationFrom',
components: { components: {
...@@ -548,7 +549,8 @@ export default { ...@@ -548,7 +549,8 @@ export default {
], ],
uploadOtherFields: [{ key: 41, label: '其他图片', required: false, accept: 'image', maxCount: 30, fullwidth: true }], uploadOtherFields: [{ key: 41, label: '其他图片', required: false, accept: 'image', maxCount: 30, fullwidth: true }],
currentField: null, currentField: null,
query: {} query: {},
validateVinState:null
} }
}, },
onLoad(options) { onLoad(options) {
...@@ -872,22 +874,38 @@ export default { ...@@ -872,22 +874,38 @@ export default {
} }
// 车架号验证 - 长度17且只能包含数字和大写字母 // 车架号验证 - 长度17且只能包含数字和大写字母
const vin = this.formData.carBaseReqDTO.vin // const vin = this.formData.carBaseReqDTO.vin
const vinRegex = /^[A-Z0-9]+$/ // const vinRegex = /^[A-Z0-9]+$/
if (!vinRegex.test(vin)) { // if (!vinRegex.test(vin)) {
uni.showToast({ // uni.showToast({
title: '车架号只能包含数字和大写字母', // title: '车架号只能包含数字和大写字母',
icon: 'none' // icon: 'none'
}) // })
return // return
// }
// if (vin.length != 17) {
// uni.showToast({
// title: '车架号必须为17位',
// icon: 'none'
// })
// return
// }
// VIN车架号-动态校验
const carVin = this.formData.carBaseReqDTO.vin
console.log("validateState",this.validateState);
if (carVin) {
// 前置判断
if (carVin.length !== 17) {
uni.showToast({title:'请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)',icon:'none'})
return false
}
// 根据接口校验结果判断
if (carVin.length === 17 && !this.validateState) {
uni.showToast({title:'车架号校验不匹配,请核对后重新输入',icon:'none'})
return false
} }
if (vin.length != 17) {
uni.showToast({
title: '车架号必须为17位',
icon: 'none'
})
return
} }
const engineNumber = this.formData.carBaseReqDTO.engineNumber const engineNumber = this.formData.carBaseReqDTO.engineNumber
const engineNumberRegex = /^[A-Za-z0-9]+$/ const engineNumberRegex = /^[A-Za-z0-9]+$/
...@@ -990,7 +1008,7 @@ export default { ...@@ -990,7 +1008,7 @@ export default {
}, },
handleCell(field) { handleCell(field) {
const that = this const that = this
console.log("handleCellAAAAA");
if (field.isCar) { if (field.isCar) {
this.openSelectCar() this.openSelectCar()
} else if (field.isCity) { } else if (field.isCity) {
...@@ -1110,6 +1128,17 @@ export default { ...@@ -1110,6 +1128,17 @@ export default {
if (upperValue !== value) { if (upperValue !== value) {
this.$set(this.formData.carBaseReqDTO, 'vin', upperValue) this.$set(this.formData.carBaseReqDTO, 'vin', upperValue)
} }
// VIN车架号动态校验:车架号字段,动态转换为大写
validateVin(upperValue).then(result => {
console.log("validateVin",result);
let { valid } = result.data;
this.validateState = valid
// 校验成功,所有提示已在公共方法中处理
console.log('车架号校验成功:', result)
}).catch(err => {
console.log("validateVinErr",result);
})
} }
if (field.key === 'mileage') { if (field.key === 'mileage') {
let numValue = Number(value) let numValue = Number(value)
...@@ -1285,6 +1314,15 @@ export default { ...@@ -1285,6 +1314,15 @@ export default {
if (res.data.code == 0) { if (res.data.code == 0) {
if (res.data.data.status == 1) { if (res.data.data.status == 1) {
this.formData.carBaseReqDTO.vin = res.data.data.vin this.formData.carBaseReqDTO.vin = res.data.data.vin
validateVin(this.formData.carBaseReqDTO.vin).then(result => {
console.log("validateVin",result);
let { valid } = result.data;
this.validateState = valid
// 校验成功,所有提示已在公共方法中处理
console.log('车架号校验成功:', result)
}).catch(err => {
console.log("validateVinErr",result);
})
uni.showToast({ title: '车架号识别完成并已自动填写到表单中', icon: 'none' }) uni.showToast({ title: '车架号识别完成并已自动填写到表单中', icon: 'none' })
uni.hideLoading() uni.hideLoading()
} else { } else {
......
import api from '@/api/index.js'
// 有效字符:大写 A-H/J-N/P-Z、0-9(排除 I、O、Q)
const VALID_VIN_REG = /^[A-HJ-NPR-Z0-9]{17}$/
const ERROR_MSG = '请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)'
// 防抖相关变量
let debounceTimer = null
let pendingResolve = null
let pendingReject = null
let pendingVin = null
const DEBOUNCE_DELAY = 500 // 防抖延迟时间(毫秒)
/**
* 车架号校验(统一处理版本)
* @param {string} vin - 车架号
* @returns {Promise<Object>} 返回校验结果 { success: boolean, message: string, data?: any, vin?: string }
*/
export function validateVin(vin) {
console.log("工具调用",vin);
return new Promise((resolve, reject) => {
const upperVin = vin ? vin.toUpperCase() : ''
// 格式校验失败
if (!upperVin || upperVin.length !== 17 || !VALID_VIN_REG.test(upperVin)) {
uni.showToast({
title: ERROR_MSG,
icon: 'none'
})
reject({
success: false,
message: ERROR_MSG
})
return
}
// 保存当前调用的 resolve 和 reject
pendingResolve = resolve
pendingReject = reject
pendingVin = upperVin
// 清除之前的定时器
if (debounceTimer) {
clearTimeout(debounceTimer)
}
// 设置防抖定时器
debounceTimer = setTimeout(() => {
// 执行接口调用
const currentVin = pendingVin
const currentResolve = pendingResolve
const currentReject = pendingReject
// 清空待处理变量
pendingVin = null
pendingResolve = null
pendingReject = null
debounceTimer = null
// 调用后端接口校验
api.commonApi.checkVinValidate({ vin: currentVin })
.then(res => {
console.log("checkVinValidate接口校验",res);
let { valid,message } = res
if (valid) {
// 校验成功但有提示信息
if (message) {
uni.showToast({
title: message,
icon: 'none'
})
}
currentResolve({
success: true,
message: message || '校验成功',
data: res,
vin: currentVin
})
} else {
// 接口返回失败
const errorMsg = message || '车架号校验失败'
uni.showToast({
title: errorMsg,
icon: 'none'
})
currentResolve({
success: false,
message: errorMsg,
data: res
})
}
})
.catch(err => {
const errorMsg = err.message || '车架号校验异常'
uni.showToast({
title: errorMsg,
icon: 'none'
})
currentReject({
success: false,
message: errorMsg
})
})
}, DEBOUNCE_DELAY)
})
}
/**
* 实时输入处理:自动转大写
*/
export function formatVinInput(value) {
return value ? value.toUpperCase() : ''
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!