dict.vue
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<template>
<div class="app-container">
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="字典" name="dict">
<DictList :switchToDetail="switchToDetail" :sendParams="sendParams" />
</el-tab-pane>
<el-tab-pane label="字典明细" name="dictDetail">
<DictDetail
ref="dictDetailRef"
:dictCode="dictCode"
:dictName="dictName"
:dictId="dictId"
/>
</el-tab-pane>
</el-tabs>
</div>
</template>
<script>
import DictList from "./components/DictList";
import DictDetail from "./components/DictDetail";
export default {
name: "Dict",
components: {
DictList,
DictDetail,
},
data() {
return {
activeName: "dict",
dictCode: "",
dictName: "",
dictId: 0,
lastSentParams: null,
};
},
methods: {
handleClick(tab) {
// console.log("切换到标签:", tab.name);
},
switchToDetail() {
this.activeName = "dictDetail";
this.$refs.dictDetailRef.fuzhi();
},
sendParams(code, name, id) {
if (this.shouldUpdateParams(code, name, id)) {
this.dictCode = code;
this.dictName = name;
this.dictId = id;
this.lastSentParams = { code, name, id };
this.$nextTick(() => {
this.switchToDetail();
});
}
},
shouldUpdateParams(code, name, id) {
return (
!this.lastSentParams ||
this.lastSentParams.code !== code ||
this.lastSentParams.name !== name ||
this.lastSentParams.id !== id
);
},
},
};
</script>
<style scoped></style>