Browse Source

用户组织联动填充

lwx_v12
liwenxuan 1 week ago
parent
commit
b705583735
  1. 215
      src/components/formTable/index.vue
  2. 9
      src/components/lowCode/assistant/org.vue
  3. 9
      src/components/lowCode/assistant/rangedUserTree.vue

215
src/components/formTable/index.vue

@ -12,7 +12,7 @@ import { appendOrRemoveStyle, constControlChange, constFormBtnEvent, constFormPr
import { currencyFormApiSubmit, createAppTask, saveDraftAgain } from '@/api/lowCode/taskapi/management' import { currencyFormApiSubmit, createAppTask, saveDraftAgain } from '@/api/lowCode/taskapi/management'
import formatResult from '@/utils/lowCode/formatResult' 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( const props = withDefaults(
defineProps<{ defineProps<{
@ -2239,6 +2239,9 @@ function groupExpandUserConfigs(configs) {
const rangedUserTrees1= ref([]); const rangedUserTrees1= ref([]);
const rangedUserTrees :any= []; const rangedUserTrees :any= [];
const selectOrgs :any = [];
const rangedUsersPath :any= [];
const selectOrgsPath :any = [];
function getAsfs() { function getAsfs() {
/* setTimeout(() => { */ /* setTimeout(() => { */
@ -2248,27 +2251,43 @@ function getAsfs() {
dataList.value = props.formData.list; dataList.value = props.formData.list;
if (dataList && Array.isArray(dataList.value) && dataList.value.length > 0) { if (dataList && Array.isArray(dataList.value) && dataList.value.length > 0) {
for (let i = 0; i < dataList.value.length; i++) { for (let i = 0; i < dataList.value.length; i++) {
//console.log(dataList.value[i]) let for1Name = dataList.value[i].name
if (dataList.value[i].type == "associatedForms") { if (dataList.value[i].type == "associatedForms") {
asfs.push(dataList.value[i]); asfs.push(dataList.value[i]);
} else if(dataList.value[i].type == "expand-user"){ } else if(dataList.value[i].type == "expand-user"){
rangedUserTrees.push(dataList.value[i]) let pathObj = {path:"",obj: dataList.value[i].name}
} else if ( 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 == "card" ||
dataList.value[i].type == "flex" || dataList.value[i].type == "flex" ||
dataList.value[i].type == "div" || dataList.value[i].type == "div" ||
dataList.value[i].type == "table" dataList.value[i].type == "table"
) { ) {
if (dataList.value[i].type == "table") { if (dataList.value[i].type == "table") {
tables.push(dataList.value[i]); tables.push(dataList.value[i]);
} }
dataList.value[i].list.forEach((element: any) => { dataList.value[i].list.forEach((element: any) => {
if (element.type == "associatedForms") { if (element.type == "associatedForms") {
asfs.push(element); asfs.push(element);
}else if(element.type == "expand-user"){ }else if(element.type == "expand-user"){
rangedUserTrees.push(element) 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") { } else if (dataList.value[i].type == "grid") {
@ -2281,8 +2300,14 @@ function getAsfs() {
if (a.type == "associatedForms") { if (a.type == "associatedForms") {
asfs.push(a); asfs.push(a);
}else if (a.type == "expand-user") { }else if(a.type == "expand-user"){
let pathObj = {path:""+for1Name,obj:a.name}
rangedUsersPath.push(pathObj)
rangedUserTrees.push(a); rangedUserTrees.push(a);
}else if(a.type == "orgCentent"){
let pathObj = {path:""+for1Name,obj:a.name}
selectOrgsPath.push(pathObj)
selectOrgs.push(a);
} }
} }
} }
@ -2297,9 +2322,16 @@ function getAsfs() {
if (a.type == "associatedForms") { if (a.type == "associatedForms") {
asfs.push(a); asfs.push(a);
}else if(a.type == "expand-user"){ } else if(a.type == "expand-user"){
let pathObj = {path:""+for1Name,obj:a.name}
rangedUsersPath.push(pathObj)
rangedUserTrees.push(a); rangedUserTrees.push(a);
} else if (a.type == "flex" || a.type == "table") { } 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") { if (a.type == "table") {
tables.push(dataList.value[i]); tables.push(dataList.value[i]);
} }
@ -2310,8 +2342,14 @@ function getAsfs() {
if (q.type == "associatedForms") { if (q.type == "associatedForms") {
asfs.push(q); asfs.push(q);
}else if (q.type == "expand-user") { }else if(q.type == "expand-user"){
let pathObj = {path:""+for2Name,obj:q.name}
rangedUsersPath.push(pathObj)
rangedUserTrees.push(q); rangedUserTrees.push(q);
}else if(q.type == "orgCentent"){
let pathObj = {path:""+for2Name,obj:q.name}
selectOrgsPath.push(pathObj)
selectOrgs.push(q);
} }
} }
} }
@ -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({ defineExpose({
setOptions, setOptions,
setValue, setValue,

9
src/components/lowCode/assistant/org.vue

@ -262,6 +262,13 @@ function filterTreeNodes(nodes: any[], keepIds: Set<unknown>) {
} }
const multiple = props.data.control.multiple == '1' 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" :props="orgTreeProps"
:data="orgTreeList" :data="orgTreeList"
:render-after-expand="false" :render-after-expand="false"
:disabled="disabled1"
:show-checkbox="multiple" :show-checkbox="multiple"
:multiple="multiple" :multiple="multiple"
:check-strictly="!multiple" :check-strictly="!multiple"

9
src/components/lowCode/assistant/rangedUserTree.vue

@ -1,5 +1,6 @@
<script lang='ts' setup> <script lang='ts' setup>
import { computed, ref, watch, onBeforeMount, nextTick } from 'vue' import { computed, ref, watch, onBeforeMount, nextTick } from 'vue'
const { location, updateLocation } = inject('location')
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
@ -54,6 +55,13 @@ const handleValueChange = (newValue) => {
value.value = newValue; value.value = newValue;
} }
} }
//, liwenxuan 2025-11-11 start
//,form
updateLocation(value.value,props.data.name)
//, liwenxuan 2025-11-11 end
} else { } else {
// //
if (newValue.length > 0) { if (newValue.length > 0) {
@ -81,6 +89,7 @@ const handleValueChange = (newValue) => {
} }
} }
watch(value, handleValueChange, { deep: true }) watch(value, handleValueChange, { deep: true })
const multiSelect = computed(()=>{ const multiSelect = computed(()=>{

Loading…
Cancel
Save