You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
219 lines
4.7 KiB
219 lines
4.7 KiB
<!--
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-11-14 11:36:15
|
|
@ 备注: 级联选择器
|
|
-->
|
|
<script lang='ts' setup>
|
|
import { FormList } from '@/api/lowCode/form/type';
|
|
import { nodePoweInfo,powerAryInfo } from '@/api/workFlow/type'
|
|
|
|
const props = withDefaults(
|
|
defineProps<{
|
|
modelValue?: string
|
|
disabled?: boolean
|
|
action?: string
|
|
name?: string
|
|
fileList?: Object
|
|
control?: Object
|
|
config?: Object
|
|
data?: FormList
|
|
options?: any
|
|
types?: number
|
|
}>(),
|
|
{}
|
|
)
|
|
const emits = defineEmits<{
|
|
(e: 'update:modelValue', value: string): void
|
|
}>()
|
|
const value = computed({
|
|
get: () => {
|
|
// console.log("图片上传处理-112->",props.modelValue)
|
|
if(props.modelValue != "" && props.modelValue != undefined){
|
|
if(Array.isArray(props.modelValue)){
|
|
return props.modelValue
|
|
}else{
|
|
return JSON.parse(props.modelValue);
|
|
}
|
|
}else{
|
|
return ""
|
|
}
|
|
|
|
},
|
|
set: (newVal: any) => {
|
|
emits('update:modelValue', newVal)
|
|
return newVal
|
|
},
|
|
});
|
|
const handleChange = () => {
|
|
|
|
}
|
|
/**
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-06-11 09:06:05
|
|
@ 功能: 获取值
|
|
*/
|
|
const valPrint = (val:string,orgList:any) => {
|
|
let title = treeData(orgList)
|
|
let nameAry = new Array
|
|
console.log("递归查询-2--->",val,title)
|
|
if(val != "" && val != undefined){
|
|
if(Array.isArray(val)){
|
|
console.log("递归查询-4--->",val)
|
|
val.forEach((vItem:any) => {
|
|
if(Array.isArray(title)){
|
|
console.log("递归查询-3--->",vItem,title)
|
|
title.forEach((item:TreeNodeInfo) => {
|
|
if(vItem == item.value){
|
|
nameAry.push(item.label)
|
|
}
|
|
})
|
|
}
|
|
})
|
|
}else{
|
|
let valAry = JSON.parse(val);
|
|
console.log("递归查询-45--->",val)
|
|
valAry.forEach((vItem:any) => {
|
|
if(Array.isArray(title)){
|
|
console.log("递归查询-3--->",vItem,title)
|
|
title.forEach((item:TreeNodeInfo) => {
|
|
if(vItem == item.value){
|
|
nameAry.push(item.label)
|
|
}
|
|
})
|
|
}
|
|
})
|
|
|
|
}
|
|
}
|
|
console.log("递归查询-1--->",nameAry)
|
|
if(nameAry.length > 0){
|
|
return nameAry.join("、")
|
|
}else{
|
|
return ""
|
|
}
|
|
}
|
|
/**
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-06-11 09:10:37
|
|
@ 功能: 递归处理树循环数据
|
|
*/
|
|
// 定义树节点接口
|
|
interface TreeNode {
|
|
value: number;
|
|
label: string;
|
|
children?: TreeNode[];
|
|
}
|
|
interface TreeNodeInfo {
|
|
value: number;
|
|
label: string;
|
|
}
|
|
|
|
function treeData(node: TreeNode[],title?: TreeNodeInfo[]){
|
|
|
|
// let title = new Array
|
|
if(Array.isArray(node)){
|
|
node.forEach((item:TreeNode) => {
|
|
if(Array.isArray(title)){
|
|
title.push({
|
|
value:item.value,
|
|
label:item.label
|
|
});
|
|
}else{
|
|
title =[{
|
|
value:item.value,
|
|
label:item.label
|
|
}];
|
|
}
|
|
if (item.children) {
|
|
|
|
if(Array.isArray(item.children)){
|
|
treeData(item.children,title)
|
|
// for (const child of item.children) {
|
|
// treeData(child,title)
|
|
// }
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
return title;
|
|
}
|
|
//获取阶段权限判断
|
|
const allNodePwoer = inject('flowNodePower') as any
|
|
const currentNodePowerKey = inject('currentNodeKey') as any
|
|
|
|
//获取当前节点授权
|
|
const curNodePowerAry = () => {
|
|
if(currentNodePowerKey && currentNodePowerKey.value && currentNodePowerKey.value != ""){
|
|
if(allNodePwoer.value && Array.isArray(allNodePwoer.value) && allNodePwoer.value.length > 0){
|
|
let powerAry: any[] = []
|
|
allNodePwoer.value.forEach((item:nodePoweInfo) => {
|
|
if(item.nodeKey == currentNodePowerKey.value){
|
|
powerAry = item.powerAry
|
|
}
|
|
})
|
|
return powerAry
|
|
}else{
|
|
return []
|
|
}
|
|
}else{
|
|
return []
|
|
}
|
|
}
|
|
/**
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-11-06 14:03:21
|
|
@ 功能: 判断此组件是否可见
|
|
*/
|
|
const judgeIsShow = (key: string) => {
|
|
let myPower = curNodePowerAry() //获取权限数组
|
|
if(Array.isArray(myPower) && myPower.length > 0){
|
|
let isOk = true
|
|
myPower.forEach((item:powerAryInfo) => {
|
|
if(key == item.id){
|
|
isOk = item.isLook
|
|
}
|
|
})
|
|
return isOk
|
|
}else{
|
|
return true
|
|
}
|
|
}
|
|
/**
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-11-06 14:03:21
|
|
@ 功能: 判断此组件是否可编辑
|
|
*/
|
|
const judgeIsEdit = (key: string) => {
|
|
let myPower = curNodePowerAry() //获取权限数组
|
|
if(Array.isArray(myPower) && myPower.length > 0){
|
|
let isOk = false
|
|
myPower.forEach((item:powerAryInfo) => {
|
|
if(key == item.id){
|
|
isOk = !item.isEdit
|
|
}
|
|
})
|
|
return isOk
|
|
}else{
|
|
return false
|
|
}
|
|
}
|
|
const data = computed(() => {
|
|
return props.data || {name:""}
|
|
})
|
|
</script>
|
|
<template>
|
|
<el-cascader
|
|
v-if="props.types!=3&&judgeIsShow(data.name)"
|
|
v-model="value"
|
|
:options="props.options"
|
|
:disabled="judgeIsEdit(data.name)"
|
|
@change="handleChange"
|
|
/>
|
|
<el-text v-else class="wordColor">{{valPrint(value,props.options)}}</el-text>
|
|
</template>
|
|
<style lang='scss' scoped>
|
|
.wordColor{
|
|
color:#000000;
|
|
}
|
|
</style>
|
|
|