|
@@ -85,6 +85,10 @@ const props = defineProps({
|
|
|
type: Boolean,
|
|
|
default: false
|
|
|
},
|
|
|
+ classifyType: {
|
|
|
+ type: String,
|
|
|
+
|
|
|
+ },
|
|
|
})
|
|
|
|
|
|
//变量
|
|
@@ -104,6 +108,7 @@ const projectId = ref(props.projectId);
|
|
|
const contractId = ref(props.contractId);
|
|
|
const idPrefix = ref(props.idPrefix);
|
|
|
const isSubmitCounts = ref(props.submitCounts);
|
|
|
+const classifyTypedata=ref(props.classifyType)
|
|
|
|
|
|
//监听
|
|
|
watch(() => [
|
|
@@ -115,7 +120,8 @@ watch(() => [
|
|
|
props.contractId,
|
|
|
props.idPrefix,
|
|
|
props.submitCounts,
|
|
|
-], ([menus, isMark, AutoKeys, expandKeys, UserProjectId, UserContractId, UserIdPrefix, submitCounts]) => {
|
|
|
+ props.classifyType
|
|
|
+], ([menus, isMark, AutoKeys, expandKeys, UserProjectId, UserContractId, UserIdPrefix, submitCounts,ClassifyType]) => {
|
|
|
menusData.value = menus
|
|
|
menuMark.value = isMark
|
|
|
isAutoKeys.value = AutoKeys
|
|
@@ -124,6 +130,7 @@ watch(() => [
|
|
|
contractId.value = UserContractId
|
|
|
idPrefix.value = UserIdPrefix
|
|
|
isSubmitCounts.value = submitCounts
|
|
|
+ classifyTypedata.value=ClassifyType
|
|
|
})
|
|
|
|
|
|
//事件
|
|
@@ -131,9 +138,13 @@ const emit = defineEmits(['menuTap','nodeTap', 'nodeLoading'])
|
|
|
|
|
|
//树形结构异步加载数据
|
|
|
const defaultExpandedCids = ref([])
|
|
|
+const rootNode=ref({})
|
|
|
+const rootResolve=ref(null)
|
|
|
const ElTreeLoadNode = async (node, resolve) => {
|
|
|
let contractIdRelation = '', parentId = '', primaryKeyId = '';
|
|
|
if (node.level !== 0) {
|
|
|
+ rootNode.value = node
|
|
|
+ rootResolve.value = resolve
|
|
|
const nodeData = getObjValue(node?.data);
|
|
|
contractIdRelation = nodeData?.contractIdRelation || ''
|
|
|
parentId = contractIdRelation ? nodeData?.primaryKeyId : nodeData?.id
|
|
@@ -144,7 +155,8 @@ const ElTreeLoadNode = async (node, resolve) => {
|
|
|
contractId: contractId.value || '',
|
|
|
contractIdRelation,
|
|
|
primaryKeyId,
|
|
|
- parentId
|
|
|
+ parentId,
|
|
|
+ classifyType:classifyTypedata.value
|
|
|
})
|
|
|
//处理数据
|
|
|
if (!error && code === 200) {
|
|
@@ -185,7 +197,25 @@ const ElTreeLoadNode = async (node, resolve) => {
|
|
|
resolve([])
|
|
|
}
|
|
|
}
|
|
|
+ // 刷新tree
|
|
|
+ const resetNode=async()=>{
|
|
|
+ const theChildren = rootNode?.value.childNodes
|
|
|
+ theChildren?.splice(0, theChildren.length)
|
|
|
+ nextTick(()=>{
|
|
|
+ ElTreeLoadNode(rootNode.value, rootResolve.value)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+watch(classifyTypedata, (val) => {
|
|
|
+ if(val){
|
|
|
+ classifyTypedata.value=val
|
|
|
+ }
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+{immediate:true}
|
|
|
|
|
|
+)
|
|
|
//节点被点击
|
|
|
const ElTreeClick = async (data,node) => {
|
|
|
if (isAutoKeys.value) {
|
|
@@ -272,7 +302,8 @@ const removeElTreeNode = (key) => {
|
|
|
// 暴露出去
|
|
|
defineExpose({
|
|
|
setElTreeMenuMark,
|
|
|
- removeElTreeNode
|
|
|
+ removeElTreeNode,
|
|
|
+ resetNode
|
|
|
})
|
|
|
</script>
|
|
|
|