王震
2023-08-30 e40c2d5988a9ad1afa26421bf8cfdfffba1e0ff3
Merge remote-tracking branch 'origin/master'
已修改9个文件
971 ■■■■ 文件已修改
src/api/inspection/commisioninspection.js 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layout/components/Sidebar/SidebarItem.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/request.js 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/inspectionManagement/commissionInspection/addCommision.vue 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/laboratory/gather/index.vue 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/laboratory/measure/Add.vue 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/laboratory/measure/index.vue 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/laboratory/personnel/index.vue 801 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/inspection/commisioninspection.js
@@ -88,3 +88,11 @@
        params
  })
}
export function getSpecificationsName(params){
  return request({
    url: '/link-basic-table/getSpecificationsName',
    method: 'get',
        params
  })
}
src/layout/components/Sidebar/SidebarItem.vue
@@ -2,10 +2,10 @@
  <div v-if="!item.hidden">
    <template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow">
      <app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)">
        <el-menu-item v-if="onlyOneChild.meta.show==false ?onlyOneChild.meta.show: true" :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}">
          <item :show="onlyOneChild.meta.show" :icon="onlyOneChild.meta.icon||(item.meta&&item.meta.icon)" :title="onlyOneChild.meta.title" />
          <span v-if="onlyOneChild.meta.title==='主页'">主页</span>
                    <span v-if="onlyOneChild.meta.title==='基础数据'">基础数据</span>
        </el-menu-item>
      </app-link>
    </template>
src/router/index.js
@@ -539,9 +539,11 @@
      let menuFather = baseRouter
      const dataMenuFather = fn3(menuFather)
      role.roleMenuList.forEach((r) => {
        dataMenuFather.push(Routees.filter(item => {
          return item.path === r.menuUrl
        })[0])
        if(r.menuName!='首页'){
          dataMenuFather.push(Routees.filter(item => {
            return item.path === r.menuUrl
          })[0])
        }
      })
      let eqChildren = [];
      role.roleMenuList.forEach((r) => {
src/utils/request.js
@@ -1,4 +1,5 @@
import axios from 'axios'
import router from '../router/index'
import { MessageBox, Message } from 'element-ui'
import store from '@/store'
import { getToken } from '@/utils/auth'
@@ -63,8 +64,8 @@
      })
      sessionStorage.removeItem("user")
      sessionStorage.setItem("flushPage",1)
      this.$router.replace({path: '/login'});
      location.reload()
      router.replace({path: '/login'});
      // location.reload()
      }
      if(res.code===403){
        Message({
src/views/inspectionManagement/commissionInspection/addCommision.vue
@@ -22,7 +22,8 @@
                        <el-table-column type="index" label="序号" min-width="10%" />
                        <el-table-column prop="sampleNumber" label="样品编号" min-width="8%" />
                        <el-table-column prop="sampleName" label="样品名称" min-width="10%" />
                        <el-table-column prop="specificationsModels" label="规格型号" min-width="10%" />
                        <el-table-column prop="speName" label="规格型号" min-width="10%" >
                        </el-table-column>
                        <el-table-column prop="unit" label="单位" min-width="8%" />
                        <el-table-column prop="samplesNumber" label="数量" min-width="8%" />
                        <!-- <el-table-column prop="addway" label="添加方式" min-width="8%">
@@ -228,7 +229,8 @@
        addInspection,
        isIfViewUUID,
        getProductList,
        getContractsSampleInfo
        getContractsSampleInfo,
        getSpecificationsName
    } from '@/api/inspection/commisioninspection'
    export default {
        data() {
@@ -342,7 +344,6 @@
                let res = await getContractsSampleInfo({
                    viewId
                })
                console.log(res.data);
            },
            async getSampleName() {
                const res = await getSampleName()
@@ -384,7 +385,8 @@
                    samplesNumber: '',
                    remarks: '',
                    experiment: [],
                    addway: ''
                    addway: '',
                    speName: ''
                }
            },
            async submitInspection() {
@@ -406,7 +408,8 @@
                    reportNumber: parseInt(this.infoForm.num),
                    sampleDeliveryMode: sampledeliveryway,
                    sampleDeliveryPhone: this.infoForm.sendertel,
                    sampleSender: this.infoForm.sender
                    sampleSender: this.infoForm.sender,
                    speName: this.infoForm.speName
                })
                this.infoForm.commisioncode = res.data
                if (res.data) {
@@ -444,6 +447,11 @@
                        return item.name
                    })
                })
                this.model_sta_options.forEach(a=>{
                    if(a.key == val){
                        this.addPointerForm.speName = a.value
                    }
                })
            },
            getContractsSampleInfo() {
                getContractsSampleInfo({
@@ -467,7 +475,7 @@
                    }
                    this.detectionInfo = res.data.linkDetectionList
                })
            }
            },
        }
    }
