Browse Source

矩阵填充适配行列未选择条件

lwx_v28
liwenxuan 7 days ago
parent
commit
51d7b8e4a6
  1. 50
      src/components/DesignForm/formControlPropertiNew.vue
  2. 18
      src/components/DesignForm/public/form/form.vue

50
src/components/DesignForm/formControlPropertiNew.vue

@ -2912,7 +2912,6 @@ function mergeArrays(a, b) {
// liwenxuan 20251230 start
let datapropsformList = JSON.parse(JSON.stringify(props.formList))
@ -2989,13 +2988,17 @@ const leftTopLabel = computed(() => {
return `${indexColumnLabel.value}\\${titleColumnLabel.value}`
})
// ==
// ==''
const titleOptions = computed(() => {
return currentTitleColumnNode.value?.options || []
const options = currentTitleColumnNode.value?.options || []
// ''
return [...options, { label: '未选择', value: 'notChosen' }]
})
const indexOptions = computed(() => {
return currentIndexColumnNode.value?.options || []
const options = currentIndexColumnNode.value?.options || []
// ''
return [...options, { label: '未选择', value: 'notChosen' }]
})
//
@ -3016,22 +3019,38 @@ watch([titleOptions, indexOptions], ([newTitleOptions, newIndexOptions]) => {
return
}
// controlData
// controlData
const savedData = controlData.value?.control?.zdtcsz?.tableData || {}
// ''
const convertOldData = (data) => {
const converted = {}
Object.keys(data).forEach(rowKey => {
const newRowKey = rowKey === '' ? 'notChosen' : rowKey
converted[newRowKey] = {}
Object.keys(data[rowKey]).forEach(colKey => {
const newColKey = colKey === '' ? 'notChosen' : colKey
converted[newRowKey][newColKey] = data[rowKey][colKey]
})
})
return converted
}
const convertedSavedData = convertOldData(savedData)
// 1
if (newTitleOptions.length && !newIndexOptions.length) {
//
const defaultRowKey = 'default'
// ''
const rowKey = 'notChosen'
const rowObj = {
rowKey: defaultRowKey,
rowLabel: '默认' // ""
rowKey: rowKey,
rowLabel: '未选择' // ""
}
// 使
newTitleOptions.forEach(colItem => {
const colKey = colItem.value
const savedValue = savedData[defaultRowKey]?.[colKey] || ''
const savedValue = convertedSavedData[rowKey]?.[colKey] || ''
rowObj[`col_${colKey}`] = savedValue
})
@ -3048,8 +3067,8 @@ watch([titleOptions, indexOptions], ([newTitleOptions, newIndexOptions]) => {
}
//
const defaultColKey = 'default'
const savedValue = savedData[rowKey]?.[defaultColKey] || ''
const defaultColKey = 'notChosen'
const savedValue = convertedSavedData[rowKey]?.[defaultColKey] || ''
rowObj[`col_${defaultColKey}`] = savedValue
return rowObj
@ -3057,7 +3076,7 @@ watch([titleOptions, indexOptions], ([newTitleOptions, newIndexOptions]) => {
zdtcszTableData.value = newTableData
}
// 3
// 3
else if (newTitleOptions.length && newIndexOptions.length) {
//
const newTableData = newIndexOptions.map(rowItem => {
@ -3070,7 +3089,7 @@ watch([titleOptions, indexOptions], ([newTitleOptions, newIndexOptions]) => {
// 使
newTitleOptions.forEach(colItem => {
const colKey = colItem.value
const savedValue = savedData[rowKey]?.[colKey] || ''
const savedValue = convertedSavedData[rowKey]?.[colKey] || ''
rowObj[`col_${colKey}`] = savedValue
})
@ -3135,9 +3154,6 @@ const handleDetermineZdtcszDialogFlag = () => {
}
/**
* 合并两个组件树仅保留type为radio和select的节点并过滤掉指定compId的节点同时保留options属性
* @param {Array} treeA - 组件树a包含表单结构信息

18
src/components/DesignForm/public/form/form.vue

@ -694,9 +694,9 @@ function showOrHide(data: any,currentDataNameValue?:any) {
if(data=="onMounted"||data=="kong"){
}else{
console.log(data)
//console.log(data)
dataObjFlag = true
console.log(data.name)
//console.log(data.name)
}
if(dataObjFlag){
if(data.type=="select"||data.type=="radio"||data.type=="checkbox"||data.type=="switch"){
@ -1306,10 +1306,20 @@ nextTick(()=>{
//console.log(element.name)
let rowValue = model.value[tbx]
//console.log(rowValue)
let columnValue = model.value[tby]
//console.log(columnValue)
if(rowValue==""){
rowValue="notChosen"
}
if(columnValue==""){
columnValue="notChosen"
}
/* console.log(rowValue)
console.log(columnValue) */
/* if(dataObjFlag && element.name==data.name && currentDataNameValue!=""){//允许直接选择被矩阵填充的字段
console.log(data.name)
console.log("直接选择被矩阵填充的字段,允许")

Loading…
Cancel
Save