jiangping
2024-06-20 09da100729793848bc01b51f7b05ca3f1e7ec64f
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<template>
    <GlobalWindow
        :title="title"
        width="100%"
        :visible.sync="visible"
        :confirm-working="isWorking"
        @confirm="confirm"
    >
      <div style="display: inline-block;padding: 20px 10px;color: red"   class="el-upload__tip" >
       操作提示: 请在下面搜索框内输入员工姓名或身份证号进行员工信息搜索,并选择员工进行操作
      </div>
      <el-select
          value-key="id"
          v-model="seleData"
          filterable
          multiple
          remote
          style="margin-bottom: 15px;width: 100%;margin-right: 10px"
          placeholder="请输入员工姓名或身份证号进行选择"
          :remote-method="searchSelData"
          :loading="loading">
        <el-option
            v-for="item in memberList"
            :key="item.id"
            :label="item.name+' ' +(item.idcardNo||'')"
            :value="item">
        </el-option>
      </el-select>
<!--
        <el-input v-model="val" placeholder="请输入员工姓名后,点击搜索按钮或者按下enter键进行查询" @keypress.enter.native="getList" style="margin-bottom: 15px;width: 50%;margin-right: 10px"></el-input>
-->
<!--        <el-button type="primary" @click="getList" style="width: 100px;">搜索</el-button>-->
        <el-table
            :data="seleData"
            border
            selection-change1="handleSelectionChange"
            style="width: 100%">
<!--            <el-table-column
                type="selection"
                width="55">
            </el-table-column>-->
            <el-table-column label="序号" width="80px">
                <template slot-scope="scope">
                    <span>{{scope.$index + 1}}</span>
                </template>
            </el-table-column>
            <el-table-column
                prop="name"
                label="姓名">
            </el-table-column>
            <el-table-column
                prop="idcardNo"
                label="身份证号">
            </el-table-column>
            <el-table-column
                prop="duName"
                label="派遣单位">
            </el-table-column>
            <el-table-column
                prop="workTypeName"
                label="所属工种">
            </el-table-column>
        </el-table>
      <template  v-slot:footer>
        <el-button type="primary"  :loading="confirming" @click="confirm">确定</el-button>
        <el-button @click="visible=false">返回</el-button>
      </template>
    </GlobalWindow>
</template>
 
<script>
import BaseOpera from '@/components/base/BaseOpera'
import GlobalWindow from '@/components/common/GlobalWindow'
import { findListByDTO } from '@/api/business/member'
export default {
  name: 'selectEmployees',
  extends: BaseOpera,
  components: { GlobalWindow },
  data () {
    return {
      confirming:false,
      type: '',
      val: '',
      memberIds:[],
      loading:false,
      memberList:[],
      list: [],
      price: '',
      insuranceApplyId: '',
      notInInsuranceApplyId: '',
      validTime: '',
      seleData: [],
      oldList: []
    }
  },
  created () {
    this.config({
      api: '/business/dispatchUnit',
      'field.id': 'id'
    })
  },
  methods: {
    open (title, obj) {
      this.insuranceApplyId = ''
      this.notInInsuranceApplyId = ''
      this.val = ''
      this.price = obj.price
      this.confirming=false
      this.oldList = obj.arr
      // this.seleData = obj.arr || []
      this.memberIds=[]
      this.seleData=[]
      this.memberList=[]
      this.confirming=false
      if (obj.type) {
        this.type = obj.type
      }
      this.list = []
      if (obj.insuranceApplyId) {
        this.insuranceApplyId = obj.insuranceApplyId
      }
      if (obj.notInInsuranceApplyId) {
        this.notInInsuranceApplyId = obj.notInInsuranceApplyId
      }
      if (obj.validTime) {
        this.validTime = obj.validTime
      }
      this.title = title
      this.visible = true
      // this.getList()
    },
    confirm () {
      if(this.confirming){
        return
      }
      this.confirming=true
      if (this.seleData.length === 0) {
        this.$message.warning('至少搜索选择一位员工进行操作')
        this.confirming=false
        return
      }
      for (let i = 0; i < this.seleData.length; i++) {
        for (let a = 0; a < this.oldList.length; a++) {
          // this.seleData[i].name === this.oldList[a].memberName ||
          if (this.seleData[i].idcardNo === this.oldList[a].idCard) {
            this.$message.warning(`[${this.seleData[i].name}]员工重复`)
            this.confirming=false
            return
          }
        }
      }
      this.seleData.forEach(item => {
        item.idCard = item.idcardNo
        item.memberName = item.name
        item.memberId = item.id
        item.reducePrice = item.fee
        if (this.notInInsuranceApplyId || this.type == 1) {
          item.workTypeName = ''
          item.worktypeId = ''
          item.duId = ''
          item.duName = ''
        }
        item.fee = this.price
      })
 
      console.log(this.oldList)
      console.log(this.seleData)
      this.confirming=false
      this.$emit('result', this.seleData)
      this.seleData=[]
      this.visible = false
    },
    handleSelectionChange (e) {
      this.seleData = e
    },
    getList () {
      if(this.memberIds ==null || !this.memberIds.length){
        this.$message.error('请搜索框检查人员信息后进行搜索!')
        return;
      }
      findListByDTO({
        name: this.val,
        subtractMemberIds:this.memberIds,
        insuranceApplyId: this.insuranceApplyId,
        notInInsuranceApplyId: this.notInInsuranceApplyId,
        validTime: this.validTime
      }).then(res => {
        res.forEach(item => {
          item.reducePrice = item.fee
          item.fee = ''
        })
        this.list = res
      })
    },
    searchSelData (query) {
      if (query !== '') {
        this.loading = true;
        findListByDTO({
          name: query,
          insuranceApplyId: this.insuranceApplyId,
          notInInsuranceApplyId: this.notInInsuranceApplyId,
          validTime: this.validTime
        }).then(res => {
          this.loading = false
          this.memberList = res
        }).finally(() => {
          this.loading = false
        })
      }
    }
  }
}
</script>
 
<style lang="scss" scoped>
 
</style>