</script>
src/views/laboratory/gather/index.vue
@@ -17,7 +17,7 @@
      </el-form>
    </div>
    <div class="library-table">
      <el-card v-for="item in device" :key="index" class="box-card" style="width: 22.8%;">
      <el-card v-for="(item,index) in device" :key="index" class="box-card" style="width: 22.8%;">
        <div class="header">
          <div style="display: flex;justify-content: start; width: 100%;">
            <div class="el-icon-set-up" style="font-size: 25px;color: rgb(103, 194, 58);line-height: 55px ;"></div>
@@ -76,6 +76,14 @@
      ]
    }
  },
    methods:{
        searchInspections(){
        },
        reset(){
        }
    }
}
</script>
src/views/laboratory/measure/Add.vue
@@ -5,26 +5,30 @@
        </el-col>
        <el-col>
            <el-form :model="planAddInfo" style="padding-left: 150px;">
                <el-form-item>
                <el-col>
                    <el-col :span="6" style="display: flex;justify-content: space-around;">
                        <span>负责人:</span>
                        <el-select v-model="planAddInfo.measurePerson" placeholder="请选择负责人">
                            <el-option v-for="item in userList" :key="item.value" :label="item.label" :value="item.value">
                            </el-option>
                        </el-select>
                        <el-form-item label="负责人:" :rules="[{ required: true, message: '请选择负责人', trigger: 'change' }]">
                            <el-select v-model="planAddInfo.measurePerson" placeholder="请选择负责人">
                                <el-option v-for="item in userList" :key="item.value" :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8" style="display: flex;justify-content: space-around;">
                        <span>计划时间:</span>
                        <el-date-picker v-model="planAddInfo.planDate" type="daterange" range-separator="至"
                            start-placeholder="开始日期" end-placeholder="结束日期">
                        </el-date-picker>
                        <el-form-item label="计划时间:" :rules="[{ required: true, message: '请选择计划时间', trigger: 'change' }]">
                            <el-date-picker v-model="planAddInfo.planDate" type="daterange" range-separator="至"
                                start-placeholder="开始日期" end-placeholder="结束日期">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="5"></el-col>
                    <el-col :span="5" style="display: flex;justify-content: space-around;">
                        <span>计量单位:</span>
                        <el-input style="width: 150px;" v-model="planAddInfo.unit" placeholder=""></el-input>
                        <el-form-item label="计量单位:">
                            <el-input style="width: 150px;" v-model="planAddInfo.unit" placeholder=""></el-input>
                        </el-form-item>
                    </el-col>
                </el-form-item>
                </el-col>
            </el-form>
        </el-col>
        <el-col>
@@ -47,7 +51,8 @@
                <el-table-column prop="equipmentPointName" label="仪器设备" min-width="150">
                    <template slot-scope="scope">
                        <span v-show="!codePointesTableStatus">{{ scope.row.equipmentPointName }}</span>
                        <el-select @change="insListChange(scope.row.equipmentPointName,scope)" v-model="scope.row.equipmentPointName" placeholder="请选择仪器设备">
                        <el-select @change="insListChange(scope.row.equipmentPointName, scope)"
                            v-model="scope.row.equipmentPointName" placeholder="请选择仪器设备">
                            <el-option v-for="item in insList" :key="item.value" :label="item.label" :value="item.value">
                            </el-option>
                        </el-select>
@@ -95,6 +100,7 @@
    getListUserAndListIns, addPlanAndMeasure
} from '@/api/laboratory/measure'
import { dateFormat } from "../../../utils/dateUtil";
import { MessageBox, Message } from 'element-ui'
export default {
    data() {
        return {
@@ -125,7 +131,7 @@
            }],
            userList: [],
            insList: [],
            instrumentList:[],
            instrumentList: [],
            // 码点表格的状态:数据展示false/新增输入true
            codePointesTableStatus: false,
        }
@@ -136,7 +142,7 @@
        res.data.userList.forEach(element => {
            this.userList.push({ label: element.name, value: element.id })
        });
        this.instrumentList=res.data.instrumentList
        this.instrumentList = res.data.instrumentList
        res.data.instrumentList.forEach(item => {
            this.insList.push({ label: item.equipmentName, value: item.id })
        })
