element ui tree 高亮默认显示,this.$nextTick(() => { this.$refs.tree.setCurrentKey(value);}

本文介绍了一个单位管理系统的实现,包括单位组树的展示、单位的增删改查功能,以及用户与单位之间的关联管理。系统支持内部和外部单位的区分,提供了单位下用户的搜索、新增、删除操作,并实现了单位和用户数据的动态加载与分页显示。
 <!-- Unit.vue -->
<template>
  <div>
    <div class="container">
      <el-row :gutter="20">
        <!-- 左侧内容 -->
        <el-col :span="6">
          <el-card class="height">
            <!-- 单位组树 -->
            <el-row :span="24">
              <el-col>
                <el-tabs v-model="activeName" @tab-click="handleClick" :stretch="stretchable">
                  <el-tab-pane label="内部单位" name="first"></el-tab-pane>
                  <el-tab-pane label="外部单位" name="second"></el-tab-pane>
                </el-tabs>
                <el-row class="btn" :span="24">
                  <el-col :span="8">
                    <el-button type="primary" @click="add">新增</el-button>
                  </el-col>
                  <el-col :span="8">
                    <el-button plain :disabled="editDisabled" @click="edit">编辑</el-button>
                  </el-col>
                  <el-col :span="8">
                    <el-button plain :disabled="editDisabled" @click="deletes">删除</el-button>
                  </el-col>
                </el-row>
                <!-- 单位组树列表 -->
                <el-tree ref="tree" :data="roleGroupData" :default-expanded-keys="keys" :default-checked-keys="key" @node-expand="changeNode" node-key="id" :props="defaultProps" @node-click="handleNodeClick" :highlight-current="highlight" accordion></el-tree>
                <!-- 新建单位弹框 -->
                <!-- 新建单位弹框 -->
                <el-dialog :title="title" :visible.sync="dialog.dialogFormVisible" :width="DIALOG.width" :id="fileId" :before-close="cancel">
                  <!-- 新增单位 -->
                  <el-form label-width="80px" :model="formLabelAlign" ref="formLabelAlign" :rules="addUnitRules">
                    <el-form-item label="单位名称" prop="unitName">
                      <el-input v-model.trim="formLabelAlign.unitName"></el-input>
                    </el-form-item>
                    <el-form-item label="单位编码" prop="unitCode">
                      <el-input v-model.trim="formLabelAlign.unitCode"></el-input>
                    </el-form-item>
                    <el-form-item label="单位属性" prop="type">
                      <el-input v-model="type" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="上级单位" prop="parentName">
                      <el-input v-model="formLabelAlign.parentName" disabled></el-input>
                    </el-form-item>
                    <el-form-item class="dialogConfirm">
                      <el-button type="primary" @click="save('formLabelAlign')">确认</el-button>
                      <el-button @click="cancel">取消</el-button>
                    </el-form-item>
                  </el-form>
                </el-dialog>
              </el-col>
            </el-row>
          </el-card>
        </el-col>
        <!-- 右侧内容 -->
        <el-col :span="18">
          <el-card class="height">
            <el-form :inline="true" :label-position="labelPosition" ref="searchForm" :model="searchForm" label-width="80px" class="topSearchForm" :rules="searchFormRule">
              <el-form-item label="用户姓名" prop="param.userFullname">
                <el-input v-model.trim="searchForm.param.userFullname" placeholder="请输入用户姓名"></el-input>
              </el-form-item>
              <el-form-item label="用户账号" prop="param.accountCode">
                <el-input v-model.trim="searchForm.param.accountCode" placeholder="请输入用户名/手机号码/邮箱地址" style="min-width:260px"></el-input>
              </el-form-item>
              <el-form-item label="" class="queryReset">
                <el-button type="primary" @click="toView('searchForm')">查询</el-button>
                <el-button @click="reset('searchForm')">重置</el-button>
              </el-form-item>
              <div class="clearfix"></div>
            </el-form>
            <div>
              <el-row class="btnGroup">
                <el-col :span="24">
                  <el-button type="primary" :disabled="addDisabledUser" @click="addList">新增</el-button>
                  <el-button @click="remove" :disabled="removeRole">删除</el-button>
                </el-col>
              </el-row>
              <!-- 单位列表 -->
              <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange">
                <el-table-column type="selection" width="55"></el-table-column>
                <el-table-column prop="userFullname" label="用户姓名">
                  <template slot-scope="scope">{{ scope.row.userFullname }}</template>
                </el-table-column>
                <el-table-column prop="unitName" label="所属单位">
                  <template slot-scope="scope">{{ scope.row.units[0].unit.unitName }}</template>
                </el-table-column>
                <el-table-column prop="userName" label="用户名">
                  <template slot-scope="scope">{{ scope.row.userName }}</template>
                </el-table-column>
                <el-table-column prop="userMobile" label="手机号码">
                  <template slot-scope="scope">{{ scope.row.userMobile | conceal }}</template>
                </el-table-column>
                <el-table-column prop="userEmail" label="邮箱地址">
                  <template slot-scope="scope">{{ scope.row.userEmail }}</template>
                </el-table-column>
              </el-table>
              <!-- 分页 -->
              <div class="page">
                <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="PAGE_CONFIG.pageNum" :page-sizes="PAGE_CONFIG.sizes" :page-size="PAGE_CONFIG.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="PAGE_CONFIG.total" v-if="PAGE_CONFIG.total>0"></el-pagination>
              </div>
              <!-- 新增关联 -->
              <AddcontentVue ref="addContent" :dialogFormContent="dialog.dialogFormContent" :unitType="unitType" @updataContent="changeContent" @updataTable="changeTablie" />
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import '@/assets/styles/identity.styl'
import { IDENTITY_CLIENT, PAGE_CONFIG, DIALOG } from '@/utils/identity/constants'
// import { getErrorMessage } from '@/utils/i18n'
import { Message } from 'element-ui'
import { getMessagesFromError } from '@/utils/i18n'
import AddcontentVue from './components/AddContent'
import gql from 'graphql-tag'
export default {
  components: {
    AddcontentVue
  },

  filters: {
    // 隐藏手机号中间四位
    conceal: function (value) {
      if (value) {
        return (value = value.substr(0, 3) + '****' + value.substr(7))
      } else {
        return (value = '')
      }
    }
  },
  // props: {},

  data () {
    return {
      fileId: this.id || 'vue-filesone-' + +new Date() + +Math.random(),
      PAGE_CONFIG,
      DIALOG,
      activeName: 'first',
      unitType: '2',
      parentName: '',
      groupData: [],
      stretchable: true,
      getCurrentItem: {},
      editDisabled: true,
      // addDisabledUser: true,
      // 左侧属性单位列表
      roleGroupData: [],
      defaultProps: {
        children: 'children',
        label: 'unitName'
      },
      tabPosition: 'top',
      labelPosition: 'left',
      multipleSelection: [],
      // 编辑,新增必填
      addUnitRules: {
        unitName: [{ required: true, message: '请输入名称', trigger: 'blur' }],
        unitCode: [{ required: true, message: '请选择编码', trigger: 'blur' }]
      },
      // 左侧新增,编辑单位表单
      formLabelAlign: {
        id: '',
        unitName: '',
        unitCode: '',
        parentId: '',
        parentName: '组织机构'
      },
      // 弹出框标题
      title: '',
      // 右侧查询单位下单位列表
      searchForm: {
        pageNum: PAGE_CONFIG.pageNum,
        pageSize: PAGE_CONFIG.pageSize,
        param: {
          unitId: '',
          userType: '2',
          accountCode: '',
          userFullname: ''
        }
      },
      searchFormRule: {},
      // 右侧单位数组
      tableData: [],
      // 弹框关闭删除
      dialog: {
        dialogFormVisible: false,
        dialogFormContent: false
      },
      keys: [],
      key: [],
      highlight: true,
      nodeKey: ''
    }
  },
  computed: {
    // 多选删除是否能用
    removeRole () {
      return this.multipleSelection.length === 0
    },
    // 判断单位属性
    type () {
      return this.activeName === 'second' ? '外部单位' : '内部单位'
    },
    addDisabledUser () {
      return !this.getCurrentItem.children || (this.getCurrentItem.children.length > 0)
    }
  },

  // created () {},

  mounted () {
    this.getUnitList(this.unitType)
  },

  methods: {
    addList () {
      this.dialog.dialogFormContent = true
      this.$refs.addContent.searchUserList()
    },
    //  获取单位列表
    searchUserList () {
      this.$apollo
        .query({
          query: gql`
            query users ($unitUserInput:UnitUserInput, $pageInput:PageInput) {
              users (unitUserInput:$unitUserInput, pageInput:$pageInput) {
                total
                list {
                  id
                  userSex
                  userName
                  userFullname
                  userMobile
                  userEmail
                  units {
                    unit {
                      unitName
                    }
                  }
                }
              }
            }
          `,
          fetchPolicy: 'network-only',
          variables: {
            unitUserInput: {
              userFullname: this.searchForm.param.userFullname,
              accountCode: this.searchForm.param.accountCode,
              userType: this.searchForm.param.userType,
              unitId: this.searchForm.param.unitId
            },
            pageInput: {
              pageNum: this.searchForm.pageNum,
              pageSize: this.searchForm.pageSize
            }
          },
          client: IDENTITY_CLIENT
        })
        .then(res => {
          if (res.data.users) {
            this.tableData = JSON.parse(JSON.stringify(res.data.users.list))
            this.PAGE_CONFIG.total = res.data.users.total
          }
        })
        .catch(err => {
          Message.error(getMessagesFromError(err).join(';'))
        })
    },
    // 点击切换内部用户外部用户
    handleClick (tab, event) {
      // 1代表外部,2代表内部
      // this.addDisabledUser = true
      this.getCurrentItem = {}
      if (tab.name === 'first') {
        this.unitType = '2'
        this.getUnitList(this.unitType)
      } else {
        this.unitType = '1'
        this.getUnitList(this.unitType)
      }
      this.searchForm.param.userType = this.unitType
    },
    // 根据type查询内部机构单位
    getUnitList (type) {
      this.$apollo
        .query({
          query: gql`
            query units ($unitType:String){
              units (unitType: $unitType) {
                id
                parentId
                unitName
                unitCode
                children {
                  id
                  parentId
                  unitName
                  unitCode
                  children {
                    id
                    parentId
                    unitName
                    unitCode
                    children {
                      id
                      parentId
                      unitName
                      unitCode
                      children {
                        id
                        parentId
                        unitName
                        unitCode
                      }
                    }
                  }
                }
              }
            }`,
          fetchPolicy: 'network-only',
          variables: {
            unitType: type
          },
          client: IDENTITY_CLIENT
        }).then(res => {
          if (res.data.units.length) {
            let form = {}
            this.$set(form, 'unitName', '组织机构')
            this.$set(form, 'children', JSON.parse(JSON.stringify(res.data.units)))
            this.roleGroupData = []
            this.roleGroupData.push(form)
            // 暂时保留
            // this.$store.commit('SET_ID', this.roleGroupData[0].id)
            this.$store.commit('SET_ID', this.roleGroupData[0].children[0].id)
            this.keys = []
            this.keys.push(this.roleGroupData[0].children[0].id)
            this.key = []
            this.key.push(this.roleGroupData[0].children[0].id)
            this.$nextTick(() => {
              this.$refs.tree.setCurrentKey(this.roleGroupData[0].children[0].id)
            })
            this.searchForm.param.unitId = this.roleGroupData[0].children[0] ? this.roleGroupData[0].children[0].id : ''
            this.searchUserList()
            this.groupData = JSON.parse(JSON.stringify(res.data.units))
            this.groupData.push({ unitName: '组织机构', id: 'ae60506073b14983868c8b752914f027' })
            this.groupData.push({ unitName: '组织机构', id: '1c0acfadb4fa4939b3a25330589de332' })
          }
        }).catch(err => {
          Message.error(getMessagesFromError(err).join(';'))
        })
    },
    // 单位树点击事件
    handleNodeClick (data, node) {
      this.getCurrentItem = {}
      this.formLabelAlign.parentId = ''
      this.formLabelAlign.parentName = ''
      // 判断点击结构组织中是不是有id 不调用接口
      if (data.id) {
        if (data.parentId) {
          this.editDisabled = false
        } else {
          // 一级组织机构不可编辑,删除
          this.editDisabled = true
        }
        this.getCurrentItem = data
        this.searchForm.param.unitId = data.id
        this.$store.commit('SET_ID', data.id)
        this.searchUserList()
      }
    },
    // 获取单位下的用户列表
    // 关闭弹框事件
    closeDialogHandle () {
      this.dialog.dialogFormVisible = false
    },
    // 展开事件
    changeNode () {
    },
    // 数据库删除
    // 删除
    deleteUnit () {
      this.$apollo
        .mutate({
          mutation: gql`mutation deleteUnit ($id:ID!){
            deleteUnit (id: $id)
          }
          `,
          variables: {
            id: this.getCurrentItem.id
          },
          client: IDENTITY_CLIENT
        })
        .then(res => {
          if (res.data.deleteUnit) {
            this.$message({
              type: 'success',
              message: '删除成功!'
            })
            this.getUnitList(this.unitType)
            this.editDisabled = true
            this.getCurrentItem = {}
          }
        })
        .catch(err => {
          Message.error(getMessagesFromError(err).join(';'))
        })
    },
    // 删除事件
    deletes () {
      if (this.getCurrentItem.hasOwnProperty('children')) {
        if (this.tableData.length === 0) {
          this.$confirm('此操作将永久删除记录, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            // 一级 无二级
            this.roleGroupData = this.roleGroupData.filter(
              item => item.id !== this.getCurrentItem.id
            )
            this.deleteUnit()
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            })
          })
        } else {
          this.$message.error('该单位下有用户,不可删除')
        }
      } else {
        // 二级
        if (this.tableData.length === 0) {
          this.$confirm('此操作将永久删除记录, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          })
            .then(() => {
              // 一级 无二级
              this.deleteUnit()
            })
            .catch(() => {
              this.$message({
                type: 'info',
                message: '已取消删除'
              })
            })
        } else {
          this.$message.error('该单位下有子单位,不可删除')
        }
      }
    },
    // 新增单位
    add () {
      this.dialog.dialogFormVisible = true
      this.title = '新增单位'
      this.formLabelAlign.id = ''
      this.formLabelAlign.unitName = ''
      this.formLabelAlign.unitCode = ''
      if (this.getCurrentItem.parentId) {
        this.formLabelAlign.parentId = this.getCurrentItem.id
        this.formLabelAlign.parentName = this.getCurrentItem.unitName
      } else {
        this.formLabelAlign.parentName = '组织机构'
      }
    },
    saveParentName (arr) {
      // var self = this
      arr.forEach(item => {
        if (item.id === this.getCurrentItem.parentId) {
          this.formLabelAlign.parentName = item.unitName
        } else {
          if (item.hasOwnProperty('children') && item.children.length !== 0) {
            this.saveParentName(item.children)
          }
        }
      })
    },
    // 编辑单位
    edit () {
      this.title = '编辑单位'
      this.dialog.dialogFormVisible = true
      this.formLabelAlign.id = this.getCurrentItem.id
      this.formLabelAlign.unitCode = this.getCurrentItem.unitCode
      this.formLabelAlign.unitName = this.getCurrentItem.unitName
      // fu 赋值parentId
      this.formLabelAlign.parentId = this.getCurrentItem.parentId
      if (this.getCurrentItem.parentId) {
        this.saveParentName(this.groupData)
      }
    },
    // 列表查询
    toView (searchForm) {
      this.$refs[searchForm].validate((valid) => {
        if (valid) {
          this.searchForm.pageNum = '1'
          this.searchForm.pageSize = '10'
          this.searchUserList()
        } else {
          return false
        }
      })
    },
    // 取消
    cancel () {
      this.dialog.dialogFormVisible = false
      this.$refs['formLabelAlign'].clearValidate()
    },
    // 重置
    reset (formData) {
      this.$refs[formData].resetFields()
      this.dialog.dialogFormVisible = false
    },
    // table多选
    handleSelectionChange (val) {
      this.multipleSelection = val
    },
    // 接收返回值
    changeContent () {
      this.dialog.dialogFormContent = false
    },
    changeTablie () {
      this.dialog.dialogFormContent = false
      this.searchUserList()
    },
    // 删除
    remove () {
      let arr = this.multipleSelection.map(value => {
        return value.id
      })
      this.$confirm('此操作将永久删除记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$apollo
          .mutate({
            mutation: gql`mutation deleteUnitUser($unitId:ID, $userIds:[ID!]){
              deleteUnitUser(unitId: $unitId, userIds: $userIds)
            }`,
            variables: {
              unitId: this.searchForm.param.unitId,
              userIds: arr
            },
            client: IDENTITY_CLIENT
          })
          .then(res => {
            if (res.data.deleteUnitUser) {
              this.$message({
                message: '删除成功',
                type: 'success'
              })
              this.multipleSelection = []
              this.searchUserList()
            }
          })
          .catch(err => {
            Message.error(getMessagesFromError(err).join(';'))
          })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    // 编辑新增单位提交事件
    save (ruleForm) {
      // console.log(this.formLabelAlign)
      this.$refs[ruleForm].validate(valid => {
        if (valid) {
          this.$apollo
            .mutate({
              mutation: gql`mutation saveUnit($id:ID, $unit:UnitInput){
                saveUnit (id:$id, unit:$unit) {
                  id
                }
              }`,
              variables: {
                id: this.formLabelAlign.id,
                unit: {
                  unitType: this.unitType,
                  parentId: this.formLabelAlign.parentId,
                  unitName: this.formLabelAlign.unitName,
                  unitCode: this.formLabelAlign.unitCode
                }
              },
              client: IDENTITY_CLIENT
            })
            .then(res => {
              if (this.formLabelAlign.id) {
                if (res.data.saveUnit.id) {
                  this.$message({
                    message: '更新成功',
                    type: 'success'
                  })
                } else {
                  this.$message.error('更新失败')
                }
              } else {
                if (res.data.saveUnit.id) {
                  this.$message({
                    message: '添加成功',
                    type: 'success'
                  })
                } else {
                  this.$message.error('添加失败')
                }
              }
              this.$refs[ruleForm].resetFields()
              this.dialog.dialogFormVisible = false
              this.getCurrentItem = {}
              this.editDisabled = true
              this.getUnitList(this.unitType)
            })
            .catch(err => {
              Message.error(getMessagesFromError(err).join(';'))
            })
        } else {
          return false
        }
      })
    },
    // 一页几条查询事件
    handleSizeChange (val) {
      this.searchForm.pageSize = val
      this.searchUserList()
    },
    // 第几页查询事件
    handleCurrentChange (val) {
      this.searchForm.pageNum = val
      this.searchUserList()
    }
  }
}

</script>
<style lang='stylus'  rel='stylesheet/stylus' scoped>
.btn
  margin-bottom 20px
  .listBtn
    float right
</style>

 

页面导航栏其中一个菜单点击时第一次点击左侧菜单栏没有子菜单,并且导航栏未高亮,其他导航栏菜单无这个问题,只有这个连续点击两次才正常高亮并展示左侧菜单,下面是页面代码<style> @import "./assets/style/MainApp.css"; </style> <template> <el-container id="app" v-if="$store.state.user&&$store.state.user.id" style="overflow-x: visible;border: 0;" v-loading="isLoading" element-loading-text="加载中···" > <!-- ↓↓ 头部栏 ↓↓ --> <el-header v-if="!hideHeader" class="el-header_index" style="height:55px;position:fixed;width:100%;z-index:1999;"> <div class="toplogo" > <img src="@/assets/images/logo.png" class="logo_img"/> </div> <div class="logo" style="margin-left: 70px"> <router-link :to="{path: indexPage}"> {{ "PCS能源与碳排放管控功能" }} </router-link> </div> <el-tabs v-if="menuList&&menuList.length>0" :class="headerTabMenuClass" class="top-menu" v-model="activeMenu" @tab-click="(index)=>handleSelect(index,true)"> <el-tab-pane v-for="(item, index) in menuList" :name="item.id" :key="index"> <span slot="label" style="margin: 0px 20px;">{{ item.name }}</span> </el-tab-pane> </el-tabs> <div class="topbar"> <div class="menu"> <div class="right"> <!-- 测试按钮 --> <div class="topbar_but" @click="logInfo" v-if="false"> <i class="el-icon-cpu"></i> </div> <!-- 主页按钮 --> <div class="topbar_but" @click="goPage(indexPage)"> <i class="sinopec-icon icon-home"></i> </div> <!-- 全屏按钮 --> <div class="topbar_but" @click="toggleScreenFull"> <el-tooltip :content="isFullscreen?'取消全屏':'全屏'" effect="dark" placement="bottom"> <i class="sinopec-icon icon-Fullscreen" style="cursor: pointer;"></i> </el-tooltip> </div> <!-- 按钮 --> <div class="gxh" @click="openSetting" v-if="false"> <i class="el-icon-s-operation"></i> </div> <!-- 切换油气田 --> <!-- <div v-if="systemYqtOptions.length >= 3">--> <div> <el-select v-model="systemYqt" v-show="isYqtSelectShow" size="mini" style="width: 110px !important;" placeholder="" class="systemYqt" @change="updateFieldValue"> <el-option v-for="item in systemYqtOptions" :key="item.value" :label="item.label" :value="item.value"> </el-option> </el-select> </div> <div class="user"> <el-dropdown @command="goPage"> <div> <img class="cover" src="@/assets/images/user.svg" style="float: left"/> <span class="name" v-if="$store.state.user">{{ $store.state.user.name }}</span> </div> <el-dropdown-menu slot="dropdown"> <el-dropdown-item command="/system/user-info"> <i class="menu-icon el-icon-user"></i> <span class="menu-txt">个人中心</span> </el-dropdown-item> <el-dropdown-item command="loginOut"> <i class="menu-icon el-icon-switch-button"></i> <span class="menu-txt">退出登录</span> </el-dropdown-item> </el-dropdown-menu> </el-dropdown> </div> </div> </div> </div> </el-header> <!-- ↑↑ 头部栏 ↑↑ --> <!-- ↓↓ 有侧栏主体 ↓↓ --> <el-container :style="mainContainerStyle" ref="main_container"> <!-- ↓↓ 左侧菜单 ↓↓ --> <div v-show="leftMenuBoxShow" class="sidebar scroll_hide_content" :style="hideHeader?{top:'5px'}:{}" > <a class="navbar-minimalize" title='收起菜单' @click="toggleMenu"> <img src="@/assets/images/list_icon41.svg" style="width:16px;height:16px;margin: 14px 0 0 24px;" v-if="!this.menuConfig.collapse"/> <img src="@/assets/images/list_icon42.svg" style="width:16px;height:16px;margin: 14px 0 0 24px;" v-else/> </a> <!-- 实现菜单多级分类 --> <el-menu :style="{width: menuConfig.width +'px'}" id="left_menu" ref="left_menu" router :collapse="menuConfig.collapse" @open="menuOpen" @close="menuClose" @select="menuSelect" v-loading="menuLoading" :default-active="menuConfig.active" :default-openeds="menuConfig.open" text-color="#666666" :unique-opened="true"> <!-- 引入组件 --> <!-- <menu-tree :menuData="menuList"></menu-tree>--> <menu-tree v-if="activeMenu&&topMenuMap[activeMenu]&&topMenuMap[activeMenu].children" :menuData="topMenuMap[activeMenu].children"></menu-tree> </el-menu> </div> <!-- ↑↑ 左侧菜单 ↑↑ --> <el-container :style="rightContainerStyle"> <el-main class="main_page" ref="main_page"> <!-- ↓↓ 标签页和面包屑 ↓↓ --> <el-row :class="tabClass"> <!-- 标签页 --> <tab-header v-if="true" ref="tabHeader" :menu-item-map="menuItemMap" @tab-remove="handleTabRemove" :index-page="indexPage" @tab-refresh="handleTabRefresh"> </tab-header> <!-- 面包屑 --> <!-- <el-breadcrumb separator="/"> <el-breadcrumb-item :to="{ path: '/index'}">首页</el-breadcrumb-item> <template v-for="item in breadcrumbList"> <el-breadcrumb-item v-if="item.leaf&&$route.path != item.path" :to="item.path"> {{ item.name }} </el-breadcrumb-item> <el-breadcrumb-item v-else>{{ item.name }}</el-breadcrumb-item> </template> </el-breadcrumb> --> </el-row> <!-- ↑↑ 标签页和面包屑 ↑↑ --> <!-- ↓↓ 页面主体 ↓↓ --> <div :class="viewClass"> <!-- 路由保持页面原本数据 --> <keep-alive :exclude="excludeArray"> <router-view v-if="pageShow" @add-bread="addBread($event)" :page-height="mainPageHeight" :fullscreen="isFullscreen" @close-page="closeTab" /> </keep-alive> </div> <!-- ↑↑ 页面主体 ↑↑ --> <el-dialog title="账号" :visible.sync="loginDlgVisible" :close-on-click-modal="false" width="50%" > <el-input v-model="updateLoginName"></el-input> <div slot="footer" class="dialog-footer" style="text-align: center"> <el-button type="primary" @click="changeUser">切换账号 </el-button> <el-button @click="loginDlgVisible = false">关闭</el-button> </div> </el-dialog> </el-main> </el-container> </el-container> <!-- ↑↑ 有侧栏主体 ↑↑ --> </el-container> <!-- <login-layer v-else @login-success="loadUserInfo"></login-layer>--> </template> <script> import DevicePixelRatio from './utils/devicePixelRatio'; //引入动态等比例调整页面 import Notice from "./components/layout/Notice"; import screenfull from "screenfull"; import LoginLayer from "./LoginApp.vue"; import TabHeader from "./layout/TabHeader.vue"; import {urlIndex} from "./utils/urlindex.js"; import {excludeArray} from "./utils/excludeKeepAlive.js"; import jsC from "../public/js/common"; export default { name: "MainApp", components: {TabHeader, Notice, LoginLayer}, data() { return { menuLoading: false, // menuCollapse: false, isLoading: false, notifyDisFlg: false, loginDlgVisible: false, notifyNum: 0, userOption: {show: false}, contentStyle: { height: window.innerHeight - 110 + "px", overflow: "auto", }, // tab标签样式 tabClass: 'main_page_header_isIndex', // router-view样式 viewClass: 'main_page_view_isIndex', // 头部tab菜单样式 headerTabMenuClass: 'top-menu-width', activeMenu: '', menuListAll: [], menuList: [], lastMenu: {}, topMenuMap: {}, menuItemMap: {}, jsonData: {}, breadcrumbList: [], isFullscreen: false, currentUpdateTask: null, mainPageHeight: window.innerHeight - 115, updateLoginName: '', menuConfig: { active: '', open: [], collapse: false, collapseWidth: 64, minWidth:200, maxWidth:200, width:200, }, hideHeader: false, cachePathMap: {},//路径到页面信息映射 cacheComponentNames: [],//keep-alive缓存路由name数组 user:{}, // 左侧菜单显示 leftMenuBoxShow: false, // 右侧内容 左边框 rightContainerStyle: { 'padding-left': 0 }, //选择的油气田 systemYqt: '', systemYqtOptions: [], // systemYqt: '油气田板块', // systemYqtOptions: [ // { // value: '油气田板块', // label: '油气田板块' // }, // { // value: '油田板块', // label: '油田板块' // }, // { // value: '气田板块', // label: '气田板块' // }, // ], isYqtSelectShow: false, //页面view显示状态 pageShow: false, // 排除keep-alive 数组 excludeArray: [], //主页路由 indexPage: '/index/home', }; }, created() { // 排除缓存页面 this.dealExcludeArray(); //等比自动缩放 new DevicePixelRatio().init(); // 获取本地缓存的用户token let user_token = localStorage.getItem("user_token"); // 重置token if (user_token) { this.$store.commit("updateToken", user_token); } // this.loadMenu(); this.loadUserInfo(); // this.loadUnitNameMap(); }, mounted() { // 读取隐藏左侧菜单页面链接 this.jsonData = urlIndex(); window.addEventListener("resize", (event) => { if (this.currentUpdateTask) { //防止调用频繁 clearTimeout(this.currentUpdateTask); } this.currentUpdateTask = setTimeout(() => { this.computePageSize(this.$route.path) }, 100); }); }, watch: { $route(to, from) { this.computePageSize(to.path); this.activeMenuQuery(to) this.leftMenuShow(to.path); this.changeBread(to.path); this.addCacheTab(to); }, '$store.state.selectedDw'(newValue) { // 功能:切换单位后,根据所选单位切换菜单类型 this.isYqtSelectShow = newValue === '油气田板块'; this.systemYqt = newValue === '中国石化' ? '油气田板块' : newValue; this.$store.commit('updateSelectedField', this.systemYqt); this.menuSwitch(); }, '$store.state.selectedRootDw'(newValue){ // 功能:选择单位后,根据单位的分公司油气田类型,隐藏或显示油气田板块选择框 // 规则:如果是油气田板块,则显示,否则隐藏 this.isYqtSelectShow = newValue === '油气田板块'; } }, computed: { mainContainerStyle() { return { // 'padding-top':'5px', 'margin-top': this.hideHeader ? '0' : '55px', 'overflow': 'auto' }; } }, methods: { // 主页面自适应宽度 computePageSize(path) { if(!this.$refs["main_page"]) { return; } // 获取router-view高度 this.mainPageHeight = this.$refs["main_page"].$el.offsetHeight; if(this.isIndexPage(path)){ // router-view高度 this.contentStyle.height = this.mainPageHeight + "px"; // 隐藏tab菜单栏 this.tabClass = 'main_page_header_isIndex'; // router-view样式 this.viewClass = 'main_page_view_isIndex'; // 右侧内容边框 this.$refs["main_page"].$el.style.padding = 0; }else { // router-view高度 this.contentStyle.height = this.mainPageHeight - 50 + "px"; // 显示tab菜单栏 this.tabClass = 'main_page_header'; // router-view样式 this.viewClass = 'main_page_view'; // 右侧内容边框 this.$refs["main_page"].$el.style.padding = '0 10px'; } }, // 是否主页 isIndexPage(path) { let urlIndex = this.jsonData; for(let i of urlIndex){ if(path === i.name){ return true } } if(this.$store.state.menuHide!=undefined&&this.$store.state.menuHide) return true; return false }, //定位点击的菜单 activeMenuQuery(to){ let activeMenuNot = false; this.menuListAll.forEach((item,key) => { let menu = this.getMenuInfo(to.path,item); if(menu){ activeMenuNot = true; //顶部菜单定位 this.activeMenu = item.id; //左侧菜单定位 this.menuConfig.active = menu.path; let index = menu.path; if(this.ifMenuPath(index)){ //获取展开的菜单 let pathArray = Array.from(menu.parentPath); pathArray.push(index); this.menuConfig.open = pathArray; this.updateMenuOpen(index,'open'); }else { this.updateMenuOpen(index,'select'); } } }) if(!activeMenuNot){ //顶部菜单定位 // this.activeMenu = ''; //左侧菜单定位 // this.menuConfig.active = ''; } }, // 菜单收起展开操作 toggleMenu() { this.menuConfig.collapse = !this.menuConfig.collapse; if (this.menuConfig.collapse) { this.menuConfig.width = this.menuConfig.collapseWidth; } else { this.menuConfig.width = this.menuConfig.maxWidth; } this.$set(this.rightContainerStyle, 'padding-left', (this.menuConfig.width + 1) + 'px'); }, // 左侧菜单栏隐藏功能 leftMenuShow(path){ //主页path if(this.isIndexPage(path)){ //菜单栏宽度 this.menuConfig.width = 0; //菜单栏外侧div隐藏 this.leftMenuBoxShow = false; this.$set(this.rightContainerStyle, 'padding-left', 0 + 'px'); }else { //菜单栏宽度 if (this.menuConfig.collapse) { this.menuConfig.width = this.menuConfig.collapseWidth; } else { this.menuConfig.width = this.menuConfig.maxWidth; } //菜单栏外侧div隐藏 this.leftMenuBoxShow = true; this.$set(this.rightContainerStyle, 'padding-left', (this.menuConfig.width + 1) + 'px'); } this.$nextTick(() => { this.computePageSize(path); }) }, // 查询菜单 loadMenu() { //显示菜单 this.leftMenuShow(window.location.hash.slice(1)); this.menuLoading = true; this.$get("/api/main/menu/list/user/data", {}, (response) => { // this.$get("/api/main/menu/list/data", {lx: '1'}, (response) => { this.menuListAll = response.data; //切换油气田菜单 this.menuSwitch(); //页面样式重新计算 }, (response) => { this.menuLoading = false; }); }, // 油气田菜单初始化 menuSwitch(){ // menuListAll- 全部菜单 // menuList- 当前菜单 this.menuList = []; this.menuListAll.forEach((item,key) => { if(this.$store.state.selectedField === '油田板块'){ if(item.lx === '1' || item.lx === '0'){this.menuList.push(item)} }else if(this.$store.state.selectedField === '气田板块'){ if(item.lx === '2' || item.lx === '0'){this.menuList.push(item)} }else if(this.$store.state.selectedField === '天分板块'){ if(item.lx === '3' || item.lx === '0'){this.menuList.push(item)} }else {} }) if(this.menuList == undefined || this.menuList.length == 0){ return; } //控制左侧菜单显示APP指定菜单--油田电能管控APP let tmpArray = window.location.href; if(tmpArray.indexOf('ytdngkapp') >= 0){ let ytdngkapp = ["电量运行","提升系统","注入系统","集输系统","后辅用电","转供电量"]; this.activeMenu = this.menuList[0].id; var topMenuMap = {}; let newitem = []; let newch = []; let newmenuList = []; for (var item of this.menuList) { // console.log(item) if(item.name === "能耗监控"){ for(let ch of item.children){ if(ch.name === "电能监控"){ for(let chch of ch.children){ if(ytdngkapp.includes(chch.name)){ newitem.push(chch); } } ch.children = newitem; newch.push(ch); } } item.children = newch; topMenuMap[item.id] = item; newmenuList.push(item); } } this.topMenuMap = topMenuMap; this.menuList = newmenuList; // this.menuList = this.menuList[0]; }else { this.activeMenu = this.menuList[0].id; var topMenuMap = {}; for (var item of this.menuList) { topMenuMap[item.id] = item; } this.topMenuMap = topMenuMap; } this.$store.commit("updateMenuList", this.menuList); this.menuListY = JSON.parse(JSON.stringify(this.menuList)); jsC.menuInfoZh(this.menuList,this); // this.menuList = menuList; function addChildren(menuItem, map) { if (menuItem.children && menuItem.children.length > 0) { for (item of menuItem.children) { item.parentPath = []; for (var p of menuItem.parentPath) { item.parentPath.push(p); } item.parentPath.push(menuItem.path); item.parentIds = []; for (var p of menuItem.parentIds) { item.parentIds.push(p); } item.parentIds.push(menuItem.id); map[item.path] = item; addChildren(item, map); } } else { menuItem.leaf = true; } } var map = {}; for (var item of this.menuListAll) { item.parentPath = []; item.parentIds = []; map[item.path] = item; addChildren(item, map); } map["/todo/list"] = { parentPath: [], path: "/todo/list", name: "事务列表", leaf: true, }; this.menuItemMap = map; this.changeBread(this.$route.path); }, // 切换油气田菜单 updateFieldValue(newValue) { this.$store.commit('SET_SELECT_FIELD', newValue); // 缓存变量,刷新保持 油气田菜单不变 window.sessionStorage.setItem("selectedField",newValue); // 油气田菜单初始化 this.menuSwitch(); // 转到油田|气田第一个页面 if(this.menuList !== undefined && this.menuList.length > 0){ let path = this.getFirstChild(this.menuList[0]) this.menuConfig.active = path; if(this.$route.path !== this.indexPage &&this.$route.path !== path){ this.openPage(path); } }else if(this.$store.state.selectedField === '油气田板块'){ if(this.$route.path !== this.indexPage){ this.openPage(this.indexPage) } } }, // 面包屑 changeBread(toPath, from) { var list = []; if (toPath == "/") { this.breadcrumbList = list; } var item = this.menuItemMap[toPath]; if (!item) { this.breadcrumbList = []; return; } if (item.parentIds && item.parentIds.length > 0) { this.activeMenu = item.parentIds[0]; } for (var path of item.parentPath) { var target = this.menuItemMap[path]; if (!target) { continue; } list.push(target); } var target = this.menuItemMap[toPath]; if (target && target.path != '/') { list.push(this.menuItemMap[toPath]); } this.breadcrumbList = list; }, // 增加面包屑 addBread(item) { var currentPath = this.$route.path; if ( item.parent && item.parent != "/todo/list" && item.parent != "/todo/info" && this.menuItemMap[item.parent] ) { this.changeBread(item.parent); } else { var customPathMapping = { "/eemg/sjjc/dnjk/index-fgs-dnjk": "/eemg/sjjc/dnjk/index-fgs-dnjk", }; var parentPath = customPathMapping[currentPath]; if (parentPath) { this.changeBread(parentPath); } else { var findParentPaths = [ this.$route.path, this.$route.path.replace(/(\_\w*$)/g, ""), this.$route.path.replace(/(\_\w*$)/g, "") + "/list", this.$route.path.replace(/(\/\w*$)/g, "") + "/list", ]; for (var path of findParentPaths) { if (this.menuItemMap[path]) { this.changeBread(path); break; } } } } if ( this.breadcrumbList.length > 0 && this.breadcrumbList[this.breadcrumbList.length - 1].path == currentPath ) { return; } this.breadcrumbList.push(item); }, // 打开个性化设置 openSetting() { this.$get("/api/main/user/info/current_user",{}, (response) => { }); }, // 跳转页面 goPage(path) { if(path == 'loginOut') { this.logout() return } if(this.$route.path !== path){ this.$router.push({path}) } }, // 退出登录 logout: function () { this.$ElConfirm('您确定退出登录当前账户吗?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { // this.loadSlCloudApi("登出",this.invokeLogout); // console.log("登出"); this.invokeLogout(); }).catch(() => {}); }, invokeLogout(){ // 清除本地缓存token localStorage.removeItem("user_token"); // 清除内存缓存token this.$store.commit("removeToken"); if (env == 'dev') { this.$get('/api/main/logout', {}, (response) => { // location.href = this.$ctx + envConfig[env].loginPath; this.$store.commit("updateUser",null); location.href = this.$ctx + envConfig[env].loginPath; }); return; } if (envConfig[env].sso) { // this.$get(this.$ctx + "/api/main/logout", {}, (response) => { // // 目前退出到能管平台的登录页面 // location.href = "https://10.172.30.29:9091/front/login"; // }); location.href = '/api/main/logout'; } else { this.$get(this.$ctx + "/api/main/logout", {}, (response) => { this.$store.commit("updateUser",null); location.href = this.$ctx + envConfig[env].loginPath; }); } }, // 验证用户登陆 changeUser: function () { if (!this.updateLoginName) { return; } this.$post('/api/main/login/change', {username: this.updateLoginName}, (response) => { location.reload(); }, () => { this.loginDlgVisible = false; }) }, // 根据path获取菜单 getMenuInfo(path,menuInfo) { if(path === menuInfo.path || (menuInfo.path && path === menuInfo.path.slice(1,menuInfo.path.length)) ){ return menuInfo } if(!menuInfo || !menuInfo.children){ return null; } for (let child of menuInfo.children) { let result = this.getMenuInfo(path,child); if (result !== null) { return result; } } return null; }, // 新增缓存标签页 addCacheTab(to) { //通过路由名称进行查找 (路由名称默认与文件名相同,可以通过$$route name属性设置,不可重复) let index = this.cacheComponentNames.indexOf(to.name); if (index < 0) { this.cacheComponentNames.push(to.name); this.cachePathMap[to.fullPath] = { name: to.name, activeMenu: this.menuConfig.active, version: new Date().getTime(), }; } else if (this.cachePathMap[to.fullPath]) { let activeMenu = this.cachePathMap[to.fullPath].activeMenu; if (activeMenu) { this.menuConfig.active = activeMenu; } } else { //如果该页面组件已经纳入缓存队列,但是不是该路径触发,则认为该页面有多个访问路径 this.cachePathMap[to.fullPath] = { name: to.name, activeMenu: this.menuConfig.active, version: new Date().getTime(), }; } }, //处理标签页关闭 handleTabRemove(path) { //获取路径缓存信息 let cacheInfo = this.cachePathMap[path]; if (cacheInfo) { //删除路径缓存信息 Reflect.deleteProperty(this.cachePathMap, path); //首先判断缓存的页面里是否有和该路径公用页面的情况,如果有,则不做处理 for (let key in this.cachePathMap) { if (key == path) { continue; } let otherInfo = this.cachePathMap[key]; if (otherInfo.name == cacheInfo.name) { //匹配到其他路径与该路径共用页面,不做后续处理 return; } } //从keep-alive中移除 --- 不在标签页里的页面打开重新加载 this.excludeArray.push(cacheInfo.name); this.$nextTick(() => { this.excludeArray = this.excludeArray.filter(item => { return cacheInfo.name !== item; }); }) this.dealExcludeArray(); } }, //处理标签页关闭 handleTabRefresh(path, index) { // //获取路径缓存信息 // let cacheInfo = this.cachePathMap[path]; // if(cacheInfo){ // //修改version值,使router-view key更新达到刷新目的 // cacheInfo.version=new Date().getTime(); // } this.closeTab(path); this.$router.push({path: path}, () => { setTimeout(() => { //恢复原来位置 this.$refs.tabHeader.changeTabIndex(path, index); }, 40) }); }, //处理关闭标签页事件 closeTab(path) { if (this.$refs.tabHeader) { this.$refs.tabHeader.handleTabRemove(path); } }, // 排除不缓存页面 dealExcludeArray(){ this.excludeArray = excludeArray; const routes = this.$router.options.routes.filter((item) => {return item.meta}).filter((item) => {return item.meta.keepAlive === false}) routes.forEach((item,key) => { this.excludeArray.push(item.name) }) }, // 获取第一个菜单 getFirstChild: function(menuItem) { if (!menuItem.children || (menuItem.path && this.ifMenuPath(menuItem.path))) { return menuItem.path; } else { return this.getFirstChild(menuItem.children[0]); } }, // 横向菜单选项 handleSelect(path, openPage) { let menuItem = null; for (let item of this.menuList) { if (item.id == path.name) { menuItem = item; break; } } // 展开第一个菜单 if (menuItem) { if (menuItem.children && menuItem.children.length > 0) { this.$nextTick(function () { //切换到有侧栏 if(this.leftMenuBoxShow){ const width = this.$refs['left_menu'].$el.offsetWidth; this.$set(this.rightContainerStyle, 'padding-left', width + 'px'); }else{ this.$set(this.rightContainerStyle, 'padding-left', 0 + 'px'); } if (openPage) { const openPath = this.getFirstChild(menuItem); if(openPath){ //判断是否为展开菜单页面 if(this.ifMenuPath(openPath)){ this.openPage( openPath.slice(1,openPath.length) ); this.updateMenuOpen(openPath,'open'); }else { this.openPage(openPath); this.updateMenuOpen(openPath,'select'); } }else { this.openPage("*"); } } }); } else if (menuItem.path) { if (openPage) { this.openPage(menuItem.path); } this.$set(this.rightContainerStyle, 'padding-left', '0') } } }, // 点击菜单 - 不包括展开收起菜单 menuSelect(index,indexPath){ this.updateMenuOpen(index,'select'); }, // 展开菜单 menuOpen(index,indexPath){ this.expandMenu('open'); // 如果是菜单展开有页面跳转当前页面 - '$' if(index && this.ifMenuPath(index)){ this.$router.push({path: index.slice(1,index.length)}) this.menuConfig.active = index; this.updateMenuOpen(index,'open'); } }, // 收起菜单 menuClose(index,indexPath){ this.expandMenu('close'); }, // 更新菜单展开时高亮 updateMenuOpen(index,type){ debugger; //等待组件加载完修改 this.$refs["left_menu"].$nextTick(() => { let menu = document.getElementById("left_menu"); //展开菜单 && 有展开菜单页面 if(type === 'open' && this.ifMenuPath(index)){ let active = menu.querySelectorAll(".is-active"); active.forEach((item,key) => { item.classList.remove('is-active') }) let menuArray = [] this.getOpened(menu,menuArray); // 查找展开的菜单div let submenuTitle = menuArray[menuArray.length-1].querySelector(".el-submenu__title"); if(submenuTitle) { submenuTitle.classList.add('is-active'); } this.menuConfig.active = index; //清除展开菜单的高亮 }else { let submenu = menu.querySelectorAll(".el-submenu"); submenu.forEach((item,key) => { let submenuTitle = item.querySelectorAll(".el-submenu__title"); submenuTitle.forEach((item2,key2) => { item2.classList.remove('is-active') }) }) } }) }, // 查找展开的菜单树 getOpened(menu,array){ array.push(menu); let submenu = menu.querySelector(".is-opened"); if(submenu){ this.getOpened(submenu,array) } }, // 是否为展开菜单页 ifMenuPath(path){ return path.slice(0,1) === '$' }, // 展开菜单 expandMenu(type) { // 缓存当前页面菜单 /*if(index && index !== window.sessionStorage.getItem("menuSelect")){ window.sessionStorage.setItem("menuSelect",index); }*/ this.$nextTick(function () { const width = this.$refs['left_menu'].$el.offsetWidth; if(width>this.menuConfig.width&&width>this.menuConfig.minWidth) { this.menuConfig.width = width; } else if(width<this.menuConfig.minWidth) { this.menuConfig.width = this.menuConfig.minWidth+1; } if(this.menuConfig.width>this.menuConfig.maxWidth) { this.menuConfig.maxWidth = this.menuConfig.width; } }) }, getQueryMap: function () { let tmpArray = window.location.href.split('#'); tmpArray = tmpArray[0].split('?'); if (!tmpArray || tmpArray.length < 2) { return {}; } let dataStr = tmpArray[1]; let paramArray = dataStr.split("&"); let result = {}; for (let item of paramArray) { let pair = item.split("="); result[pair[0]] = pair[1]; } return result; }, // 用户信息加载 loadUserInfo: function () { this.isLoading = true; let queryData = this.getQueryMap(); let redirect = null; if(queryData&&queryData.redirect) { redirect = queryData.redirect; } this.$get("/api/main/user/info/current_user", {redirect:redirect}, (response) => { if(redirect) { location.href = decodeURIComponent(redirect); return; } // 因首页报错,注掉这里。咨询陈子严说可能是别的项目的东西,当时一起初始化了 // if (envConfig[env].sso) { // this.$get("/getToken", {}, (res) => { // localStorage.setItem("user_token", res.token); // // console.log(localStorage.getItem("user_token")); // }, (res) => { // this.isLoading = false; // }); // } var userData = response.data; var userid = userData.id; this.$store.commit("updateUser", response.data); this.loadUserExtraInfo(userid, userData); }, (response) => { this.isLoading = false; }); }, loadUserExtraInfo: function (userid, userData) { this.isLoading = true; // 数据授权验证 this.isUserSjsq(userid); let queryData = {}; queryData.userid = userid; this.$get("/api/main/basis/sys/userMgr/obtainUserExtraInfo", queryData, (response) => { // console.log("==obtainUserExtraInfo==response.data====" + JSON.stringify(response.data)) var data1 = response.data; // 取缓存的用户信息、油气田值 // 因为存在首页覆盖授权的情况,可能会导致应该使用的值与后端结果不一致 // 如果存在缓存的值且与后端返回结果不一致,优先取缓存的值。避免刷新页面错乱 const selectField = this.$store.state.selectedField; const userFgsdwdm = this.$store.state.userFgsdwdm; const userCjdwdm = this.$store.state.userCjdwdm; const shouldUpdateFgsdwdm = userFgsdwdm !== null && userFgsdwdm !== undefined && userFgsdwdm !== '' && userFgsdwdm !== userData.fgsdwdm; const shouldUpdateCjdwdm = userCjdwdm !== null && userCjdwdm !== undefined && userCjdwdm !== '' && userCjdwdm !== userData.cjdwdm; userData.ejdwdm = data1.ejdwdm; userData.ejdwmc = data1.ejdwmc; userData.fgsdwdm = shouldUpdateFgsdwdm ? userFgsdwdm : data1.fgsdwdm; userData.cjdwdm = shouldUpdateCjdwdm ? userCjdwdm : data1.cjdwdm; // userData.fgsdwdm = data1.fgsdwdm; // userData.cjdwdm = data1.cjdwdm; userData.oilfield = data1.lx.slice(0,1); userData.gasfield = data1.lx.slice(1,2); userData.naturegas = data1.lx.slice(2,3); // console.log("==aaaaaaaaaa==userData.data====" + JSON.stringify(userData)) this.$store.commit("updateUser", userData); let userFieldType = null; if (userData.oilfield === "1" && userData.gasfield === "1" && userData.naturegas === "0") { this.isYqtSelectShow = true; userFieldType = '油气田板块'; } else if (userData.oilfield === "1" && userData.gasfield === "0" && userData.naturegas === "0") { userFieldType = '油田板块'; } else if (userData.oilfield === "0" && userData.gasfield === "1" && userData.naturegas === "0") { userFieldType = '气田板块'; } else if (userData.oilfield === "0" && userData.gasfield === "0" && userData.naturegas === "1") { userFieldType = '天分板块'; } else if (userData.oilfield === "1" && userData.gasfield === "1" && userData.naturegas === "1") { userFieldType = '油气田板块'; } else { console.warn('未知的油气田板块类型:', userData.oilfield + userData.gasfield + userData.naturegas) } if (selectField !== null && selectField !== undefined && selectField !== '' && selectField !== userFieldType) { userFieldType = selectField; } //油气田板块调用和切换方法 this.setFieldType(userFieldType); //调用云平台接口 // this.loadSlCloudApi("登录"); //加载菜单 this.loadMenu(); this.pageShow = true; }, (response) => { this.isLoading = false; }); }, isUserSjsq(userid) { let queryData = {}; queryData.userid = userid; this.$get("/api/main/basis/sys/userMgr/obtainUserSjsqInfo", queryData, (response) => { let data; if (response.data.length > 0) { data = response.data[0]; if (data == null) { // this.$ElMessage.error('当前用户没有进行数据授权,请联系管理员!') // this.$router.push("/no-auth") location.href = "./no_data_auth.html"; } } }, () => { }); }, setFieldType(userFieldType) { if (userFieldType === '油田板块') { this.headerTabMenuClass = 'top-menu-width';// 更换菜单宽度 this.systemYqtOptions = [ { value: '油田板块', label: '油田板块' }, ] } else if (userFieldType === '气田板块') { this.headerTabMenuClass = 'top-menu-width';// 更换菜单宽度 this.systemYqtOptions = [ { value: '气田板块', label: '气田板块' }, ] } else if (userFieldType === '油气田板块') { this.headerTabMenuClass = 'top-menu-width-yqt';// 更换菜单宽度 this.systemYqtOptions = [ { value: '油气田板块', label: '油气田板块' }, { value: '油田板块', label: '油田板块' }, { value: '气田板块', label: '气田板块' }, ] } else if (userFieldType === '天分板块') { this.headerTabMenuClass = 'top-menu-width';// 更换菜单宽度 this.systemYqtOptions = [ { value: '天分板块', label: '天分板块' }, ] } else { // this.$ElMessage.error('当前用户没有进行数据授权,请联系管理员!') } this.systemYqt = userFieldType; // 油气田赋值全局变量 this.$store.commit('updateSelectedField', userFieldType); // 油气田赋值缓存变量 if(!window.sessionStorage.getItem("selectedField")){ window.sessionStorage.setItem("selectedField",userFieldType); }else { this.$store.commit('updateSelectedField', window.sessionStorage.getItem("selectedField")); this.systemYqt = window.sessionStorage.getItem("selectedField"); } }, // 切换全屏 toggleScreenFull() { if (!screenfull.isEnabled) { // 如果不支持进入全屏,发出不支持提示 this.$ElMessage({ message: "您的浏览器版本过低不支持全屏显示!", type: "warning" }); return false; } screenfull.toggle(); }, // 展示/隐藏header toggleHeader() { this.hideHeader = !this.hideHeader; }, loadUnitNameMap: function () { this.$get("/api/main/meta/type/unit-type", {}, (data) => { let map = {}; for (const item of data.data) { map[item.id] = item.name; } this.$store.commit("updateUnitNameMap", map); }); }, login: function () { if (!this.user.password || this.user.password == '') { this.$ElMessage.warning("请填写密码") return; } this.isLoading = true; this.$post("/api/main/login/check", this.user, (response) => { // location.href = this.$ctx+envConfig[env].indexPath; this.loadUserInfo(); }, (response) => { if(response.code!=0) { this.isLoading = false; } }); }, // loadSlCloudApi(loginStatus,hook) { // let queryData = {}; // queryData.moduleid = "RES_SLYTNYGKZX_0"; // queryData.modulename = "开发单位外部施工用电管理"; // queryData.moduletype = "APP"; // if(this.$store.state.menu!=undefined){ // queryData.moduleid = this.$store.state.menu.ModuleID; // queryData.modulename = this.$store.state.menu.ModuleName; // queryData.moduletype = this.$store.state.menu.ModuleType; // } // queryData.loginStatus = loginStatus; // if(envConfig[env].sso) { // this.$get("/api/main/slcloud/api/loginApiHandler", queryData, (response) => { // }, (response) => { // if (hook) { // hook(); // } // }); // } // }, logInfo(){ console.log(this.$store) console.log("menuConfig.active",this.menuConfig.active) }, }, }; </script>
07-06
同样的解释对下面代码,尽可能详细且解释语法:<template> <div class="body"> <div class="annotation_Table"> <div class="contentBox"> <el-tabs v-model="activeName" @tab-click="handleClick"> <el-tab-pane label="任务" name="task"></el-tab-pane> <el-tab-pane label="工程" name="engineering"></el-tab-pane> </el-tabs> </div> <div> <div class="treeSelect" v-if="activeName == 'task'"> <el-input size="small" placeholder="请输入内容" suffix-icon="el-icon-search" v-model="taskSearch"> </el-input> </div> <div class="treeSelect" v-else> <el-input size="small" placeholder="请输入内容" suffix-icon="el-icon-search" v-model="engineeringSearch"> </el-input> </div> <!-- <el-tree--> <!-- :data="tree_data"--> <!-- show-checkbox--> <!-- node-key="id"--> <!-- @check="check"--> <!-- :default-expand-all="true"--> <!-- :props="defaultProps"--> <!-- @node-click="handleNodeClick"--> <!-- >--> <!-- </el-tree>--> <!-- 修改:树节点:default-expand-all="true"展开改为false闭合 --> <el-tree class="treeLine" :data="tree_data" show-checkbox :node-key="activeName == 'engineering'?'projectId':'taskId'" @check="check" :default-expand-all="false" :props="defaultProps" @node-click="handleNodeClick" ref="treeRefImg" :highlight-current="true" filterable :key="treeKey" :filter-node-method="filterNode"> </el-tree> </div> </div> <div class="image_lazy_right body-tabel"> <div class="top-form" style="position: relative" @keyup.enter="getPicFun()"> <div class="select-box"> <label>专业</label> <el-select @change="taskMajorChange" filterable placeholder="专业" clearable v-model="params.taskMajor"> <el-option v-for="item in MajorList" :key="item.majorType" :label="item.majorTypeName" :value="item.majorType"></el-option> </el-select> </div> <div class="select-box"> <label>电压等级</label> <el-select @change="dydjListChange" filterable placeholder="电压等级" clearable v-model="params.dydj"> <el-option v-for="item in dydjList" :key="item.typeValue" :label="item.typeName" :value="item.typeValue"></el-option> </el-select> </div> <div class="select-box"> <label>工程名称</label> <el-select class="selectCss" clearable filterable @change="gcxxListChange" v-model="params.lineName" placeholder="工程名称"> <el-option v-for="item in gcxxList" :key="item.basicId" :label="item.basicName" :value="item.basicId"></el-option> </el-select> </div> <div class="select-box"> <label>杆塔/间隔名称</label> <!-- 新增@change="handleGtbhChange"杆塔和工程树联动 --> <el-select multiple collapse-tags class="selectCss selectCssList" clearable filterable v-model="gtbhList" placeholder="杆塔/间隔名称" @change="handleGtbhChange"> <el-option v-for="item in gcgtList" :key="item.keyId" :label="item.towerName" :value="item.keyId"></el-option> </el-select> </div> <div class="date-picker-box"> <label>上传时间</label> <el-date-picker v-model="timeValue" type="daterange" value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"> </el-date-picker> </div> <div class="date-picker-box"> <label>处理时间</label> <el-date-picker v-model="timeValue1" type="daterange" value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"> </el-date-picker> </div> <div class="select-box"> <label>是否有问题</label> <el-select class="selectCss" clearable filterable v-model="params.isMark" placeholder="是否有问题"> <el-option label="否" value="0"></el-option> <el-option label="是" value="1"></el-option> </el-select> </div> <div class="select-box"> <label>图片类型</label> <el-select class="selectCss" clearable filterable v-model="params.picType" placeholder="图片类型"> <el-option label="可见光巡检照片" value="1"></el-option> <el-option label="红外巡检照片" value="2"></el-option> </el-select> </div> <div class="select-box"> <label>数据来源</label> <el-select class="selectCss" clearable filterable v-model="params.uploadtype" placeholder="数据来源"> <el-option label="app上传" value="1"></el-option> <el-option label="离线上传" value="2"></el-option> </el-select> </div> <div class="select-box"> <label>是否归档</label> <el-select class="selectCss" clearable filterable v-model="params.isArc" placeholder="是否归档"> <el-option label="否" value="0"></el-option> <el-option label="是" value="1"></el-option> </el-select> </div> <div class="select-box"> <label>处理状态</label> <el-select class="selectCss" clearable filterable v-model="params.handleFlag" placeholder="处理状态"> <el-option label="已处理" value="1"></el-option> <el-option label="未处理" value="2"></el-option> </el-select> </div> <div class="input-box"> <label>处理人</label> <el-input v-model="params.handleUser" placeholder="处理人"></el-input> </div> <!-- <div class="select-box">--> <!-- <label>有无问题</label>--> <!-- <el-select--> <!-- class="selectCss"--> <!-- clearable--> <!-- filterable--> <!-- v-model="params.handleFlag"--> <!-- placeholder="有无问题"--> <!-- >--> <!-- <el-option label="有" value="1"></el-option>--> <!-- <el-option label="无" value="2"></el-option>--> <!-- </el-select>--> <!-- </div>--> <div class="button-box"> <el-button v-if="this.$menu.getMenuBus('查询')" v-on:click="getPicFun">查询</el-button> </div> <div class="button-box" style="position: absolute;right: 0px;bottom: -1px;"> <el-button v-if="this.$menu.getMenuBus('批量下载')" :loading="loading" v-on:click="downloadC()">批量下载</el-button> <el-button v-if="this.$menu.getMenuBus('导出')" v-on:click="exportDronePic()">导出</el-button> <el-button v-if="this.$menu.getMenuBus('数据统计')" v-on:click="getWorkCount()">数据统计</el-button> </div> </div> <div class="demo-image__lazy"> <div class="imgBox"> <div class="imgList" v-for="(item,index) in tableData"> <el-image v-on:click="viewimg(item,index)" :key="item.sourceUrl" :src="getImgUrl(item)"> </el-image> <!-- :preview-src-list="srcList"--> <!-- :initial-index="listIndex"--> <div class="typeNeme">{{ item.taskType }}</div> <div class="typeGD">{{ item.isArcName }}</div> <div class="isWenTi">{{ item.handleName }} 发现 {{ item.defectNum?item.defectNum:0 }} 个问题</div> <div class="imgText"> <li style="cursor: pointer;" v-on:click="modifyTest(item)"><span style="border-bottom: 1px solid #ffffff">{{ item.picName ? item.picName : "" }}</span></li> <!-- <li>--> <!-- <span>名称:</span--> <!-- >{{--> <!-- (item.lineName ? item.lineName : "") +--> <!-- "-" +--> <!-- (item.towerName ? item.towerName : "")--> <!-- }}--> <!-- </li>--> <li><span>采集时间:</span>{{ parseTime(item.photoTime) }}</li> <li class="imgTextLi" v-on:click="modifyTest(item)">标注 >></li> </div> </div> </div> </div> <div class="pageBox"> 共 {{ total }} 条数据 <el-pagination background :current-page.sync="page.pageNum" layout="prev, pager, next, jumper, sizes" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange"> </el-pagination> </div> </div> <manually-annotated ref="examineInitMap" @getPicFun="getPicFun" @pre="pre" @next="next" v-if="dialogUploadObj.isShow" :dialogUploadObj="dialogUploadObj" :AnnotatedRow="AnnotatedRow" :imageObj="imageObj"></manually-annotated> <view-img @closeImgBox="closeImgBox" v-if="view.isShow" :view="view"></view-img> <!-- 隐藏原本代码 --> <!-- <data-statistics v-if="dataStatisticsObj.isShow" :dataStatisticsObj="dataStatisticsObj"></data-statistics> --> <el-dialog title="数据统计" :visible.sync="dataStatisticsObj.isShow" :modal-append-to-body="false" :append-to-body="false" :close-on-click-modal="false" top="12vh" width="70%" class="dialogBox data-statistics-dialog" custom-class="data-statistics-dialog"> <!-- 新增:查询按钮 --> <div class="button-box"> <el-button v-on:click="getWorkCount">查询</el-button> </div> <!-- 新增:任务名称、工程名称、处理时间三个筛选 --> <div class="top-form"> <div class="input-box"> <label>任务名称</label> <el-input placeholder="请输入任务名称" v-model="params.taskName" clearable></el-input> </div> <div class="select-box"> <label>工程名称</label> <el-select class="selectCss" clearable filterable v-model="params.lineName" placeholder="工程名称"> <el-option v-for="item in gcxxList" :key="item.basicId" :label="item.basicName" :value="item.basicId"></el-option> </el-select> </div> <div class="date-picker-box"> <label>处理时间</label> <el-date-picker v-model="timeValue1" type="daterange" value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker> </div> </div> <div class="button-box" style="margin-bottom: 5px; height: 30px;"> <el-row :gutter="3"> <el-col v-for="(tag, index) in filterTags" :key="index" :span="1.5"> <el-tag color="#0C53CF" closable @close="removeFilterTag(index)"> {{ tag.label }}: {{ tag.value }} </el-tag> </el-col> </el-row> </div> <div class="body-tabel"> <div class="body-tabels"> <!-- 新增:auto-resize自动调整大小 --> <vxe-table :data="dataStatisticsObj.tableData" style="width: 100%; height: 100%" border ref="table" :filter-config="{ remote: true }" @filter-change="handleFilterChange" :custom-config="{ placement: 'top-left', storage: true }" :column-config="columnConfig, columnDragConfig" :toolbar-config="toolbarConfig" auto-resize > <vxe-column title="序号" type="seq" align="center" :width="80 * scale"></vxe-column> <vxe-column field="handleUser" align="center" title="标注人员" show-header-overflow show-overflow="title" show-footer-overflow :filters="[{ data: '' }]" sortable> <template #filter="{ column }"> <FuzzySearch ref="fuzzySearch" type="input" @reset="handleReset" @filter="(value) => handleColumnFilter(column, value)" label="标注人员" @changeTab="changeTab" /> </template> </vxe-column> <vxe-column field="towerNum" align="center" title="杆塔数量" show-header-overflow show-overflow="title" show-footer-overflow :filters="[{ data: '' }]" sortable> <template #filter="{ column }"> <FuzzySearch ref="fuzzySearch" type="input" @reset="handleReset" @filter="(value) => handleColumnFilter(column, value)" label="杆塔数量" @changeTab="changeTab" /> </template> </vxe-column> <vxe-column field="markNum" align="center" title="缺陷数据" show-header-overflow show-overflow="title" show-footer-overflow :filters="[{ data: '' }]" sortable> <template #filter="{ column }"> <FuzzySearch ref="fuzzySearch" type="input" @reset="handleReset" @filter="(value) => handleColumnFilter(column, value)" label="缺陷标注" @changeTab="changeTab" /> </template> </vxe-column> <vxe-column field="allNum" align="center" title="处理数据" show-header-overflow show-overflow="title" show-footer-overflow :filters="[{ data: '' }]" sortable> <template #filter="{ column }"> <FuzzySearch ref="fuzzySearch" type="input" @reset="handleReset" @filter="(value) => handleColumnFilter(column, value)" label="处理数据" @changeTab="changeTab" /> </template> </vxe-column> </vxe-table> <!-- 新增分页 --> <!-- 添加分页 --> <div class="pageBox"> 共 {{ dataStatisticsObj.total }} 条数据 <el-pagination background :page-sizes="[10, 20, 50, 100]" :page-size="dataStatisticsObj.page.pageSize" :total="dataStatisticsObj.total" :current-page="dataStatisticsObj.page.pageNum" layout="prev, pager, next, jumper, sizes" @current-change="handleCurrentChangeStats" @size-change="handleSizeChangeStats" > </el-pagination> </div> </div> </div> </el-dialog> </div> </template> <script> import { getProject, getProjectTower, } from "@/api/jobManagement/jobManagementUrl"; import { getCommonReadFile } from '@/api/common' // import dataStatistics from './dataStatistics' //隐藏 import { deletePic, downloadPic, exportDronePic, getPicFun, getSampleEngineerTree, getSampleTaskTree, getWorkCount } from '@/api/dataManageMent' import moment from "moment"; import { getMajorType, getSysDictionary } from "@/api/publicUrl"; import viewImg from "./viewImg"; import manuallyAnnotated from "./manuallyAnnotated"; import { requestParams, resetAddress } from '@/api/url' import { Loading } from 'element-ui' import FuzzySearch from "@/views/FuzzySearch.vue" export default { name: "annotationTable", components: { viewImg, manuallyAnnotated, // dataStatistics, //隐藏 FuzzySearch }, data() { return { view: { isShow: false, obj: {}, }, activeName: "task", treeKey: 0, loading: false, tree_data: [], listIndex: 0, srcList: [], defaultProps: { children: "child", label: "title", }, uro: require("../../../../../assets/images/operation/example.jpg"), gtbhList:[], params: { gtbh: "", //杆塔id companyId: "", //单位id lineName: "", //线路id dydj: "", //电压等级 taskMajor: "", //专业 startTime: "", //开始时间 endTime: "", //结束时间 handleStartTime:'', handleEndTime:'', isMark: "", //是否标注 isArc: "", //是否标注 picType: "", //图片类型 uploadtype: "", //数据来源 taskIds: "", //任务id projectIds: "", //工程id handleFlag: '2', // handleUser: '', // taskName: "", // 新增任务名称参数 }, AnnotatedRow: {}, timeValue: [], timeValue1: [], tableData: [], imageObj: {}, MajorList: [], dydjList: [], gcxxList: [],//左侧工程树与右侧工程名称下拉框联动(左侧树有选中节点时下拉框显示选中的内容,如果没有选中的显示初始化查询的所有工程名称) gcxxListAll: [],//初始化查询的所有工程名称 gcgtList: [], page: { pageNum: 1, pageSize: 10, }, total: 0, upDialogObj: { isShow: false, title: "上传", width: "50%", top: "11vh", "modal-append-to-body": false, "close-on-click-modal": false, "append-to-body": false, }, dataStatisticsObj:{ isShow: false, tableData: [], // 新增:以下 total: 0, page: { pageNum: 1, pageSize: 10 }, }, dialogUploadObj: { isShow: false, title: "图像标注", width: "99%", // width: "96%", // top: "11vh", top: "1vh", "modal-append-to-body": false, "close-on-click-modal": false, "append-to-body": true, }, taskSearch:'',//任务搜索 engineeringSearch:'',//工程搜索 scale: document.documentElement.clientWidth / 1920, // 新增:从子组件移入 // 新增数据统计表格的筛选条件 columnFilters: { handleUser: '', towerNum: '', markNum: '', allNum: '' }, //新增:当前筛选条件 filters: {}, // 新增:字段设置的工具栏配置项 toolbarConfig: { custom: true, // 启用自定义列功能 customStorage: true, // 启用自定义列的本地存储 }, // 相关配置项 columnConfig: { drag: true, // 启用表头左右拖拽排序功能 resizable: true, // 启用拖拽列宽功能 }, columnDragConfig: { trigger: 'cell', showIcon: false, showGuidesStatus: true }, filterTags: [], // 新增:tag标签用于存储筛选条件的标签 }; }, watch: { taskSearch(val) { this.$refs.treeRefImg.filter(val); }, engineeringSearch(val) { this.$refs.treeRefImg.filter(val); }, // 新增: dataStatisticsObj: { handler(newVal) { // 从子组件移入的watch }, deep: true, immediate: true } }, mounted() { this.getPicFun(); this.getMajorType(); this.getSysDictionary(0); this.handleClick(); this.getProject() // 新增:连接vxe-toolbar和vxe-table const $table = this.$refs.table; const $toolbar = this.$refs.toolbarRef; if ($table && $toolbar) { $table.connect($toolbar); } }, methods: { filterNode(value, data) { if (!value) return true; if(!data.title) return true; return data.title.indexOf(value) !== -1; }, handleNodeClick(val){ var _this = this; _this.params.projectIds = ""; _this.params.taskIds = ""; _this.params.lineName = ""; var data = this.$refs.treeRefImg.getCheckedNodes(); var Index = data.findIndex((item) => { return item == val; }); if(Index== -1){ data.push(val) }else { data.splice(Index, 1) } if (_this.activeName == "task") { data.forEach((res) => { if(res.taskId){ _this.params.taskIds += res.taskId + ","; } }); } else { if(data.length > 0){ let arr = [] data.forEach((res) => { if(res.projectId){ if(res.projectId) _this.params.projectIds += res.projectId + ","; } arr.push({basicld:res.projectId,basicName:res.projectName}) }); this.gcxxList = arr }else{ _this.gcxxList = _this.gcxxListAll; } } _this.getPicFun(); this.$refs.treeRefImg.setCheckedNodes(data); }, // handleNodeClick(data){ // var _this = this; // _this.params.projectIds = ""; // _this.params.taskIds = ""; // if (_this.activeName == "task") { // _this.params.taskIds = data.taskId || ''; // } else { // _this.params.projectIds += data.projectId || ""; // } // _this.getPicFun(); // // }, // 隐藏原代码 // check(val, node) { // var _this = this; // _this.params.projectIds = ""; // _this.params.taskIds = ""; // if (_this.activeName == "task") { // node.checkedNodes.forEach((res) => { // _this.params.taskIds += res.taskId + ","; // }); // } else { // if(node.checkedNodes && node.checkedNodes.length > 0){ // let arr = [] // node.checkedNodes.forEach((res) => { // _this.params.projectIds += res.projectId + ","; // arr.push({basicld:res.projectId,basicName:res.projectName}) // }); // this.gcxxList = arr // this.params.lineName = '' // }else{ // this.gcxxList = this.gcxxListAll // this.params.lineName = '' // } // } // _this.getPicFun(); // }, // 修改以上代码 // 修改check方法,处理树节点选中时的联动 check(val, node) {debugger var _this = this; _this.params.projectIds = ""; _this.params.taskIds = ""; _this.params.lineName = ""; // 清空工程名称选择 _this.gtbhList = []; // 清空杆塔选择 if (_this.activeName == "task") { node.checkedNodes.forEach((res) => { _this.params.taskIds += res.taskId + ","; }); } else { // 工程树逻辑 let projectIds = []; let projectNames = []; let arr = [] node.checkedNodes.forEach((res) => { if (res.projectId) { projectIds.push(res.projectId); projectNames.push(res.projectName); _this.params.projectIds += res.projectId + ","; } arr.push({basicld:res.projectId,basicName:res.projectName}) }); this.gcxxList = arr // 更新工程名称下拉框选项 if (projectIds.length > 0) { // 新增:如果选中了工程节点,则只显示选中的工程 // _this.gcxxList = projectIds.map((id, index) => ({ // basicId: id, // basicName: projectNames[index] // })); // 自动查询第一个选中工程的杆塔数据 if (projectIds[0]) { this.getProjectTower(projectIds[0]); } } else { // 新增:如果没有选中任何工程节点,则显示所有工程 _this.gcxxList = _this.gcxxListAll; } } _this.getPicFun(); }, getImgUrl(obj) { // url = requestParams.dronePic+url obj.fileType = obj.fileType ? obj.fileType : 0; var URL= obj.sourceThumbUrl?obj.sourceThumbUrl:obj.sourceUrl var url = requestParams.ImgPathOss + "/uavMap/data/readFile?filePath=" + URL + "&fileType=" + obj.fileType; // console.log(url.replaceAll('#','%23')) // // getCommonReadFile({fileType:obj.fileType,filePath:obj.urlPath,ossPath:obj.urlPath}).then(res=>{ // let url1 = window.URL.createObjectURL(res); // console.log(url1) // }) return resetAddress(url); // return url1.toString(); }, handleClick() { var _this = this; _this.engineeringSearch = '' _this.taskSearch = '' this.gcxxList = this.gcxxListAll if (_this.activeName == "task") { getSampleTaskTree().then((res) => { _this.tree_data = res.data; }); } else { getSampleEngineerTree().then((res) => { _this.tree_data = res.data; }); } _this.treeKey+=1 }, pre() { if (this.page.pageNum == 1) { } else { this.page.pageNum--; this.getPicFun(); } }, next(type) { if(type){ this.page.pageNum = 1; }else{ this.page.pageNum = this.page.pageNum += 1; } this.getPicFun(); }, closeImgBox() { this.view.isShow = false; }, viewimg(row,index) { // this.listIndex = index+1 var Index = this.tableData.findIndex((item) => { return item.keyId == row.keyId; }); this.view.listIndex = Index; this.view.obj = row; this.view.obj.urlPath = row.sourceUrl this.view.isShow = true; }, modifyTest(row) { this.AnnotatedRow = row; this.dialogUploadObj.isShow = true; }, taskMajorChange(val) { // this.MajorList.filter((item, index) => { // return item.majorType == val; // }); }, dydjListChange(val) { let arr = this.dydjList.filter((item, index) => { return item.typeValue == val; }); this.getProject(arr[0]); }, getProject(val) { var _this = this; getProject({ voltageName: val?val.typeName:'', majorType: _this.params.taskMajor?_this.params.taskMajor:'0', voltageLevel: val?val.typeValue:'', }).then((res) => { _this.gcxxListAll = res.data; _this.gcxxList = res.data; }); }, // 原代码隐藏 // gcxxListChange(val) { // this.getProjectTower(val); // // var list = this.gcxxList.filter(item => { // // return item.basicId == val // // }); // }, // 修改以上代码 修改工程名称变化处理方法 gcxxListChange(val) { if (val) { this.getProjectTower(val); } else { this.gcgtList = []; // 清空杆塔列表 this.gtbhList = []; // 清空杆塔选择 } this.getPicFun(); }, // 新增:杆塔选择变化处理方法 handleGtbhChange(val) { this.getPicFun(); }, // 隐藏原代码 // getProjectTower(val) { // var _this = this; // getProjectTower({ keyId: val, majorType: _this.params.taskMajor }).then( // (res) => { // _this.gcgtList = res.data; // } // ); // }, // 新增:修改以上代码:获取杆塔数据方法 getProjectTower(val) { var _this = this; getProjectTower({ keyId: val, majorType: _this.params.taskMajor }).then((res) => { _this.gcgtList = res.data; // 可优化:自动选中第一个杆塔(可选) // if (res.data.length > 0) { // _this.gtbhList = [res.data[0].keyId]; // } }).catch(() => { _this.gcgtList = []; }); }, downloadC(row) { let that = this; let str = "", type = ".zip"; let parmas = {}; that.params.startTime = that.timeValue ? that.timeValue[0] : ""; that.params.endTime = that.timeValue ? that.timeValue[1] : ""; that.params.handleStartTime = that.timeValue1 ? that.timeValue1[0] : ""; that.params.handleEndTime = that.timeValue1 ? that.timeValue1[1] : ""; that.params.gtbh = that.gtbhList.join(",") that.loading = true downloadPic({ ...that.params }).then((data) => { if (!data) { return; } let time = new Date(); let url = window.URL.createObjectURL(new Blob([data])); let link = window.document.createElement("a"); link.style.display = "none"; link.href = url; link.setAttribute("download", moment(time).format("YYYYMMDD") + type); document.body.appendChild(link); link.click(); //释放内存 window.URL.revokeObjectURL(link.href); that.loading = false }).catch(e=>{ that.loading = false }); return; if (row) { str += row.keyId + ","; str = str.slice(0, str.length - 1); parmas = { keyId: str, type: 1, }; type = ".zip"; that.params.startTime = that.timeValue ? that.timeValue[0] : ""; that.params.endTime = that.timeValue ? that.timeValue[1] : ""; that.params.handleStartTime = that.timeValue1 ? that.timeValue1[0] : ""; that.params.handleEndTime = that.timeValue1 ? that.timeValue1[1] : ""; downloadPic({ ...that.params }).then((data) => { if (!data) { return; } let time = new Date(); let url = window.URL.createObjectURL(new Blob([data])); let link = window.document.createElement("a"); link.style.display = "none"; link.href = url; link.setAttribute("download", moment(time).format("YYYYMMDD") + type); document.body.appendChild(link); link.click(); //释放内存 window.URL.revokeObjectURL(link.href); }); } }, deletePic(val) { var _this = this; deletePic({ keyId: val.keyId, fileUrl: val.sourceUrl }).then((res) => { if (res.code == 200) { _this.$message({ message: "删除成功", type: "success", }); } else { _this.$message({ message: "删除失败", type: "error", }); } _this.getPicFun(); }); }, getFile(row) { // debugger let url = process.env.VUE_APP_BASE_API + "/uavMap/data/readFile?filePath=" + row.filePath + "&fileType=" + row.fileType; window.open(resetAddress(url)); }, getSysDictionary(sum) { var _this = this; getSysDictionary({ parentId: sum }).then((res) => { if (sum == 0) { _this.dydjList = res.data; } }); }, getMajorType() { var _this = this; getMajorType({}).then((res) => { _this.MajorList = res.data; }); }, getPicFun() { let instance = Loading.service({ text: "正在查询数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", }); var _this = this; _this.params.startTime = _this.timeValue ? _this.timeValue[0] : ""; _this.params.endTime = _this.timeValue ? _this.timeValue[1] : ""; _this.params.handleStartTime = _this.timeValue1 ? _this.timeValue1[0] : ""; _this.params.handleEndTime = _this.timeValue1 ? _this.timeValue1[1] : ""; _this.params.gtbh = _this.gtbhList.join(",") $(".v-modal").remove(); getPicFun({ ..._this.page, ..._this.params }).then((res) => { _this.tableData = res.data.rows; _this.view.srcList = []; _this.tableData.forEach((item,index)=>{ var url = requestParams.ImgPathOss +"/uavMap/data/readFile?filePath="+item.sourceUrl+"&fileType="+item.fileType; _this.view.srcList.push(resetAddress(url)) }) // _this.tableData = _this.tableData.concat(res.data.rows); _this.total = res.data.total; _this.imageObj = res.data; _this.imageObj["pageNum"] = _this.page.pageNum; _this.srcList = [] // _this.tableData.forEach(obj=>{ // getCommonReadFile({fileType:obj.fileType,filePath:obj.sourceUrl,ossPath:obj.sourceUrl}).then(res=>{ // let url1 = window.URL.createObjectURL(res); // _this.srcList.push(url1) // console.log(_this.srcList) // }) // }) instance.close(); _this.$refs.examineInitMap.preCG(_this.tableData); }).catch(e=>{ instance.close(); }); }, // 新增分页选择器大小 handleSizeChange(val) { this.page.pageSize = val; //更新每页显示条数 this.getPicFun(); //重新获取数据 }, handleCurrentChange(val) { this.page.pageNum = val; this.getPicFun(); }, // 新增分页 handleCurrentChangeStats(val) { this.dataStatisticsObj.page.pageNum = val; this.getWorkCount(); }, // 数据统计表格的每页条数变化 handleSizeChangeStats(val) { this.dataStatisticsObj.page.pageSize = val; this.getWorkCount(); }, getWorkCount(){ var _this = this; // 设置处理时间参数 // _this.params.handleStartTime = _this.timeValue1 ? _this.timeValue1[0] : ""; // _this.params.handleEndTime = _this.timeValue1 ? _this.timeValue1[1] : ""; // 合并表单查询条件和列筛选条件 let queryParams = { ...this.params, ...this.columnFilters, pageNum: this.dataStatisticsObj.page.pageNum, pageSize: this.dataStatisticsObj.page.pageSize, }; // 暂时隐藏不可删除 _this.params.startTime = _this.timeValue ? _this.timeValue[0] : ""; _this.params.endTime = _this.timeValue ? _this.timeValue[1] : ""; _this.params.handleStartTime = _this.timeValue1 ? _this.timeValue1[0] : ""; _this.params.handleEndTime = _this.timeValue1 ? _this.timeValue1[1] : ""; _this.params.gtbh = _this.gtbhList.join(",") _this.dataStatisticsObj.isShow = true getWorkCount(queryParams).then(res =>{ _this.dataStatisticsObj.tableData = res.data.rows || res.data; // 根据后端返回结构调整, _this.dataStatisticsObj.total = res.data.total || res.data.length; // 根据后端返回结构调整; }) }, exportDronePic() { var _this = this; _this.params.startTime = _this.timeValue ? _this.timeValue[0] : ""; _this.params.endTime = _this.timeValue ? _this.timeValue[1] : ""; _this.params.handleStartTime = _this.timeValue1 ? _this.timeValue1[0] : ""; _this.params.handleEndTime = _this.timeValue1 ? _this.timeValue1[1] : ""; _this.params.gtbh = _this.gtbhList.join(",") exportDronePic({ ..._this.params }).then((data) => { let time = new Date(); let url = window.URL.createObjectURL(new Blob([data])); let link = window.document.createElement("a"); link.style.display = "none"; link.href = url; link.setAttribute( "download", "样本库列表" + this.parseTime(new Date(), "{y}{m}{d}{h}{i}{s}") + ".xlsx" ); document.body.appendChild(link); link.click(); //释放内存 window.URL.revokeObjectURL(link.href); }); }, // 数据统计表格的列筛选 handleColumnFilter(column, value) { // 清除每个重复展示的筛选条件 this.filterTags = this.filterTags.filter(tag => tag.prop !== column.property); // 映射列字段到查询字段 const fieldMap = { handleUser: 'handleUser', towerNum: 'towerNum', markNum: 'markNum', allNum: 'allNum' }; if (value || value == 0) { let displayValue = value; // 将筛选条件添加到 filterTags的el-tag标签中 this.filterTags.push({ label: column.title, value: Array.isArray(displayValue) ? displayValue.join(', ') : displayValue, prop: column.property, }); // 更新对应的查询字段 const queryField = fieldMap[column.property] || column.property; this.columnFilters[column.property] = value; this.params[queryField] = value; } else { // 清除筛选条件 const queryField = fieldMap[column.property] || column.property; delete this.columnFilters[column.property]; } this.handleFilterChange({ filters: this.filters }); }, // 移除数据统计表格的筛选标签 removeFilterTag(index) { const removedTag = this.filterTags.splice(index, 1)[0]; // 映射列字段到查询字段 const fieldMap = { companyName: 'companyName', taskName: 'taskName', workDescribe: 'workDescribe', implementTypeName: 'implementType', taskTypeName: 'taskType', planStateName: 'planState', createUser: 'createUser' }; // 清除对应的查询条件 const queryField = fieldMap[removedTag.prop] || removedTag.prop; delete this.params[queryField]; delete this.columnFilters[removedTag.prop]; this.getWorkCount(); }, // 筛选变化事件 handleFilterChange({ column }) {}, // 重置筛选条件 handleReset() { this.filters = {}; this.getWorkCount(); }, changeTab() { this.$nextTick(() => { this.$refs.table.closeFilter(); this.$refs.table.clearFilter(); }); } }, }; </script> <style lang="scss" scoped> .pageBox { display: flex; justify-content: flex-end; align-items: center; color: rgba($color: #fff, $alpha: 0.6); margin-top: 16px; letter-spacing: 1px; ::v-deep .el-pagination { .el-pager li, .btn-prev, .btn-next { width: 34px; height: 34px; color: #fff; font-size: 16px; background: rgba($color: #0045c0, $alpha: 0.2); border: 1px solid rgba($color: #005cff, $alpha: 0.9); line-height: 34px; padding: 0; } .el-pager li.active { background: #005cff; } .el-pagination__jump { color: rgba($color: #fff, $alpha: 0.6); margin-left: 20px; .el-pagination__editor { margin: 0 5px; .el-input__inner { background: rgba($color: #0045c0, $alpha: 0.4); height: 34px; color: #fff; border: 0; } } } .el-pagination__sizes { color: #ffffff !important; .el-input__inner { height: 34px; font-size: 16px; background: rgba($color: #0045c0, $alpha: 0.2); border: 1px solid rgba($color: #005cff, $alpha: 0.9); color: #ffffff !important; } } } } // 新增:引入定义好的样式文件 @import "@/assets/styles/vxeClass.scss"; .body { width: calc(100% - 60px); height: calc(100% - 190px); position: fixed; left: 20px; top: 150px; display: flex; //flex-direction: column; flex-direction: initial; .annotation_Table { width: 20%; height: 100%; //background: #f0f8ff21; .contentBox { width: 100%; flex: 1; //margin-top: 20px; margin-bottom: 20px; ::v-deep .el-tabs { .el-tabs__header { margin: 0; } .el-tabs__nav { width: 100%; display: flex; .el-tabs__item { flex: 1; height: 32px; padding: 0; display: flex; justify-content: center; align-items: center; font-size: 14px; color: #fff; letter-spacing: 1px; background: rgba($color: #000c23, $alpha: 0.3); } .is-active { background: rgba($color: #469bff, $alpha: 0.4); } } .el-tabs__nav-wrap::after { height: 4px; background: rgba($color: #469bff, $alpha: 0.4); } .el-tabs__active-bar { height: 4px; background: #469bff; } ::v-deep .el-tabs__active-bar { width: 200px !important; transform: translateX(0); } } } ::v-deep .el-tree { background: transparent; color: #fff; overflow: auto; height: 586px; //原本675px flex: 1; .el-icon-caret-right:before { //display: none; } >.el-tree-node { min-width: 100%; display: inline-block; } //.el-tree-node__expand-icon { // width: 14px; // height: 14px; // background: url("../../../../../../assets/images/operation/add.png") no-repeat; // background-size: 100% 100%; // // margin-left: -25px; //} .custom-tree-node { margin-left: 14px; } //.el-tree-node__expand-icon.expanded { // transform: rotateY(0); // background: url("../../../../../../assets/images/operation/reduce.png") // no-repeat; // background-size: 100% 100%; //} .el-tree-node__expand-icon.is-leaf { //display: none; } .el-tree-node__content { // margin-left: 42px; } .el-tree-node__content:hover { background: rgba($color: #469bff, $alpha: 0.3); } .el-tree-node:focus>.el-tree-node__content { background: rgba($color: #469bff, $alpha: 0.8); } } ::v-deep .el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content { background: rgba($color: #469bff, $alpha: 0.8); } } .image_lazy_right { width: 80%; height: 100%; //background: rgba(0, 137, 255, 0.13); .date-picker-box { width: 360px; } .select-box { width: 360px; } .input-box { width: 360px; } .demo-image__lazy { display: flex; height: 65%; overflow-y: auto; } .imgBox { display: flex; flex-wrap: wrap; .imgList { position: relative; width: 275px; margin: 0px 10px 0px 10px; overflow: hidden; .el-image { width: 100%; height: 165px; } } .typeNeme { position: absolute; top: 0px; background: #ffb802c7; padding: 2px 25px 2px 10px; border-bottom-right-radius: 19px; color: white; font-size: 13px; } .isWenTi { position: absolute; top: 145px; background: #000000a6; padding: 2px 15px 2px 10px; /* border-bottom-right-radius: 19px; */ color: white; font-size: 13px; } .typeGD { position: absolute; top: 12px; right: -27px; background: #00a3ff; padding: 2px 32px; -webkit-transform: rotate(45deg); transform: rotate(45deg); color: #ffffff; font-size: 13px; } .imgText { color: #ffffff; position: relative; margin-bottom: 10px; font-size: 12px; .imgTextLi { position: absolute; right: 10px; bottom: 0px; color: #00a3ff; cursor: pointer; } } } } .btn { width: 80px; height: 28px; cursor: pointer; display: flex; align-items: center; justify-content: center; } .audit { color: #07ffe1; background: rgba(0, 92, 255, 0.08); border-radius: 2px 2px 2px 2px; border: 1px solid; border-image: linear-gradient(180deg, rgba(7, 255, 225, 0.8), rgba(7, 255, 225, 0.24)) 1 1; margin-right: 8px; img { width: 14px; height: 14px; margin-right: 4px; } } .delete { color: #ff4e02; background: rgba(0, 92, 255, 0.08); border-radius: 2px 2px 2px 2px; border: 1px solid; border-image: linear-gradient(180deg, rgba(255, 78, 2, 0.8), rgba(255, 78, 2, 0.24)) 1 1; img { width: 14px; height: 14px; margin-right: 4px; } } .examine { color: #469bff; background: rgba(0, 92, 255, 0.08); border-radius: 2px 2px 2px 2px; border: 1px solid; border-image: linear-gradient(180deg, rgba(0, 92, 255, 0.8), rgba(0, 92, 255, 0.24)) 1 1; margin-right: 8px; img { width: 14px; height: 14px; margin-right: 4px; } } .downloadC { color: #e6a23c; background: rgba(0, 92, 255, 0.08); border-radius: 2px 2px 2px 2px; border: 1px solid; border-image: linear-gradient(180deg, rgba(236, 162, 60, 0.8), rgba(236, 162, 60, 0.24)) 1 1; margin-right: 8px; img { width: 14px; height: 14px; margin-right: 4px; } } // 新增:从子组件移入的样式 //修改后的样式 .data-statistics-dialog { ::v-deep .el-dialog { height: 70vh !important; // 使用视口高度单位 display: flex; flex-direction: column; .el-dialog__body { flex: 1; padding: 20px; overflow: hidden; display: flex; flex-direction: column; } } .body-tabel { flex: 1; display: flex; flex-direction: column; overflow: hidden; .body-tabels { flex: 1; overflow: hidden; overflow-y: auto; display: flex; flex-direction: column; .vxe-table { flex: 1; display: flex; flex-direction: column; overflow: hidden; overflow-y: auto; .vxe-table--body-wrapper { flex: 1; overflow: auto; } } } } } } </style>
09-09
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值