selectStaffDialog.vue
4.33 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
<!-- 选择员工弹窗 -->
<template>
<GLDialog class="muti-pro" :close-on-click-modal="false" bigTitle="选择员工" mode="big" :before-close="handleMutiSelectClose" :visible.sync="isMutiSelectVisible" @onOk="handleMutiSelectConfirm" @onCancel="handleMutiSelectClose" v-loading="loading">
<!-- <div class="noproDiv" v-show="!staffList.length && fnCallBack">
<img src="@/assets/noPro.png" />
<p class="noproP">系统暂无已创建的员工</p>
</div> -->
<div>
<slot name="search"></slot>
<GLTable v-loading="loading" ref="mutiProRef" :tableData="staffList" :pageConf="pageConf" :noDataImg="url" :tableParams="tableParams" @refreshTable="getList"></GLTable>
</div>
</GLDialog>
</template>
<script>
import url from '@/assets/empty.png'
export default {
name: 'selectStaffDialog',
data() {
return {
// 表格组件
userInfo: {},
staffList: [],
selectList: [],
fnCallBack: false,
url: url,
loading: true,
tableSearchForm: {
staffName: ''
},
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
// 表格参数
tableParams: {
listName: 'list',
// 行数据的key
mutiSelectUniqueKey: 'userOneId',
// 多选ref的名称
mutiSelectName: 'list',
tableColumns: [
{
label: '姓名',
prop: 'staffName'
},
{
label: '部门',
prop: 'departmentName'
},
{
label: '跟进员工类型',
prop: 'followerTypeName'
}
]
}
}
},
props: {
isMutiSelectVisible: {
type: Boolean,
default: false
},
searchForm: {
type: Object,
default: () => {}
},
selectedStaffList: {
type: Array,
default: () => []
}
},
mounted() {
this.userInfo = this.$globalState.session
this.selectList = JSON.parse(JSON.stringify(this.selectedStaffList))
this.selectList.map(item => (item.userOneId = item.staffUUID))
this.getList({}, true)
},
methods: {
getList(page, isResetPage = false) {
var params = {
...this.searchForm,
pageNum: isResetPage ? 1 : this.$refs.mutiProRef.page.pageNum,
pageSize: isResetPage ? 10 : this.$refs.mutiProRef.page.pageSize
}
this.loading = true
this.$apis.giftBag.getFollowerStaffListApi(params).then(res => {
// 重置分页组件
if (this.$refs.mutiProRef && isResetPage) {
this.$refs.mutiProRef.page.pageNum = 1
this.$refs.mutiProRef.page.pageSize = 10
}
this.staffList = res.data
this.loading = false
this.fnCallBack = true
this.$refs.mutiProRef.tableTotal = res.count
this.$nextTick(() => {
this.recoverySelected()
})
this.$refs.mutiProRef.tableHeightValues = '50vh'
})
},
recoverySelected() {
if (this.selectedStaffList && this.selectedStaffList.length) {
this.selectedStaffList.forEach(row => {
row.userOneId = row.staffUUID
this.$nextTick(() => {
let idx = this.$refs.mutiProRef.$refs[this.tableParams.mutiSelectName + 'MutiTable'].data.findIndex(item => item.userOneId == row.staffUUID)
if (idx > -1) {
try {
this.$refs.mutiProRef.$refs[this.tableParams.mutiSelectName + 'MutiTable'].toggleRowSelection(this.$refs.mutiProRef.$refs[this.tableParams.mutiSelectName + 'MutiTable'].data[idx], true)
let id = this.selectList.findIndex(item => item.staffUUID == row.staffUUID)
if (id > -1) this.selectList.splice(id, 1)
} catch (err) {
console.log(err)
}
}
})
})
}
},
handleMutiSelectConfirm() {
var selectedData = [...this.$refs.mutiProRef.mutiSelectArr[this.tableParams.mutiSelectName], ...this.selectList]
this.$emit('handleMutiSelectConfirm', selectedData)
},
handleMutiSelectClose() {
this.$emit('handleMutiSelectClose')
}
}
}
</script>
<style>
.muti-pro .m-t-10 {
margin-top: 10px;
}
.muti-pro .noproP {
width: 100%;
height: 20px;
font-family: PingFangSC-Medium;
font-size: 16px;
color: #666666;
line-height: 20px;
font-weight: 500;
text-align: center;
}
</style>