zhanghua
2024-01-21 e1aa0ecffbabd618c71e4ad94370fb8dffe6ee1c
src/views/layout/components/Header/index.vue
@@ -4,27 +4,23 @@
    <!-- 左侧菜单 -->
    <div class="header-left">
      <div class="menu-left__item" v-for="(item, index) in menuLeftList" :key="item.id" @click="changeActive(index)">
        <span :class="item.checked ? 'my-active' : ''" @click="menuChange(item)">{{ item.label }}</span>
        <span :class="item.checked ? 'my-active' : 'my-activeno'" @click="menuChange(item)">{{ item.label }}</span>
      </div>
      <div class="menu-left__item" v-for="(item, index) in menuLinkList" :key="item.id+index" >
        <span class="link-active" @click="menuOpen(item)">{{ item.name }}</span>
      </div>
      <el-dropdown trigger="click" @command="handleCommand" v-if="linkLeng">
      <span class="el-dropdown-link">
        <i class="el-icon-arrow-down el-icon--right"></i>
      </span>
        <el-dropdown-menu slot="dropdown" >
          <el-dropdown-item  v-for="(i,dx) in menuLinkLists" :key="i.id+dx" :command="i">{{i.name}}</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
    <!-- 右侧菜单 -->
    <div class="header-right">
      <div class="menu-right__item search"></div>
      <!-- 登录用户 -->
      <div class="menu-right__item user" @mousemove="flag.user = true" @mouseleave="flag.user = false">
        <el-avatar :size="20" :src="user.user.icon" v-if="user.user.icon"></el-avatar>
        <el-avatar :size="20" src="https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png" v-else>
        </el-avatar>
        <span style="padding: 0 5px;">{{ user.user.username }}</span>
        <i class="el-icon-arrow-down"></i>
        <!-- 用户操作 -->
        <div class="user-card" v-if="flag.user" @mouseleave="flag.user = false">
          <el-card class="box-card">
            <div class="user-card__item" @click="updatePassword()">修改密码</div>
            <div style="margin-top: 10px;" class="user-card__item" @click="baseInfo()">基本信息</div>
          </el-card>
        </div>
      </div>
      <!-- 消息 -->
      <div class="menu-right__item btn" @mousemove="flag.message = true" @mouseleave="flag.message = false">
        <el-tooltip effect="dark" content="消息中心" placement="bottom-end" :hide-after="600">
@@ -37,7 +33,7 @@
          <el-card class="box-card">
            <div class="card-header">
              <span>消息中心</span>
              <el-button type="text">接收设置</el-button>
              <el-button type="text" @click="channelSetting">接收设置</el-button>
            </div>
            <div v-for="item in menuMessageList" :key="item.id" class="message-card__item">
              <router-link to='/home/operate/message/messageIndex'>
