|
|
|
@ -170,6 +170,128 @@ const forEachGetFormModel = (list: FormList[], obj: any) => { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
interface hideFieldConditionArritem { |
|
|
|
toShow:string |
|
|
|
conditions: any[] |
|
|
|
} |
|
|
|
|
|
|
|
const recursionToGetFinallyHideFields = (hideFieldArr: any[],radioSelectArr3: string | any[],modelKeyArr: string | any[],defaultHideFields: any[],nowShowingDefaultHideFieldArr: any[],nowShowingFieldArr: string[]) => { |
|
|
|
|
|
|
|
//以被默认隐藏的每个字段为key,显示该字段的所有条件的数组作为value,来作为该数组的每一项。 |
|
|
|
const hideFieldConditionArr:hideFieldConditionArritem[] = [] |
|
|
|
|
|
|
|
|
|
|
|
for(let i = 0;i < hideFieldArr.length;i++){ |
|
|
|
hideFieldConditionArr.push({ |
|
|
|
toShow:hideFieldArr[i], |
|
|
|
conditions:[], |
|
|
|
}) |
|
|
|
} |
|
|
|
console.log(hideFieldConditionArr) |
|
|
|
|
|
|
|
//遍历所有配置条件数组radioSelectArr3,当radioSelectArr3 [ i ] . toshowFieldKey 【i】==hideFieldArr【i】时 |
|
|
|
for(let i = 0;i < radioSelectArr3.length;i++){ |
|
|
|
for(let j = 0;j < radioSelectArr3[i].toShowFieldKey.length;j++){ |
|
|
|
for(let n = 0;n < hideFieldConditionArr.length;n++){ |
|
|
|
/* console.log(i) |
|
|
|
console.log(j) |
|
|
|
console.log(n) */ |
|
|
|
if(radioSelectArr3[i].toShowFieldKey[j]==hideFieldConditionArr[n].toShow){ |
|
|
|
hideFieldConditionArr[n].conditions.push({ |
|
|
|
conditionFrom:"radioOrSelect",//本条件来自于单选或者下拉 |
|
|
|
condition:[{//条件详细信息//当表单字段conditionField的值为conditionFieldValue时,显示hideFieldConditionArr[n] |
|
|
|
conditionField:radioSelectArr3[i].conditionFieldKey, |
|
|
|
conditionFieldValue:radioSelectArr3[i].conditionFieldValue// |
|
|
|
}] |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
console.log(hideFieldConditionArr); |
|
|
|
//要显示的和其满足显示条件的个数. |
|
|
|
//let showfieldsCountX = []; |
|
|
|
for(let i = 0;i<hideFieldConditionArr.length;i++){ |
|
|
|
let x = 0//满足显示条件的次数 |
|
|
|
|
|
|
|
let toshow = hideFieldConditionArr[i].toShow |
|
|
|
let conditions = hideFieldConditionArr[i].conditions |
|
|
|
//console.log(conditions) |
|
|
|
for(let j = 0;j<conditions.length;j++){ |
|
|
|
if(conditions[j].conditionFrom == "radioOrSelect"){//本条件来自于单选或者下拉,其只有一项 |
|
|
|
let conditionField = conditions[j].condition[0].conditionField |
|
|
|
let conditionFieldValue = conditions[j].condition[0].conditionFieldValue |
|
|
|
console.log(conditionField) |
|
|
|
console.log(conditionFieldValue) |
|
|
|
for(let n = 0; n< modelKeyArr.length;n++){ |
|
|
|
if(modelKeyArr[n]==conditionField){ |
|
|
|
let count_1 = 0; |
|
|
|
let trueValue = model.value[modelKeyArr[n]] |
|
|
|
//console.log(modelKeyArr[n]) |
|
|
|
//console.log(trueValue) |
|
|
|
if(trueValue==conditionFieldValue){ |
|
|
|
//此时满足了条件,但是必须看一下conditionField有没有被隐藏.如果被隐藏了,则x不能增加. |
|
|
|
|
|
|
|
let flag = false//其依赖的选项的父字段是否被隐藏.默认没被隐藏, |
|
|
|
//如果此时的conditionField有可能被隐藏且已被隐藏,x不能++ |
|
|
|
for(let a = 0;a<hideFieldConditionArr.length;a++){ |
|
|
|
if(hideFieldConditionArr[a].toShow==conditionField){//当conditions.length>1说明时多选,=1说明是单选. |
|
|
|
for(let b = 0;b<hideFieldConditionArr[a].conditions.length;b++){ |
|
|
|
for(let c = 0;c<hideFieldConditionArr[a].conditions[b].condition.length;c++){ |
|
|
|
if(hideFieldConditionArr[a].conditions[b].condition[c]==conditionField){ |
|
|
|
//暂时写到这里,先去组装多选条件数组. |
|
|
|
console.log(1) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(flag==false){ |
|
|
|
x++ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}else{//本条件来自于多选,其可能有多项 |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(x>0){ |
|
|
|
|
|
|
|
hideFieldArr = hideFieldArr.filter((item: string) => item!=toshow) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//将隐藏的字段值重置 |
|
|
|
for(let i = 0; i< hideFieldArr.length;i++){ |
|
|
|
//console.log(i+"dsfafdasdfasfsda===="+hideFieldArr[i]+"=====jiuopfdsahokjuhuiofadshuiofadsjbknfdjisahuifhjken wij================"+model.value[hideFieldArr[i]]) |
|
|
|
if(typeof model.value[hideFieldArr[i]] === "string" || typeof model.value[hideFieldArr[i]] === "number"){ |
|
|
|
model.value[hideFieldArr[i]] = "" |
|
|
|
}else if( model.value[hideFieldArr[i]] instanceof Array){ |
|
|
|
model.value[hideFieldArr[i]] = [] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//默认隐藏的字段中目前被显示出来的 |
|
|
|
nowShowingDefaultHideFieldArr = defaultHideFields.filter(a => !hideFieldArr.includes(a)) |
|
|
|
console.log("(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))") |
|
|
|
console.log(nowShowingDefaultHideFieldArr) |
|
|
|
/* for(let i = 0;i< nowShowingDefaultHideFieldArr.length; i++){ |
|
|
|
//当被显示出来的字段涉及到的conditionfield已经被隐藏了时,其x应-1,如果x-1后造成该field被隐藏,应递归重新敲定hideFieldArr |
|
|
|
if() |
|
|
|
} */ |
|
|
|
|
|
|
|
return hideFieldArr |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 表单组件值改变事件 tProp为子表格相关 |
|
|
|
provide(constControlChange, ({ key, value, data, tProp, type, attribute }: any) => { |
|
|
|
|
|
|
|
@ -309,6 +431,7 @@ provide(constControlChange, ({ key, value, data, tProp, type, attribute }: any) |
|
|
|
|
|
|
|
//以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){ |
|
|
|
@ -346,6 +469,7 @@ provide(constControlChange, ({ key, value, data, tProp, type, attribute }: any) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//console.log(radioSelectShowConfigArr2) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -359,6 +483,8 @@ provide(constControlChange, ({ key, value, data, tProp, type, attribute }: any) |
|
|
|
hideFieldArr = Array.from(new Set(hideFieldArr)) |
|
|
|
const defaultHideFields: any[] = JSON.parse(JSON.stringify(hideFieldArr)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nextTick(() => { |
|
|
|
console.log("以showFields的处理过冒号的每个元素为key,其对应的optionValue为value,新建的数组radioselectArr3 --- 内容为完整显示隐藏条件") |
|
|
|
console.log(radioSelectArr3) |
|
|
|
@ -372,105 +498,16 @@ provide(constControlChange, ({ key, value, data, tProp, type, attribute }: any) |
|
|
|
} |
|
|
|
console.log("所有字段modelKeyArr^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^") |
|
|
|
console.log(modelKeyArr) |
|
|
|
//以被默认隐藏的每个字段为key,显示该字段的所有条件的数组作为value,来作为该数组的每一项。 |
|
|
|
const hideFieldConditionArr:hideFieldConditionArritem[] = [] |
|
|
|
|
|
|
|
interface hideFieldConditionArritem { |
|
|
|
toShow:string |
|
|
|
conditions: any[] |
|
|
|
} |
|
|
|
for(let i = 0;i < hideFieldArr.length;i++){ |
|
|
|
hideFieldConditionArr.push({ |
|
|
|
toShow:hideFieldArr[i], |
|
|
|
conditions:[], |
|
|
|
}) |
|
|
|
} |
|
|
|
console.log(hideFieldConditionArr) |
|
|
|
|
|
|
|
//遍历所有配置条件数组radioSelectArr3,当radioSelectArr3 [ i ] . toshowFieldKey 【i】==hideFieldArr【i】时 |
|
|
|
for(let i = 0;i < radioSelectArr3.length;i++){ |
|
|
|
for(let j = 0;j < radioSelectArr3[i].toShowFieldKey.length;j++){ |
|
|
|
for(let n = 0;n < hideFieldConditionArr.length;n++){ |
|
|
|
/* console.log(i) |
|
|
|
console.log(j) |
|
|
|
console.log(n) */ |
|
|
|
if(radioSelectArr3[i].toShowFieldKey[j]==hideFieldConditionArr[n].toShow){ |
|
|
|
hideFieldConditionArr[n].conditions.push({ |
|
|
|
conditionFrom:"radioOrSelect",//本条件来自于单选或者下拉 |
|
|
|
condition:[{//条件详细信息//当表单字段conditionField的值为conditionFieldValue时,显示hideFieldConditionArr[n] |
|
|
|
conditionField:radioSelectArr3[i].conditionFieldKey, |
|
|
|
conditionFieldValue:radioSelectArr3[i].conditionFieldValue// |
|
|
|
}] |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
console.log(hideFieldConditionArr); |
|
|
|
//要显示的和其满足显示条件的个数. |
|
|
|
//let showfieldsCountX = []; |
|
|
|
for(let i = 0;i<hideFieldConditionArr.length;i++){ |
|
|
|
let x = 0//满足显示条件的次数 |
|
|
|
|
|
|
|
let toshow = hideFieldConditionArr[i].toShow |
|
|
|
let conditions = hideFieldConditionArr[i].conditions |
|
|
|
//console.log(conditions) |
|
|
|
for(let j = 0;j<conditions.length;j++){ |
|
|
|
if(conditions[j].conditionFrom == "radioOrSelect"){//本条件来自于单选或者下拉,其只有一项 |
|
|
|
let conditionField = conditions[j].condition[0].conditionField |
|
|
|
let conditionFieldValue = conditions[j].condition[0].conditionFieldValue |
|
|
|
console.log(conditionField) |
|
|
|
console.log(conditionFieldValue) |
|
|
|
for(let n = 0; n< modelKeyArr.length;n++){ |
|
|
|
if(modelKeyArr[n]==conditionField){ |
|
|
|
let trueValue = model.value[modelKeyArr[n]] |
|
|
|
//console.log(modelKeyArr[n]) |
|
|
|
//console.log(trueValue) |
|
|
|
if(trueValue==conditionFieldValue){ |
|
|
|
//此时满足了条件,但是必须看一下conditionField有没有被隐藏.如果被隐藏了,则x不能增加. |
|
|
|
//let flag = false//其依赖的选项的字段是否被隐藏.默认没被隐藏,其依赖的选项的字段一定是有可能被隐藏的.也就是在遍历defaultHideFields时有可能找到他:条件- |
|
|
|
x++ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}else{//本条件来自于多选,其可能有多项 |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(x>0){ |
|
|
|
/* showfieldsCountX.push({ |
|
|
|
count:x, |
|
|
|
field:toshow, |
|
|
|
conditionField: |
|
|
|
}) */ |
|
|
|
//alert(x) |
|
|
|
hideFieldArr = hideFieldArr.filter(item => item!=toshow) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//将隐藏的字段值重置 |
|
|
|
for(let i = 0; i< hideFieldArr.length;i++){ |
|
|
|
//console.log(i+"dsfafdasdfasfsda===="+hideFieldArr[i]+"=====jiuopfdsahokjuhuiofadshuiofadsjbknfdjisahuifhjken wij================"+model.value[hideFieldArr[i]]) |
|
|
|
if(typeof model.value[hideFieldArr[i]] === "string" || typeof model.value[hideFieldArr[i]] === "number"){ |
|
|
|
model.value[hideFieldArr[i]] = "" |
|
|
|
}else if( model.value[hideFieldArr[i]] instanceof Array){ |
|
|
|
model.value[hideFieldArr[i]] = [] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//默认隐藏的字段中目前被显示出来的 |
|
|
|
//当前处于显示状态的默认隐藏的字段 |
|
|
|
let nowShowingDefaultHideFieldArr = defaultHideFields.filter(a => !hideFieldArr.includes(a)) |
|
|
|
console.log("(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))") |
|
|
|
console.log(nowShowingDefaultHideFieldArr) |
|
|
|
//for(let i = 0;i< nowShowingDefaultHideFieldArr.length; i++){ |
|
|
|
//当被显示出来的字段涉及到的conditionfield已经被隐藏了时,其x应-1,如果x-1后造成该field被隐藏,应递归重新敲定hideFieldArr |
|
|
|
//if() |
|
|
|
//} |
|
|
|
|
|
|
|
//当前所有处于显示状态的字段 |
|
|
|
let nowShowingFieldArr = modelKeyArr.filter(a => !hideFieldArr.includes(a)) |
|
|
|
|
|
|
|
hideFieldArr = recursionToGetFinallyHideFields(hideFieldArr,radioSelectArr3,modelKeyArr,defaultHideFields,nowShowingDefaultHideFieldArr,nowShowingFieldArr) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -543,6 +580,9 @@ const formProps = computed(() => { |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
provide(constFormProps, formProps) |
|
|
|
|
|
|
|
// 提供一个方法,用于根据name从formData.list里查找数据 |
|
|
|
|