Browse Source

矩阵填充设置效果实现

lwx_v12
liwenxuan 2 weeks ago
parent
commit
364834db6e
  1. 283
      src/components/formTable/index.vue

283
src/components/formTable/index.vue

@ -1270,97 +1270,147 @@ function showOrHide(data: any) {
//showFieldskey,optionValuevalue,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") {
//tabsflextable
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);
}
}
//tabsflextable
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;
}
// nullundefined
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[];

Loading…
Cancel
Save