@@ -161,21 +167,28 @@
            })
        },
        async add() {
            console.log(111111);
            if (this.planAddInfo.measurePerson == null || this.planAddInfo.measurePerson == ''||this.planAddInfo.planDate[0]==null||this.planAddInfo.planDate[0]=='') {
                Message({
                    message: "负责人和计划日期不能为空!",
                    type: 'warning',
                    duration: 2 * 1000
                })
                return false
            }
            this.planAddInfo.startTime = dateFormat(this.planAddInfo.planDate[0])
            this.planAddInfo.endTime = dateFormat(this.planAddInfo.planDate[1])
            console.log(this.planAddInfo);
            this.planAddInfo.planDate = null
            this.codePointsTable.forEach(item => {
                if(item.endDate!=null&&item.endDate!=''){
                if (item.endDate != null && item.endDate != '') {
                    item.endDate = dateFormat(item.endDate)
                }
            })
            console.log(this.codePointsTable);
            console.log(this.codePointsTable);
            let data = {}
            this.codePointsTable.length>0?data = { measureList: this.codePointsTable, plan: this.planAddInfo }:data = {plan: this.planAddInfo }
            this.codePointsTable.length > 0 ? data = { measureList: this.codePointsTable, plan: this.planAddInfo } : data = { plan: this.planAddInfo }
            let add = await addPlanAndMeasure(data)
            this.planAddInfo={
            this.planAddInfo = {
                plannedOrderNumber: '',
                measurePerson: '',
                planDate: "",
@@ -183,17 +196,17 @@
                createPerson: '',
                createTime: ''
            }
            this.codePointsTable=[]
            this.codePointsTable = []
            return add.data
        },
        insListChange(i,s){
        insListChange(i, s) {
            console.log(i);
            console.log(s.$index);
            let ins= this.instrumentList.filter(item=>{
                return item.id==i
            let ins = this.instrumentList.filter(item => {
                return item.id == i
            })[0]
            this.codePointsTable[s.$index].measuringRange=ins.measuringRange
            this.codePointsTable[s.$index].termValidity=ins.termValidity+'月'
            this.codePointsTable[s.$index].measuringRange = ins.measuringRange
            this.codePointsTable[s.$index].termValidity = ins.termValidity + '月'
        }
    }
}
src/views/laboratory/measure/index.vue
@@ -7,6 +7,9 @@
            <el-input v-model="searchData.code" @blur="blurSearch()" class="input-form" placeholder="请输入">
            </el-input>
          </el-form-item>
          <el-form-item v-if="this.radioValue === 1">
            <el-button type="primary" @click="searchPlan">查询</el-button>
          </el-form-item>
          <el-form-item v-if="this.radioValue === 0" :label="this.radioValue === 0 ? '仪器设备名称:' : '设备名称'"
            class="sermargin">
            <el-input v-model="searchData.name" class="input-form" placeholder="请输入">
@@ -70,10 +73,10 @@
            <el-table-column prop="name" label="负责人" min-width="10%" />
            <el-table-column prop="createTime" label="创建日期" min-width="10%" />
            <el-table-column prop="name" label="创建人" min-width="8%" />
            <el-table-column prop="code" label="计量编号" min-width="8%" />
            <el-table-column prop="code" label="计量编号" min-width="12%" />
            <el-table-column label="操作" min-width="15%">
              <template slot-scope="scope">
                <el-button type="text" @click="lookMeasurement(scope.row.equipmentCode)" size="small">查看计量履历</el-button>
                <!-- <el-button type="text" @click="lookMeasurement(scope.row.equipmentCode)" size="small">查看计量履历</el-button> -->
                <el-button type="text" size="small">查看附件</el-button>
              </template>
            </el-table-column>
@@ -109,7 +112,7 @@
            </el-table-column>
          </el-table>
          <!-- 分页器 -->
          <div style="display: flex;justify-content: end;">
          <div style="display: flex;justify-content: end;padding: 10px 0;">
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
              :current-page="currentPage" :page-sizes="[5, 10, 20]" :page-size="pageSize"
              layout="total, sizes, prev, pager, next, jumper" :total="total">
@@ -118,9 +121,12 @@
        </div>
      </div>
      <div>
        <el-button v-if="selectInfoBtn" @click="combackLookPlan" style="position: fixed;top: 43px;right: 14px; z-index: 1000;" type="primary" icon="el-icon-refresh-left" size="mini" plain >返回</el-button>
        <div v-if="addBtn" style="display: flex;justify-content: center;width: 10%;position: fixed;top: 43px;right: 14px; z-index: 1000;">
          <el-button @click="addTop = -82;addBtn=false" size="mini" style="width: 60px;" >返回</el-button>
        <el-button v-if="selectInfoBtn" @click="combackLookPlan"
          style="position: fixed;top: 43px;right: 14px; z-index: 1000;" type="primary" icon="el-icon-refresh-left"
          size="mini" plain>返回</el-button>
        <div v-if="addBtn"
          style="display: flex;justify-content: center;width: 10%;position: fixed;top: 43px;right: 14px; z-index: 1000;">
          <el-button @click="addTop = -82; addBtn = false" size="mini" style="width: 60px;">返回</el-button>
          <el-button size="mini" @click="measureAdd" style="width: 60px;" type="primary">保存</el-button>
        </div>
      </div>
@@ -378,13 +384,19 @@
      this.measureUpInfo.remarks = scope.row.remarks
      this.measureUpInfo.termValidity = scope.row.termValidity
    },
    measureAdd() {
    async measureAdd() {
      let res = await this.$refs.add.add()
      if (!res) {
        return
      }
      this.addTop = -82
        this.$message({
          message: '操作成功!',
          type: 'success'
        });
        this.lookVisible = false
      this.$message({
        message: '操作成功!',
        type: 'success'
      });
      this.lookVisible = false
      this.addBtn = false
      this.limitGetPlanMeasureInstrument()
    },
    async handleSizeChangePlan(num) {
      this.pageSizePlan = num
@@ -399,7 +411,7 @@
      this.addTop = 2
      this.lookVisible = true
      this.$parent.mainShowAdd()
      this.addBtn=true
      this.addBtn = true
    },
    async limitGetPlanMeasureInstrument() {
      let param = {
@@ -418,7 +430,7 @@
      this.getPlanAndInfoAndIns(id)
      this.lookVisible = true
      this.mymodelTop = 2
      this.selectInfoBtn=true
      this.selectInfoBtn = true
      this.$parent.triggerMainBtnPlan()
    },
    async getPlanAndInfoAndIns(id) {
@@ -440,7 +452,7 @@
    combackLookPlan() {
      this.lookVisible = false
      this.mymodelTop = -1000
      this.selectInfoBtn=false
      this.selectInfoBtn = false
    },
    blurSearch() {
      if (this.radioValue === 1) {
@@ -495,6 +507,9 @@
    search() {
      this.getStandingPageList()
    },
    searchPlan(){
      this.getPlanPageList()
    },
    reset(formName) {
      this.searchData.name = ''
      this.searchData.code = ''
@@ -506,8 +521,9 @@
    },
    async getPlanPageList() {
      let param = {
        currentPage: this.currentPage, pageSize: this.pageSize,
        code: this.searchData.code, name: this.searchData.name, unit: this.searchData.measureunit
        currentPage: this.currentPage,
        pageSize: this.pageSize,
        plannedOrderNumber: this.searchData.code
      }
      const res = await getPlanPageList(param)
      res.data.list.forEach(item => {
src/views/laboratory/personnel/index.vue
@@ -1,478 +1,393 @@
<template>
  <div class="personnel-main">
    <div class="page-header-search">
      <div class="search-bar">
        <el-form ref="form" :inline="true">
          <el-form-item>
            <el-input v-model="keyword" placeholder="请输入人员名称">
              <i slot="prefix" class="el-input__icon el-icon-search" />
            </el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="getData()">查询</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"
          icon="el-icon-plus"
          @click="dialogFormVisible = true"
          >新增人员</el-button
        >
        <el-dialog
          :title="isUpdate == true ? '更新人员信息' : '新增人员'"
          :visible.sync="dialogFormVisible"
          width="30%"
        >
          <el-form :model="form" ref="form" :rules="rules">
            <el-form-item
              label="账号"
              :label-width="formLabelWidth"
              prop="account"
            >
              <el-input v-model="form.account" />
            </el-form-item>
            <el-form-item label="年龄" :label-width="formLabelWidth">
              <el-input v-model="form.age" />
            </el-form-item>
            <el-form-item
              label="邮箱"
              :label-width="formLabelWidth"
              prop="email"
            >
              <el-input v-model="form.email" />
            </el-form-item>
            <el-form-item
              label="名字"
              :label-width="formLabelWidth"
              prop="name"
            >
              <el-input v-model="form.name" />
            </el-form-item>
            <el-form-item
              label="电话"
              :label-width="formLabelWidth"
              prop="phone"
            >
              <el-input v-model="form.phone" />
            </el-form-item>
            <el-form-item
              label="部门"
              :label-width="formLabelWidth"
              required
              prop="organizationId"
            >
              <el-cascader
                style="width: 100%"
                :options="options"
                :props="myProp"
                v-model="form.organizationId"
                clearable
              ></el-cascader>
            </el-form-item>
            <el-form-item
              label="权限"
              :label-width="formLabelWidth"
              prop="roleId"
            >
              <el-select
                v-model="form.roleId"
                clearable
                style="width: 100%"
                placeholder="请选择权限"
              >
                <el-option
                  v-for="item in roleList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFormVisible = false">取 消</el-button>
            <el-button type="primary" @click="submitForm()">{{
    <div class="personnel-main">
        <div class="page-header-search">
            <div class="search-bar">
                <el-form ref="form" :inline="true">
                    <el-form-item>
                        <el-input v-model="keyword" placeholder="请输入人员名称">
                            <i slot="prefix" class="el-input__icon el-icon-search" />
                        </el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="getData()">查询</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" icon="el-icon-plus" @click="dialogFormVisible = true">新增人员</el-button>
                <el-dialog :title="isUpdate == true ? '更新人员信息' : '新增人员'" :visible.sync="dialogFormVisible" width="30%">
                    <el-form :model="form" ref="form" :rules="rules" style="padding-right: 50px;">
                        <el-form-item label="账号" :label-width="formLabelWidth" prop="account">
                            <el-input v-model="form.account" />
                        </el-form-item>
                        <el-form-item label="年龄" :label-width="formLabelWidth">
                            <el-input v-model="form.age" />
                        </el-form-item>
                        <el-form-item label="邮箱" :label-width="formLabelWidth" prop="email">
                            <el-input v-model="form.email" />
                        </el-form-item>
                        <el-form-item label="名字" :label-width="formLabelWidth" prop="name">
                            <el-input v-model="form.name" />
                        </el-form-item>
                        <el-form-item label="电话" :label-width="formLabelWidth" prop="phone">
                            <el-input v-model="form.phone" />
                        </el-form-item>
                        <el-form-item label="部门" :label-width="formLabelWidth" required prop="organizationId">
                            <el-cascader style="width: 100%" :options="options" :props="myProp" v-model="form.organizationId"
                                clearable></el-cascader>
                        </el-form-item>
                        <el-form-item label="权限" :label-width="formLabelWidth" prop="roleId">
                            <el-select v-model="form.roleId" clearable style="width: 100%" placeholder="请选择权限">
                                <el-option v-for="item in roleList" :key="item.id" :label="item.name" :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible = false">取 消</el-button>
                        <el-button type="primary" @click="submitForm()">{{
              isUpdate == true ? "更 新" : "确 定"
            }}</el-button>
          </div>
        </el-dialog>
      </div>
    </div>
    <div class="content-main">
      <div class="personner-table">
        <el-table
          ref="personnerlTable"
          height="calc(100vh - 240px)"
          border
          :cell-style="{ textAlign: 'center' }"
          :header-cell-style="{
                    </div>
                </el-dialog>
            </div>
        </div>
        <div class="content-main">
            <div class="personner-table">
                <el-table ref="personnerlTable" height="calc(100vh - 240px)" border :cell-style="{ textAlign: 'center' }"
                    :header-cell-style="{
            border: '0px',
            background: '#f5f7fa',
            color: '#606266',
            boxShadow: 'inset 0 1px 0 #ebeef5',
            textAlign: 'center',
          }"
          @filter-change="fnFilterChangeInit"
          :data="personnerlTable"
          style="width: 100%"
        >
          <el-table-column prop="username" label="角色名称" min-width="120" />
          <el-table-column prop="roleName" label="角色权限" min-width="120" />
          <el-table-column prop="age" label="年龄" min-width="150">
            <template scope="scope">
              {{
          }" @filter-change="fnFilterChangeInit" :data="personnerlTable" style="width: 100%">
                    <el-table-column prop="username" label="角色名称" min-width="120" />
                    <el-table-column prop="roleName" label="角色权限" min-width="120" />
                    <el-table-column prop="age" label="年龄" min-width="150">
                        <template scope="scope">
                            {{
                scope.row.age === "" ||
                scope.row.age === null ||
                scope.row.age == undefined
                  ? "---"
                  : scope.row.age
              }}
            </template>
          </el-table-column>
          <el-table-column prop="department" label="部门" min-width="150" />
          <el-table-column prop="createTime" label="创建时间" min-width="180" />
          <el-table-column prop="phone" label="电话" min-width="200">
            <template scope="scope">
              {{
                        </template>
                    </el-table-column>
                    <el-table-column prop="department" label="部门" min-width="150" />
                    <el-table-column prop="createTime" label="创建时间" min-width="180" />
                    <el-table-column prop="phone" label="电话" min-width="200">
                        <template scope="scope">
                            {{
                scope.row.phone === "" || scope.row.phone === undefined
                  ? "---"
                  : scope.row.phone
              }}
            </template>
          </el-table-column>
          <el-table-column prop="email" label="邮箱" min-width="200">
            <template scope="scope">
              {{
                        </template>
                    </el-table-column>
                    <el-table-column prop="email" label="邮箱" min-width="200">
                        <template scope="scope">
                            {{
                scope.row.email === "" || scope.row.email === undefined
                  ? "---"
                  : scope.row.email
              }}
            </template>
          </el-table-column>
          <el-table-column
            prop="jobState"
            label="在职状态"
            min-width="120"
            :filters="[
                        </template>
                    </el-table-column>
                    <el-table-column prop="jobState" label="在职状态" min-width="120" :filters="[
              { text: '在职', value: 1 },
              { text: '离岗', value: 0 },
            ]"
            column-key="status"
            :filter-method="filterTag"
            filter-placement="bottom-end"
          >
            <template slot-scope="scope">
              <el-tag
                :type="scope.row.jobState === 0 ? 'danger' : 'success'"
                disable-transitions
                >{{ scope.row.jobState === 0 ? "离岗" : "在职" }}</el-tag
              >
            </template>
          </el-table-column>
          <el-table-column label="操作" min-width="120">
            <template slot-scope="scope">
              <el-button
                type="text"
                size="small"
                @click="handleClick(scope.row)"
                >编辑</el-button
              >
            </template>
          </el-table-column>
        </el-table>
        <div>
          <!-- 分页器 -->
          <el-pagination
            :current-page="currentPage"
            :page-sizes="[10, 15, 20, 25]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
      </div>
    </div>
  </div>
            ]" column-key="status" :filter-method="filterTag" filter-placement="bottom-end">
                        <template slot-scope="scope">
                            <el-tag :type="scope.row.jobState === 0 ? 'danger' : 'success'"
                                disable-transitions>{{ scope.row.jobState === 0 ? "离岗" : "在职" }}</el-tag>
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" min-width="120">
                        <template slot-scope="scope">
                            <el-button type="text" size="small" @click="handleClick(scope.row)">编辑</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div>
                    <!-- 分页器 -->
                    <el-pagination :current-page="currentPage" :page-sizes="[10, 15, 20, 25]" :page-size="pageSize"
                        layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange"
                        @current-change="handleCurrentChange" />
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import { get, post, put } from "@/api/util/requestUtil";
import urlInfo from "../../../api/urlEnum/personnel.js";
import { getOrganizationalApi } from "@/api/laboratory/organizational";
export default {
  data() {
    return {
      keyword: "",
      roleList: "",
      personnerlTable: [],
      filteredpersonnerlTable: [],
      currentindex: 1,
      currentPage: 1, // 当前页码
      total: 0, // 总条数
      pageSize: 100, // 每页的数据条数
      personData: [], // 用来存放接口传过来的人员列表数据
      dialogFormVisible: false,
      form: {
        account: "",
        age: "",
        email: "",
        name: "",
        phone: "",
        organizationId: "",
        roleId: "",
      },
      myProp: {
        value: "id",
        label: "department",
        checkStrictly: true, //允许选择任意一节
      },
      formLabelWidth: "100px",
      rules: {
        account: [
          {
            required: true,
            message: "请输入账号",
            trigger: "blur",
          },
        ],
        name: [
          {
            required: true,
            message: "请输入名字",
            trigger: "blur",
          },
        ],
        phone: [
          // { required: true, message: '请输入11位电话号码', trigger: 'blur' },
          {
            pattern: /^1[3456789]\d{9}$/,
            message: "非法手机号码",
            trigger: ["blur", "change"],
          },
        ],
        email: [
          // { required: true, message: '请输入邮箱地址', trigger: 'blur' },
          {
            type: "email",
            message: "非法邮箱地址",
            trigger: ["blur", "change"],
          },
        ],
        organizationId: [
          {
            required: true,
            type: "array",
            message: "请选择部门",
            trigger: "change",
          },
        ],
        roleId: [
          { required: true, message: "请输入权限(0或1)", trigger: "blur" },
        ],
      },
      options: [],
      status: "",
      isUpdate: false,
    };
  },
  mounted() {
    this.getData();
    this.getTreeData();
  },
  methods: {
    // 每页条数改变时触发 选择一页显示多少行
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.currentPage = 1;
      this.pageSize = val;
    },
    filterTag(value) {
      this.status = "";
      this.status = value;
      return true;
    },
    // 当前页改变时触发 跳转其他页
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.currentPage = val;
    },
    async getData() {
      let data = {
        pageNo: 0,
        pageSize: 10,
        name: this.keyword,
        status: this.status,
      };
      let res = await get(urlInfo.url.list_new_personnel, data);
      this.personnerlTable = res.data.row;
      this.total = res.data.total;
    },
    searchData() {
      this.filteredpersonnerlTable = this.personnerlTable.filter((item) => {
        return item.username === this.keyword;
      });
      this.personnerlTable = this.filteredpersonnerlTable;
    },
    resetData() {
      this.personnerlTable = this.personData;
      this.keyword = "";
      this.status = "";
      this.getData();
    },
    // 提交新增人员表单
    submitForm() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          let departmentId = this.form.organizationId;
          this.form.organizationId = departmentId[departmentId.length - 1];
          if (!this.isUpdate) {
            post("/user/add_new_personnel", this.form).then((response) => {
              this.$message({
                message: response.message,
                type: "success",
              });
              this.dialogFormVisible = false;
              this.getData();
            });
          } else {
            put("/user/update_new_personnel", this.form).then((res) => {
              this.$message({
                message: res.message,
                type: "success",
              });
              this.dialogFormVisible = false;
              this.getData();
            });
          }
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    // 清空Cascader空白
    clearCascaderBlank(list) {
      list.forEach((i) => {
        if (i.children.length === 0) {
          i.children = undefined;
        } else {
          this.clearCascaderBlank(i.children);
        }
      });
    },
    fnFilterChangeInit() {
      this.personData = [];
      this.getData();
    },
    /*
     * @param  list 数据列表
     * @param  id 后端返回的id
     **/
    getParentsById(list, id) {
      for (let i in list) {
        if (list[i].id == id) {
          return [list[i].id];
        }
        if (list[i].children) {
          let node = this.getParentsById(list[i].children, id);
          if (node !== undefined) {
            //查询到把父节把父节点加到数组前面
            node.unshift(list[i].id);
            return node;
          }
        }
      }
    },
    import {
        get,
        post,
        put
    } from "@/api/util/requestUtil";
    import urlInfo from "../../../api/urlEnum/personnel.js";
    import {
        getOrganizationalApi
    } from "@/api/laboratory/organizational";
    export default {
        data() {
            return {
                keyword: "",
                roleList: "",
                personnerlTable: [],
                filteredpersonnerlTable: [],
                currentindex: 1,
                currentPage: 1, // 当前页码
                total: 0, // 总条数
                pageSize: 100, // 每页的数据条数
                personData: [], // 用来存放接口传过来的人员列表数据
                dialogFormVisible: false,
                form: {
                    account: "",
                    age: "",
                    email: "",
                    name: "",
                    phone: "",
                    organizationId: "",
                    roleId: "",
                },
                myProp: {
                    value: "id",
                    label: "department",
                    checkStrictly: true, //允许选择任意一节
                },
                formLabelWidth: "100px",
                rules: {
                    account: [{
                        required: true,
                        message: "请输入账号",
                        trigger: "blur",
                    }, ],
                    name: [{
                        required: true,
                        message: "请输入名字",
                        trigger: "blur",
                    }, ],
                    phone: [
                        // { required: true, message: '请输入11位电话号码', trigger: 'blur' },
                        {
                            pattern: /^1[3456789]\d{9}$/,
                            message: "非法手机号码",
                            trigger: ["blur", "change"],
                        },
                    ],
                    email: [
                        // { required: true, message: '请输入邮箱地址', trigger: 'blur' },
                        {
                            type: "email",
                            message: "非法邮箱地址",
                            trigger: ["blur", "change"],
                        },
                    ],
                    organizationId: [{
                        required: true,
                        type: "array",
                        message: "请选择部门",
                        trigger: "change",
                    }, ],
                    roleId: [{
                        required: true,
                        message: "请输入权限(0或1)",
                        trigger: "blur"
                    }, ],
                },
                options: [],
                status: "",
                isUpdate: false,
            };
        },
        mounted() {
            this.getData();
            this.getTreeData();
        },
        methods: {
            // 每页条数改变时触发 选择一页显示多少行
            handleSizeChange(val) {
                this.currentPage = 1;
                this.pageSize = val;
            },
            filterTag(value) {
                this.status = "";
                this.status = value;
                return true;
            },
            // 当前页改变时触发 跳转其他页
            handleCurrentChange(val) {
                this.currentPage = val;
            },
            async getData() {
                let data = {
                    pageNo: 0,
                    pageSize: 10,
                    name: this.keyword,
                    status: this.status,
                };
                let res = await get(urlInfo.url.list_new_personnel, data);
                this.personnerlTable = res.data.row;
                this.total = res.data.total;
            },
            searchData() {
                this.filteredpersonnerlTable = this.personnerlTable.filter((item) => {
                    return item.username === this.keyword;
                });
                this.personnerlTable = this.filteredpersonnerlTable;
            },
            resetData() {
                this.personnerlTable = this.personData;
                this.keyword = "";
                this.status = "";
                this.getData();
            },
            // 提交新增人员表单
            submitForm() {
                this.$refs.form.validate((valid) => {
                    if (valid) {
                        let departmentId = this.form.organizationId;
                        this.form.organizationId = departmentId[departmentId.length - 1];
                        if (!this.isUpdate) {
                            post("/user/add_new_personnel", this.form).then((response) => {
                                this.$message({
                                    message: response.message,
                                    type: "success",
                                });
                                this.dialogFormVisible = false;
                                this.getData();
                            });
                        } else {
                            put("/user/update_new_personnel", this.form).then((res) => {
                                this.$message({
                                    message: res.message,
                                    type: "success",
                                });
                                this.dialogFormVisible = false;
                                this.getData();
                            });
                        }
                    } else {
                        return false;
                    }
                });
            },
            // 清空Cascader空白
            clearCascaderBlank(list) {
                list.forEach((i) => {
                    if (i.children.length === 0) {
                        i.children = undefined;
                    } else {
                        this.clearCascaderBlank(i.children);
                    }
                });
            },
            fnFilterChangeInit() {
                this.personData = [];
                this.getData();
            },
            /*
             * @param  list 数据列表
             * @param  id 后端返回的id
             **/
            getParentsById(list, id) {
                for (let i in list) {
                    if (list[i].id == id) {
                        return [list[i].id];
                    }
                    if (list[i].children) {
                        let node = this.getParentsById(list[i].children, id);
                        if (node !== undefined) {
                            //查询到把父节把父节点加到数组前面
                            node.unshift(list[i].id);
                            return node;
                        }
                    }
                }
            },
    handleClick(row) {
      this.isUpdate = true;
      this.dialogFormVisible = true;
      this.form.name = row.username;
      this.form.roleName = row.roleName;
      this.form.phone = row.phone;
      this.form.id = row.id;
      this.form.email = row.email;
      this.form.organizationId = this.getParentsById(
        this.options,
        row.departmentId
      );
      this.form.roleId = row.roleName;
      this.form.age = row.age;
      this.form.account = row.account;
    },
    getTreeData() {
      getOrganizationalApi().then((res) => {
        this.options = res.data[0].children;
        this.clearCascaderBlank(this.options);
      });
    },
    getRoleList() {
      get("/user/list").then((res) => {
        console.log(`output->res`, res);
        this.roleList = res.data;
      });
    },
  },
  watch: {
    dialogFormVisible: {
      handler(newVal, oldVal) {
        if (newVal == false) {
          this.isUpdate = false;
          this.form = {};
          this.$refs.form.resetFields();
        } else {
          this.getRoleList();
        }
      },
    },
  },
};
            handleClick(row) {
                this.isUpdate = true;
                this.dialogFormVisible = true;
                this.form.name = row.username;
                this.form.roleName = row.roleName;
                this.form.phone = row.phone;
                this.form.id = row.id;
                this.form.email = row.email;
                this.form.organizationId = this.getParentsById(
                    this.options,
                    row.departmentId
                );
                this.form.roleId = row.roleName;
                this.form.age = row.age;
                this.form.account = row.account;
            },
            getTreeData() {
                getOrganizationalApi().then((res) => {
                    this.options = res.data[0].children;
                    this.clearCascaderBlank(this.options);
                });
            },
            getRoleList() {
                get("/user/list").then((res) => {
                    this.roleList = res.data;
                });
            },
        },
        watch: {
            dialogFormVisible: {
                handler(newVal, oldVal) {
                    if (newVal == false) {
                        this.isUpdate = false;
                        this.form = {};
                        this.$refs.form.resetFields();
                    } else {
                        this.getRoleList();
                    }
                },
            },
        },
    };
</script>
<style lang="scss" scoped>
.personnel-main {
  // width: 100%;
  // height: 100%;
  .page-header-search {
    background: #fff;
    display: flex;
    justify-content: space-between;
    padding: 0 24px 12px 24px;
    .personnel-main {
    .search-bar {
      .el-form {
        .el-form-item {
          margin-bottom: 0px !important;
        // width: 100%;
        // height: 100%;
        .page-header-search {
            background: #fff;
            display: flex;
            justify-content: space-between;
            padding: 20px 24px 12px 24px;
          .el-input {
            width: 360px;
          }
        }
      }
    }
  }
            .search-bar {
                .el-form {
                    .el-form-item {
                        margin-bottom: 0px !important;
  .personner-table {
    background: #fff;
    padding: 20px 20px 10px 20px;
                        .el-input {
                            width: 360px;
                        }
                    }
                }
            }
        }
    > div:nth-child(2) {
      display: flex;
      justify-content: end;
      margin: 10px 0;
    }
  }
}
</style>
        .personner-table {
            background: #fff;
            padding: 20px 20px 10px 20px;
            >div:nth-child(2) {
                display: flex;
                justify-content: end;
                margin: 10px 0;
            }
        }
    }
</style>