@@ -48,18 +44,66 @@
          </el-card>
        </div>
      </div>
      <!-- 登录用户 -->
      <div class="menu-right__item user" @mousemove="flag.user = true" @mouseleave="flag.user = false">
        <span class="user-span">|</span>
        <el-avatar :size="20" :src="user.user.icon" v-if="user.user.icon"></el-avatar>
        <el-avatar :size="20" src="../../../../assets/imgs/login/3ea6beec64369c2642b92c6726f1epng.png" v-else>
        </el-avatar>
        <span style="padding: 0 5px;">{{ user.user.username }}</span>
        <i class="el-icon-arrow-down"></i>
        <!-- 用户操作 -->
        <div class="user-card" v-if="flag.user" @mouseleave="flag.user = false">
          <el-card class="box-card">
            <div class="user-card__item" @click="updatePassword()">修改密码</div>
            <div style="margin-top: 10px;" class="user-card__item" @click="baseInfo()">基本信息</div>
          </el-card>
        </div>
      </div>
      <!-- 退出登录 -->
      <div class="menu-right__item btn" @click="loginout">
        <el-tooltip effect="dark" content="退出登录" placement="bottom-end" :hide-after="1000">
          <i class="el-icon-switch-button"></i>
        </el-tooltip>
      </div>
      <el-dialog :visible.sync="channelSettingVisible" width="25%" title="消息栏目设置" v-if="channelSettingVisible"
        :before-close="handleChannelClose">
        <el-table ref="multipleTable" :header-cell-style="{
                                        'font-size': '14px',
                                        'font-weight': '650',
                                        'line-height': '45px',
                                      }" :data="channelData" style="width: 100%" @selection-change="handleSelectionChange">
          <el-table-column width="55">
          </el-table-column>
          <el-table-column prop="columnName" label="全部" min-width="5" align="center">
            <!-- <template slot-scope="scope">{{ scope.row.id }}</template> -->
          </el-table-column>
          <el-table-column label="启用" min-width="5">
            <template slot-scope="scope">
              <!-- @change="handleChangeStatus(scope.row)" -->
              <el-switch class="switchStyle"
              v-model="scope.row.isReceive"
              active-color="#3fef9a"
              inactive-color="#000212"
              :active-value="1"
              :inactive-value="0"
              @change="handleSelectionChange(scope.row)">
              </el-switch>
            </template>
          </el-table-column>
        </el-table>
        <el-button type="button" @click="cancelChannel">取消</el-button>
      </el-dialog>
      <el-dialog :visible.sync="updatePasswordDialog" width="40%" title="修改密码" v-if="updatePasswordDialog"
        :before-close="handleClose">
        <updatePassword />
      </el-dialog>
      <el-dialog :visible.sync="baseInformationVisible" width="35%" title="基本信息" v-if="baseInformationVisible"
        >
      <el-dialog :visible.sync="baseInformationVisible" width="35%" title="基本信息" v-if="baseInformationVisible">
        <el-form :model="info" class="info" label-width="6vw">
          <el-form-item label="用户ID" min-width="6">
            <el-input v-model="info.id"></el-input>
