2 changed files with 243 additions and 0 deletions
@ -0,0 +1,242 @@ |
|||||
|
<template> |
||||
|
|
||||
|
|
||||
|
<div class="container" > |
||||
|
<!-- <span style="font-size: 14px; margin-right: 12px;padding-top: 4px;" class="small-span" >{{ props.data.item?props.data.item.label:"关联表单" }}</span> --> |
||||
|
<el-select-v2 v-if="!tableFlag" v-model="value1" :options="options" multiple |
||||
|
show-checkbox |
||||
|
class="big-span" |
||||
|
|
||||
|
clearable |
||||
|
filterable placeholder="选择要自动填充的记录" |
||||
|
@change="asfValueChanged"> |
||||
|
<!-- <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" /> --> |
||||
|
</el-select-v2> |
||||
|
<el-select-v2 v-if="tableFlag" v-model="value2" :options="options" multiple |
||||
|
show-checkbox |
||||
|
class="big-span" |
||||
|
clearable |
||||
|
filterable placeholder="选择要自动填充的记录" |
||||
|
@change="asfValueChangedTable"> |
||||
|
<!-- <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" /> --> |
||||
|
</el-select-v2> |
||||
|
</div> |
||||
|
|
||||
|
</template> |
||||
|
|
||||
|
<script lang='ts' setup> |
||||
|
import request from '@/utils/request'; |
||||
|
import { inject } from 'vue' |
||||
|
import { FormItem, FormList } from '@/api/DesignForm/types' |
||||
|
/* const props = defineProps({ |
||||
|
// eslint-disable-next-line vue/require-default-prop |
||||
|
data: { |
||||
|
type: Object, |
||||
|
}, |
||||
|
formProps:{ |
||||
|
type: Object, |
||||
|
}, |
||||
|
tableKey:{ |
||||
|
type: Object, |
||||
|
}, |
||||
|
}) */ |
||||
|
|
||||
|
/* const asfRangeDoubleCondiChangeObj = inject('asfRangeDoubleCondiChangeObj') |
||||
|
watch(() => asfRangeDoubleCondiChangeObj,(newVal:any) => { |
||||
|
value1.value = "" |
||||
|
value2.value = "" |
||||
|
|
||||
|
let newValObj = JSON.parse(JSON.stringify(newVal.value)); |
||||
|
|
||||
|
let toShowDoubleCondiValValStr = newValObj.toShowDoubleCondiValVal+""; |
||||
|
|
||||
|
const filteredData = asfDataTitlesData.filter((item: any) => item.doubleCondiVal == toShowDoubleCondiValValStr); |
||||
|
|
||||
|
options.value = filteredData |
||||
|
|
||||
|
},{deep: true}) */ |
||||
|
const props = withDefaults( |
||||
|
defineProps<{ |
||||
|
data: FormList |
||||
|
ids: any |
||||
|
//formProps:Object |
||||
|
//tablekey: any |
||||
|
//rowIndex:number |
||||
|
}>(), |
||||
|
{} |
||||
|
) |
||||
|
const emits = defineEmits(["valueChanged", "valueChangedTable"]); |
||||
|
const value1 = ref('') |
||||
|
const value2 = ref('') |
||||
|
const valueTest = ref('') |
||||
|
let tableFlag = false |
||||
|
const options = ref([]) |
||||
|
|
||||
|
|
||||
|
function hasTableProperty(obj: object): boolean { |
||||
|
for (let key in obj) { |
||||
|
if (key.startsWith("table")) { |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
let asfDataTitlesData: any = [] |
||||
|
onMounted(() => { |
||||
|
if (props.data.control.formid != null && props.data.control.formid != "") { |
||||
|
getAsfDataTitles().then(({ data }) => { |
||||
|
asfDataTitlesData = data |
||||
|
//console.log(data) |
||||
|
options.value = data |
||||
|
value1.value = props.ids |
||||
|
|
||||
|
/* |
||||
|
|
||||
|
// 确定哪个或哪些表单是被放置在子表中的 |
||||
|
valueTest.value = props.formProps.model |
||||
|
for (let key in valueTest.value) { |
||||
|
if (key.startsWith("table")) { |
||||
|
if(Array.isArray(valueTest.value[key])){ |
||||
|
|
||||
|
if(valueTest.value[key].length>0){ |
||||
|
for (let key1 in valueTest.value[key][0]) { |
||||
|
if(key1==props.data.name){ |
||||
|
tableFlag = true |
||||
|
|
||||
|
//当前关联表单在子表的第几行 |
||||
|
//console.log(props.formProps.model[key][props.rowIndex][key1]) |
||||
|
value2.value = props.formProps.model[key][props.rowIndex][key1] |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} */ |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
}) |
||||
|
let fillFieldsMaster = ""; |
||||
|
let fillFieldsChild: any |
||||
|
function asfValueChanged() { |
||||
|
|
||||
|
let val = { |
||||
|
options: options.value, |
||||
|
currentVal: value1.value, |
||||
|
fillFieldsMaster: fillFieldsMaster, |
||||
|
fillFieldsChild: fillFieldsChild, |
||||
|
asfFormId: props.data.control.formid, |
||||
|
glbbddbd: props.data.control.glbbddbd, |
||||
|
tableFlag: false, |
||||
|
} |
||||
|
|
||||
|
emits("valueChanged",val) |
||||
|
} |
||||
|
|
||||
|
function asfValueChangedTable() { |
||||
|
|
||||
|
let val = { |
||||
|
options: options.value, |
||||
|
currentVal: value2.value, |
||||
|
fillFieldsMaster: fillFieldsMaster, |
||||
|
fillFieldsChild: fillFieldsChild, |
||||
|
asfFormId: props.data.control.formid, |
||||
|
glbbddbd: props.data.control.glbbddbd, |
||||
|
tableFlag: true, |
||||
|
} |
||||
|
|
||||
|
//emits("valueChangedTable",val) |
||||
|
} |
||||
|
|
||||
|
function getAsfDataTitles() { |
||||
|
let dataTitle = '' |
||||
|
//console.log(props) |
||||
|
/* if(props.tablekey&&props.tablekey.dataTitle&&props.tablekey.dataTitle!=null&&props.tablekey.dataTitle.length>0){ |
||||
|
for(let i = 0;i<props.tablekey.dataTitle.length;i++){ |
||||
|
dataTitle = dataTitle+props.tablekey.dataTitle[i]+"###" |
||||
|
} |
||||
|
} */ |
||||
|
//数据填充规则条件参数处理 |
||||
|
|
||||
|
|
||||
|
//console.log(props.data.control.fillRoles) |
||||
|
//let fillRoles = JSON.parse(JSON.stringify(props.data.control.fillRoles)) |
||||
|
if (props.data.control.fillRoles && props.data.control.fillRoles.master && props.data.control.fillRoles.master.length > 0) { |
||||
|
for (let i = 0; i < props.data.control.fillRoles.master.length; i++) { |
||||
|
if (props.data.control.fillRoles.master[i].leftValue != "" && props.data.control.fillRoles.master[i].rightValue != "") { |
||||
|
fillFieldsMaster = fillFieldsMaster + props.data.control.fillRoles.master[i].id + "_" + props.data.control.fillRoles.master[i].leftValue + "_" + props.data.control.fillRoles.master[i].rightValue + ";" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if (props.data.control.fillRoles.child) { |
||||
|
fillFieldsChild = JSON.parse(JSON.stringify(props.data.control.fillRoles.child)) |
||||
|
fillFieldsChild = fillFieldsChild.filter((item: any) => { |
||||
|
//console.log(item) |
||||
|
return item.asfChildTableKey != "" |
||||
|
}) |
||||
|
|
||||
|
|
||||
|
//console.log(fillFieldsChild) |
||||
|
for (let i = 0; i < fillFieldsChild.length; i++) { |
||||
|
if (fillFieldsChild[i].asfChildTableKey != "") { |
||||
|
if (fillFieldsChild[i].childRoles.length > 0) { |
||||
|
fillFieldsChild[i].childRoles = fillFieldsChild[i].childRoles.filter((element: any) => { |
||||
|
if (element.leftValue != "" && element.rightValue != "") { |
||||
|
return element |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
//console.log(fillFieldsMaster) |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/* |
||||
|
|
||||
|
*/ |
||||
|
fillFieldsChild = JSON.stringify(fillFieldsChild) |
||||
|
//console.log(fillFieldsChild) |
||||
|
return request({ |
||||
|
url: '/javasys/lowCode/AssociatedForms/getAsfDataTitles', |
||||
|
method: 'post', |
||||
|
data: { |
||||
|
glbbddbd: props.data.control.glbbddbd, |
||||
|
formId: props.data.control.formid, |
||||
|
dataTitle: dataTitle, |
||||
|
rangeFormula: props.data.control.dataRangeGongShi.mathsFormula, |
||||
|
rangeString: props.data.control.dataRangeGongShi.mathsString, |
||||
|
hideFormula: props.data.control.hideGongShi.mathsFormula, |
||||
|
hideString: props.data.control.hideGongShi.mathsString, |
||||
|
masterOnField: props.data.name, |
||||
|
fillFieldsMaster: fillFieldsMaster, |
||||
|
fillFieldsChild: fillFieldsChild, |
||||
|
}, |
||||
|
}); |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style> |
||||
|
/* style="font-size: 14px; margin-right: 12px;" */ |
||||
|
.container { |
||||
|
display: flex; |
||||
|
} |
||||
|
|
||||
|
.small-span { |
||||
|
width: auto; |
||||
|
/* 您可以根据需要调整第一个 span 的宽度比例 */ |
||||
|
} |
||||
|
|
||||
|
.big-span { |
||||
|
flex: 1; |
||||
|
/* 第二个 span 占据剩余的所有宽度 */ |
||||
|
} |
||||
|
</style> |
||||
Loading…
Reference in new issue