|
|
|
@ -8,6 +8,8 @@ import { reactive, computed, toRefs, ref, watch, inject } from 'vue' |
|
|
|
import { getRequest } from '@/api/DesignForm' |
|
|
|
import { useDesignFormStore } from '@/store/DesignForm/designForm' |
|
|
|
import validate from './validate' |
|
|
|
import validateText from './validateText' |
|
|
|
import validateInt from './validateInt' |
|
|
|
import { ValidateTextTypes } from '@/components/DesignForm/validateText' |
|
|
|
import { ElMessage } from 'element-plus' |
|
|
|
import { formatNumber } from '@/api/DesignForm/utils' |
|
|
|
@ -74,6 +76,7 @@ const store = useDesignFormStore() as any |
|
|
|
const controlData = computed(() => { |
|
|
|
// console.log("注册自定义事件----------------->",props.formInfo) |
|
|
|
// console.log("注册自定义事件--------1--------->",store.controlAttr) |
|
|
|
// console.log("注册自定义事件---------3-------->",controlData.value.customRules) |
|
|
|
return store.controlAttr |
|
|
|
}) |
|
|
|
//获取组件样式Demo |
|
|
|
@ -134,9 +137,28 @@ const state = reactive({ |
|
|
|
@ 时间: 2024-08-14 08:41:02 |
|
|
|
@ 功能: 必填 |
|
|
|
*/ |
|
|
|
const ValidateTextTypes = reactive({ |
|
|
|
|
|
|
|
const ValidateText = reactive<ValidateTextTypes>({ |
|
|
|
type: 'required', |
|
|
|
label: '必填', |
|
|
|
regExp: /^\s*$/, |
|
|
|
message: '必填项', |
|
|
|
checkbox: false |
|
|
|
}) |
|
|
|
/** |
|
|
|
@ 作者: 秦东 |
|
|
|
@ 时间: 2024-08-14 08:41:02 |
|
|
|
@ 功能: 单选校验 |
|
|
|
*/ |
|
|
|
const radioVerify = reactive<ValidateTextTypes>({}) |
|
|
|
|
|
|
|
|
|
|
|
const textUinrVerfy = reactive([ |
|
|
|
...validateText |
|
|
|
]) |
|
|
|
const numberUinrVerfy = reactive([ |
|
|
|
...validateInt |
|
|
|
]) |
|
|
|
|
|
|
|
|
|
|
|
const formAttr = computed(() => { |
|
|
|
const isSearch = state.isSearch |
|
|
|
@ -237,6 +259,33 @@ const attrList = computed(() => { |
|
|
|
columnIndex = list[0].type === 'index' |
|
|
|
} |
|
|
|
} |
|
|
|
//判断校验规则 |
|
|
|
// console.log("判断校验规则--->",typeof(controlData.value.customRules)) |
|
|
|
if(typeof(controlData.value.customRules)=="object"){ |
|
|
|
if(Array.isArray(controlData.value.customRules)){ |
|
|
|
let otherPick = [] |
|
|
|
controlData.value.customRules.forEach((item:any)=>{ |
|
|
|
// console.log("判断校验规则-1-->",item) |
|
|
|
if(item.type == ValidateText.type){ |
|
|
|
ValidateText.checkbox = true |
|
|
|
}else{ |
|
|
|
otherPick.push(item) |
|
|
|
} |
|
|
|
}) |
|
|
|
if(otherPick.length > 0){ |
|
|
|
otherPick.forEach((item:any)=>{ |
|
|
|
radioVerify.type = item.type |
|
|
|
radioVerify.label = item.label |
|
|
|
radioVerify.regExp = item.regExp |
|
|
|
radioVerify.message = item.message |
|
|
|
radioVerify.checkbox = true |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
ValidateText.checkbox = false |
|
|
|
radioVerify.type = "" |
|
|
|
} |
|
|
|
|
|
|
|
const temp =reactive<PublicAtrr[]>([ |
|
|
|
{ |
|
|
|
@ -816,8 +865,6 @@ const attrList = computed(() => { |
|
|
|
vIf: state.isSearch, |
|
|
|
vShow: ['videoUpAndPlay'] |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
label: '上传地址', |
|
|
|
value: control.action, |
|
|
|
@ -991,6 +1038,8 @@ const attrList = computed(() => { |
|
|
|
]) |
|
|
|
// 过滤显示对应的值 |
|
|
|
return temp.filter((item: any) => { |
|
|
|
// console.log("过滤显示对应的值--->",item) |
|
|
|
// console.log("过滤显示对应的值-1-->",type) |
|
|
|
let hasFilter = true |
|
|
|
if (item.vShow) { |
|
|
|
hasFilter = item.vShow.includes(type) |
|
|
|
@ -2421,6 +2470,7 @@ function handleDetermineFillRoles(){ |
|
|
|
|
|
|
|
|
|
|
|
watch(()=>store.activeKey, () => { |
|
|
|
// console.log("activeKey",store.activeKey); |
|
|
|
if(controlData.value.type==='associatedForms'){ |
|
|
|
setTimeout(() => { |
|
|
|
formidChanged() |
|
|
|
@ -2502,6 +2552,7 @@ function handleDetermineGlxxszDialogCheckBox(){ |
|
|
|
} |
|
|
|
//同步开关的设置值和开关关联选项设置的值 |
|
|
|
watch(()=>controlData.value.control,(newVal) => { |
|
|
|
// console.log("同步开关的设置值和开关关联选项设置的值",typeof(newVal)) |
|
|
|
if(typeof(newVal)!="undefined"){ |
|
|
|
if(typeof(newVal.glxxszSwitch)!="undefined"){ |
|
|
|
if(typeof(controlData.value.control.activeValue)!="undefined"){ |
|
|
|
@ -2514,6 +2565,7 @@ watch(()=>controlData.value.control,(newVal) => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// console.log("同步开关的设置值和开关关联选项设置的值",controlData.value.control) |
|
|
|
},{ deep: true }) |
|
|
|
|
|
|
|
|
|
|
|
@ -2745,6 +2797,152 @@ const disabledIstrue = (val:string) => { |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// watch(()=>controlData.value.customRules,(val:any) => { |
|
|
|
// // console.log("啊啊啊啊啊",val,typeof(val)); |
|
|
|
// if(typeof(val)=="object"){ |
|
|
|
// if(Array.isArray(val)){ |
|
|
|
// val.forEach((item:any)=>{ |
|
|
|
|
|
|
|
// }) |
|
|
|
// } |
|
|
|
// } |
|
|
|
// },{ |
|
|
|
// deep: true |
|
|
|
// }) |
|
|
|
/** |
|
|
|
@ 作者: 秦东 |
|
|
|
@ 时间: 2024-08-14 13:16:26 |
|
|
|
@ 功能: 必填文本框改变 |
|
|
|
*/ |
|
|
|
const requiredText = (val:any) => { |
|
|
|
|
|
|
|
if(typeof(controlData.value.customRules)=="object"){ |
|
|
|
if(Array.isArray(controlData.value.customRules)){ |
|
|
|
controlData.value.customRules.forEach((item:any)=>{ |
|
|
|
if(item.type == ValidateText.type){ |
|
|
|
item.message = val |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
console.log("判断校验规则-1-->",controlData.value.customRules) |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ 作者: 秦东 |
|
|
|
@ 时间: 2024-08-14 14:35:07 |
|
|
|
@ 功能: 校验文本框改变 |
|
|
|
*/ |
|
|
|
const requiredTextRadio = (val:any) => { |
|
|
|
console.log("校验文本框改变-->",val) |
|
|
|
if(val.type == radioVerify.type){ |
|
|
|
if(typeof(controlData.value.customRules)=="object"){ |
|
|
|
if(Array.isArray(controlData.value.customRules)){ |
|
|
|
controlData.value.customRules.forEach((item:any)=>{ |
|
|
|
if(item.type == radioVerify.type){ |
|
|
|
item.message = val.message |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ 作者: 秦东 |
|
|
|
@ 时间: 2024-08-14 13:21:43 |
|
|
|
@ 功能: 是否选中必填 |
|
|
|
*/ |
|
|
|
const requiredChangeSet = (val:boolean) => { |
|
|
|
if (!controlData.value?.customRules) { |
|
|
|
controlData.value.customRules = [] |
|
|
|
} |
|
|
|
if(val){ |
|
|
|
if(Array.isArray(controlData.value.customRules) && controlData.value.customRules.length > 0){ |
|
|
|
let isNewWrite = true |
|
|
|
controlData.value.customRules.forEach((item:any)=>{ |
|
|
|
if(item.type == ValidateText.type){ |
|
|
|
isNewWrite = false |
|
|
|
} |
|
|
|
}) |
|
|
|
if(isNewWrite){ |
|
|
|
controlData.value.customRules.push({ |
|
|
|
type: ValidateText.type, |
|
|
|
message: ValidateText.message, |
|
|
|
trigger: "blur" |
|
|
|
}) |
|
|
|
} |
|
|
|
}else{ |
|
|
|
controlData.value.customRules.push({ |
|
|
|
type: ValidateText.type, |
|
|
|
message: ValidateText.message, |
|
|
|
trigger: "blur" |
|
|
|
}) |
|
|
|
} |
|
|
|
}else{ |
|
|
|
if(Array.isArray(controlData.value.customRules) && controlData.value.customRules.length > 0){ |
|
|
|
controlData.value.customRules.forEach((item:any,index:number)=>{ |
|
|
|
|
|
|
|
if(item.type == ValidateText.type){ |
|
|
|
controlData.value.customRules.splice(index, 1) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
// controlData.value.item.rules.splice(0, 1) |
|
|
|
} |
|
|
|
// console.log("判断校验规则-222-->",controlData.value.customRules) |
|
|
|
} |
|
|
|
/** |
|
|
|
@ 作者: 秦东 |
|
|
|
@ 时间: 2024-08-14 14:14:42 |
|
|
|
@ 功能: 单选改变事件 |
|
|
|
*/ |
|
|
|
const radioChangeSet = (val:any) => { |
|
|
|
console.log("单选改变事件-222-->",val) |
|
|
|
let pickRadio = {} |
|
|
|
let isTrue = true |
|
|
|
textUinrVerfy.forEach((item:any) => { |
|
|
|
if(item.type == val){ |
|
|
|
pickRadio = item |
|
|
|
isTrue = false |
|
|
|
} |
|
|
|
}) |
|
|
|
if(isTrue){ |
|
|
|
numberUinrVerfy.forEach((item:any) => { |
|
|
|
if(item.type == val){ |
|
|
|
pickRadio = item |
|
|
|
isTrue = false |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
// console.log("单选改变事件-3333-->",pickRadio) |
|
|
|
if (!controlData.value?.customRules) { |
|
|
|
controlData.value.customRules = [] |
|
|
|
} |
|
|
|
if(Array.isArray(controlData.value.customRules) && controlData.value.customRules.length > 0){ |
|
|
|
let isNewWrite = true |
|
|
|
controlData.value.customRules.forEach((item:any,index:number)=>{ |
|
|
|
if(item.type == ValidateText.type){ |
|
|
|
isNewWrite = false |
|
|
|
}else{ |
|
|
|
controlData.value.customRules.splice(index, 1) |
|
|
|
} |
|
|
|
}) |
|
|
|
controlData.value.customRules.push({ |
|
|
|
type: pickRadio.type, |
|
|
|
message: pickRadio.message, |
|
|
|
trigger: "blur" |
|
|
|
}) |
|
|
|
}else{ |
|
|
|
controlData.value.customRules.push({ |
|
|
|
type: pickRadio.type, |
|
|
|
message: pickRadio.message, |
|
|
|
trigger: "blur" |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
<template> |
|
|
|
<div class="sidebar-tools"> |
|
|
|
@ -2753,6 +2951,7 @@ const disabledIstrue = (val:string) => { |
|
|
|
<el-form size="small" class="form"> |
|
|
|
<!-- <div class=""><h3>通用属性</h3></div> --> |
|
|
|
<el-divider content-position="left">通用属性</el-divider> |
|
|
|
|
|
|
|
<template v-for="(item, index) in attrList" :key="index"> |
|
|
|
|
|
|
|
|
|
|
|
@ -3390,21 +3589,44 @@ const disabledIstrue = (val:string) => { |
|
|
|
|
|
|
|
<!-- <div class="h3"><h3>校验设置</h3></div> --> |
|
|
|
<el-divider content-position="left">校验设置</el-divider> |
|
|
|
<div v-if="showHide(['input', 'password', 'component'], true)"> |
|
|
|
{{controlData.customRules}} |
|
|
|
<div v-if="showHide(['input', 'password', 'component','digitpage'], true)" class="jiaoYan"> |
|
|
|
|
|
|
|
<el-form-item class="form_cont"> |
|
|
|
<el-input v-model="message" placeholder="校验提示信息"> |
|
|
|
<el-input v-model="ValidateText.message" @input="requiredText" :placeholder="ValidateText.message"> |
|
|
|
<template #prepend> |
|
|
|
必填 |
|
|
|
</template> |
|
|
|
<template #append> |
|
|
|
<el-checkbox v-model="checked1" /> |
|
|
|
<el-checkbox v-model="ValidateText.checkbox" @change="requiredChangeSet" /> |
|
|
|
</template> |
|
|
|
</el-input> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item v-if="showHide(['input', 'password', 'component'], true)" class="form_cont"> |
|
|
|
<el-radio-group v-model="radioVerify.type" @change="radioChangeSet"> |
|
|
|
<el-input v-for="item in textUinrVerfy" v-model="item.message" @input="requiredTextRadio(item)" :placeholder="item.message" class="radioInput"> |
|
|
|
<template #prepend> |
|
|
|
{{item.label}} |
|
|
|
</template> |
|
|
|
<template #append> |
|
|
|
<el-radio :value="item.type" /> |
|
|
|
</template> |
|
|
|
</el-input> |
|
|
|
</el-radio-group> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item v-else class="form_cont"> |
|
|
|
<el-radio-group v-model="radioVerify.type" @change="radioChangeSet"> |
|
|
|
<el-input v-for="item in numberUinrVerfy" v-model="item.message" @input="requiredTextRadio(item)" :placeholder="item.message" class="radioInput"> |
|
|
|
<template #prepend> |
|
|
|
{{item.label}} |
|
|
|
</template> |
|
|
|
<template #append> |
|
|
|
<el-radio :value="item.type" /> |
|
|
|
</template> |
|
|
|
</el-input> |
|
|
|
</el-radio-group> |
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
|
|
|
|
<el-form-item |
|
|
|
<!-- <el-form-item |
|
|
|
v-for="(item, index) in controlData.customRules" |
|
|
|
:key="item.type" |
|
|
|
class="form_cont" |
|
|
|
@ -3457,7 +3679,7 @@ const disabledIstrue = (val:string) => { |
|
|
|
</el-icon> |
|
|
|
</el-tooltip> |
|
|
|
</el-button> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> --> |
|
|
|
</div> |
|
|
|
<el-form-item class="form_cont" v-else> |
|
|
|
|
|
|
|
@ -4303,6 +4525,9 @@ li::before { |
|
|
|
|
|
|
|
.form_cont{ |
|
|
|
padding: 0 10px; |
|
|
|
.radioInput{ |
|
|
|
margin-bottom: 10px; |
|
|
|
} |
|
|
|
} |
|
|
|
.avatar-uploader{ |
|
|
|
width: 100px; |
|
|
|
@ -4336,4 +4561,9 @@ li::before { |
|
|
|
.el-main{ |
|
|
|
--el-main-padding: 5px |
|
|
|
} |
|
|
|
.jiaoYan{ |
|
|
|
.el-input-group__append, .el-input-group__prepend{ |
|
|
|
padding: 0 5px; |
|
|
|
} |
|
|
|
} |
|
|
|
</style> |
|
|
|
|