|
|
@ -115,7 +115,7 @@ const setWindowEvent = (bool?: boolean) => { |
|
|
} |
|
|
} |
|
|
watch( |
|
|
watch( |
|
|
() => props.formData, |
|
|
() => props.formData, |
|
|
() => { |
|
|
() => { |
|
|
emits('update:issave', false) |
|
|
emits('update:issave', false) |
|
|
}, |
|
|
}, |
|
|
{ deep: true } |
|
|
{ deep: true } |
|
|
@ -239,16 +239,170 @@ provide(constControlChange, ({ key, value, data, tProp, type, attribute }: any) |
|
|
} |
|
|
} |
|
|
// }) |
|
|
// }) |
|
|
|
|
|
|
|
|
|
|
|
//liwenxuan 关联选项设置效果实现 start |
|
|
|
|
|
console.log("监听表单-1-constControlChange-->",props.formData) |
|
|
|
|
|
console.log("监听表单-2-constControlChange-->",key) |
|
|
|
|
|
console.log("监听表单-3-constControlChange-->", value) |
|
|
|
|
|
console.log("监听表单-4-constControlChange-->",data) |
|
|
|
|
|
console.log("监听表单-5-constControlChange-->",type) |
|
|
|
|
|
console.log("监听表单-6-constControlChange-->",attribute) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//得到当前表单各选项的值 |
|
|
|
|
|
//props.formData.config.hideField.push("nin2yuan4yi4wei4wo3menda3fen1ma101939") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log("监听表单-1-constControlChange-->",props.formData) |
|
|
|
|
|
// console.log("监听表单-2-constControlChange-->",key) |
|
|
|
|
|
// console.log("监听表单-3-constControlChange-->", value) |
|
|
|
|
|
// console.log("监听表单-4-constControlChange-->",data) |
|
|
|
|
|
// console.log("监听表单-5-constControlChange-->",type) |
|
|
|
|
|
// console.log("监听表单-6-constControlChange-->",attribute) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log("监听表单--constControlChange-->",key, value, data, tProp,type,attribute)//liwenxuan |
|
|
//得到所有配置对象,包括radio,checkbox,select |
|
|
|
|
|
const radioSelectShowConfigArr = [] |
|
|
|
|
|
const checkboxShowConfigArr = [] |
|
|
|
|
|
//以showFields的处理过冒号的每个元素为key,其对应的optionValue为value,新建一个数组radioselectArr2。----用于获取所有出现在配置中的字段。 |
|
|
|
|
|
const radioSelectArr2:any[] = [] |
|
|
|
|
|
for(let i = 0;i<props.formData.list.length;i++){ |
|
|
|
|
|
if(props.formData.list[i].type=="radio"||props.formData.list[i].type=="select"||props.formData.list[i].type=="checkbox"){ |
|
|
|
|
|
props.formData.config.hideField = []; |
|
|
|
|
|
} |
|
|
|
|
|
//console.log(props.formData.list[i].type) |
|
|
|
|
|
if(props.formData.list[i].type=="radio"||props.formData.list[i].type=="select"){ |
|
|
|
|
|
radioSelectShowConfigArr.push(props.formData.list[i].control.glxxsz) |
|
|
|
|
|
|
|
|
|
|
|
}else if(props.formData.list[i].type=="checkbox"){ |
|
|
|
|
|
|
|
|
|
|
|
checkboxShowConfigArr.push(props.formData.list[i].control.glxxszForCheckBox) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//数组深拷贝 |
|
|
|
|
|
const radioSelectShowConfigArr2 = JSON.parse(JSON.stringify(radioSelectShowConfigArr)); |
|
|
|
|
|
const checkboxShowConfigArr2 = JSON.parse(JSON.stringify(checkboxShowConfigArr)); |
|
|
|
|
|
console.log(radioSelectShowConfigArr2) |
|
|
|
|
|
console.log(checkboxShowConfigArr2) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(radioSelectShowConfigArr2.length>0){ |
|
|
|
|
|
for(let i = 0;i<radioSelectShowConfigArr2.length;i++){ |
|
|
|
|
|
if( radioSelectShowConfigArr2[i].length>0){ |
|
|
|
|
|
for(let j = 0;j<radioSelectShowConfigArr2[i].length;j++){ |
|
|
|
|
|
//数组深拷贝 |
|
|
|
|
|
const jArr = JSON.parse(JSON.stringify(radioSelectShowConfigArr2[i][j])); |
|
|
|
|
|
const optionValueJArr = jArr.optionValue |
|
|
|
|
|
if(jArr.showFields!=undefined&&jArr.showFields.length>0){ |
|
|
|
|
|
for(let n = 0;n<jArr.showFields.length;n++){ |
|
|
|
|
|
let fieldKeyArr = jArr.showFields[n].split(":") |
|
|
|
|
|
let fieldKeyStr = fieldKeyArr[fieldKeyArr.length-1] |
|
|
|
|
|
radioSelectArr2.push({ |
|
|
|
|
|
//conditionFieldKey:jArr.conditionField, |
|
|
|
|
|
//conditionFieldValue:optionValueJArr, |
|
|
|
|
|
toShowFieldKey:fieldKeyStr, |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//以showFields的处理过冒号的每个元素为key,其对应的optionValue为value,新建一个数组radioselectArr3 ---用于组装完整显示隐藏条件、 |
|
|
|
|
|
const radioSelectArr3:any[] = [] |
|
|
|
|
|
if(radioSelectShowConfigArr2.length>0){ |
|
|
|
|
|
for(let i = 0;i<radioSelectShowConfigArr2.length;i++){ |
|
|
|
|
|
if( radioSelectShowConfigArr2[i].length>0){ |
|
|
|
|
|
for(let j = 0;j<radioSelectShowConfigArr2[i].length;j++){ |
|
|
|
|
|
//数组深拷贝 |
|
|
|
|
|
const jArr = JSON.parse(JSON.stringify(radioSelectShowConfigArr2[i][j])); |
|
|
|
|
|
const optionValueJArr = jArr.optionValue |
|
|
|
|
|
if(jArr.showFields!=undefined&&jArr.showFields.length>0){ |
|
|
|
|
|
if(jArr.showFields.length>1){ |
|
|
|
|
|
let arr1 = [] |
|
|
|
|
|
for(let n = 0;n<jArr.showFields.length;n++){ |
|
|
|
|
|
let fieldKeyArr = jArr.showFields[n].split(":") |
|
|
|
|
|
let fieldKeyStr = fieldKeyArr[fieldKeyArr.length-1] |
|
|
|
|
|
arr1.push(fieldKeyStr) |
|
|
|
|
|
} |
|
|
|
|
|
radioSelectArr3.push({ |
|
|
|
|
|
conditionFieldKey:jArr.conditionField, |
|
|
|
|
|
conditionFieldValue:optionValueJArr, |
|
|
|
|
|
toShowFieldKey:arr1, |
|
|
|
|
|
}) |
|
|
|
|
|
}else{//等于1 |
|
|
|
|
|
for(let n = 0;n<jArr.showFields.length;n++){ |
|
|
|
|
|
let fieldKeyArr = jArr.showFields[n].split(":") |
|
|
|
|
|
let fieldKeyStr = fieldKeyArr[fieldKeyArr.length-1] |
|
|
|
|
|
radioSelectArr3.push({ |
|
|
|
|
|
conditionFieldKey:jArr.conditionField, |
|
|
|
|
|
conditionFieldValue:optionValueJArr, |
|
|
|
|
|
toShowFieldKey:[fieldKeyStr], |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//暂时使用的隐藏数组,数据敲定后赋给props.formData.config.hideField |
|
|
|
|
|
let hideFieldArr: any[] = []; |
|
|
|
|
|
//但凡配置条件的字段先放入隐藏数组中 |
|
|
|
|
|
for(let i = 0;i< radioSelectArr2.length;i++){ |
|
|
|
|
|
hideFieldArr.push(radioSelectArr2[i].toShowFieldKey) |
|
|
|
|
|
} |
|
|
|
|
|
hideFieldArr = Array.from(new Set(hideFieldArr)) |
|
|
|
|
|
|
|
|
|
|
|
nextTick(() => { |
|
|
|
|
|
console.log(radioSelectArr3) |
|
|
|
|
|
console.log(model.value) |
|
|
|
|
|
let modelKeyArr = []; |
|
|
|
|
|
for(let i= 0;i<props.formData.list.length;i++){ |
|
|
|
|
|
modelKeyArr.push(props.formData.list[i].name+"") |
|
|
|
|
|
} |
|
|
|
|
|
console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"+modelKeyArr) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//根据条件的生效情况从隐藏数组中过滤字段 |
|
|
|
|
|
for(let i = 0;i< radioSelectArr3.length;i++){ |
|
|
|
|
|
for(let j = 0; j< modelKeyArr.length;j++){ |
|
|
|
|
|
|
|
|
|
|
|
if(modelKeyArr[j]==radioSelectArr3[i].conditionFieldKey){ |
|
|
|
|
|
//console.log("当前:字段标识modelKeyArr[j]========="+modelKeyArr[j]+"字段标识modelKeyArr[j]的值===="+model.value[modelKeyArr[j]]) |
|
|
|
|
|
//console.log("规则:字段标识radioSelectArr3[i].conditionFieldKey========="+radioSelectArr3[i].conditionFieldKey+"conditionFieldValue的值======"+radioSelectArr3[i].conditionFieldValue) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//作为条件的字段的设定条件值等于其当前的值 |
|
|
|
|
|
if(radioSelectArr3[i].conditionFieldValue == model.value[modelKeyArr[j]]){ |
|
|
|
|
|
console.log("当前的值==="+model.value[modelKeyArr[j]]) |
|
|
|
|
|
console.log("modelKeyArr[j]==="+modelKeyArr[j]) |
|
|
|
|
|
console.log("作为条件的字段的设定条件值radioSelectArr3[i]==="+radioSelectArr3[i].conditionFieldValue) |
|
|
|
|
|
console.log(radioSelectArr3[i].toShowFieldKey) |
|
|
|
|
|
//hideFieldArr = hideFieldArr.filter( item => radioSelectArr3[i].toShowFieldKey.find((bItem: any) => item != bItem)) |
|
|
|
|
|
for(let n = 0; n < hideFieldArr.length; n++){ |
|
|
|
|
|
for(let m = 0; m < radioSelectArr3[i].toShowFieldKey.length; m++){ |
|
|
|
|
|
if(hideFieldArr[n] == radioSelectArr3[i].toShowFieldKey[m]){ |
|
|
|
|
|
hideFieldArr.splice(n,1); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
console.log(hideFieldArr) |
|
|
|
|
|
props.formData.config.hideField?.push(...hideFieldArr) |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//props.formData.config?.hideField?.push("nin2yuan4yi4wei4wo3menda3fen1ma101939") |
|
|
|
|
|
//console.log("监听表单--constControlChange-->",key, value, data, tProp,type,attribute)//liwenxuan |
|
|
|
|
|
|
|
|
if (typeof props.changeKeyVal === 'function') { |
|
|
if (typeof props.changeKeyVal === 'function') { |
|
|
props.changeKeyVal(key, value,type,attribute) |
|
|
props.changeKeyVal(key, value,type,attribute) |
|
|
@ -274,7 +428,10 @@ provide(constControlChange, ({ key, value, data, tProp, type, attribute }: any) |
|
|
emits('change', { key, value, model: model.value, data, tProp }) |
|
|
emits('change', { key, value, model: model.value, data, tProp }) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
|
}) |
|
|
}) |
|
|
const dictForm = computed(() => { |
|
|
const dictForm = computed(() => { |
|
|
const storage = window.localStorage.getItem('akFormDict') |
|
|
const storage = window.localStorage.getItem('akFormDict') |
|
|
@ -295,6 +452,7 @@ const formProps = computed(() => { |
|
|
dict: dictForm.value |
|
|
dict: dictForm.value |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
provide(constFormProps, formProps) |
|
|
provide(constFormProps, formProps) |
|
|
|
|
|
|
|
|
// 提供一个方法,用于根据name从formData.list里查找数据 |
|
|
// 提供一个方法,用于根据name从formData.list里查找数据 |
|
|
@ -709,6 +867,11 @@ watch( |
|
|
} |
|
|
} |
|
|
) |
|
|
) |
|
|
// ------------------------数据处理结束------------------------ |
|
|
// ------------------------数据处理结束------------------------ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 重置表单方法 |
|
|
// 重置表单方法 |
|
|
const resetFields = () => { |
|
|
const resetFields = () => { |
|
|
ruleForm.value.resetFields() |
|
|
ruleForm.value.resetFields() |
|
|
|