PeopleTable.vue 5.12 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
<template>
    <div>
      <!-- 搜索 -->
      <div class="top-search flex">
        <el-select
          v-model="queryParam.personPost"
          filterable
          placeholder="请选择职务"
          size="mini"
          style="width: 40%"
          clearable
        >
          <el-option
            v-for="item in linePatrolPost"
            :key="item.dictValue"
            :label="item.dictLabel"
            :value="item.dictValue"
          >
          </el-option>
        </el-select>
        <!--<el-select
          v-model="queryParam.groupNum"
          filterable
          placeholder="请选择组号"
          size="mini"
          style="width: 25%"
          clearable
        >
          <el-option
            v-for="item in linePatrolGroup"
            :key="item.dictValue"
            :label="item.dictLabel"
            :value="item.dictValue"
          >
          </el-option>
        </el-select>-->
        <el-input
          v-model="queryParam.personName"
          size="mini"
          placeholder="请输入姓名"
          clearable
          style="width: 40%"
        >
        </el-input>
        <div>
          <el-button  @click="searchTable" size="mini">搜索</el-button>
        </div>
      </div>
      <!-- 列表 -->
      <div class="left-middle-table">
        <el-table
          v-loading="loading"
          :data="nameList"
          @select="select"
          @select-all="all"
          ref="multipleTable"
        >
          <el-table-column v-if='!disabled' type="selection" />
          <el-table-column label="姓名" align="center" prop="personName" />
          <el-table-column label="职务" align="center" prop="personPost" :formatter="postFormatter"/>
          <el-table-column label="组号" align="center" prop="groupNum" :formatter="groupFormatter"/>
        </el-table>
      </div>
    </div>
</template>

<script>
  import { linePatrolPersonList } from "@/api/regulation/person";
  export default {
    name: "people-table",
    props: {
      selectNameList: {
        type: Array,
      },
      disabled: {
        type: Boolean,
      },
    },
    data(){
        return{
          nameList: [],
          linePatrolPost: [],
          linePatrolGroup: [],
          personName: "",
          personPost: "",
          loading: false,
          queryParam:{
            personPost: null,
            personName: null,
            groupNum: null
          }
        }
    },
    created(){
      this.getLinePatrolPost();
      this.getLinePatrolGroup();
      //this.getPersonInfo();
    },
    methods:{
      getPersonInfo(){
        this.loading = true;
        linePatrolPersonList(this.queryParam).then(res =>{
          this.loading = false;
          if(res.code == 200 && res.data && res.data.length > 0){
            this.nameList = res.data.filter(item =>(item.personPost != '0' && item.personPost != '1'));
            this.$nextTick((item) => {
                this.selectNameList.forEach((item) => {
                    this.toggleSelection(item.personId, true);
                });

            });
          }else{
            this.nameList = [];
          }
        })
      },
      select(all,row){
        this.$emit("selectOne", all, row);
      },
      all(all){
        let allSelect = false;
        if (all.length == 0 || (all.length == 1 && [0] == undefined)) {
          allSelect = false;
        } else if (all.length > 1) {
          allSelect = true;
        }
        this.$emit("selectAll", this.nameList, allSelect);
      },
      getLinePatrolPost(){
        this.getDicts("t_line_patrol_post").then(response => {
          this.linePatrolPost = response.data.filter(item =>(item.dictCode != 112 && item.dictCode != 113));
      });
      },
      getLinePatrolGroup(){
        this.getDicts("t_line_patrol_group").then(response => {
            this.linePatrolGroup = response.data;
        });
      },
      groupFormatter(row){
        return this.selectDictLabel(this.linePatrolGroup, row.groupNum);
      },
      postFormatter(row){
        return this.selectDictLabel(this.linePatrolPost, row.personPost);
      },
      searchTable(){
        this.getPersonInfo();
      },
      toggleSelection(personId, SeclctFlag = false) {
        const item = this.nameList.find((item) => {
            return item.personId == personId;
        });
        this.$refs.multipleTable.toggleRowSelection(item, SeclctFlag);
      },
    }
  }
</script>

<style scoped lang="scss">
  .top-search {
    margin-bottom: 12px;
    justify-content: space-between;
  }
  .left-middle-table {
    flex: 1;
    // background: red;
    height: 331px;
    overflow-y: scroll;
    &::-webkit-scrollbar {
      /* 设置滚动条宽度 */
      width: 4px;
      /* 设置滚动条背景色 */
      //background: black;
    }

    //滚动条轨道
    &::-webkit-scrollbar-track {
      background-color:transparent;
      -webkit-border-radius: 2em;
      -moz-border-radius: 2em;
      border-radius:2em;
    }

    //滚动条滑块
    &::-webkit-scrollbar-thumb {
      background-color: rgb(147,147,153,0.5);
      -webkit-border-radius: 2em;
      -moz-border-radius: 2em;
      border-radius:2em;
    }
  }
</style>