Browse Source

修改矩阵

qin_s5
herenshan112 2 weeks ago
parent
commit
491875c23d
  1. 122
      src/views/sysworkflow/lowcodepage/appPage/appPageForm/unitsPageFrom/attribute.vue

122
src/views/sysworkflow/lowcodepage/appPage/appPageForm/unitsPageFrom/attribute.vue

@ -4,6 +4,7 @@
@ 备注: 属性
-->
<script lang='ts' setup>
import { reactive, computed, toRefs, ref, watch, inject, onBeforeMount, onMounted } from "vue";
import validateConfig from "@/components/DesignForm/validate";
import { useDesignFormStore } from "@/store/DesignForm/designForm";
import { getRequest, uploadUrl } from "@/api/DesignForm";
@ -162,6 +163,22 @@ watch(roleTreeFilterText, (val) => {
const multipleSelection = ref<User[]>([])
/**
@ 作者: 秦东
@ 时间: 2026-03-03 08:41:39
@ 功能: 原始选项数组标题行=索引列=将空值选项放在末尾键改为'未选择'
*/
const titleOptions = computed(() => {
const options = currentTitleColumnNode.value?.options || []
// ''
return [...options, { label: '未选择', value: 'notChosen' }]
})
const indexOptions = computed(() => {
const options = currentIndexColumnNode.value?.options || []
// ''
return [...options, { label: '未选择', value: 'notChosen' }]
})
interface User {
id: number
name: string
@ -4346,6 +4363,97 @@ const titleColumnLabel = computed(() => {
const leftTopLabel = computed(() => {
return `${indexColumnLabel.value}\\${titleColumnLabel.value}`
})
//
watch([titleOptions, indexOptions], ([newTitleOptions, newIndexOptions]) => {
//
if (!newTitleOptions.length && !newIndexOptions.length) {
console.log("如果都没有选择,清空表格数据")
zdtcszTableData.value = []
return
}
// 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 rowKey = 'notChosen'
const rowObj = {
rowKey: rowKey,
rowLabel: '未选择' // ""
}
// 使
newTitleOptions.forEach(colItem => {
const colKey = colItem.value
const savedValue = convertedSavedData[rowKey]?.[colKey] || ''
rowObj[`col_${colKey}`] = savedValue
})
zdtcszTableData.value = [rowObj]
}
// 2
else if (!newTitleOptions.length && newIndexOptions.length) {
//
const newTableData = newIndexOptions.map(rowItem => {
const rowKey = rowItem.value
const rowObj = {
rowKey: rowKey,
rowLabel: rowItem.label
}
//
const defaultColKey = 'notChosen'
const savedValue = convertedSavedData[rowKey]?.[defaultColKey] || ''
rowObj[`col_${defaultColKey}`] = savedValue
return rowObj
})
zdtcszTableData.value = newTableData
}
// 3
else if (newTitleOptions.length && newIndexOptions.length) {
//
const newTableData = newIndexOptions.map(rowItem => {
const rowKey = rowItem.value
const rowObj = {
rowKey: rowKey,
rowLabel: rowItem.label
}
// 使
newTitleOptions.forEach(colItem => {
const colKey = colItem.value
const savedValue = convertedSavedData[rowKey]?.[colKey] || ''
rowObj[`col_${colKey}`] = savedValue
})
return rowObj
})
zdtcszTableData.value = newTableData
}
}, { immediate: true })
/**
@ 作者: 秦东
@ 时间: 2026-03-02 16:53:00
@ -4796,16 +4904,7 @@ const asfPropsData = computed(()=>{
});
return result
})
/**
@ 作者: 秦东
@ 时间: 2026-03-03 08:41:39
@ 功能: 原始选项数组标题行=索引列=将空值选项放在末尾键改为'未选择'
*/
const titleOptions = computed(() => {
const options = currentTitleColumnNode.value?.options || []
// ''
return [...options, { label: '未选择', value: 'notChosen' }]
})
/**
@ -8563,7 +8662,8 @@ const updataBase = (val: any) => {
/>
</div>
<div style="width: 100%; padding: 20px; overflow-x: auto;">
{{zdtcszTableData}} <br> {{ currentComponentOptions }}
zdtcszTableData--> {{zdtcszTableData}} <br/> <br/> currentComponentOptions --> {{ currentComponentOptions }}
<br/> <br/>leftTopLabel ----> {{ leftTopLabel }}<br/><br/>titleOptions ----> {{ titleOptions }}<br/><br/>zdtcszTableData ----> {{ zdtcszTableData }}
<el-table
:data="zdtcszTableData"
border

Loading…
Cancel
Save