diff --git a/src/components/DesignForm/app/index.vue b/src/components/DesignForm/app/index.vue index 3e12ce1..df24ee5 100644 --- a/src/components/DesignForm/app/index.vue +++ b/src/components/DesignForm/app/index.vue @@ -2600,7 +2600,7 @@ const getNonValue = () => { type="primary" @click="showAsfDetailDialog(item, scope, asfQueryParams)" > - {{ scope.row[scope.column.property] }}== + {{ scope.row[scope.column.property] }} diff --git a/src/components/DesignForm/public/form/childTable.vue b/src/components/DesignForm/public/form/childTable.vue index 34caf36..91dd84a 100644 --- a/src/components/DesignForm/public/form/childTable.vue +++ b/src/components/DesignForm/public/form/childTable.vue @@ -47,7 +47,51 @@ const type = computed(() => { const editDisabled = computed(() => { return formProps.value.type === 2 && props.data.config?.editDisabled; }); +const preFillFlag = computed(() => { + if(props.data.control.preFill){ + if(props.data.control.preFill.asf==""){ + return 0 + }else{ + if(props.data.control.preFill.ids.length>0){ + return 1 + }else{ + return 0 + } + } + }else{ + return 1 + } + + +}) const defaultOneFlag = ref(true) + +/** + * 提取字符串中最后一个英文冒号后的内容,无冒号则返回原字符串 + * @param {string} str - 输入的字符串 + * @returns {string} 最后一个冒号后的内容或原字符串 + */ +function getAfterLastColon(str:string) { + //console.log(str) + // 首先验证入参类型,确保是字符串(避免非字符串类型导致方法出错) + if (typeof str !== 'string') { + //console.warn('入参必须是字符串类型,当前已自动转为字符串'); + str = String(str); // 非字符串类型自动转为字符串 + } + + // 查找最后一个英文冒号的索引位置 + const lastColonIndex = str.lastIndexOf(':'); + + // 若未找到冒号(索引为 -1),或冒号在字符串最后一位(后面无内容),返回原字符串 + if (lastColonIndex === -1 || lastColonIndex === str.length - 1) { + return str; + } + + // 截取最后一个冒号后面的字符(索引+1 开始到字符串结尾) + return str.slice(lastColonIndex + 1); +} + + //新增页面,子表默认新增一行 onMounted(()=>{ @@ -55,10 +99,31 @@ onMounted(()=>{ defaultOneFlag.value = false } if(formProps.value.type === 1&&defaultOneFlag.value){ + //alert(preFillFlag.value) setTimeout(()=>{ - //alert(defaultOneFlag) - addColumn() - },200) + if(preFillFlag.value==1){ + let i = 0; + props.data.control.preFill.ids.forEach((element:any) => { + addColumn() + //console.log(element) + + setTimeout(()=>{ + let asfName = getAfterLastColon(props.data.control.preFill.asf) + //console.log(asfName) + tableDataNew.value[i][asfName] = element + i++ + },200) + + + }); + + }else{ + + //alert(defaultOneFlag.value) + addColumn() + + } + },400) } }) @@ -89,6 +154,9 @@ const getText = (text: any, val: any, name: any) => { const delColumn = (index: number) => { tableDataNew.value.splice(index, 1); }; +/* + +*/ /** @ 作者: 秦东 @ 时间: 2024-08-02 13:22:14 @@ -277,6 +345,7 @@ function optionsValue3Get1(data: any, fieldName: string) {