Browse Source

选择用户联动效果实现v1.0

lwx_v27
liwenxuan 2 weeks ago
parent
commit
181eae4803
  1. 2
      src/components/DesignForm/public/expand/org.vue
  2. 2
      src/components/DesignForm/public/expand/rangedUserTree.vue
  3. 129
      src/components/DesignForm/public/form/form.vue

2
src/components/DesignForm/public/expand/org.vue

@ -309,7 +309,7 @@ function filterTreeNodes(nodes: any[], keepIds: Set<unknown>) {
const multiple = props.data.control.multiple=='1'
</script>
<template>
<template>{{ props.data.name }}
<el-tree-select
v-bind="$props"
v-model="value"

2
src/components/DesignForm/public/expand/rangedUserTree.vue

@ -277,7 +277,7 @@ function hasNodesInTree(tree) {
{{ loading ? '正在加载' : '无数据' }}
</div>
</template>
</el-tree-select><!-- <button >{{ location }}</button> -->
</el-tree-select>
</div>
</template>
<style lang='scss' scoped>

129
src/components/DesignForm/public/form/form.vue

@ -1776,6 +1776,71 @@ const location = ref('North Pole')
function updateLocation(currentValue: any,currentComp:any) {
location.value = currentValue+currentComp
let deepCopyedCurrentValue:string = JSON.stringify(toRaw(currentValue))
let workNumber = getParenthesesContent(deepCopyedCurrentValue)
console.log(workNumber)
let mainOrg = 309
getMainOrgByWorkNumber({workNumber:workNumber}).then(({ data }) => {
console.log(data)
mainOrg = data*1
}).finally(()=>{
// user org
let connectOrgs: any[] = []
selectOrgs.forEach((element:any) => {
if(element.control.connectUserComponent){
let realCurrentCompName = getAfterLastColon(element.control.connectUserComponent)
if(currentComp == realCurrentCompName){
connectOrgs.push(element)
}
}
});
let deepCopyedConnectOrgs = JSON.parse(JSON.stringify(connectOrgs))
//console.log(selectOrgsPath)
deepCopyedConnectOrgs.forEach((element:any) => {
selectOrgsPath.forEach((item: any) => {
if(item.obj==element.name){
if(item.path==undefined || item.path=="" || item.path=="undefined"){
element.path = ""
}else{
element.path = item.path
}
}
});
if(element.path==""){
model.value[element.name] = mainOrg
}else{
let length = model.value[element.path].length
//console.log(length)
model.value[element.path].forEach((x:any) => {
x[element.name] = mainOrg
});
//model.value[element.path][element.name] = 309
}
});
//console.log(deepCopyedConnectOrgs)
console.log(model.value)
});
}
function getMainOrgByWorkNumber(obj: { workNumber: string}) {
return request({
url: "/javasys/lowCode/manCont/getMainOrgByWorkNumber",
method: "post",
data: obj,
});
}
function getParenthesesContent(str:string) {
//console.log(str)
const match = str.match(/\((.*?)\)/);
return match ? match[1] : '';
}
provide('location', {
@ -1783,7 +1848,38 @@ provide('location', {
updateLocation
})
/**
* 提取字符串中最后一个英文冒号后的内容无冒号则返回原字符串
* @param {string} str - 输入的字符串
* @returns {string} 最后一个冒号后的内容或原字符串
*/
function getAfterLastColon(str:string) {
//
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 2025-11-11 end
function modifyTreeData(treeData, idList) {
//console.log("modifyTreeDataMinimal ");
let gkFlag = true
@ -2057,10 +2153,13 @@ function groupExpandUserConfigs(configs) {
const asfs: any[] = [];
const rangedUsers :any= [];
const selectOrgs :any = [];
const selectOrgsPath :any = [];
const tables: any[] = [];
const getAsfsRunedFlag = ref(false)
function getAsfs() {
/* setTimeout(() => { */
if(props.formData.list&&props.formData.list.length>0){
@ -2071,26 +2170,38 @@ function getAsfs() {
if (dataList && Array.isArray(dataList.value) && dataList.value.length > 0) {
for (let i = 0; i < dataList.value.length; i++) {
let for1Name = dataList.value[i].name
if (dataList.value[i].type == "associatedForms") {
asfs.push(dataList.value[i]);
} else if(dataList.value[i].type == "expand-user"){
rangedUsers.push(dataList.value[i]);
} else if(dataList.value[i].type == "orgCentent"){
let pathObj = {path:"",obj: dataList.value[i].name}
selectOrgsPath.push(pathObj)
selectOrgs.push(dataList.value[i]);
}else if (
dataList.value[i].type == "card" ||
dataList.value[i].type == "flex" ||
dataList.value[i].type == "div" ||
dataList.value[i].type == "table"
) {
if (dataList.value[i].type == "table") {
tables.push(dataList.value[i]);
}
dataList.value[i].list.forEach((element: any) => {
if (element.type == "associatedForms") {
asfs.push(element);
}else if(element.type == "expand-user"){
rangedUsers.push(element);
}
rangedUsers.push(element);
}else if(element.type == "orgCentent"){
let pathObj = {path:""+for1Name,obj:element.name}
selectOrgsPath.push(pathObj)
selectOrgs.push(element);
}
});
} else if (dataList.value[i].type == "grid") {
let columns = JSON.parse(JSON.stringify(dataList.value[i].columns));
@ -2104,6 +2215,10 @@ function getAsfs() {
asfs.push(a);
}else if(a.type == "expand-user"){
rangedUsers.push(a);
}else if(a.type == "orgCentent"){
let pathObj = {path:""+for1Name,obj:a.name}
selectOrgsPath.push(pathObj)
selectOrgs.push(a);
}
}
}
@ -2120,7 +2235,12 @@ function getAsfs() {
asfs.push(a);
} else if(a.type == "expand-user"){
rangedUsers.push(a);
} else if(a.type == "orgCentent"){
let pathObj = {path:""+for1Name,obj:a.name}
selectOrgsPath.push(pathObj)
selectOrgs.push(a);
}else if (a.type == "flex" || a.type == "table") {
let for2Name = a.name
if (a.type == "table") {
tables.push(dataList.value[i]);
}
@ -2133,6 +2253,10 @@ function getAsfs() {
asfs.push(q);
}else if(q.type == "expand-user"){
rangedUsers.push(q);
}else if(q.type == "orgCentent"){
let pathObj = {path:""+for2Name,obj:q.name}
selectOrgsPath.push(pathObj)
selectOrgs.push(q);
}
}
}
@ -2586,6 +2710,7 @@ const webPage = computed({
//
</script>
<template>
{{ model }}
<div v-if="webPage" class="webBox">
<el-form
v-bind="formData.form"

Loading…
Cancel
Save