Commit 9fe1f551 by yuzhenWang

Merge branch 'feature-20250827wyz-写业务' into 'test'

流程修改6

See merge request !12
parents 922cec12 56adb469
...@@ -67,7 +67,7 @@ const applicant = [ ...@@ -67,7 +67,7 @@ const applicant = [
lg: 8 //栅格布局份数 lg: 8 //栅格布局份数
}, },
{ {
label: '姓名', label: '名字',
key: 'name', key: 'name',
customerKey: 'name', customerKey: 'name',
domType: 'Input', domType: 'Input',
...@@ -102,7 +102,7 @@ const applicant = [ ...@@ -102,7 +102,7 @@ const applicant = [
key: 'documentType', key: 'documentType',
customerKey: 'idType', customerKey: 'idType',
domType: 'Select', domType: 'Select',
required: false, required: true,
disabled: false, disabled: false,
placeholder: '请选择', placeholder: '请选择',
dictType: 'csf_id_type', dictType: 'csf_id_type',
...@@ -118,7 +118,7 @@ const applicant = [ ...@@ -118,7 +118,7 @@ const applicant = [
customerKey: 'idCard', customerKey: 'idCard',
domType: 'Input', domType: 'Input',
inputType: 'number', inputType: 'number',
required: false, required: true,
maxLength: 20, maxLength: 20,
disabled: false, disabled: false,
placeholder: '请输入', placeholder: '请输入',
...@@ -150,7 +150,7 @@ const applicant = [ ...@@ -150,7 +150,7 @@ const applicant = [
inputType: 'number', inputType: 'number',
required: false, required: false,
maxLength: 20, maxLength: 20,
disabled: false, disabled: true,
placeholder: '请输入', placeholder: '请输入',
show: true, show: true,
labelPosition: 'top', //标签的位置 labelPosition: 'top', //标签的位置
......
...@@ -57,7 +57,7 @@ const beneficiary = [ ...@@ -57,7 +57,7 @@ const beneficiary = [
customerKey: 'name', customerKey: 'name',
domType: 'Input', domType: 'Input',
inputType: 'text', inputType: 'text',
required: true, required: false,
maxLength: 20, maxLength: 20,
disabled: false, disabled: false,
placeholder: '请输入', placeholder: '请输入',
...@@ -121,7 +121,7 @@ const beneficiary = [ ...@@ -121,7 +121,7 @@ const beneficiary = [
customerKey: 'idCard', customerKey: 'idCard',
domType: 'Input', domType: 'Input',
inputType: 'number', inputType: 'number',
required: false, required: true,
maxLength: 20, maxLength: 20,
disabled: false, disabled: false,
placeholder: '请输入', placeholder: '请输入',
...@@ -377,7 +377,7 @@ const beneficiary = [ ...@@ -377,7 +377,7 @@ const beneficiary = [
showMoudle: true, //模块是否展示 showMoudle: true, //模块是否展示
data: [ data: [
{ {
label: '受益比例', label: '受益比例(%)',
key: 'benefitRatio', key: 'benefitRatio',
customerKey: 'idCard', customerKey: 'idCard',
domType: 'Input', domType: 'Input',
......
...@@ -35,7 +35,7 @@ const customer = [ ...@@ -35,7 +35,7 @@ const customer = [
// lg: 8 //栅格布局份数 // lg: 8 //栅格布局份数
// }, // },
{ {
label: '姓名', label: '名字',
key: 'name', key: 'name',
type: 'Input', type: 'Input',
inputType: 'text', inputType: 'text',
...@@ -251,7 +251,7 @@ const customer = [ ...@@ -251,7 +251,7 @@ const customer = [
type: 'Input', type: 'Input',
inputType: 'text', inputType: 'text',
maxLength: 300, maxLength: 300,
required: false, required: true,
disabled: false, disabled: false,
placeholder: '请输入', placeholder: '请输入',
show: true, show: true,
...@@ -400,29 +400,29 @@ const customer = [ ...@@ -400,29 +400,29 @@ const customer = [
labelWidth: '120px', //标签宽度 labelWidth: '120px', //标签宽度
sm: 8, //栅格布局份数 sm: 8, //栅格布局份数
lg: 8 //栅格布局份数 lg: 8 //栅格布局份数
},
{
label: '邮寄地址',
key: 'mailingAddress',
type: 'arrowRight',
required: false,
disabled: false,
placeholder: '请填写',
show: true,
drawerType: 'address',
mailingAddress: {},
labelPosition: 'top', //标签的位置
labelWidth: '120px', //标签宽度
sm: 8, //栅格布局份数
lg: 8 //栅格布局份数
} }
// {
// label: '邮寄地址',
// key: 'mailingAddress',
// type: 'arrowRight',
// required: false,
// disabled: false,
// placeholder: '请填写',
// show: true,
// drawerType: 'address',
// mailingAddress: {},
// labelPosition: 'top', //标签的位置
// labelWidth: '120px', //标签宽度
// sm: 8, //栅格布局份数
// lg: 8 //栅格布局份数
// }
] ]
}, },
{ {
fatherTitle: '证件信息', fatherTitle: '证件信息',
type: 'object', type: 'object',
key: 'pid', key: 'pid',
description: '证件信息至少填写一项', // description: '证件信息至少填写一项',
data: [ data: [
{ {
label: '证件类型', label: '证件类型',
...@@ -443,7 +443,7 @@ const customer = [ ...@@ -443,7 +443,7 @@ const customer = [
key: 'idCard', key: 'idCard',
type: 'Input', type: 'Input',
inputType: 'text', inputType: 'text',
required: false, required: true,
maxLength: 20, maxLength: 20,
disabled: false, disabled: false,
placeholder: '请输入', placeholder: '请输入',
......
...@@ -87,7 +87,7 @@ const insured = [ ...@@ -87,7 +87,7 @@ const insured = [
customerKey: 'name', customerKey: 'name',
domType: 'Input', domType: 'Input',
inputType: 'text', inputType: 'text',
required: true, required: false,
maxLength: 20, maxLength: 20,
disabled: false, disabled: false,
placeholder: '请输入', placeholder: '请输入',
...@@ -117,7 +117,7 @@ const insured = [ ...@@ -117,7 +117,7 @@ const insured = [
key: 'documentType', key: 'documentType',
customerKey: 'idType', customerKey: 'idType',
domType: 'Select', domType: 'Select',
required: false, required: true,
disabled: false, disabled: false,
placeholder: '请选择', placeholder: '请选择',
dictType: 'csf_id_type', dictType: 'csf_id_type',
...@@ -133,7 +133,7 @@ const insured = [ ...@@ -133,7 +133,7 @@ const insured = [
customerKey: 'idCard', customerKey: 'idCard',
domType: 'Input', domType: 'Input',
inputType: 'number', inputType: 'number',
required: false, required: true,
maxLength: 20, maxLength: 20,
disabled: false, disabled: false,
placeholder: '请输入', placeholder: '请输入',
...@@ -165,7 +165,7 @@ const insured = [ ...@@ -165,7 +165,7 @@ const insured = [
inputType: 'number', inputType: 'number',
required: false, required: false,
maxLength: 20, maxLength: 20,
disabled: false, disabled: true,
placeholder: '请输入', placeholder: '请输入',
show: true, show: true,
labelPosition: 'top', //标签的位置 labelPosition: 'top', //标签的位置
......
const secondHolder = [ const secondHolder = [
// 基础信息 // 基础信息
{ {
......
...@@ -5,25 +5,28 @@ ...@@ -5,25 +5,28 @@
* @returns {Boolean} * @returns {Boolean}
*/ */
export function isPathMatch(pattern, path) { export function isPathMatch(pattern, path) {
const regexPattern = pattern.replace(/\//g, '\\/').replace(/\*\*/g, '.*').replace(/\*/g, '[^\\/]*') const regexPattern = pattern
.replace(/\//g, '\\/')
.replace(/\*\*/g, '.*')
.replace(/\*/g, '[^\\/]*')
const regex = new RegExp(`^${regexPattern}$`) const regex = new RegExp(`^${regexPattern}$`)
return regex.test(path) return regex.test(path)
} }
/** /**
* 判断value字符串是否为空 * 判断value字符串是否为空
* @param {string} value * @param {string} value
* @returns {Boolean} * @returns {Boolean}
*/ */
export function isEmpty(value) { export function isEmpty(value) {
if (value == null || value == "" || value == undefined || value == "undefined") { if (value == null || value == '' || value == undefined || value == 'undefined') {
return true return true
} }
return false return false
} }
/** /**
* 判断url是否是http或https * 判断url是否是http或https
* @param {string} url * @param {string} url
* @returns {Boolean} * @returns {Boolean}
*/ */
...@@ -54,7 +57,8 @@ export function validUsername(str) { ...@@ -54,7 +57,8 @@ export function validUsername(str) {
* @returns {Boolean} * @returns {Boolean}
*/ */
export function validURL(url) { export function validURL(url) {
const reg = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/ const reg =
/^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/
return reg.test(url) return reg.test(url)
} }
...@@ -90,7 +94,8 @@ export function validAlphabets(str) { ...@@ -90,7 +94,8 @@ export function validAlphabets(str) {
* @returns {Boolean} * @returns {Boolean}
*/ */
export function validEmail(email) { export function validEmail(email) {
const reg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ const reg =
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
return reg.test(email) return reg.test(email)
} }
...@@ -112,3 +117,59 @@ export function isArray(arg) { ...@@ -112,3 +117,59 @@ export function isArray(arg) {
} }
return Array.isArray(arg) return Array.isArray(arg)
} }
/**
* 英文姓名校验规则
*/
export const validateEnglish = (rule, value, callback) => {
// if (!value) {
// // 如果值为空且字段不是必填的,直接通过校验
// return callback()
// }
// 1. 基本字符检查
if (!/^[A-Za-z\s\-'.]+$/.test(value)) {
return callback(new Error("包含非法字符,只允许英文字母、空格、-、'和."))
}
// 2. 首字母大写检查
// if (!/^[A-Z]/.test(value)) {
// return callback(new Error('名字应以大写字母开头'))
// }
// 3. 长度检查
if (value.length < 2) {
return callback(new Error('名字至少需要2个字符'))
}
// 4. 连续特殊字符检查
if (/[\s\-'.]{2,}/.test(value)) {
return callback(new Error('不能连续使用特殊字符'))
}
// 5. 开头或结尾不能是特殊字符
if (/^[\s\-'.]|[\s\-'.]$/.test(value.trim())) {
return callback(new Error('名字不能以特殊字符开头或结尾'))
}
callback()
}
/**
* 手机号校验规则
*/
export const validatePhone = (rule, value, callback) => {
if (!value) {
return callback()
}
const phoneRegex = /^1[3-9]\d{9}$/
if (!phoneRegex.test(value)) {
return callback(new Error('请输入正确的手机号码'))
}
callback()
}
export default {
validateEnglish,
validatePhone
}
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
class="searchInput" class="searchInput"
v-model="searchValue" v-model="searchValue"
placeholder="请输入国家/地区名称" placeholder="请输入国家/地区名称"
@change="searchCountry" @input="searchCountry"
/> />
<el-icon class="searchIcon"><Search /></el-icon> <el-icon class="searchIcon"><Search /></el-icon>
</div> </div>
...@@ -64,11 +64,20 @@ ...@@ -64,11 +64,20 @@
<div v-if="searchValue"> <div v-if="searchValue">
<div class="hotCountryList"> <div class="hotCountryList">
<el-row :gutter="20"> <el-row :gutter="20">
<template v-for="item in searchList" :key="item.name"> <template v-if="searchList.length > 0">
<el-col :sm="24" :lg="24" @click="handleCountryClick(item)"> <template v-for="item in searchList" :key="item.name">
<div class="hotCountryItem"> <el-col :sm="24" :lg="24" @click="handleCountryClick(item)">
<span>{{ item.name }}</span> <div class="hotCountryItem">
<span>{{ item.areaCode }}</span> <span>{{ item.name }}</span>
<span>{{ item.areaCode }}</span>
</div>
</el-col>
</template>
</template>
<template v-else>
<el-col :span="24">
<div class="countryEmpty">
<span>暂无数据</span>
</div> </div>
</el-col> </el-col>
</template> </template>
...@@ -131,11 +140,17 @@ const searchCountry = () => { ...@@ -131,11 +140,17 @@ const searchCountry = () => {
isSearchLoading.value = true isSearchLoading.value = true
if (searchValue.value.trim()) { if (searchValue.value.trim()) {
getSearchCountry(searchValue.value.trim()).then(res => { getSearchCountry(searchValue.value.trim()).then(res => {
// searchList.value = []
if (res.code === 200) { if (res.code === 200) {
res.data.countryList.forEach(d => { if (res.data.countryList && res.data.countryList.length > 0) {
d.areaCode = `+${d.areaCode}` res.data.countryList.forEach(d => {
}) d.areaCode = `+${d.areaCode}`
searchList.value = res.data.countryList })
searchList.value = res.data.countryList
} else {
searchList.value = []
}
isSearchLoading.value = false isSearchLoading.value = false
} }
}) })
...@@ -310,7 +325,7 @@ watch(countryDrawer, val => { ...@@ -310,7 +325,7 @@ watch(countryDrawer, val => {
margin-top: 10px; margin-top: 10px;
color: #909399; color: #909399;
} }
.empty-state { .countryEmpty {
text-align: center; text-align: center;
padding: 40px 0; padding: 40px 0;
color: #909399; color: #909399;
......
...@@ -234,6 +234,7 @@ watch( ...@@ -234,6 +234,7 @@ watch(
border: 1px solid #e5e6e8; border: 1px solid #e5e6e8;
border-radius: 3px; border-radius: 3px;
padding: 10px; padding: 10px;
cursor: pointer;
} }
} }
} }
......
...@@ -185,6 +185,7 @@ ...@@ -185,6 +185,7 @@
</div> </div>
</template> </template>
<script setup name="customer"> <script setup name="customer">
import { validateEnglish } from '@/utils/validate'
import { calculateExactAge } from '@/utils/date' import { calculateExactAge } from '@/utils/date'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { ArrowRight } from '@element-plus/icons-vue' import { ArrowRight } from '@element-plus/icons-vue'
...@@ -219,7 +220,7 @@ const tableLoading = ref(false) ...@@ -219,7 +220,7 @@ const tableLoading = ref(false)
const tableData = ref([]) const tableData = ref([])
const total = ref(0) const total = ref(0)
const customerRef = ref(null) const customerRef = ref(null)
// / 计算默认显示的日期(18年前的今天) //计算默认显示的日期(18年前的今天)
const defaultDisplayDate = ref(dayjs().subtract(18, 'year').toDate()) const defaultDisplayDate = ref(dayjs().subtract(18, 'year').toDate())
// 地址组件菜单数据 // 地址组件菜单数据
...@@ -371,17 +372,6 @@ const fetchDictData = dictType => { ...@@ -371,17 +372,6 @@ const fetchDictData = dictType => {
return [] return []
} }
} }
// 添加英文校验函数
const validateEnglish = (rule, value, callback) => {
if (value && !/^[A-Za-z]*$/.test(value)) {
// 清空非英文字符
form.value.firstNamePinyin = ''
callback(new Error('只能输入英文字母'))
} else {
callback()
}
}
// 处理表单配置,添加字典数据 // 处理表单配置,添加字典数据
const processFormData = async () => { const processFormData = async () => {
// 深拷贝原始数据 // 深拷贝原始数据
......
...@@ -612,6 +612,7 @@ const handleSubmit = type => { ...@@ -612,6 +612,7 @@ const handleSubmit = type => {
submitAppointmentObj.value.apiBeneficiaryInfoDtoList = submitAppointmentObj.value.apiBeneficiaryInfoDtoList =
beneficiaryInfoRef.value[0].handleFormValues() beneficiaryInfoRef.value[0].handleFormValues()
} }
// return
// 代表新增预约 // 代表新增预约
if (formStatus.value == 'appointmentAdd' && !idsObj.value.appointmentBizId) { if (formStatus.value == 'appointmentAdd' && !idsObj.value.appointmentBizId) {
submitAppointmentObj.value.apiAppointmentInfoDto.customerBizId = submitAppointmentObj.value.apiAppointmentInfoDto.customerBizId =
......
...@@ -339,6 +339,22 @@ const handleButtonClick = child => { ...@@ -339,6 +339,22 @@ const handleButtonClick = child => {
} }
const handleDateChange = child => { const handleDateChange = child => {
if (child.key === 'confirmAppointmentTime' && form.value[child.key]) { if (child.key === 'confirmAppointmentTime' && form.value[child.key]) {
if (form.value['arrivalTime']) {
const appointmentTimestamp = dayjs(form.value['confirmAppointmentTime']).valueOf()
const arrivalTimestamp = dayjs(form.value['arrivalTime']).valueOf()
if (appointmentTimestamp < arrivalTimestamp) {
proxy.$modal.msgError('预约时间早于到港时间,请重新选择预约时间')
form.value['confirmAppointmentTime'] = ''
return
} else if (appointmentTimestamp > arrivalTimestamp) {
// proxy.$modal.msgError('预约时间早于到港时间,请重新选择预约时间')
// form.value['confirmAppointmentTime'] = ''
} else {
proxy.$modal.msgError('预约时间应晚于到港时间,请重新选择预约时间')
form.value['confirmAppointmentTime'] = ''
return
}
}
resetShow({ type: 'child', key: 'newPolicyButton', status: true }) resetShow({ type: 'child', key: 'newPolicyButton', status: true })
} else if (child.key === 'confirmAppointmentTime' && !form.value[child.key]) { } else if (child.key === 'confirmAppointmentTime' && !form.value[child.key]) {
resetShow({ type: 'child', key: 'newPolicyButton', status: false }) resetShow({ type: 'child', key: 'newPolicyButton', status: false })
...@@ -356,8 +372,26 @@ const handleDateChange = child => { ...@@ -356,8 +372,26 @@ const handleDateChange = child => {
form.value['arrivalTime'] = '' form.value['arrivalTime'] = ''
} }
} }
} else if (child.key === 'confirmAppointmentTime') {
if (form.value['arrivalTime']) {
console.log('22222')
const appointmentTimestamp = dayjs(form.value['confirmAppointmentTime']).valueOf()
const arrivalTimestamp = dayjs(form.value['arrivalTime']).valueOf()
console.log('appointmentTimestamp', appointmentTimestamp)
console.log('arrivalTimestamp', arrivalTimestamp)
// if (appointmentTimestamp < arrivalTimestamp) {
// // proxy.$modal.msgError('预约时间早于到港时间,请重新选择预约时间')
// // form.value['confirmAppointmentTime'] = ''
// } else if (appointmentTimestamp > arrivalTimestamp) {
// proxy.$modal.msgError('预约时间早于到港时间,请重新选择预约时间')
// form.value['confirmAppointmentTime'] = ''
// } else {
// proxy.$modal.msgError('预约时间应晚于到港时间,请重新选择预约时间')
// form.value['confirmAppointmentTime'] = ''
// }
}
} }
} }
// 获取字典数据 // 获取字典数据
const fetchDictData = dictType => { const fetchDictData = dictType => {
......
...@@ -41,13 +41,7 @@ ...@@ -41,13 +41,7 @@
<template v-for="child in level2.data" :key="child.key"> <template v-for="child in level2.data" :key="child.key">
<el-col :sm="child.sm" :lg="child.lg" class="formItem" v-if="child.show"> <el-col :sm="child.sm" :lg="child.lg" class="formItem" v-if="child.show">
<div> <div>
<el-form-item <!-- :rules="
:label-width="child.labelWidth"
:label="child.label"
:prop="`apiBeneficiaryInfoDtoList.${l1}.${child.key}`"
:key="child.key"
:label-position="child.labelPosition"
:rules="
child.required child.required
? [ ? [
{ {
...@@ -57,8 +51,16 @@ ...@@ -57,8 +51,16 @@
} }
] ]
: [] : []
" " -->
<el-form-item
:label-width="child.labelWidth"
:label="child.label"
:prop="`apiBeneficiaryInfoDtoList.${l1}.${child.key}`"
:key="child.key"
:label-position="child.labelPosition"
:rules="getRules(child)"
> >
<!-- @input="handleInputChange(father, child, l1)" -->
<el-input <el-input
v-if="child.domType === 'Input'" v-if="child.domType === 'Input'"
:type="child.inputType" :type="child.inputType"
...@@ -200,6 +202,7 @@ ...@@ -200,6 +202,7 @@
</div> </div>
</template> </template>
<script setup name="beneficiaryInfo"> <script setup name="beneficiaryInfo">
import { validateEnglish } from '@/utils/validate'
import { ArrowRight } from '@element-plus/icons-vue' import { ArrowRight } from '@element-plus/icons-vue'
import beneficiaryDomData from '@/formJson/beneficiary' import beneficiaryDomData from '@/formJson/beneficiary'
import Country from '@/views/components/country' import Country from '@/views/components/country'
...@@ -327,6 +330,39 @@ const { ...@@ -327,6 +330,39 @@ const {
tempBeneficiaryForm, tempBeneficiaryForm,
tempBeneficiaryDomData tempBeneficiaryDomData
} = toRefs(data) } = toRefs(data)
// 获取表单项的校验规则
const getRules = child => {
const rules = []
// 必填校验
if (child.required) {
rules.push({
required: true,
message: `${child.label}不能为空`,
trigger: 'blur'
})
}
// 为英文姓名添加自定义校验
if (child.key === 'nameEn') {
rules.push({
validator: validateEnglish,
trigger: 'change'
})
}
return rules
}
// const handleInputChange = (father, child, index) => {
// switch (child.key) {
// case 'nameEn':
// validateEnglish(form.value['apiBeneficiaryInfoDtoList'][index][child.key], child.key)
// break
// default:
// break
// }
// }
// 新增受益人 // 新增受益人
const addBeneficiary = () => { const addBeneficiary = () => {
let oneMoudle = JSON.parse(JSON.stringify(processedBeneficiaryData.value[0])) let oneMoudle = JSON.parse(JSON.stringify(processedBeneficiaryData.value[0]))
...@@ -415,16 +451,16 @@ const fetchDictData = dictType => { ...@@ -415,16 +451,16 @@ const fetchDictData = dictType => {
return [] return []
} }
} }
// 添加英文校验函数 // // 添加英文校验函数
const validateEnglish = (rule, value, callback) => { // const validateEnglish = (rule, value, callback) => {
if (value && !/^[A-Za-z]*$/.test(value)) { // if (value && !/^[A-Za-z]*$/.test(value)) {
// 清空非英文字符 // // 清空非英文字符
form.value.firstNamePinyin = '' // form.value.firstNamePinyin = ''
callback(new Error('只能输入英文字母')) // callback(new Error('只能输入英文字母'))
} else { // } else {
callback() // callback()
} // }
} // }
// 处理表单配置,添加字典数据 // 处理表单配置,添加字典数据
/** /**
...@@ -457,12 +493,6 @@ const processFormData = async obj => { ...@@ -457,12 +493,6 @@ const processFormData = async obj => {
// 获取字典数据 // 获取字典数据
field.options = fetchDictData(field.dictType) field.options = fetchDictData(field.dictType)
} }
// if (props.idsObj.appointmentBizId) {
// field.disabled = true
// } else {
// field.disabled = false
// }
} }
} }
} }
...@@ -805,6 +835,13 @@ const setFormValue = () => { ...@@ -805,6 +835,13 @@ const setFormValue = () => {
} else { } else {
section.showMoudle = true section.showMoudle = true
} }
} else if (
(info.customerType == 'COMPANY' || info.customerType == 'INDIVIDUAL') &&
info.insurantRel &&
info.insurantRel == 'MYSELF' &&
section.key !== 'customer'
) {
section.showMoudle = false
} }
} }
} }
......
...@@ -34,13 +34,7 @@ ...@@ -34,13 +34,7 @@
<template v-for="child in father.data" :key="child.key"> <template v-for="child in father.data" :key="child.key">
<el-col :sm="child.sm" :lg="child.lg" class="formItem" v-if="child.show"> <el-col :sm="child.sm" :lg="child.lg" class="formItem" v-if="child.show">
<div> <div>
<el-form-item <!-- :rules="
:label-width="child.labelWidth"
:label="child.label"
:prop="child.key"
:key="child.key"
:label-position="child.labelPosition"
:rules="
child.required child.required
? [ ? [
{ {
...@@ -50,8 +44,16 @@ ...@@ -50,8 +44,16 @@
} }
] ]
: [] : []
" " -->
<el-form-item
:label-width="child.labelWidth"
:label="child.label"
:prop="child.key"
:key="child.key"
:label-position="child.labelPosition"
:rules="getRules(child)"
> >
<!-- @input="handleInputChange(father, child)" -->
<el-input <el-input
v-if="child.domType === 'Input'" v-if="child.domType === 'Input'"
:type="child.inputType" :type="child.inputType"
...@@ -79,9 +81,10 @@ ...@@ -79,9 +81,10 @@
style="width: 100%" style="width: 100%"
v-if="child.domType === 'DatePicker'" v-if="child.domType === 'DatePicker'"
type="date" type="date"
:disabled-date="disabledDate"
:placeholder="child.placeholder" :placeholder="child.placeholder"
:disabled="child.disabled" :disabled="child.disabled"
:disabled-date="time => disabledDate(time, child)"
@change="handleDateChange(child)"
/> />
<el-input <el-input
v-if="child.domType === 'arrowRight'" v-if="child.domType === 'arrowRight'"
...@@ -195,6 +198,9 @@ ...@@ -195,6 +198,9 @@
</div> </div>
</template> </template>
<script setup name="insuredInfo"> <script setup name="insuredInfo">
import { validateEnglish } from '@/utils/validate'
import { calculateExactAge } from '@/utils/date'
import dayjs from 'dayjs'
import { ArrowRight } from '@element-plus/icons-vue' import { ArrowRight } from '@element-plus/icons-vue'
import policyDomData from '@/formJson/insured' import policyDomData from '@/formJson/insured'
import Country from '@/views/components/country' import Country from '@/views/components/country'
...@@ -316,8 +322,58 @@ const data = reactive({ ...@@ -316,8 +322,58 @@ const data = reactive({
}) })
const { form, rules, processedinsuredData, queryParams, oldAppointmentData, tempPolicyForm } = const { form, rules, processedinsuredData, queryParams, oldAppointmentData, tempPolicyForm } =
toRefs(data) toRefs(data)
const disabledDate = time => { // 获取表单项的校验规则
const getRules = child => {
const rules = []
// 必填校验
if (child.required) {
rules.push({
required: true,
message: `${child.label}不能为空`,
trigger: 'blur'
})
}
// 为英文姓名添加自定义校验
if (child.key === 'nameEn') {
rules.push({
validator: validateEnglish,
trigger: 'change'
})
}
return rules
}
const handleInputChange = (father, child) => {
switch (child.key) {
case 'nameEn':
validateEnglish(form.value[child.key], child.key)
break
default:
break
}
}
const handleDateChange = child => {
let age = null
if (child.key == 'birthday') {
age = calculateExactAge(proxy.formatToDate(form.value.birthday))
if (age >= 0) {
form.value.age = age
}
}
}
const disabledDate = (time, child) => {
return time.getTime() > Date.now() return time.getTime() > Date.now()
// if (child.key == 'birthday') {
// // 计算18年前的今天
// const eighteenYearsAgo = dayjs().subtract(18, 'year')
// // 禁用今天之后的日期和18年前的今天之后的日期
// return time.getTime() > Date.now() || time.getTime() > eighteenYearsAgo.valueOf()
// } else {
// return time.getTime() > Date.now()
// }
} }
const exportInfo = () => { const exportInfo = () => {
if (props.customerBizId && editStatus.value) { if (props.customerBizId && editStatus.value) {
...@@ -373,16 +429,16 @@ const fetchDictData = dictType => { ...@@ -373,16 +429,16 @@ const fetchDictData = dictType => {
return [] return []
} }
} }
// 添加英文校验函数 // // 添加英文校验函数
const validateEnglish = (rule, value, callback) => { // const validateEnglish = (rule, value, callback) => {
if (value && !/^[A-Za-z]*$/.test(value)) { // if (value && !/^[A-Za-z]*$/.test(value)) {
// 清空非英文字符 // // 清空非英文字符
form.value.firstNamePinyin = '' // form.value.firstNamePinyin = ''
callback(new Error('只能输入英文字母')) // callback(new Error('只能输入英文字母'))
} else { // } else {
callback() // callback()
} // }
} // }
const mergeObjects = (obj1, obj2) => { const mergeObjects = (obj1, obj2) => {
const result = Object.assign({}, obj1) const result = Object.assign({}, obj1)
...@@ -563,7 +619,11 @@ const processFormData = async obj => { ...@@ -563,7 +619,11 @@ const processFormData = async obj => {
if (props.idsObj.appointmentBizId) { if (props.idsObj.appointmentBizId) {
field.disabled = true field.disabled = true
} else { } else {
field.disabled = false if (field.key == 'age') {
field.disabled = true
} else {
field.disabled = false
}
} }
} }
} }
...@@ -604,6 +664,14 @@ const processFormData = async obj => { ...@@ -604,6 +664,14 @@ const processFormData = async obj => {
} else { } else {
editStatus.value = false editStatus.value = false
} }
if (form.value['birthday']) {
let age = calculateExactAge(proxy.formatToDate(form.value.birthday))
if (age >= 0) {
form.value.age = age
}
} else {
form.value.age = null
}
processedinsuredData.value = oldAppointmentData.value = processedData processedinsuredData.value = oldAppointmentData.value = processedData
} }
...@@ -792,7 +860,11 @@ const handleEditStatus = status => { ...@@ -792,7 +860,11 @@ const handleEditStatus = status => {
if (editStatus.value) { if (editStatus.value) {
field.disabled = true field.disabled = true
} else { } else {
field.disabled = false if (field.key == 'age') {
field.disabled = true
} else {
field.disabled = false
}
} }
} }
} }
......
...@@ -34,13 +34,7 @@ ...@@ -34,13 +34,7 @@
<template v-for="child in father.data" :key="child.key"> <template v-for="child in father.data" :key="child.key">
<el-col :sm="child.sm" :lg="child.lg" class="formItem" v-if="child.show"> <el-col :sm="child.sm" :lg="child.lg" class="formItem" v-if="child.show">
<div> <div>
<el-form-item <!-- :rules="
:label-width="child.labelWidth"
:label="child.label"
:prop="child.key"
:key="child.key"
:label-position="child.labelPosition"
:rules="
child.required child.required
? [ ? [
{ {
...@@ -50,8 +44,16 @@ ...@@ -50,8 +44,16 @@
} }
] ]
: [] : []
" " -->
<el-form-item
:label-width="child.labelWidth"
:label="child.label"
:prop="child.key"
:key="child.key"
:label-position="child.labelPosition"
:rules="getRules(child)"
> >
<!-- @input="handleInputChange(father, child)" -->
<el-input <el-input
v-if="child.domType === 'Input'" v-if="child.domType === 'Input'"
:type="child.inputType" :type="child.inputType"
...@@ -74,14 +76,16 @@ ...@@ -74,14 +76,16 @@
:value="item.value" :value="item.value"
/> />
</el-select> </el-select>
<!-- :default-value="defaultDisplayDate" -->
<el-date-picker <el-date-picker
v-model="form[child.key]" v-model="form[child.key]"
style="width: 100%" style="width: 100%"
v-if="child.domType === 'DatePicker'" v-if="child.domType === 'DatePicker'"
type="date" type="date"
:disabled-date="disabledDate"
:placeholder="child.placeholder" :placeholder="child.placeholder"
:disabled="child.disabled" :disabled="child.disabled"
:disabled-date="time => disabledDate(time, child)"
@change="handleDateChange(child)"
/> />
<el-input <el-input
v-if="child.domType === 'arrowRight'" v-if="child.domType === 'arrowRight'"
...@@ -195,6 +199,9 @@ ...@@ -195,6 +199,9 @@
</div> </div>
</template> </template>
<script setup name="policyholderInfo"> <script setup name="policyholderInfo">
import { validateEnglish } from '@/utils/validate'
import { calculateExactAge } from '@/utils/date'
import dayjs from 'dayjs'
import { ArrowRight } from '@element-plus/icons-vue' import { ArrowRight } from '@element-plus/icons-vue'
import policyDomData from '@/formJson/applicant' import policyDomData from '@/formJson/applicant'
import Country from '@/views/components/country' import Country from '@/views/components/country'
...@@ -216,6 +223,9 @@ const props = defineProps({ ...@@ -216,6 +223,9 @@ const props = defineProps({
appointmentStatus: { type: Number }, //父组件传递过来的预约的状态 appointmentStatus: { type: Number }, //父组件传递过来的预约的状态
customerInfo: { type: Object, default: () => ({}) } //客户详情回显表单用 customerInfo: { type: Object, default: () => ({}) } //客户详情回显表单用
}) })
//计算默认显示的日期(18年前的今天)
const defaultDisplayDate = ref(dayjs().subtract(18, 'year').toDate())
const emit = defineEmits(['handleSuccessEdit']) const emit = defineEmits(['handleSuccessEdit'])
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
// const { csf_id_type, sys_gender } = proxy.useDict('csf_id_type', 'sys_gender') // const { csf_id_type, sys_gender } = proxy.useDict('csf_id_type', 'sys_gender')
...@@ -316,8 +326,59 @@ const data = reactive({ ...@@ -316,8 +326,59 @@ const data = reactive({
}) })
const { form, rules, processedPolicyData, queryParams, oldAppointmentData, tempPolicyForm } = const { form, rules, processedPolicyData, queryParams, oldAppointmentData, tempPolicyForm } =
toRefs(data) toRefs(data)
const disabledDate = time => {
// 获取表单项的校验规则
const getRules = child => {
const rules = []
// 必填校验
if (child.required) {
rules.push({
required: true,
message: `${child.label}不能为空`,
trigger: 'blur'
})
}
// 为英文姓名添加自定义校验
if (child.key === 'nameEn') {
rules.push({
validator: validateEnglish,
trigger: 'change'
})
}
return rules
}
const handleInputChange = (father, child) => {
switch (child.key) {
case 'nameEn':
validateEnglish(form.value[child.key], child.key)
break
default:
break
}
}
const handleDateChange = child => {
let age = null
if (child.key == 'birthday') {
age = calculateExactAge(proxy.formatToDate(form.value.birthday))
if (age >= 0) {
form.value.age = age
}
}
}
const disabledDate = (time, child) => {
return time.getTime() > Date.now() return time.getTime() > Date.now()
// if (child.key == 'birthday') {
// // 计算18年前的今天
// const eighteenYearsAgo = dayjs().subtract(18, 'year')
// // 禁用今天之后的日期和18年前的今天之后的日期
// return time.getTime() > Date.now() || time.getTime() > eighteenYearsAgo.valueOf()
// } else {
// return time.getTime() > Date.now()
// }
} }
const exportInfo = () => { const exportInfo = () => {
if (props.customerBizId && editStatus.value) { if (props.customerBizId && editStatus.value) {
...@@ -374,16 +435,16 @@ const fetchDictData = dictType => { ...@@ -374,16 +435,16 @@ const fetchDictData = dictType => {
return [] return []
} }
} }
// 添加英文校验函数 // // 添加英文校验函数
const validateEnglish = (rule, value, callback) => { // const validateEnglish = (rule, value, callback) => {
if (value && !/^[A-Za-z]*$/.test(value)) { // if (value && !/^[A-Za-z]*$/.test(value)) {
// 清空非英文字符 // // 清空非英文字符
form.value.firstNamePinyin = '' // form.value.firstNamePinyin = ''
callback(new Error('只能输入英文字母')) // callback(new Error('只能输入英文字母'))
} else { // } else {
callback() // callback()
} // }
} // }
const mergeObjects = (obj1, obj2) => { const mergeObjects = (obj1, obj2) => {
const result = Object.assign({}, obj1) const result = Object.assign({}, obj1)
...@@ -562,7 +623,11 @@ const processFormData = async obj => { ...@@ -562,7 +623,11 @@ const processFormData = async obj => {
if (props.idsObj.appointmentBizId) { if (props.idsObj.appointmentBizId) {
field.disabled = true field.disabled = true
} else { } else {
field.disabled = false if (field.key == 'age') {
field.disabled = true
} else {
field.disabled = false
}
} }
} }
} }
...@@ -605,6 +670,14 @@ const processFormData = async obj => { ...@@ -605,6 +670,14 @@ const processFormData = async obj => {
} else { } else {
editStatus.value = false editStatus.value = false
} }
if (form.value['birthday']) {
let age = calculateExactAge(proxy.formatToDate(form.value.birthday))
if (age >= 0) {
form.value.age = age
}
} else {
form.value.age = null
}
processedPolicyData.value = oldAppointmentData.value = processedData processedPolicyData.value = oldAppointmentData.value = processedData
} }
...@@ -789,7 +862,11 @@ const handleEditStatus = status => { ...@@ -789,7 +862,11 @@ const handleEditStatus = status => {
if (editStatus.value) { if (editStatus.value) {
field.disabled = true field.disabled = true
} else { } else {
field.disabled = false if (field.key == 'age') {
field.disabled = true
} else {
field.disabled = false
}
} }
} }
} }
......
...@@ -651,6 +651,15 @@ const handleFormValues = () => { ...@@ -651,6 +651,15 @@ const handleFormValues = () => {
submitObj[key1] = proxy.formatToDateTime(submitObj[key1]) submitObj[key1] = proxy.formatToDateTime(submitObj[key1])
} }
} }
// if (Object.keys(submitObj).length > 0) {
// if (submitForm['documentType'] && !submitForm['idNumber']) {
// proxy.$message.error('请输入证件号码')
// return
// } else if(submitForm['idNumber'] && !submitForm['documentType']){
// proxy.$message.error('请输入证件类型')
// return
// }
// }
return submitObj return submitObj
} }
// 表单提交 // 表单提交
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment