herenshan112 2 months ago
parent
commit
6340a49301
  1. 6
      src/components/DesignForm/assembly/index.ts
  2. 561
      src/components/DesignForm/formControlPropertiNew.vue

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

@ -696,7 +696,11 @@ export default [
tableData: [], // 子表表格列表数据集合
control: {
border: true,
defaultOne: ''
defaultOne: '',
preFill: {
asf: '',
ids: []
}
},
config: {
addBtnText: '添加一行'

561
src/components/DesignForm/formControlPropertiNew.vue

@ -14,6 +14,7 @@ import { ValidateTextTypes } from "@/components/DesignForm/validateText";
import { ElMessage } from "element-plus";
import { formatNumber } from "@/api/DesignForm/utils";
import { getOrgTreeList } from "@/api/hr/org/index";
import AssociatedformsForCreate from "@/widget/associatedforms/associatedformsForCreate.vue";
import { orgInfo } from "@/api/hr/org/type";
@ -831,6 +832,14 @@ const attrList = computed(() => {
vIf: state.isSearch,
vShow: ["table"],
},
{
label: "预填充设置",
value: config.table,
path: "config.table",
type: "table_preFill",
vIf: state.isSearch,
vShow: ["table"],
},
{
label: "关联填充",
value: config.orgCentent,
@ -2930,6 +2939,22 @@ const zdtcszTree = computed(()=>{
return []
}
})//
const xTree = computed(()=>{
if(datapropsformList&&datapropsformList.length==0){
datapropsformList = JSON.parse(JSON.stringify(props.formList))
}
if(associatedFormsCurrentFormFieldTreeForGlxxszExceptSelf && associatedFormsCurrentFormFieldTreeForGlxxszExceptSelf.value[0].children && associatedFormsCurrentFormFieldTreeForGlxxszExceptSelf.value[0].children.length>0){
let datab = JSON.parse(JSON.stringify(associatedFormsCurrentFormFieldTreeForGlxxszExceptSelf.value[0].children))
let currentCompId = controlData.value.name
//console.log(currentCompId)
const treeC = mergeAndFilterAssociatedForms(datapropsformList, datab);
return treeC
}else{
return []
}
})
// 使 ref computed使
@ -3154,6 +3179,408 @@ const handleDetermineZdtcszDialogFlag = () => {
}
/**
* 合并两个组件树仅保留type为table内的type为associatedForms的节点
* @param {Array} treeA - 组件树a包含表单结构信息
* @param {Array} treeB - 组件树b包含字段数据信息
* @returns {Array} - 合并后仅包含table内的associatedForms节点的组件树c
*/
function mergeAndFilterAssociatedForms(treeA, treeB) {
// bkeynameidvalueb
const bMap = new Map();
// bparentIdparentId
let commonParentId = null;
// idnameformField:30540:upload1765154030446 -> upload1765154030446
treeB.forEach(node => {
const id = node.id;
if (id) {
const parts = id.split(':');
const name = parts[parts.length - 1]; // name
bMap.set(name, node);
// parentId
if (node.parentId && !commonParentId) {
commonParentId = node.parentId;
}
}
});
// parentId使
if (!commonParentId) {
commonParentId = "formField:30540";
}
//
let tableCount = 0;
let gridCount = 0;
let tabsCount = 0;
let divCount = 0;
let cardCount = 0;
// atableassociatedForms
function processANode(node, parentId = commonParentId, isInTable = false) {
// nametype
const nodeName = node.name;
const nodeType = node.type;
// table
if (nodeType === 'table') {
tableCount++;
// b
let bNode = null;
if (nodeName && bMap.has(nodeName)) {
bNode = bMap.get(nodeName);
bMap.delete(nodeName);
}
let cNode;
const tableLabel = `子表${node.item?.label || nodeName || tableCount}`;
if (bNode) {
// b
cNode = { ...bNode };
// children
if (!cNode.children) {
cNode.children = [];
}
// 使bparentId
cNode.parentId = bNode.parentId || parentId;
// label
cNode.label = tableLabel;
// treeAttrs.show
if (cNode.treeAttrs) {
cNode.treeAttrs.show = tableLabel;
} else {
cNode.treeAttrs = { show: tableLabel };
}
// treeAname
cNode.name = nodeName;
} else {
// b
const id = nodeName ? `${commonParentId}:${nodeName}` : null;
cNode = {
id: id,
name: nodeName, // treeAname
label: tableLabel,
parentId: parentId,
children: [],
value: id,
treeAttrs: {
show: tableLabel
},
disabled: false, // table使
type: 'table'
};
}
// tableassociatedForms
let hasAssociatedForms = false;
if (node.list && Array.isArray(node.list)) {
const childNodes = [];
node.list.forEach(child => {
const processedChild = processANode(child, cNode.id, true); // isInTable=true
if (processedChild) {
childNodes.push(processedChild);
hasAssociatedForms = true;
}
});
cNode.children = childNodes;
}
// tableassociatedFormstable
if (!hasAssociatedForms) {
return null;
}
return cNode;
}
// associatedFormstable
if (nodeType === 'associatedForms' && isInTable) {
// b
let bNode = null;
if (nodeName && bMap.has(nodeName)) {
bNode = bMap.get(nodeName);
bMap.delete(nodeName); // map使
}
let cNode;
if (bNode) {
// b
cNode = { ...bNode };
// children
if (!cNode.children) {
cNode.children = [];
}
// 使bparentId
cNode.parentId = bNode.parentId || parentId;
// treeAname
cNode.name = nodeName;
// a
if (node.options && Array.isArray(node.options)) {
cNode.options = node.options;
}
if (node.control) {
if (!cNode.control) {
cNode.control = {};
}
// control
if (node.control.glxxsz) {
cNode.control.glxxsz = node.control.glxxsz;
}
if (node.control.modelValue !== undefined) {
cNode.control.modelValue = node.control.modelValue;
}
}
if (node.config) {
cNode.config = node.config;
}
} else {
// b
const label = node.item?.label || nodeName || 'associatedForms';
const id = nodeName ? `${commonParentId}:${nodeName}` : null;
cNode = {
id: id,
name: nodeName, // treeAname
label: label,
parentId: parentId,
children: [],
value: id,
treeAttrs: {
show: label
},
disabled: false, // associatedFormsdisabledfalse
type: 'associatedForms'
};
// a
if (node.options && Array.isArray(node.options)) {
cNode.options = node.options;
}
if (node.control) {
cNode.control = { ...node.control };
}
if (node.config) {
cNode.config = { ...node.config };
}
}
return cNode;
}
//
const containerTypes = ['card', 'flex', 'div', 'grid', 'tabs'];
if (containerTypes.includes(nodeType)) {
//
let containerId;
let containerLabel;
// idlabel
switch(nodeType) {
case 'grid':
gridCount++;
containerId = `格栅布局${gridCount}`;
containerLabel = containerId;
break;
case 'tabs':
tabsCount++;
containerId = `标签页${tabsCount}`;
containerLabel = containerId;
break;
case 'div':
divCount++;
containerId = `容器${divCount}`;
containerLabel = containerId;
break;
case 'card':
cardCount++;
containerId = `卡片${cardCount}`;
containerLabel = containerId;
break;
case 'flex':
// flexb
let bNode = null;
if (nodeName && bMap.has(nodeName)) {
bNode = bMap.get(nodeName);
bMap.delete(nodeName);
}
if (bNode) {
containerId = bNode.id || `${commonParentId}:${nodeName}`;
containerLabel = `弹性布局${bNode.label || nodeName}`;
} else {
containerId = `${commonParentId}:${nodeName}`;
containerLabel = `弹性布局${node.item?.label || nodeName}`;
}
break;
default:
containerId = `${commonParentId}:${nodeName}`;
containerLabel = node.item?.label || nodeName || nodeType;
}
//
const containerNode = {
id: containerId,
name: nodeName, // treeAname
label: containerLabel,
parentId: parentId,
children: [],
value: containerId,
treeAttrs: {
show: containerLabel
},
disabled: null, //
type: nodeType
};
//
let hasValidChildren = false;
if (nodeType === 'card' || nodeType === 'flex' || nodeType === 'div') {
// list
if (node.list && Array.isArray(node.list)) {
const childNodes = [];
node.list.forEach(child => {
const processedChild = processANode(child, containerId, false);
if (processedChild) {
childNodes.push(processedChild);
hasValidChildren = true;
}
});
containerNode.children = childNodes;
}
} else if (nodeType === 'grid' || nodeType === 'tabs') {
// columns.list
if (node.columns && Array.isArray(node.columns)) {
// tabscolumn
if (nodeType === 'tabs') {
const tabNodes = [];
node.columns.forEach((column, index) => {
// column
const columnId = `${containerId}:${column.label}`;
const columnNode = {
id: columnId,
name: column.label || `Tab${index + 1}`, // 使column.labelname
label: column.label || `Tab${index + 1}`,
parentId: containerId,
children: [],
value: columnId,
treeAttrs: {
show: column.label || `Tab${index + 1}`
},
disabled: null, //
type: 'tab'
};
// column
let columnHasValidChildren = false;
if (column.list && Array.isArray(column.list)) {
const childNodes = [];
column.list.forEach(child => {
const processedChild = processANode(child, columnId, false);
if (processedChild) {
childNodes.push(processedChild);
columnHasValidChildren = true;
hasValidChildren = true;
}
});
columnNode.children = childNodes;
}
// columntabs
if (columnHasValidChildren) {
tabNodes.push(columnNode);
}
});
containerNode.children = tabNodes;
} else {
// gridcolumns
const childNodes = [];
node.columns.forEach(column => {
if (column.list && Array.isArray(column.list)) {
column.list.forEach(child => {
const processedChild = processANode(child, containerId, false);
if (processedChild) {
childNodes.push(processedChild);
hasValidChildren = true;
}
});
}
});
containerNode.children = childNodes;
}
}
}
// null
if (!hasValidChildren) {
// flex使
if (nodeType === 'flex') {
containerNode.disabled = false;
return containerNode;
}
return null;
}
// disabled
// flex使disabledfalse
if (nodeType === 'flex') {
containerNode.disabled = false;
} else {
// nulltrue
containerNode.disabled = null;
}
return containerNode;
}
// null
return null;
}
// a
const cTree = [];
treeA.forEach(rootNode => {
const processedNode = processANode(rootNode);
if (processedNode) {
cTree.push(processedNode);
}
});
// bassociatedFormsac
// associatedFormstabletable
// bMapassociatedForms
bMap.forEach((bNode, nodeName) => {
if (bNode.type === 'associatedForms') {
// b
const newNode = { ...bNode };
// children
if (!newNode.children) {
newNode.children = [];
}
// disabledfalse
newNode.disabled = false;
// name
newNode.name = nodeName;
cTree.push(newNode);
}
});
return cTree;
}
/**
* 合并两个组件树仅保留type为radio和select的节点并过滤掉指定compId的节点同时保留options属性
* @param {Array} treeA - 组件树a包含表单结构信息
@ -5187,6 +5614,80 @@ const requiredTextRadio = (val: any) => {
}
};
// liwenxuan 20260204 start
const preFillDialogFlag = ref(false)
function preFillDialogShow(){
preFillDialogFlag.value = true
}
function preFillDialogDetermine(){
preFillDialogFlag.value = false
}
const asfsCurrentTable = computed(()=>{
let currentTable = []
let count = 0
let result = []
xTree.value.forEach((element:any) => {
if(getAfterLastColon(element.value) == controlData.value.name){
currentTable.push(element)
count++
}
});
if(count>0){
result = currentTable[0].children
}else{
result = []
}
return result
})
const asfPropsData = computed(()=>{
let result = {}
asfsCurrentTable.value.forEach((element:any) => {
if(element.id==controlData.value.control.preFill.asf){
result = element
}else{
result = {}
}
});
return result
})
/**
* 提取字符串中最后一个英文冒号后的内容无冒号则返回原字符串
* @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);
}
// liwenxuan 20260204 end
/**
@ 作者: 秦东
@ 时间: 2024-08-14 13:21:43
@ -6281,6 +6782,20 @@ const formatTooltip = (val: number) => {
</el-row>
<el-row v-else-if="item.type === 'table_preFill'">
<el-link
:underline="false"
type="primary"
@click="preFillDialogShow"
>
预填充设置
</el-link>
</el-row>
<el-row v-else-if="item.type === 'orgCentent_ConnectUser'">
<!-- <div v-if="controlData.control.connectUserComponent && controlData.control.connectUserComponent.length>0"> -->
@ -8842,7 +9357,53 @@ const formatTooltip = (val: number) => {
<!-- 选项批量编辑 liwenxuan 20251212 end -->
<!-- 子表预填充设置 liwenxuan 20260204 start -->
<el-dialog
v-model="preFillDialogFlag"
title="子表预填充设置"
width="700px"
:close-on-click-modal="false"
:close-on-press-escape="false"
style="--el-dialog-padding-primary: 20px; border-radius: 8px; box-shadow: 0 2px 16px rgba(0,0,0,0.08); border: none; "
>
<!-- {{ currentFormChildTableFieldsForFillRole[0].children}} -->
<!-- {{ controlData.name}} -->
{{ asfsCurrentTable }}
<hr>
{{ controlData.control.preFill.asf }}
<hr>
{{ asfPropsData }}
<!-- -->
<!-- 选择本子表中的某个关联表单,若没有则显示 本子表内没有关联表单,请添加后再试.
若选择的关联表单没有数据,则显示 选择的关联表单暂无数据,无法选择关联记录 -->
<div style="display: flex; margin-bottom: 20px; margin-top: 20px;width: 100%;">
<span style="font-size: larger; margin-left: 35px; margin-right: 15px"
>请选择关联表单</span
>
<el-tree-select
v-model="controlData.control.preFill.asf"
style="width: 60%"
:data="asfsCurrentTable"
clearable
/>
</div>
<!--关联表单-->
<AssociatedformsForCreate
:data="asfPropsData"
/>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="preFillDialogDetermine"> 确定 </el-button>
</div>
</template>
</el-dialog>
<!-- 子表预填充设置 liwenxuan 20260204 end -->
<!-- 单选下拉多选选项来源value3--系统表单字段 start-->

Loading…
Cancel
Save