@@ -89,6 +133,8 @@
<script>
import updatePassword from "./updatePassword";
import users from "@/api/users";
import { Message } from "element-ui";
import {searchexternalLinks} from "@/api/system/portal/externalLinks";
export default {
  components: {
@@ -96,26 +142,37 @@
  },
  data() {
    return {
      linkLeng:false,
      menuLinkLists:[],
      menuLinkList:[],
      baseInformationVisible: false,
      updatePasswordDialog: false,
      channelSettingVisible: false,
      checked3: true,
      menuLeftList: [
        {
          label: '驾驶舱',
          checked: true,
          url: '',
          checked: false,
          url: 'http://111.1.140.92:28081/cockpit/dist/board.html#/share-board/ze5EdUnw',
          id: '1f'
        },
        {
          label: '视频巡查',
          checked: true,
          checked: false,
          url: '',
          id: '2f'
        },
        {
          label: '执法管理',
          checked: true,
          checked: false,
          url: '',
          id: '3f',
        },
        {
          label: '油烟检测',
          checked: false,
          url: 'http://116.62.234.187:8120/#/SpecificLogin?subname=sccgj',
          id: '4f',
        },
      ],
      flag: {
@@ -124,16 +181,82 @@
      },
      user: '',
      menuMessageList: [],
      channelData: [],
      messageCounts: 0,
      keyword: '',
      info: null,
      show: false
      show: false,
      messageColumnSet: {
      }
    };
  },
  created() {
    this.setLoginInfo();
    this.getExternalLinks()
  },
  mounted(){
    window.eventBus.$on('setFeaturesData', ()=>{ // 不带参数
      this.getExternalLinks()
    })
  },
  watch:{
    $route() {
      this.menuLeftList.map(item=>{
        item.checked = false
      })
    },
  },
  methods: {
    handleCommand(e){
      console.log(e)
      this.menuOpen(e)
    },
    menuOpen(row){
      window.open('http://'+row.url, '_blank');
    },
    async getExternalLinks() {
      await searchexternalLinks().then((res) => {
        let that = this
        that.menuLinkList=[]
        if (res.length > 5) {
          that.linkLeng = true
        }
        that.menuLinkLists = res
        for (let i = 0; i < res.length; i++) {
          that.menuLinkList.push(res[i])
          if (i == 4) {
            break;
          }
        }
        // console.log(that.menuLinkLists)
        // this.menuLinkList = res
      });
    },
    cancelChannel(){
      this.channelSettingVisible=false
    },
    handleSelectionChange(val) {
      const userInfo = JSON.parse(sessionStorage.getItem('user'));
      this.messageColumnSet.userId = userInfo.user.id
      this.messageColumnSet.messageColumnId = val.id
      if (val.isReceive == null) {
        this.messageColumnSet.isReceive = 1
      }
      if (val.isReceive == 1) {
        this.messageColumnSet.isReceive = 1
      }
      else if (val.isReceive == 0) {
        this.messageColumnSet.isReceive = 0
      }
      this.$axios({
        method: 'post',
        url: 'sccg/message_column_set/update',
        data: this.messageColumnSet
      }).then(res => {
        this.$message.success("订阅成功")
      })
    },
    baseInfo() {
      this.baseInformationVisible = true;
      const name = sessionStorage.getItem('name');
@@ -146,10 +269,30 @@
          this.info = res.data.user;
        })
    },
    handleClose(done) {
    channelSetting(row) {
      this.channelSettingVisible = true;
      const userInfo = JSON.parse(sessionStorage.getItem('user'));
      this.$axios({
        method: 'get',
        url: 'sccg/message_column/getShowColumn?' + 'id=' + userInfo.user.id
      })
        .then(res => {
          this.channelData = res.data
          // this.channelData.forEach(item=>{this.$refs.multipleTable.toggleRowSelection(item,true);console.log(this.$refs.multipleTable.toggleRowSelection(item,true))})
        })
    },
    handleChannelClose(done) {
      this.$confirm("确认关闭?")
        .then((_) => {
          this.dialogUpload = false;
          done();
        })
        .catch((_) => { });
    },
    handleClose(done) {
      this.$confirm("确认关闭?")
        .then((_) => {
          this.channelSettingVisible = false;
          done();
        })
        .catch((_) => { });
@@ -210,20 +353,28 @@
    },
    menuChange(data) {
      if (data.id === '1f') {
        window.open('http://cockpit.patstech.net:28081/cockpit/dist/board.html#/share-board/zfu0LsJ9', '_blank');
        window.open('http://111.1.140.92:28081/cockpit/dist/board.html#/share-board/ze5EdUnw', '_blank');
      }
      if (data.id === '2f') {
        this.$router.push({path: "/home/video"})
        this.$router.push({ path: "/home/video" })
      }
      if (data.id === '3f') {
        this.$router.push({path: "/home/operate/casepool/pool"})
        this.$router.push({ path: "/home/operate/casepool/pool" })
      }
      if (data.id === '4f') {
        window.open('http://116.62.234.187:8120/#/SpecificLogin?subname=sccgj', '_blank');
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.el-dropdown-link {
  cursor: pointer;
  color: #409EFF;
}
::v-deep .el-form {
  padding: 3vh 5vw;
@@ -233,19 +384,19 @@
}
.el-header {
  background-color: #071a38;
  background-color: #313350;
  text-align: center;
  line-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  color: #4b9bb7;
  color: #fff;
  .header-left {
    display: flex;
    flex: 1;
align-items: center;
    .menu-left__item {
      width: 120px;
@@ -256,15 +407,40 @@
        &:hover {
          cursor: pointer;
          color: #fff;
          //color: #fff;
        }
      }
    }
.link-active{
  overflow:hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  -o-text-overflow:ellipsis;
}
    .link-active:hover{
      color: #2f54eb;
      background-color: #313350;
    }
    .my-active {
      border-radius: 20px;
      color: #2f54eb;
      background-color: #313350;
    }
    .my-activeno{
      border-radius: 20px;
      color: #fff;
      background-color: #092c4a;
      background-color: #313350;
    }
    .my-active:hover {
      color: #2f54eb;
      background-color: #313350;
    }
    .my-activeno:hover{
      color: #2f54eb;
      background-color: #313350;
    }
  }
@@ -293,13 +469,15 @@
    }
    .user {
      margin-left: 20px;
      //margin-left: 20px;
      flex: 2;
      display: flex;
      align-items: center;
      justify-content: center;
      position: relative;
.user-span{
  padding: 0 10px;
}
      .user-card {
        position: absolute;
        top: 60px;
@@ -376,9 +554,10 @@
    .user:hover,
    .btn:hover {
      background-color: #092c4a;
      //background-color: #092c4a;
      cursor: pointer;
      color: #2f54eb;
    }
  }
}
</style>
</style>