EmployeeList.vue
3.97 KB
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
<template>
<view class="employee-list">
<template v-for="(i, index) in listData">
<view
:key="index"
@click="choose(i)"
:class="['item flex', { active: checkActive(i) }]"
>
<view class="sprite-icon icon-tag-checked"></view>
{{ i.staffName }}
</view>
</template>
</view>
</template>
<script type="text/ecmascript-6">
import popupmixin from './popupmixin'
export default {
mixins: [popupmixin],
name: 'EmployeeList',
inject: ['userInfo'],
data () {
return {
}
},
computed: {
idKey () {
let { params: { idKey }, sceneType } = this
return Array.isArray(idKey) ? idKey[sceneType] : idKey
}
},
mounted () {
},
methods: {
async getList (searchValue, search) {
const { userInfo, params } = this,
{ cacheData } = params
this.currentId = ''
if (!search && cacheData && cacheData.length) {
this.initData(cacheData)
if (searchValue) this.handleSearch(searchValue)
return
}
this.componentLoading(params)
const { shopMerchantId, sceneType, merchantId } = userInfo,
apiTargetName = sceneType == 1 || params.defeat ? 'getEmployeeList' : 'getOrderScreenEmployeeList',
apiParams = {
merchantId: params.idKey == 'sellerUserId' ? merchantId : shopMerchantId,
sceneList: params.idKey == 'sellerUserId' ? '' : [sceneType],
}
if (searchValue) apiParams.name = searchValue
const data = await uni.$api.popupApi[apiTargetName](apiParams)
this.updateParams(params, data || [])
},
initData (list) {
const { idKey, data } = this
if (data[idKey]) {
this.currentId = data[idKey]
let item = list.find(i => i.uuid == this.currentId)
console.log(item)
this.$emit('choose', item)
}
this.list = list
this.$emit('onComplete')
},
handleSearch (searchValue) {
const { sceneType } = this
if (sceneType == 1) {
this.list = []
this.getList(searchValue, true)
} else this.originalDataSearch(searchValue)
},
originalDataSearch (searchValue) {
console.log(searchValue, '===')
if (!searchValue) this.searchStatus = false
else {
searchValue = searchValue.toUpperCase()
let { list } = this,
employeeList = JSON.parse(JSON.stringify(list)),
arr = []
employeeList.map(e => {
if (e.staffName && e.staffName.toUpperCase().indexOf(searchValue) != -1) arr.push(e)
})
this.searchList = arr
this.searchStatus = true
}
},
choose (i) {
let { idKey, data } = this,
userId = data.deliveryUserId,
referrerId = data.deliveryId,
deliveryUserId = data.userId,
deliveryId = data.referrerId,
value = {
userId,
deliveryUserId,
referrerId,
deliveryId
}[idKey]
if (['referrerId', 'userId', 'deliveryId', 'deliveryUserId'].includes(idKey) && value == i.uuid) return uni.showToast({
title: '销售顾问/录单员与交付专员不能选取同一人',
icon: 'none',
mask: true
})
this.currentId = i.uuid
this.$emit('choose', i)
},
checkActive (i) {
let { currentId, idKey, data } = this
return currentId ? i.uuid == currentId : i.uuid == data[idKey]
}
}
}
</script>
<style scoped lang="scss">
.employee-list {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: toRpx(32);
margin: 0 toRpx(48);
.item {
justify-content: center;
height: toRpx(72);
border-radius: toRpx(8);
border: toRpx(2) solid #dce0e6;
box-sizing: border-box;
position: relative;
color: #333333;
font-size: toRpx(32);
.sprite-icon {
display: none;
position: absolute;
top: 0;
right: 0;
}
}
.active {
border-color: #2c66f7;
background: #ecf1ff;
color: #2c66f7;
.sprite-icon {
display: block;
}
}
}
</style>