hailin
2023-07-18 b945f5a17664823e5ab2967e61bc3f3d38aa4087
修改侧边导航栏
已修改7个文件
284 ■■■■ 文件已修改
src/layout/components/Sidebar/SidebarItem.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layout/index.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/styles/element-ui.scss 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/styles/sidebar.scss 145 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/styles/variables.scss 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/laboratory/ledger/index.vue 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/laboratory/personnel/index.vue 75 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layout/components/Sidebar/SidebarItem.vue
@@ -8,7 +8,7 @@
      </app-link>
    </template>
    <el-submenu v-else ref="subMenu" :index="resolvePath(item.path)" popper-append-to-body>
    <el-submenu v-else ref="subMenu" popper-class="popMenu" :index="resolvePath(item.path)" popper-append-to-body>
      <template slot="title">
        <item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="item.meta.title" />
      </template>
src/layout/index.vue
@@ -94,11 +94,12 @@
    right: 0;
    z-index: 9;
    width: calc(100% - #{$sideBarWidth});
    // width: calc(100% - 100px);
    transition: width 0.28s;
  }
  .hideSidebar .fixed-header {
    width: calc(100% - 54px)
    width: calc(100% - #{$sideBarWidth})
  }
  .mobile .fixed-header {
src/styles/element-ui.scss
@@ -90,3 +90,24 @@
.el-radio-button__orig-radio:checked+.el-radio-button__inner {
  box-shadow: -0.00521rem 0 0 0 #b3d8ff;
}
.el-menu-item,.el-submenu{
  width: 100px;
  height: 100px !important;
  line-height:normal;
  display: flex;
  align-items: center;
  justify-content: center !important;
}
// .el-menu-popup{
//   min-width: 100px !important;
// }
.el-menu--vertical{
  max-width: 100px !important;
}
.el-menu--collapse .el-menu .el-submenu, .el-menu--popup {
  min-width: 100px !important;
  // background-color: #fff ;
}
src/styles/sidebar.scss
@@ -69,11 +69,38 @@
    }
    // menu hover
    .submenu-title-noDropdown,
    .el-submenu__title {
    .el-submenu__title,.el-tooltip{
      &:hover {
        background-color: $menuHover !important;
        border-radius: 8px;
        overflow: hidden;
        color: $menuActiveText !important;
      }
    }
    .submenu-title-noDropdown{
      &:hover {
        background-color:transparent !important;
        // background-color: $menuBg !important;
        border-radius: 8px;
        overflow: hidden;
        color: $menuActiveText !important;
      }
    }
    .el-submenu.is-active{
     .popMenu{
      background-color: #fff !important;
      }
     .el-submenu__title{
        background-color: #ffffff !important;
        border-radius: 8px;
        overflow: hidden;
        color: $menuActiveText !important;
      }
    }
    
@@ -88,26 +115,53 @@
      }
    }
    // .is-active.el-submenu{
    //   color: $subMenuActiveText !important;
    // }
    .is-active.el-menu-item {
      // color: $subMenuActiveText !important;
      // border-right: 3px solid $menuActiveText;
      // background-color: $menuHover !important;
      background: #fff !important;
      .el-tooltip{
      color: $subMenuActiveText !important;
      border-right: 3px solid $menuActiveText;
        // border-right: 3px solid $menuActiveText;
      background-color: $menuHover !important;
        border-radius: 8px;
      }
    }
  }
  .hideSidebar {
    .sidebar-container {
      width: 54px !important;
      // width: 54px !important;//原来的样式
      width: 100px !important;//修改后的样式
    }
    .main-container {
      margin-left: 54px;
      // margin-left: 54px;//原来的样式
      margin-left: 100px;//修改后的样式
    }
    .submenu-title-noDropdown {
      padding: 0 !important;
      position: relative;
      .el-tooltip{
        width: 80px !important;
        line-height: normal;
        height: 80px !important;
        padding: 0 !important;
        display: flex !important;
        flex-direction: column;
        align-items: center;
        line-height: normal;
        justify-content: center;
        position: static !important;
      }
      .el-tooltip {
        padding: 0 !important;
@@ -116,7 +170,8 @@
        }
        .sub-el-icon {
          margin-left: 19px;
          font-size: 30px;
          margin: 0px;
        }
      }
    }
