Browse Source

子表结合关联表单预填充---效果实现

qin_s3
liwenxuan 1 month ago
parent
commit
fb293dfea1
  1. 2
      src/components/DesignForm/app/index.vue
  2. 75
      src/components/DesignForm/public/form/childTable.vue
  3. 24
      src/widget/associatedforms/associatedForms.vue

2
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] }}
</el-link>
</div>
</template>

75
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) {
<template>
<div class="form-table form-table-add">
<el-text class="mx-1" size="large">{{ sunTableName }}</el-text>
<el-table v-bind="data.control" :class="[data.className]" :data="tableDataNew">

24
src/widget/associatedforms/associatedForms.vue

@ -93,8 +93,12 @@ onMounted(()=>{
tableFlag = true
//
//console.log(props.formProps.model[key][props.rowIndex][key1])
value2.value = props.formProps.model[key][props.rowIndex][key1]
//console.log(props.rowIndex)
if(props.rowIndex>=0){
//console.log(props.formProps.model[key][props.rowIndex][key1])
value2.value = props.formProps.model[key][props.rowIndex][key1]
}
}
}
}
@ -124,10 +128,17 @@ function asfValueChanged(){
glbbddbd:props.data.control.glbbddbd,
tableFlag:false,
}
//console.log(val)
emits("valueChanged",val)
}
watch(() => value1,(newVal:any) => {
asfValueChanged()
},{deep: true})
function asfValueChangedTable(){
let val = {
@ -139,10 +150,15 @@ function asfValueChangedTable(){
glbbddbd:props.data.control.glbbddbd,
tableFlag:true,
}
//console.log(val)
emits("valueChangedTable",val)
}
watch(() => value2,(newVal:any) => {
asfValueChangedTable()
},{deep: true})
function getAsfDataTitles() {
let dataTitle = ''
//console.log(props)

Loading…
Cancel
Save