Browse Source

子表结合关联表单预填充设置

qin_s3
liwenxuan 1 month ago
parent
commit
03baaf7bae
  1. 1
      src/components/DesignForm/formControlPropertiNew.vue
  2. 242
      src/widget/associatedforms/associatedFormsForCreate.vue

1
src/components/DesignForm/formControlPropertiNew.vue

@ -14,6 +14,7 @@ import { ValidateTextTypes } from "@/components/DesignForm/validateText";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { formatNumber } from "@/api/DesignForm/utils"; import { formatNumber } from "@/api/DesignForm/utils";
import { getOrgTreeList } from "@/api/hr/org/index"; import { getOrgTreeList } from "@/api/hr/org/index";
import AssociatedformsForCreate from "@/widget/associatedforms/associatedFormsForCreate.vue";
import { orgInfo } from "@/api/hr/org/type"; import { orgInfo } from "@/api/hr/org/type";

242
src/widget/associatedforms/associatedFormsForCreate.vue

@ -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…
Cancel
Save