@@ -125,19 +180,60 @@
      overflow: hidden;
      &>.el-submenu__title {
        // width: auto;
        // height: auto;
        width: 80px;
        line-height: normal;
        height: 80px !important;
        padding: 0 !important;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        .svg-icon {
          margin-left: 20px;
        }
        .sub-el-icon {
          margin-left: 19px;
          // margin-left: 19px;
          font-size: 30px;
          margin: 0px;
        }
        .el-submenu__icon-arrow {
          display: none;
        }
      }
      &>.el-menu--vertical.popMenu{
        .el-menu{
            width: 60px;
            height: 60px !important;
            line-height: normal !important;
            // >a{
            //   width: 100%;
            //   height: 60px !important;
            // }
        }
        .nest-menu{
            width: 60px;
            height: 60px !important;
            line-height: normal !important;
            background-color: #fff !important;
            // margin: 0 auto;
          // >a {
          //   height: 100%;
          // }
          .el-menu-item{
            padding: 0px !important;
            width: 60px;
            height: 30px !important;
            line-height: normal !important;
            margin: 0 auto;
          }
        }
      }
    }
@@ -145,11 +241,12 @@
      .el-submenu {
        &>.el-submenu__title {
          &>span {
            height: 0;
            width: 0;
            overflow: hidden;
            visibility: hidden;
            display: inline-block;
            // height: 0;
            // width: 0;
            // overflow: hidden;
            // visibility: hidden;
            // display: inline-block;
            // 上面是隐藏文字
          }
        }
      }
@@ -192,6 +289,7 @@
// when menu collapsed
.el-menu--vertical {
  &>.el-menu {
    background-color: $subMenuBg !important;
    .svg-icon {
      margin-right: 16px;
    }
@@ -200,12 +298,29 @@
      margin-left: -2px;
    }
  }
  .nest-menu .el-submenu>.el-submenu__title,
  .el-menu-item {
    width: 100px;
    height: 30px !important;
    min-width: 100px !important;
    line-height: 30px;
    text-align: left !important;
    font-size: 10px;
    justify-content: start !important;
    background-color: $subMenuBg !important;
    color: $subMenuHover !important;
    .svg-icon{
      margin-right: 0px;
      display: none;
    }
    span{
      text-align: center;
    }
    &:hover {
      // you can use $subMenuHover
      background-color: $menuHover !important;
      background-color: $subMenuHover !important;
      color: $subMenuBg !important;
      // background-color: red !important;
    }
  }
