diff --git a/src/components/formTable/index.vue b/src/components/formTable/index.vue index 92ecc53..49be0cf 100644 --- a/src/components/formTable/index.vue +++ b/src/components/formTable/index.vue @@ -12,7 +12,7 @@ import { appendOrRemoveStyle, constControlChange, constFormBtnEvent, constFormPr import { currencyFormApiSubmit, createAppTask, saveDraftAgain } from '@/api/lowCode/taskapi/management' import formatResult from '@/utils/lowCode/formatResult' -import { useAttrs,computed, onMounted, nextTick,ref,watch,onBeforeMount} from 'vue' +import { useAttrs,computed, onMounted, nextTick,ref,watch,onBeforeMount,provide} from 'vue' const props = withDefaults( defineProps<{ @@ -2239,6 +2239,9 @@ function groupExpandUserConfigs(configs) { const rangedUserTrees1= ref([]); const rangedUserTrees :any= []; +const selectOrgs :any = []; +const rangedUsersPath :any= []; +const selectOrgsPath :any = []; function getAsfs() { /* setTimeout(() => { */ @@ -2248,81 +2251,116 @@ function getAsfs() { dataList.value = props.formData.list; if (dataList && Array.isArray(dataList.value) && dataList.value.length > 0) { - for (let i = 0; i < dataList.value.length; i++) { - //console.log(dataList.value[i]) - if (dataList.value[i].type == "associatedForms") { - asfs.push(dataList.value[i]); - } else if(dataList.value[i].type == "expand-user"){ - rangedUserTrees.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"){ - rangedUserTrees.push(element) - } - }); - } else if (dataList.value[i].type == "grid") { - let columns = JSON.parse(JSON.stringify(dataList.value[i].columns)); - - if (columns.length > 0) { - for (let z = 0; z < columns.length; z++) { - for (let x = 0; x < columns[z].list.length; x++) { - let a = JSON.parse(JSON.stringify(columns[z].list[x])); - - if (a.type == "associatedForms") { - asfs.push(a); - }else if (a.type == "expand-user") { - rangedUserTrees.push(a); - } - } - } - } - } else if (dataList.value[i].type == "tabs") { - //tabs标签页有可能再嵌套一层flex或者table - let columns = JSON.parse(JSON.stringify(dataList.value[i].columns)); - if (columns.length > 0) { - for (let z = 0; z < columns.length; z++) { - for (let x = 0; x < columns[z].list.length; x++) { - let a = JSON.parse(JSON.stringify(columns[z].list[x])); - - if (a.type == "associatedForms") { - asfs.push(a); - }else if(a.type == "expand-user"){ - rangedUserTrees.push(a); - } else if (a.type == "flex" || a.type == "table") { - if (a.type == "table") { - tables.push(dataList.value[i]); - } - - if (a.list.length > 0) { - for (let m = 0; m < a.list.length; m++) { - let q = JSON.parse(JSON.stringify(a.list[m])); - - if (q.type == "associatedForms") { - asfs.push(q); - }else if (q.type == "expand-user") { - rangedUserTrees.push(q); - } - } - } - } - } - } - } - } - } - checkRangedUserTreesAndGet() - } + + 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"){ + let pathObj = {path:"",obj: dataList.value[i].name} + rangedUsersPath.push(pathObj) + rangedUserTrees.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"){ + let pathObj = {path:""+for1Name,obj:element.name} + rangedUsersPath.push(pathObj) + rangedUserTrees.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)); + + if (columns.length > 0) { + for (let z = 0; z < columns.length; z++) { + for (let x = 0; x < columns[z].list.length; x++) { + let a = JSON.parse(JSON.stringify(columns[z].list[x])); + + if (a.type == "associatedForms") { + asfs.push(a); + }else if(a.type == "expand-user"){ + let pathObj = {path:""+for1Name,obj:a.name} + rangedUsersPath.push(pathObj) + rangedUserTrees.push(a); + }else if(a.type == "orgCentent"){ + let pathObj = {path:""+for1Name,obj:a.name} + selectOrgsPath.push(pathObj) + selectOrgs.push(a); + } + } + } + } + } else if (dataList.value[i].type == "tabs") { + //tabs标签页有可能再嵌套一层flex或者table + let columns = JSON.parse(JSON.stringify(dataList.value[i].columns)); + if (columns.length > 0) { + for (let z = 0; z < columns.length; z++) { + for (let x = 0; x < columns[z].list.length; x++) { + let a = JSON.parse(JSON.stringify(columns[z].list[x])); + + if (a.type == "associatedForms") { + asfs.push(a); + } else if(a.type == "expand-user"){ + let pathObj = {path:""+for1Name,obj:a.name} + rangedUsersPath.push(pathObj) + rangedUserTrees.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]); + } + + if (a.list.length > 0) { + for (let m = 0; m < a.list.length; m++) { + let q = JSON.parse(JSON.stringify(a.list[m])); + + if (q.type == "associatedForms") { + asfs.push(q); + }else if(q.type == "expand-user"){ + let pathObj = {path:""+for2Name,obj:q.name} + rangedUsersPath.push(pathObj) + rangedUserTrees.push(q); + }else if(q.type == "orgCentent"){ + let pathObj = {path:""+for2Name,obj:q.name} + selectOrgsPath.push(pathObj) + selectOrgs.push(q); + } + } + } + } + } + } + } + } + } + checkRangedUserTreesAndGet() + } }else{ setTimeout(()=>{ getAsfs() @@ -2407,6 +2445,165 @@ function getAsfs() { + + +//实现选择用户选择时,自动填充选择组织 liwenxuan 2025-11-11 start + +const location = ref('North Pole') + +function updateLocation(currentValue: any,currentComp:any) { + let userPath = "" + rangedUsersPath.forEach((element: any) => { + if(element.obj==currentComp){ + userPath = element.path + } + }); + 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(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 + } + + } + }); + //console.log(element) + if(element.path==""){ + /* console.log(currentValue) + console.log(currentComp) + console.log(workNumber) */ + if(workNumber==""){ + model.value[element.name] = undefined + }else{ + model.value[element.name] = mainOrg + } + + }else{ + //console.log(model.value[element.path]) + + + model.value[element.path].forEach((x:any) => { + /* console.log(currentValue) + console.log(currentComp) + console.log(x) */ + + + if(userPath!=""){ + if(x[currentComp] == currentValue){ + if(workNumber==""){ + x[element.name] = undefined + }else{ + x[element.name] = mainOrg + } + } + + }else{ + if(workNumber==""){ + x[element.name] = undefined + }else{ + x[element.name] = mainOrg + } + } + + + + + + + + + + + }); + + } + + }); + //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', { + 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 + + + + defineExpose({ setOptions, setValue, diff --git a/src/components/lowCode/assistant/org.vue b/src/components/lowCode/assistant/org.vue index 9391d84..1342776 100644 --- a/src/components/lowCode/assistant/org.vue +++ b/src/components/lowCode/assistant/org.vue @@ -262,6 +262,13 @@ function filterTreeNodes(nodes: any[], keepIds: Set) { } const multiple = props.data.control.multiple == '1' +const disabled1 = computed(()=>{ + if(props.data.control.connectUserComponent&&props.data.control.connectUserComponent.length>0){ + return true + }else{ + return false + } +}) @@ -421,7 +428,7 @@ const valPrint = (val: any, orgList: orgInfo[]) => { :props="orgTreeProps" :data="orgTreeList" :render-after-expand="false" - + :disabled="disabled1" :show-checkbox="multiple" :multiple="multiple" :check-strictly="!multiple" diff --git a/src/components/lowCode/assistant/rangedUserTree.vue b/src/components/lowCode/assistant/rangedUserTree.vue index 26cc3ca..cf4d14e 100644 --- a/src/components/lowCode/assistant/rangedUserTree.vue +++ b/src/components/lowCode/assistant/rangedUserTree.vue @@ -1,5 +1,6 @@