Browse Source

关联表单-数据填充规则-v0.1

lwx_v6
liwenxuan 1 year ago
parent
commit
4bcdf4d84a
  1. 32
      src/components/DesignForm/assembly/index.ts
  2. 183
      src/components/DesignForm/formControlPropertiNew.vue
  3. 4
      src/widget/associatedforms/associatedFormsFillRole.vue

32
src/components/DesignForm/assembly/index.ts

@ -906,13 +906,31 @@ export default [
},
saveFlag: false,
asfasfLabel:'',
fillRoles: [
{
leftValue: '',
rightValue: '',
id: '',
}
],
fillRoles: {
master: [
{
leftValue: '',
rightValue: '',
id: '',
},
],
child: [
{
id: '',
tableKey: '',
filterCondition:{
conditionHtml: '',
conditionHtmlCopy: '',
gongShi:{
formulaHtml:'',
mathsFormula:'',
mathsString:'',
},
},
childRoles:[]
},
],
},
},
config: {}
},

183
src/components/DesignForm/formControlPropertiNew.vue

@ -1781,9 +1781,9 @@ const showImagePreview = ref(false)
controlData.value.item.label = "关联表单"
}
controlData.value.item.showLabel = true */
console.log(controlData.value.control.fillRoles)
if(controlData.value.control.fillRoles.length==0){
controlData.value.control.fillRoles = [
console.log(controlData.value.control.fillRoles.master)
if(controlData.value.control.fillRoles&&controlData.value.control.fillRoles.master.length==0){
controlData.value.control.fillRoles.master = [
{
leftValue: '',
rightValue: '',
@ -1791,7 +1791,26 @@ const showImagePreview = ref(false)
}
]
}
controlData.value.control.fillRoles[0].id = uuidv4().replaceAll('-','').toString();
if(controlData.value.control.fillRoles&&controlData.value.control.fillRoles.child.length==0){
controlData.value.control.fillRoles.child = [
{
id: '',
tableKey: '',
filterCondition:{
conditionHtml: '',
conditionHtmlCopy: '',
gongShi:{
formulaHtml:'',
mathsFormula:'',
mathsString:'',
},
},
childRoles:[]
},
]
}
controlData.value.control.fillRoles.master[0].id = uuidv4().replaceAll('-','').toString();
controlData.value.control.fillRoles.child[0].id = uuidv4().replaceAll('-','').toString();
}
// start
// console.log(controlData.value.name)
@ -2011,6 +2030,7 @@ const transferDataSourceOptions = [
import AssociatedFormsTinyace from '@/widget/associatedforms/associatedFormsTinyace.vue'
import AssociatedFormsTinyaceRange from '@/widget/associatedforms/associatedFormsTinyaceRange.vue'
import AssociatedFormsFillRole from '@/widget/associatedforms/associatedFormsFillRole.vue'
import AssociatedFormsChildFillRole from '@/widget/associatedforms/associatedFormsChildFillRole.vue'
const treeDefaultProps = {
children: 'children',
@ -2077,8 +2097,14 @@ function getAsfasfFieldTreeOptionsValue3() {
//
const asfasfFieldTree = ref<Tree[]>()
const asfasfMasterFieldTree = ref<Tree[]>()
const asfasfChildTableList = ref<Tree[]>()
const asfasfFieldTreeOptionsValue3 = ref<Tree[]>()
let currentChildTableCount = 0
function formidChanged(){
if(controlData.value.control.formid===''){
@ -2090,12 +2116,43 @@ function formidChanged(){
//alert("cfid")
}else{
let resData = ref(data.children)
//let rootid_ = data.value.label
let dataExceptChild = JSON.parse(JSON.stringify(data.children))
let dataOnlyChild = JSON.parse(JSON.stringify(data.children))
dataExceptChild = dataExceptChild.filter((obj: { type: string }) => obj.type!== 'table');
dataOnlyChild = dataOnlyChild.filter((obj: { type: string }) => obj.type== 'table');
for(let m = 0;m<dataOnlyChild.length;m++){
dataOnlyChild[m].children = []
}
let resDataExceptChild = ref(dataExceptChild)
let resDataOnlyChild = ref(dataOnlyChild)
//console.log(resDataOnlyChild.value)
let childTableCount = 0
for(let n = 0;n<resDataOnlyChild.value.length;n++){
console.log(resDataOnlyChild.value[n])
childTableCount++
}
console.log(childTableCount)
currentChildTableCount = childTableCount
asfasfFieldTree.value = [{
id: 'rootid_'+data.label,
label: '关联的表单-'+data.label,
children: [...resData.value],
treeAttrs: data.treeAttrs,
disabled:true,
}]
asfasfMasterFieldTree.value = [{
id: 'rootid_'+data.label,
label: '关联的表单-'+data.label,
children: [...resDataExceptChild.value],
treeAttrs: data.treeAttrs,
disabled:true,
}]
asfasfChildTableList.value = [{
id: 'rootid_'+data.label,
label: '关联的表单-'+data.label,
children: [...resDataOnlyChild.value],
treeAttrs: data.treeAttrs,
disabled:true,
}]
}
controlData.value.control.asfasfLabel = data.label
@ -2190,6 +2247,7 @@ getAssociatedFormsCurrentFieldTree().then(({ data }) => {
label: '当前表单-'+data.treeAttrs.show,
children: [...resData.value],
treeAttrs: data.treeAttrs,
disabled: true,
}]
resDataNoTable = resDataNoTable.filter((item: { type: string | null }) => item.type!="table")
@ -2382,13 +2440,46 @@ function associatedFormsDataRangeDialoghandle(){
//alert("cfid")
}else{
let resData = ref(data.children)
//let rootid_ = data.value.label
let dataExceptChild = JSON.parse(JSON.stringify(data.children))
let dataOnlyChild = JSON.parse(JSON.stringify(data.children))
dataExceptChild = dataExceptChild.filter((obj: { type: string }) => obj.type!== 'table');
dataOnlyChild = dataOnlyChild.filter((obj: { type: string }) => obj.type== 'table');
for(let m = 0;m<dataOnlyChild.length;m++){
dataOnlyChild[m].children = []
}
let resDataExceptChild = ref(dataExceptChild)
let resDataOnlyChild = ref(dataOnlyChild)
//console.log(asfasfChildTableList.value)
//console.log(resDataOnlyChild.value)
let childTableCount = 0
for(let n = 0;n<resDataOnlyChild.value.length;n++){
console.log(resDataOnlyChild.value[n])
childTableCount = n;
}
console.log(childTableCount)
currentChildTableCount = childTableCount
asfasfFieldTree.value = [{
id: 'rootid_'+data.label,
label: '关联的表单-'+data.label,
children: [...resData.value],
treeAttrs: data.treeAttrs,
disabled:true,
}]
asfasfMasterFieldTree.value = [{
id: 'rootid_'+data.label,
label: '关联的表单-'+data.label,
children: [...resDataExceptChild.value],
treeAttrs: data.treeAttrs,
disabled:true,
}]
asfasfChildTableList.value = [{
id: 'rootid_'+data.label,
label: '关联的表单-'+data.label,
children: [...resDataOnlyChild.value],
treeAttrs: data.treeAttrs,
disabled:true,
}]
}
});
@ -2514,15 +2605,44 @@ watch(()=>store.activeKey, () => {
function addFillRole(){
let onlyNumber = uuidv4().replaceAll('-','').toString(); //
controlData.value.control.fillRoles.push({
controlData.value.control.fillRoles.master.push({
leftValue:'',
rightValue:'',
id:onlyNumber,
})
}
function addChildFillRole(){
let onlyNumber = uuidv4().replaceAll('-','').toString(); //
controlData.value.control.fillRoles.child.push({
id: onlyNumber,
tableKey: '',
filterCondition:{
conditionHtml: '',
conditionHtmlCopy: '',
gongShi:{
formulaHtml:'',
mathsFormula:'',
mathsString:'',
},
},
childRoles:[]
})
}
function delRole(id:String){
const delRoleData:any = controlData.value.control.fillRoles
const delRoleData:any = controlData.value.control.fillRoles.master
for (var i = 0; i < delRoleData.length; i++) {
if(delRoleData[i].id===id){
delRoleData.splice(i, 1);
i--; //
}
}
}
function delChildRole(id:String){
const delRoleData:any = controlData.value.control.fillRoles.child
for (var i = 0; i < delRoleData.length; i++) {
if(delRoleData[i].id===id){
delRoleData.splice(i, 1);
@ -4388,16 +4508,47 @@ const radioChangeSet = (val:any) => {
<el-dialog v-model="associatedFormsFillRolesDialogFlag" title="数据填充规则" top="150px" :close-on-click-modal="false" :show-close="false" style="margin-top:70px ;min-height: 800px" width="80%" >
<template v-if="controlData.type=='associatedForms'">
<el-divider style="margin-top: 0px;" />
<div style="margin-top: -10px;"><span style="color: grey;">当选择具体数据后将按如下规则给当前表单字段填充数据 </span></div>
<el-button style="font-size: large;margin-top: 3px;" type="primary" link append-to-body="true" modal="true" @click="addFillRole"> 添加规则</el-button>
<el-divider />
<div style="height:600px;border:1px solid white;overflow-y:auto">
<div style="height:600px;border:1px solid white;overflow-y:auto;">
<el-button style="font-size: large;margin-top: 10px;margin-bottom: 15px;" type="primary" link append-to-body="true" modal="true" @click="addFillRole"> 主表填充规则</el-button>
<div style="background-color: #E6F3FE;padding: 12px;border-radius: 10px;padding-left:45px;margin-bottom:20px;padding-bottom: 1px;"><!-- #F5F7FA -->
<template v-for="(item, index) in controlData.control.fillRoles.master" :key="controlData.control.fillRoles.master[index].id">
<AssociatedFormsFillRole
v-model:left-value="controlData.control.fillRoles.master[index].leftValue"
v-model:right-value="controlData.control.fillRoles.master[index].rightValue"
:left-tree-source = "asfasfMasterFieldTree"
:right-tree-source = "associatedFormsCurrentFormFieldTree"
:current-key="controlData.control.fillRoles.master[index].id"
@del-role = "delRole"
>
</AssociatedFormsFillRole>
</template>
</div>
<template v-for="(item, index) in controlData.control.fillRoles" :key="controlData.control.fillRoles[index].id">
<AssociatedFormsFillRole v-model:left-value="controlData.control.fillRoles[index].leftValue" v-model:right-value="controlData.control.fillRoles[index].rightValue" :left-tree-source = "asfasfFieldTree" :right-tree-source = "associatedFormsCurrentFormFieldTree" :current-key="controlData.control.fillRoles[index].id" @del-Role = "delRole" ></AssociatedFormsFillRole>
<el-popover
v-if="currentChildTableCount>0"
placement="right-end"
title=""
:width="200"
trigger="hover"
content="【关联表单子表字段】暂不支持填充至【当前表单主表字段】; 若【设置筛选条件】,则仅填充满足筛选条件的子表数据"
>
<template #reference>
<el-button style="font-size: large;margin-top: 3px;margin-bottom: 15px;" type="primary" link append-to-body="true" modal="true" @click="addChildFillRole"> 子表填充规则</el-button>
</template>
</el-popover>
<div v-if="currentChildTableCount>0"><!-- asfasfChildTableList -->
<template v-for="(item, index) in controlData.control.fillRoles.child" :key="controlData.control.fillRoles.child[index].id">
<AssociatedFormsChildFillRole
:current-key="controlData.control.fillRoles.child[index].id"
:child-table-list="asfasfChildTableList"
@del-role = "delChildRole"
>
</AssociatedFormsChildFillRole>
</template>
<div style="height:2000px"></div>
</div>
</div>
</template>

4
src/widget/associatedforms/associatedFormsFillRole.vue

@ -2,12 +2,12 @@
<div style="margin-bottom: 15px; height: 40px; line-height: 40px;">
<el-tree-select
v-model="leftValue1" style="width: 290px;" :data="leftTreeSource"
v-model="leftValue1" style="width: 290px;" :data="leftTreeSource" placeholder="关联表单主表字段"
check-strictly :render-after-expand="false" filterable @change="leftChanged" />
<span style="margin-left: 8px;margin-right: 8px;">的值填充到</span>
<el-tree-select
v-model="rightValue1" style="width: 290px;" :data="rightTreeSource"
check-strictly :render-after-expand="false" filterable @change="rightChanged" />
check-strictly :render-after-expand="false" placeholder="当前表单字段" filterable @change="rightChanged" />
<Delete style="width: 22px; height: 22px; margin-right: 35px;cursor: pointer; color: #50A6FF;margin-top: 10px; display: block; float:right" @click="delRole" />
</div>

Loading…
Cancel
Save