孔祥富
2021-02-27 c695c32a2bb103a4d91d0c3e40efe4410ae77759
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
<template>
  <div id="mainDiv">
    <el-header :height="headerHeight">
      <el-form>
        <el-row>
          <el-col :span="10">
            <el-form-item label="关键字">
              <el-input v-model="queryParams.empNumb" placeholder="请输入内容" style="width:200px" />
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="员工状态">
              <el-checkbox-group v-model="queryParams.empStatus">
                <el-checkbox :label="0">在职</el-checkbox>
                <el-checkbox :label="1">离职</el-checkbox>
                <el-checkbox :label="2">退休</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-button size="mini" class="hr-but-all" type="primary" @click="vagueSearch">查询</el-button>
            <el-button size="mini" class="hr-but" type="danger" @click="resetSearch">重置</el-button>
          </el-col>
        </el-row>
      </el-form>
    </el-header>
    <el-main>
      <el-table
        ref="multipleTable"
        :data="list"
        row-key="prop1"
        width="80%"
        @selection-change="handleSelectionChange"
        @row-dblclick="rowDblclick"
      >
        <el-table-column type="selection" :reserve-selection="false" width="50" />
        <el-table-column v-if="show" prop="empId" label="员工Id" />
        <el-table-column prop="empNumb" label="员工编号" />
        <el-table-column prop="empName" label="姓名" />
        <el-table-column prop="certificateNumb" label="身份证号码" width="180" />
        <el-table-column v-if="show" prop="deptId" label="部门Id" />
        <el-table-column prop="deptName" label="护卫点" width="180" />
        <el-table-column v-if="show" prop="jobId" label="岗位Id" />
        <el-table-column prop="jobName" label="岗位" />
        <el-table-column prop="empTypeName" label="员工类别" />
        <el-table-column prop="sexName" label="性别" width="50" />
      </el-table>
      <!--
          page.sync 当前页
          limit.sync 每页显示数量 只能是5,10,20,30,50
          pagination 翻页的事件
           -->
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="pagination.num"
        :limit.sync="pagination.size"
        @pagination="search"
      />
      <el-button type="primary" @click="sureChoose">确定</el-button>
      <el-button type="danger" @click="cancleChoose">取消</el-button>
    </el-main>
  </div>
</template>
<script>
// 引用翻页组件
import Pagination from '@/components/Pagination'
export default {
  components: {
    Pagination
  },
  props: {
    multipleselect: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      show: false,
      headerHeight: '70px',
      deptTree: [],
      selection: [],
      multipleSelection: [],
      total: 0, // 总数量
      queryParams: {
        empNumb: '',
        empStatus: []
      }, // 查询参数
      sort: {}, // 排序
      pagination: { // 分页参数
        size: 10,
        num: 1
      },
      list: [], // 给table显示的数据
      defaultProps: {
        children: 'children',
        label: 'label'
      }
    }
  },
  mounted() {
    this.search()
  },
  methods: {
    // 翻页方法
    search() {
      this.fetch({
        ...this.queryParams,
        ...this.sort
      })
    },
    vagueSearch() {
      this.fetch({
        empNumb: this.queryParams.empNumb,
        empName: this.queryParams.empNumb,
        deptName: this.queryParams.empNumb
      })
    },
    resetSearch() {
      this.queryParams = {
        empNumb: '',
        empName: '',
        deptName: ''
      }
      this.search()
    },
    fetch(params = {}) {
      var that = this
      params.pageSize = this.pagination.size
      params.pageNum = this.pagination.num
      params.delFlag = 0
      this.$get('hr/empBaseInfo/list', {
        ...params
      }).then((r) => {
        const data = r.data.data
        that.total = data.total
        that.list = data.rows
      })
    },
    handleSelectionChange(selection) {
      if (!this.multipleselect) {
        if (selection.length > 1) {
          this.$refs.multipleTable.clearSelection()
          this.$refs.multipleTable.toggleRowSelection(selection.pop())
        }
      }
      this.multipleSelection = selection
    },
    sureChoose() {
      this.$emit('selectedUser', this.multipleSelection)
      this.$refs.multipleTable.clearSelection()
    },
    cancleChoose() {
      this.$emit('cancleChooseUser')
      this.$refs.multipleTable.clearSelection()
    },
    rowDblclick(row, column, event) {
      this.$refs.multipleTable.toggleRowSelection(row, true)
      this.sureChoose()
    }
  }
}
</script>
<style lang="scss" scoped>
  .link_button {
    color: #169BD5;
  }
 
  .del_button {
    color: #D9001B;
  }
</style>