|
|
|
@ -1270,97 +1270,147 @@ function showOrHide(data: any) { |
|
|
|
//以showFields的处理过冒号的每个元素为key,其对应的optionValue为value,新建一个数组radioselectArr2。----用于获取所有出现在配置中的字段。 |
|
|
|
const radioSelectArr2: any[] = []; |
|
|
|
|
|
|
|
const radioSelectZdtcszConfigArr = []; |
|
|
|
|
|
|
|
//20240815 关联选项设置的隐藏效果嵌套在内时不生效的问题修复 liwenxuan start |
|
|
|
//console.log(props.formData.list) newModelKeyArr |
|
|
|
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.list[i].type == "switch" |
|
|
|
) { |
|
|
|
props.formData.config.hideField = []; |
|
|
|
if ( |
|
|
|
props.formData.list[i].type == "radio" || |
|
|
|
props.formData.list[i].type == "select" || |
|
|
|
props.formData.list[i].type == "checkbox" || |
|
|
|
props.formData.list[i].type == "switch" |
|
|
|
props.formData.list[i].type == "select" |
|
|
|
) { |
|
|
|
props.formData.config.hideField = []; |
|
|
|
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); |
|
|
|
} else if (props.formData.list[i].type == "switch") { |
|
|
|
switchShowConfigArr.push(props.formData.list[i].control.glxxszSwitch); |
|
|
|
if (!props.formData.list[i].control.multiple) { |
|
|
|
radioSelectShowConfigArr.push(props.formData.list[i].control.glxxsz); |
|
|
|
if(props.formData.list[i].control.zdtcsz&&!isEmptyPlainObject(props.formData.list[i].control.zdtcsz.tableData)){ |
|
|
|
props.formData.list[i].control.zdtcsz.name = props.formData.list[i].name |
|
|
|
radioSelectZdtcszConfigArr.push(props.formData.list[i].control.zdtcsz) |
|
|
|
} |
|
|
|
} else { |
|
|
|
checkboxShowConfigArr.push(props.formData.list[i].control.glxxsz); |
|
|
|
if(props.formData.list[i].control.zdtcsz&&!isEmptyPlainObject(props.formData.list[i].control.zdtcsz.tableData)){ |
|
|
|
props.formData.list[i].control.zdtcsz.name = props.formData.list[i].name |
|
|
|
radioSelectZdtcszConfigArr.push(props.formData.list[i].control.zdtcsz) |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (props.formData.list[i].type == "checkbox") { |
|
|
|
checkboxShowConfigArr.push(props.formData.list[i].control.glxxszForCheckBox); |
|
|
|
} else if (props.formData.list[i].type == "switch") { |
|
|
|
switchShowConfigArr.push(props.formData.list[i].control.glxxszSwitch); |
|
|
|
} |
|
|
|
} else if ( |
|
|
|
props.formData.list[i].type == "card" || |
|
|
|
props.formData.list[i].type == "flex" || |
|
|
|
props.formData.list[i].type == "div" || |
|
|
|
props.formData.list[i].type == "table" |
|
|
|
props.formData.list[i].type == "card" || |
|
|
|
props.formData.list[i].type == "flex" || |
|
|
|
props.formData.list[i].type == "div" || |
|
|
|
props.formData.list[i].type == "table" |
|
|
|
) { |
|
|
|
props.formData.config.hideField = []; |
|
|
|
let a = JSON.parse(JSON.stringify(props.formData.list[i].list)); |
|
|
|
for (let w = 0; w < a.length; w++) { |
|
|
|
if (a[w].type == "radio" || a[w].type == "select") { |
|
|
|
//console.log(a[w]) |
|
|
|
radioSelectShowConfigArr.push(a[w].control.glxxsz); |
|
|
|
} else if (a[w].type == "checkbox") { |
|
|
|
checkboxShowConfigArr.push(a[w].control.glxxszForCheckBox); |
|
|
|
} else if (a[w].type == "switch") { |
|
|
|
switchShowConfigArr.push(a[w].control.glxxszSwitch); |
|
|
|
} |
|
|
|
newModelKeyArr.push(a[w].name); |
|
|
|
props.formData.config.hideField = []; |
|
|
|
let a = JSON.parse(JSON.stringify(props.formData.list[i].list)); |
|
|
|
for (let w = 0; w < a.length; w++) { |
|
|
|
if (a[w].type == "radio" || a[w].type == "select") { |
|
|
|
//console.log(a[w]) |
|
|
|
if (!a[w].control.multiple) { |
|
|
|
radioSelectShowConfigArr.push(a[w].control.glxxsz); |
|
|
|
} else { |
|
|
|
checkboxShowConfigArr.push(a[w].control.glxxsz); |
|
|
|
} |
|
|
|
if(a[w].control.zdtcsz&&!isEmptyPlainObject(a[w].control.zdtcsz.tableData)){ |
|
|
|
a[w].control.zdtcsz.name = a[w].name |
|
|
|
radioSelectZdtcszConfigArr.push(a[w].control.zdtcsz) |
|
|
|
} |
|
|
|
//radioSelectShowConfigArr.push(a[w].control.glxxsz); |
|
|
|
} else if (a[w].type == "checkbox") { |
|
|
|
checkboxShowConfigArr.push(a[w].control.glxxszForCheckBox); |
|
|
|
} else if (a[w].type == "switch") { |
|
|
|
switchShowConfigArr.push(a[w].control.glxxszSwitch); |
|
|
|
} |
|
|
|
newModelKeyArr.push(a[w].name); |
|
|
|
} |
|
|
|
} else if (props.formData.list[i].type == "grid") { |
|
|
|
props.formData.config.hideField = []; |
|
|
|
let columns = JSON.parse(JSON.stringify(props.formData.list[i].columns)); |
|
|
|
if (columns.length > 0) { |
|
|
|
for (let z = 0; z < columns.length; z++) { |
|
|
|
for (let x = 0; x < columns[z].list.length; x++) { |
|
|
|
let a = JSON.parse(JSON.stringify(columns[z].list[x])); |
|
|
|
if (a.type == "radio" || a.type == "select") { |
|
|
|
radioSelectShowConfigArr.push(a.control.glxxsz); |
|
|
|
} else if (a.type == "checkbox") { |
|
|
|
checkboxShowConfigArr.push(a.control.glxxszForCheckBox); |
|
|
|
} else if (a.type == "switch") { |
|
|
|
switchShowConfigArr.push(a.control.glxxszSwitch); |
|
|
|
} |
|
|
|
newModelKeyArr.push(a.name); |
|
|
|
} |
|
|
|
props.formData.config.hideField = []; |
|
|
|
let columns = JSON.parse(JSON.stringify(props.formData.list[i].columns)); |
|
|
|
if (columns.length > 0) { |
|
|
|
for (let z = 0; z < columns.length; z++) { |
|
|
|
for (let x = 0; x < columns[z].list.length; x++) { |
|
|
|
let a = JSON.parse(JSON.stringify(columns[z].list[x])); |
|
|
|
if (a.type == "radio" || a.type == "select") { |
|
|
|
if (!a.control.multiple) { |
|
|
|
radioSelectShowConfigArr.push(a.control.glxxsz); |
|
|
|
} else { |
|
|
|
checkboxShowConfigArr.push(a.control.glxxsz); |
|
|
|
} |
|
|
|
if(a.control.zdtcsz&&!isEmptyPlainObject(a.control.zdtcsz.tableData)){ |
|
|
|
a.control.zdtcsz.name = a.name |
|
|
|
radioSelectZdtcszConfigArr.push(a.control.zdtcsz) |
|
|
|
} |
|
|
|
|
|
|
|
//radioSelectShowConfigArr.push(a.control.glxxsz); |
|
|
|
} else if (a.type == "checkbox") { |
|
|
|
checkboxShowConfigArr.push(a.control.glxxszForCheckBox); |
|
|
|
} else if (a.type == "switch") { |
|
|
|
switchShowConfigArr.push(a.control.glxxszSwitch); |
|
|
|
} |
|
|
|
newModelKeyArr.push(a.name); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (props.formData.list[i].type == "tabs") { |
|
|
|
//tabs标签页有可能再嵌套一层flex或者table |
|
|
|
props.formData.config.hideField = []; |
|
|
|
let columns = JSON.parse(JSON.stringify(props.formData.list[i].columns)); |
|
|
|
if (columns.length > 0) { |
|
|
|
for (let z = 0; z < columns.length; z++) { |
|
|
|
for (let x = 0; x < columns[z].list.length; x++) { |
|
|
|
let a = JSON.parse(JSON.stringify(columns[z].list[x])); |
|
|
|
if (a.type == "radio" || a.type == "select") { |
|
|
|
radioSelectShowConfigArr.push(a.control.glxxsz); |
|
|
|
} else if (a.type == "checkbox") { |
|
|
|
checkboxShowConfigArr.push(a.control.glxxszForCheckBox); |
|
|
|
} else if (a.type == "switch") { |
|
|
|
switchShowConfigArr.push(a.control.glxxszSwitch); |
|
|
|
} else if (a.type == "flex" || a.type == "table") { |
|
|
|
if (a.list.length > 0) { |
|
|
|
for (let m = 0; m < a.list.length; m++) { |
|
|
|
let q = JSON.parse(JSON.stringify(a.list[m])); |
|
|
|
//console.log(q) |
|
|
|
if (q.type == "radio" || q.type == "select") { |
|
|
|
radioSelectShowConfigArr.push(q.control.glxxsz); |
|
|
|
} else if (q.type == "checkbox") { |
|
|
|
checkboxShowConfigArr.push(q.control.glxxszForCheckBox); |
|
|
|
} else if (q.type == "switch") { |
|
|
|
switchShowConfigArr.push(q.control.glxxszSwitch); |
|
|
|
} |
|
|
|
newModelKeyArr.push(q.name); |
|
|
|
} |
|
|
|
} |
|
|
|
//tabs标签页有可能再嵌套一层flex或者table |
|
|
|
props.formData.config.hideField = []; |
|
|
|
let columns = JSON.parse(JSON.stringify(props.formData.list[i].columns)); |
|
|
|
if (columns.length > 0) { |
|
|
|
for (let z = 0; z < columns.length; z++) { |
|
|
|
for (let x = 0; x < columns[z].list.length; x++) { |
|
|
|
let a = JSON.parse(JSON.stringify(columns[z].list[x])); |
|
|
|
if (a.type == "radio" || a.type == "select") { |
|
|
|
if (!a.control.multiple) { |
|
|
|
radioSelectShowConfigArr.push(a.control.glxxsz); |
|
|
|
} else { |
|
|
|
checkboxShowConfigArr.push(a.control.glxxsz); |
|
|
|
} |
|
|
|
if(a.control.zdtcsz&&!isEmptyPlainObject(a.control.zdtcsz.tableData)){ |
|
|
|
a.control.zdtcsz.name = a.name |
|
|
|
radioSelectZdtcszConfigArr.push(a.control.zdtcsz) |
|
|
|
} |
|
|
|
//radioSelectShowConfigArr.push(a.control.glxxsz); |
|
|
|
} else if (a.type == "checkbox") { |
|
|
|
checkboxShowConfigArr.push(a.control.glxxszForCheckBox); |
|
|
|
} else if (a.type == "switch") { |
|
|
|
switchShowConfigArr.push(a.control.glxxszSwitch); |
|
|
|
} else if (a.type == "flex" || a.type == "table") { |
|
|
|
if (a.list.length > 0) { |
|
|
|
for (let m = 0; m < a.list.length; m++) { |
|
|
|
let q = JSON.parse(JSON.stringify(a.list[m])); |
|
|
|
if (q.type == "radio" || q.type == "select") { |
|
|
|
if (!q.control.multiple) { |
|
|
|
radioSelectShowConfigArr.push(q.control.glxxsz); |
|
|
|
} else { |
|
|
|
checkboxShowConfigArr.push(q.control.glxxsz); |
|
|
|
} |
|
|
|
if(q.control.zdtcsz&&!isEmptyPlainObject(q.control.zdtcsz.tableData)){ |
|
|
|
q.control.zdtcsz.name = q.name |
|
|
|
radioSelectZdtcszConfigArr.push(q.control.zdtcsz) |
|
|
|
} |
|
|
|
newModelKeyArr.push(a.name); |
|
|
|
//radioSelectShowConfigArr.push(q.control.glxxsz); |
|
|
|
} else if (q.type == "checkbox") { |
|
|
|
checkboxShowConfigArr.push(q.control.glxxszForCheckBox); |
|
|
|
} else if (q.type == "switch") { |
|
|
|
switchShowConfigArr.push(q.control.glxxszSwitch); |
|
|
|
} |
|
|
|
newModelKeyArr.push(q.name); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
newModelKeyArr.push(a.name); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
newModelKeyArr.push(props.formData.list[i].name); |
|
|
|
} |
|
|
|
@ -1582,8 +1632,95 @@ function showOrHide(data: any) { |
|
|
|
|
|
|
|
//props.formData.config?.hideField?.push("nin2yuan4yi4wei4wo3menda3fen1ma101939") |
|
|
|
//console.log("监听表单--constControlChange-->",key, value, data, tProp,type,attribute)//liwenxuan |
|
|
|
|
|
|
|
|
|
|
|
nextTick(()=>{ |
|
|
|
//console.log(model.value)// |
|
|
|
radioSelectZdtcszConfigArr.forEach(element => { |
|
|
|
let tbx=getLastColonAfterString(element.tbx) |
|
|
|
let tby=getLastColonAfterString(element.tby) |
|
|
|
/* console.log(tbx) |
|
|
|
console.log(tby) */ |
|
|
|
let rowValue = model.value[tbx] |
|
|
|
let columnValue = model.value[tby] |
|
|
|
let cellValue = getTableCellValueV2(element.tableData, rowValue, columnValue) |
|
|
|
//console.log(cellValue); |
|
|
|
//console.log(element.name) |
|
|
|
if(tbx!=""&&tby!=""){ |
|
|
|
model.value[element.name] = cellValue*1 |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//console.log(getTableCellValueV2(element.tableData, 3, 2)); |
|
|
|
}); |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 判断对象是否是“内容为空的纯对象” |
|
|
|
function isEmptyPlainObject(obj) { |
|
|
|
// 先确认是对象类型,再检查属性数量为0 |
|
|
|
return Object.prototype.toString.call(obj) === '[object Object]' |
|
|
|
&& Object.keys(obj).length === 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 获取字符串最后一个英文冒号(:)后的字符 |
|
|
|
* @param {string} str - 待处理的原始字符串 |
|
|
|
* @returns {string} 最后一个冒号后的子串;无冒号/冒号在末尾时返回空字符串 |
|
|
|
*/ |
|
|
|
function getLastColonAfterString(str) { |
|
|
|
// 1. 输入校验:确保输入是字符串类型(处理非字符串入参) |
|
|
|
if (typeof str !== 'string') { |
|
|
|
console.warn('输入必须为字符串类型'); |
|
|
|
return ''; |
|
|
|
} |
|
|
|
|
|
|
|
// 2. 找到最后一个英文冒号的索引位置 |
|
|
|
const lastColonIndex = str.lastIndexOf(':'); |
|
|
|
|
|
|
|
// 3. 边界判断:无冒号 或 冒号在最后一位 → 返回空字符串 |
|
|
|
if (lastColonIndex === -1 || lastColonIndex === str.length - 1) { |
|
|
|
return ''; |
|
|
|
} |
|
|
|
|
|
|
|
// 4. 截取最后一个冒号后的所有字符并返回 |
|
|
|
return str.slice(lastColonIndex + 1); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 根据自动填充表格行列数据确定单元格值 |
|
|
|
function getTableCellValueV2(tableData, rowValue, columnValue) { |
|
|
|
try { |
|
|
|
// 检查输入参数 |
|
|
|
if (!tableData || typeof tableData !== 'object' || Array.isArray(tableData)) { |
|
|
|
return undefined; |
|
|
|
} |
|
|
|
|
|
|
|
// 处理null或undefined值 |
|
|
|
if (rowValue == null || columnValue == null) { |
|
|
|
return undefined; |
|
|
|
} |
|
|
|
|
|
|
|
// 转换为字符串 |
|
|
|
const rowStr = String(rowValue); |
|
|
|
const columnStr = String(columnValue); |
|
|
|
|
|
|
|
// 使用可选链操作符安全地访问嵌套属性 |
|
|
|
return tableData?.[columnStr]?.[rowStr]; |
|
|
|
} catch (error) { |
|
|
|
// 如果发生任何错误,返回undefined |
|
|
|
console.error('获取表格单元格值时发生错误:', error); |
|
|
|
return undefined; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface hideFieldConditionArritem { |
|
|
|
toShow: string; |
|
|
|
conditions: any[]; |
|
|
|
|