Browse Source

自动填充设置v0.25

lwx_v27
liwenxuan 3 weeks ago
parent
commit
883e8a3c8e
  1. 294
      src/components/DesignForm/formControlPropertiNew.vue

294
src/components/DesignForm/formControlPropertiNew.vue

@ -2910,60 +2910,72 @@ function mergeArrays(a, b) {
// liwenxuan 20251212 end // liwenxuan 20251212 end
// liwenxuan 20251230 start // liwenxuan 20251230 start
let datapropsformList = JSON.parse(JSON.stringify(props.formList))
/** const zdtcszTree = computed(()=>{
* 获取字符串最后一个英文冒号:后的字符 if(datapropsformList&&datapropsformList.length==0){
* @param {string} str - 待处理的原始字符串 datapropsformList = JSON.parse(JSON.stringify(props.formList))
* @returns {string} 最后一个冒号后的子串无冒号/冒号在末尾时返回空字符串
*/
function getLastColonAfterString(str) {
// 1.
if (typeof str !== 'string') {
console.warn('输入必须为字符串类型');
return '';
} }
//console.log(datapropsformList)
if(associatedFormsCurrentFormFieldTreeForGlxxszExceptSelf && associatedFormsCurrentFormFieldTreeForGlxxszExceptSelf.value[0].children && associatedFormsCurrentFormFieldTreeForGlxxszExceptSelf.value[0].children.length>0){
// 2.
const lastColonIndex = str.lastIndexOf(':'); let datab = JSON.parse(JSON.stringify(associatedFormsCurrentFormFieldTreeForGlxxszExceptSelf.value[0].children))
let currentCompId = controlData.value.name
// 3. const treeC = mergeAndFilterFormTrees(datapropsformList, datab,currentCompId);
if (lastColonIndex === -1 || lastColonIndex === str.length - 1) { //console.log(treeC)
return ''; return treeC
}else{
return []
} }
})
// 4. // 使 ref computed使
return str.slice(lastColonIndex + 1); const zdtcszTableData = ref([])
}
// label
const currentIndexColumnNode = computed(() => {
if (!controlData.value?.control?.zdtcsz?.tby) return null
return zdtcszTree.value.find(item => item.id == controlData.value.control.zdtcsz.tby)
})
// label
const currentTitleColumnNode = computed(() => {
if (!controlData.value?.control?.zdtcsz?.tbx) return null
return zdtcszTree.value.find(item => item.id == controlData.value.control.zdtcsz.tbx)
})
//
const leftTopLabel = computed(()=>{
return `${indexColumnLabel.value}\\${titleColumnLabel.value}`
})
//
const indexColumnLabel = computed(() => {
if (!currentIndexColumnNode.value) return "索引列"
return currentIndexColumnNode.value.label
})
//
const titleColumnLabel = computed(() => {
if (!currentTitleColumnNode.value) return "标题行"
return currentTitleColumnNode.value.label
})
// == // ==
const titleOptions = computed(() => { const titleOptions = computed(() => {
let result = [] return currentTitleColumnNode.value?.options || []
if(controlData.value.control.zdtcsz.tbx){
zdtcszTree.value.forEach(element => {
if(element.id==controlData.value.control.zdtcsz.tbx){
result = element.options
}
});
}
return result
}) })
const indexOptions = computed(() => { //
let result = [] const indexOptions = computed(() => {
if(controlData.value.control.zdtcsz.tby){ return currentIndexColumnNode.value?.options || []
zdtcszTree.value.forEach(element => {
if(element.id==controlData.value.control.zdtcsz.tby){
result = element.options
}
});
}
return result
}) })
// //
const zdtcszTableColumns = computed(() => { const zdtcszTableColumns = computed(() => {
return titleOptions.value.map(item => ({ return titleOptions.value.map(item => ({
label: item.label, label: item.label,
@ -2971,39 +2983,71 @@ const zdtcszTableColumns = computed(() => {
})) }))
}) })
// //
const zdtcszTableData = computed(() => { watch([titleOptions, indexOptions], ([newTitleOptions, newIndexOptions]) => {
return indexOptions.value.map(rowItem => { //
if (!newTitleOptions.length || !newIndexOptions.length) {
zdtcszTableData.value = []
return
}
// controlData
const savedData = controlData.value?.control?.zdtcsz?.tableData || {}
//
const newTableData = newIndexOptions.map(rowItem => {
const rowKey = rowItem.value
const rowObj = { const rowObj = {
rowKey: rowItem.value, rowKey: rowKey,
rowLabel: rowItem.label // rowLabel: rowItem.label // 使label
} }
//
titleOptions.value.forEach(colItem => { // 使
rowObj[`col_${colItem.value}`] = '' newTitleOptions.forEach(colItem => {
const colKey = colItem.value
const savedValue = savedData[rowKey]?.[colKey] || ''
rowObj[`col_${colKey}`] = savedValue
}) })
return rowObj return rowObj
}) })
})
const zdtcszTree = computed(()=>{
if(datapropsformList.length==0){
datapropsformList = JSON.parse(JSON.stringify(props.formList))
}
//console.log(datapropsformList) zdtcszTableData.value = newTableData
if(associatedFormsCurrentFormFieldTreeForGlxxszExceptSelf && associatedFormsCurrentFormFieldTreeForGlxxszExceptSelf.value[0].children && associatedFormsCurrentFormFieldTreeForGlxxszExceptSelf.value[0].children.length>0){ }, { immediate: true })
//
let datab = JSON.parse(JSON.stringify(associatedFormsCurrentFormFieldTreeForGlxxszExceptSelf.value[0].children)) const handleTableDataChange = () => {
let currentCompId = controlData.value.name //
const treeC = mergeAndFilterFormTrees(datapropsformList, datab,currentCompId); const tableData = {}
//console.log(treeC) zdtcszTableData.value.forEach(row => {
return treeC const rowKey = row.rowKey
}else{ tableData[rowKey] = {}
return [] titleOptions.value.forEach(col => {
const colKey = col.value
tableData[rowKey][colKey] = row[`col_${colKey}`] || ''
})
})
// controlData
if (!controlData.value.control.zdtcsz) {
controlData.value.control.zdtcsz = {}
} }
controlData.value.control.zdtcsz.tableData = tableData
}
//
const handleDetermineZdtcszDialogFlag = () => {
//
handleTableDataChange()
}) //
ZdtcszDialogFlag.value = false
//
/* console.log(':', controlData.value.control.zdtcsz.tableData)
console.log('索引列:', indexColumnLabel.value)
console.log('标题行:', titleColumnLabel.value) */
}
/** /**
* 合并两个组件树仅保留type为radio和select的节点并过滤掉指定compId的节点同时保留options属性 * 合并两个组件树仅保留type为radio和select的节点并过滤掉指定compId的节点同时保留options属性
@ -3392,7 +3436,7 @@ function mergeAndFilterFormTrees(treeA, treeB, compId) {
// liwenxuan 20251209 start // liwenxuan 20251209 start
let datapropsformList = JSON.parse(JSON.stringify(props.formList))
const glxxszTree = computed(()=>{ const glxxszTree = computed(()=>{
if(datapropsformList.length==0){ if(datapropsformList.length==0){
datapropsformList = JSON.parse(JSON.stringify(props.formList)) datapropsformList = JSON.parse(JSON.stringify(props.formList))
@ -4547,9 +4591,6 @@ function handleDetermineGlxxszDialogSwitch() {
function handleDetermineGlxxszDialogCheckBox() { function handleDetermineGlxxszDialogCheckBox() {
glxxszDialogFlagCheckBox.value = false; glxxszDialogFlagCheckBox.value = false;
} }
function handleDetermineZdtcszDialogFlag(){
ZdtcszDialogFlag.value = false;
}
// //
watch( watch(
() => controlData.value.control, () => controlData.value.control,
@ -8490,51 +8531,49 @@ const formatTooltip = (val: number) => {
<!-- 自动填充设置弹窗 start --> <!-- 自动填充设置弹窗 start -->
<el-dialog <el-dialog
v-model="ZdtcszDialogFlag" v-model="ZdtcszDialogFlag"
class="glxxsztc" class="glxxsztc"
top="150px" top="150px"
:close-on-click-modal="false" :close-on-click-modal="false"
:title="`自动填充设置--` + controlData.name" :title="`自动填充设置--` + controlData.name"
:show-close="false" :show-close="false"
style="margin-top: 70px" style="margin-top: 70px"
width="50%" width="50%"
> >
<!-- 外层容器保持flex布局核心是给文本span加固定最小宽度+禁止换行 -->
<div v-if="ZdtcszDialogFlag" style="width: 100%; display: flex; align-items: center; flex-wrap: nowrap; gap: 10px; padding: 8px 0;">
<!-- 标题行文本 -->
<span style="font-size: larger; margin-left: 35px; min-width: 60px; white-space: nowrap;">标题行</span>
<!-- 外层容器保持flex布局核心是给文本span加固定最小宽度+禁止换行 --> <!-- 第一个树形选择器 -->
<div v-if="ZdtcszDialogFlag" style="width: 100%; display: flex; align-items: center; flex-wrap: nowrap; gap: 10px; padding: 8px 0;"> <el-tree-select
<!-- 标题行文本加min-width+white-space禁止换行 --> v-model="controlData.control.zdtcsz.tbx"
<span style="font-size: larger; margin-left: 35px; min-width: 60px; white-space: nowrap;">标题行</span> :data="zdtcszTree"
collapse-tags
<!-- 第一个树形选择器限制宽度范围避免挤压文本 --> collapse-tags-tooltip
<el-tree-select :max-collapse-tags="2"
v-model="controlData.control.zdtcsz.tbx" clearable
:data="zdtcszTree" filterable
collapse-tags style="flex: 1; min-width: 200px; max-width: 400px;"
collapse-tags-tooltip />
:max-collapse-tags="2"
clearable <!-- 索引列文本 -->
filterable <span style="font-size: larger; min-width: 60px; white-space: nowrap;">索引列</span>
style="flex: 1; min-width: 200px; max-width: 400px;"
/> <!-- 第二个树形选择器 -->
<el-tree-select
<!-- 索引列文本同上加min-width+white-space禁止换行 --> v-model="controlData.control.zdtcsz.tby"
<span style="font-size: larger; min-width: 60px; white-space: nowrap;">索引列</span> :data="zdtcszTree"
collapse-tags
<!-- 第二个树形选择器同上限制宽度范围 --> collapse-tags-tooltip
<el-tree-select :max-collapse-tags="2"
v-model="controlData.control.zdtcsz.tby" clearable
:data="zdtcszTree" filterable
collapse-tags style="flex: 1; min-width: 200px; max-width: 400px; margin-right: 35px;"
collapse-tags-tooltip />
:max-collapse-tags="2" </div>
clearable
filterable
style="flex: 1; min-width: 200px; max-width: 400px; margin-right: 35px;"
/>
</div>
{{zdtcszTableData}}
<div style="width: 100%; padding: 20px; overflow-x: auto;"> <div style="width: 100%; padding: 20px; overflow-x: auto;">
<el-table <el-table
:data="zdtcszTableData" :data="zdtcszTableData"
border border
@ -8542,14 +8581,14 @@ const formatTooltip = (val: number) => {
:header-cell-style="{ textAlign: 'center' }" :header-cell-style="{ textAlign: 'center' }"
:cell-style="{ textAlign: 'center' }" :cell-style="{ textAlign: 'center' }"
> >
<!-- 第一列固定列索引列的数字 --> <!-- 第一列动态列标题显示索引列的label -->
<el-table-column <el-table-column
label="严重性\频率" :label="leftTopLabel"
prop="rowLabel" prop="rowLabel"
width="200" width="200"
align="center" align="center"
/> />
<!-- 动态生成标题行对应的表格列带完整描述 --> <!-- 动态生成标题行对应的表格列 -->
<el-table-column <el-table-column
v-for="col in zdtcszTableColumns" v-for="col in zdtcszTableColumns"
:key="col.value" :key="col.value"
@ -8563,22 +8602,21 @@ const formatTooltip = (val: number) => {
v-model="scope.row[`col_${col.value}`]" v-model="scope.row[`col_${col.value}`]"
size="small" size="small"
placeholder="请输入" placeholder="请输入"
@input="handleTableDataChange"
/> />
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<template #footer>
<div class="dialog-footer">
<template #footer> <el-button type="primary" @click="handleDetermineZdtcszDialogFlag">
<div class="dialog-footer"> 确定
<el-button type="primary" @click="handleDetermineZdtcszDialogFlag"> </el-button>
确定 </div>
</el-button> </template>
</div> </el-dialog>
</template>
</el-dialog>
<!-- 自动填充设置弹窗 end --> <!-- 自动填充设置弹窗 end -->

Loading…
Cancel
Save