|
@@ -12,6 +12,7 @@ const emits = defineEmits<{
|
|
|
(e: "clear"): void
|
|
(e: "clear"): void
|
|
|
(e: "selected", type: string, key: string): void
|
|
(e: "selected", type: string, key: string): void
|
|
|
}>()
|
|
}>()
|
|
|
|
|
+const companyId = ref("")
|
|
|
const expandedKeys = ref<Array<string>>([])
|
|
const expandedKeys = ref<Array<string>>([])
|
|
|
const selectedKeys = ref<Array<string>>([])
|
|
const selectedKeys = ref<Array<string>>([])
|
|
|
const searchWord = ref("")
|
|
const searchWord = ref("")
|
|
@@ -27,6 +28,15 @@ function loadData(fun: () => void) {
|
|
|
(res) => {
|
|
(res) => {
|
|
|
data.value = res.data
|
|
data.value = res.data
|
|
|
fun && fun()
|
|
fun && fun()
|
|
|
|
|
+ if (!companyId.value && data.value[0]) {
|
|
|
|
|
+ const key = data.value[0].key
|
|
|
|
|
+ const arr = key.split("_")
|
|
|
|
|
+ emits("selected", arr[0], key)
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ expandedKeys.value = [key]
|
|
|
|
|
+ selectedKeys.value = [key]
|
|
|
|
|
+ }, 100)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
@@ -48,7 +58,7 @@ function findCompany(hasKey = true) {
|
|
|
let key = ""
|
|
let key = ""
|
|
|
//console.log(searchWord)
|
|
//console.log(searchWord)
|
|
|
data.value.forEach((v: any) => {
|
|
data.value.forEach((v: any) => {
|
|
|
- if ((hasKey && v.title == searchWord.value) || v.title.search(searchWord.value) >= 0) {
|
|
|
|
|
|
|
+ if ((hasKey && v.title == searchWord.value) || (searchWord.value && v.title.search(searchWord.value) >= 0)) {
|
|
|
key = v.key
|
|
key = v.key
|
|
|
} else {
|
|
} else {
|
|
|
if (v.children) {
|
|
if (v.children) {
|
|
@@ -59,7 +69,7 @@ function findCompany(hasKey = true) {
|
|
|
function _findCompany(list: Array<any>, key: string, fatherKey: string) {
|
|
function _findCompany(list: Array<any>, key: string, fatherKey: string) {
|
|
|
list.forEach((v) => {
|
|
list.forEach((v) => {
|
|
|
if (
|
|
if (
|
|
|
- (hasKey && v.key == "10_" + route.query.company_id) ||
|
|
|
|
|
|
|
+ (hasKey && v.key == "10_" + companyId.value) ||
|
|
|
(v.key.search("10_") >= 0 && v.title.search(searchWord.value) >= 0)
|
|
(v.key.search("10_") >= 0 && v.title.search(searchWord.value) >= 0)
|
|
|
) {
|
|
) {
|
|
|
key = v.key
|
|
key = v.key
|
|
@@ -118,6 +128,7 @@ function onNodeClick(nodeData: any) {
|
|
|
emits("node-click", nodeData)
|
|
emits("node-click", nodeData)
|
|
|
}
|
|
}
|
|
|
function init() {
|
|
function init() {
|
|
|
|
|
+ companyId.value = route.query.company_id as string
|
|
|
const name = route.query.comName as string
|
|
const name = route.query.comName as string
|
|
|
if (name) {
|
|
if (name) {
|
|
|
searchWord.value = name
|
|
searchWord.value = name
|