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

Loading…
Cancel
Save