@@ -213,7 +328,7 @@
  >.el-menu--popup {
    max-height: 100vh;
    overflow-y: auto;
    background-color: #fff;
    &::-webkit-scrollbar-track-piece {
      background: #d3dce6;
    }
src/styles/variables.scss
@@ -12,18 +12,32 @@
// $sideBarWidth: 210px;
$menuText:#606266;
// $menuText:#606266;
// $menuActiveText:#0077DB;
// // $subMenuActiveText:#606266; //https://github.com/ElemeFE/element/issues/12951
// $subMenuActiveText:#0077DB; //https://github.com/ElemeFE/element/issues/12951
// $menuBg:#fff;
// $menuHover:#E5F1FB;
// $subMenuBg:#fff;
// $subMenuHover:#E5F1FB;
// $sideBarWidth: 100px;
$menuText:#fff;
$menuActiveText:#0077DB;
// $subMenuActiveText:#606266; //https://github.com/ElemeFE/element/issues/12951
$subMenuActiveText:#0077DB; //https://github.com/ElemeFE/element/issues/12951
$menuBg:#fff;
$menuHover:#E5F1FB;
$menuBg:#0077DB;
$menuHover:#fff;
$subMenuBg:#fff;
$subMenuHover:#E5F1FB;
$subMenuHover:#0077DB;
$sideBarWidth: 200px;
$sideBarWidth: 100px;
// the :export directive is the magic sauce for webpack
// https://www.bluematador.com/blog/how-to-share-variables-between-js-and-sass
src/views/laboratory/ledger/index.vue
@@ -5,8 +5,8 @@
        <el-form ref="form" inline="true" :model="searchData">
          <el-form-item>
            <el-input
              placeholder="请输入编号/设备名称/型号规格"
              v-model="searchData.keyword"
              placeholder="请输入编号/设备名称/型号规格"
            >
              <i slot="prefix" class="el-input__icon el-icon-search" />
            </el-input>
@@ -35,9 +35,7 @@
          :props="defaultProps"
          default-expand-all
          :filter-node-method="filterNode"
        >
        </el-tree>
        />
      </div>
      <div class="library-table">
        <div class="table-header">
@@ -50,7 +48,7 @@
              <el-radio-button label="故障" />
              <el-radio-button label="报废" />
            </el-radio-group>
            <el-checkbox :style="{'marginLeft':'12px'}" v-model="isOut">已过期</el-checkbox>
            <el-checkbox v-model="isOut" :style="{'marginLeft':'12px'}">已过期</el-checkbox>
          </div>
          <div class="serve-btn">
            <!-- <el-button type="primary" icon="el-icon-plus">新增人员</el-button> -->
@@ -126,20 +124,20 @@
              :fixed="true"
            >
              <template slot-scope="scope" >
                <el-button @click="handleClick(scope.row)" type="text" size="small">编辑</el-button>
                <el-button type="text" size="small" @click="handleClick(scope.row)">编辑</el-button>
                <!-- <el-button type="text" size="small">编辑</el-button> -->
              </template>
            </el-table-column>
          </el-table>
          <div>
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage"
              :page-sizes="[100, 200, 300, 400]"
              :page-size="100"
              layout="total, sizes, prev, pager, next, jumper"
              :total="400"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
            />
          </div>
        </div>
src/views/laboratory/personnel/index.vue
@@ -5,42 +5,42 @@
        <el-form ref="form" inline="true" :model="searchData">
          <el-form-item>
            <el-input
              placeholder="请输入人员名称"
              v-model="keyword"
              placeholder="请输入人员名称"
            >
              <i slot="prefix" class="el-input__icon el-icon-search" />
            </el-input>
          </el-form-item>
          <el-form-item>
            <el-button @click="searchData()" type="primary">查询</el-button>
            <el-button @click="resetData()" type="primary" plain>重置</el-button>
            <el-button type="primary" @click="searchData()">查询</el-button>
            <el-button type="primary" plain @click="resetData()">重置</el-button>
            <!-- <el-button type="text">高级搜索<i class="el-icon-arrow-down el-icon--right" /></el-button> -->
          </el-form-item>
        </el-form>
      </div>
      <div class="serve-btn">
        <el-button type="primary" @click="dialogFormVisible = true" icon="el-icon-plus">新增人员</el-button>
        <el-button type="primary" icon="el-icon-plus" @click="dialogFormVisible = true">新增人员</el-button>
        <el-dialog title="新增人员" :visible.sync="dialogFormVisible">
          <el-form :model="form" :rules="rules" ref="form">
          <el-form ref="form" :model="form" :rules="rules">
            <el-form-item label="账号" :label-width="formLabelWidth" prop="account">
              <el-input v-model="form.account" autocomplete="off"></el-input>
              <el-input v-model="form.account" autocomplete="off" />
            </el-form-item> 
            <el-form-item label="年龄" :label-width="formLabelWidth">
              <el-input v-model="form.age" autocomplete="off"></el-input>
              <el-input v-model="form.age" autocomplete="off" />
            </el-form-item>
            <el-form-item label="邮箱" :label-width="formLabelWidth" prop="email">
              <el-input v-model="form.email" autocomplete="off"></el-input>
              <el-input v-model="form.email" autocomplete="off" />
            </el-form-item>
            <el-form-item label="名字" :label-width="formLabelWidth" prop="name">
              <el-input v-model="form.name" autocomplete="off"></el-input>
              <el-input v-model="form.name" autocomplete="off" />
            </el-form-item>
            <el-form-item label="电话" :label-width="formLabelWidth" prop="phone">
              <el-input v-model="form.phone" autocomplete="off"></el-input>
              <el-input v-model="form.phone" autocomplete="off" />
            </el-form-item>
            
            <el-form-item label="权限" :label-width="formLabelWidth" prop="role_id">
              <el-input v-model="form.role_id" autocomplete="off"></el-input>
              <el-input v-model="form.role_id" autocomplete="off" />
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
@@ -111,7 +111,7 @@
            min-width="120"
          >
            <template slot-scope="scope">
              <el-button @click="handleClick(scope.row)" type="text" size="small">编辑</el-button>
              <el-button type="text" size="small" @click="handleClick(scope.row)">编辑</el-button>
              <!-- <el-button type="text" size="small">编辑</el-button> -->
            </template>
          </el-table-column>
@@ -119,14 +119,14 @@
        <div>
          <!-- 分页器 -->
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[100, 200, 300, 400]"
            :page-size=pageSize
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total=this.personnerlTable.length>
          </el-pagination>
            :total="this.personnerlTable.length"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
      </div>
    </div>
@@ -139,7 +139,6 @@
export default {
  data() {
    return {
      currentPage: 1,
      keyword: '',
      personnerlTable: [
@@ -152,11 +151,11 @@
      personData:[],  //用来存放接口传过来的人员列表数据
      dialogFormVisible:false,
      form: {
        account: "",
        account: '',
        age: '',
        email: "",
        name: "",
        phone: "",
        email: '',
        name: '',
        phone: '',
        role_id: ''
        },
        formLabelWidth: '120px',
@@ -181,26 +180,26 @@
            {required: true, message: '请输入权限(0或1)', trigger: 'blur'}
            
          ]
      },
      }
    }
  },
  mounted(){
    this.getData();
    this.getData()
  },
  methods: {
    //每页条数改变时触发 选择一页显示多少行
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
      this.currentPage = 1;
      this.pageSize = val;
      this.currentPage = 1
      this.pageSize = val
    },
    //当前页改变时触发 跳转其他页
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
      this.currentPage = val;
      this.currentPage = val
    },
    getData(){
      axios.get("/user/list_new_personnel",{
      axios.get('/user/list_new_personnel', {
        params:{
          pageNo:0,
          pageSize:20
@@ -210,14 +209,14 @@
        this.personData=res.data.data.row
        this.personnerlTable=this.personData
      }).catch(res=>{
        console.log("error")
        console.log('error')
      })
    },
    searchData() {
      this.filteredpersonnerlTable = this.personnerlTable.filter((item) =>{
        return item.username==this.keyword
        return item.username === this.keyword
      }
      );
      )
      this.personnerlTable=this.filteredpersonnerlTable
    },
    resetData(){
@@ -232,22 +231,22 @@
      // POST请求
      this.$refs.form.validate((valid)=>{
        if(valid){
          this.dialogFormVisible = false;
          this.dialogFormVisible = false
          axios.post('/user/add_new_personnel', this.form)
          .then(response => {
          console.log(response);
              console.log(response)
        // this.dialogVisible = false;
          })
          .catch(error => {
           console.error(error);
           });
              console.error(error)
            })
        }else{
          console.log('error submit!!');
          return false;
          console.log('error submit!!')
          return false
        }
      }) 
    }
  },
  }
}
</script>