123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <template>
- <div>
- {{this.$store.state.user.deptName}}
- </div>
- <!--
- <treeselect
- style="
- width: 180px;
- height: 40px;
- position: relative;
- display: inline-block;
- line-height: 50px;
- "
- v-model="value"
- :options="options"
- :defaultExpandLevel="Infinity"
- />
- -->
- </template>
- <script>
- import { userdepttree } from "@/api/system/dept";
- import Treeselect from "@riophae/vue-treeselect";
- import "@riophae/vue-treeselect/dist/vue-treeselect.css";
- export default {
- components: { Treeselect },
- data() {
- return {
- value: null,
- options: [],
- Infinity: 2,
- num: 0,
- };
- },
- watch: {
- // 监听deptId
- value: "currDeptChange",
- },
- created() {
- this.getTreeselect();
- },
- methods: {
- /** 查询部门下拉树结构 */
- getTreeselect() {
- userdepttree().then((response) => {
- this.options = response.data;
- if (response.data != null && response.data.length > 0) {
- this.value = response.data[0].id;
- this.$store.selectDeptName = response.data[0].label;
- this.$store.selectDeptId = response.data[0].id;
- console.log("this.$store",this.$store)
- }
- });
- },
- currDeptChange(val) {
- if (val) {
- this.$store.selectDeptId = val;
- if (this.num > 0) {
- let path = this.$route.path;
- let visitedViews = this.$store.state.tagsView.visitedViews;
- let stagpath = null;
- const proArr = [];
- for (let i = 0; i < visitedViews.length; i++) {
- let view = visitedViews[i];
- proArr.push(
- this.$store.dispatch("tagsView/delCachedView", view).then(() => {
- const { fullPath } = view;
- if (path === fullPath) {
- stagpath = view;
- } else {
- this.$nextTick(() => {
- this.$router.replace({
- path: "/redirect" + fullPath,
- });
- });
- }
- })
- );
- }
- Promise.all(proArr).then(() => {
- if (stagpath != null) {
- this.$store
- .dispatch("tagsView/delCachedView", stagpath)
- .then(() => {
- const { fullPath } = stagpath;
- this.$nextTick(() => {
- this.$router.replace({
- path: "/redirect" + fullPath,
- });
- });
- });
- }
- });
- }
- this.num = this.num + 1;
- }
- },
- },
- };
- </script>
- <style lang="scss">
- .vue-treeselect__control {
- height: 20px;
- line-height: 26px;
- font-size: 12px;
- text-indent: 4px;
- }
- .vue-treeselect__menu-container {
- position: absolute;
- left: 0;
- width: 100%;
- overflow: visible;
- transition: 0s;
- }
- .vue-treeselect__menu {
- font-size: 12px;
- }
- </style>
|