syncBeiSenDialog.vue
3.73 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
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>
<baseDialog :dialog-config="dialogConfig" :is-show.sync="visible" @handleClick="submitSyncBeiSen"
:config="baseDialogConfig">
<div class="sync-beisen-dialog">
<div class="search-container">
<el-input v-model="syncSearchForm.staffName" placeholder="请输入姓名" class="search-input" clearable></el-input>
<el-input v-model="syncSearchForm.mobilePhone" placeholder="请输入手机号" class="search-input"
clearable></el-input>
<el-button type="primary" @click="handleSyncSearch">查询</el-button>
</div>
<div v-loading="syncLoading" class="result-container">
<div v-if="!syncResultList.length" class="empty-state">
<img src="@/assets/empty.png" alt="" class="empty-img">
<span class="empty-text">未查询到匹配的北森员工数据</span>
</div>
<el-radio-group v-else v-model="selectedBeiSenUserId" class="radio-group-list">
<el-radio v-for="item in syncResultList" :key="item.userID" :label="item.userID">
{{ item.name }} | {{ item.mobilePhone }}
</el-radio>
</el-radio-group>
</div>
</div>
</baseDialog>
</template>
<script>
import { beiSenEmployeePageApi, beiSenEmployeeSingleSyncApi } from "@/api/resident";
export default {
name: "SyncBeiSenDialog",
props: {
syncBeiSenVisible: {
type: Boolean,
default: false,
},
satffId: {
type: Number,
default: 0,
}
},
data() {
return {
dialogConfig: {
title: "北森同步",
width: "600px",
},
syncSearchForm: {
staffName: "",
mobilePhone: "",
},
syncLoading: false,
syncResultList: [],
selectedBeiSenUserId: "",
};
},
computed: {
visible: {
get() {
return this.syncBeiSenVisible;
},
set(newVal) {
this.$emit("dialogClose", { flag: newVal, attrName: "syncBeiSenVisible" });
},
},
baseDialogConfig() {
return {
showClose: true,
appendToBody: false, // 是否将自身插入至 body 元素,有嵌套的弹窗时一定要设置
isShowFooter: true,
confirm_name: "提交同步",
cancel_name: "取 消"
}
}
},
mounted() {
// 默认查询
// this.handleSyncSearch();
},
methods: {
handleSyncSearch() {
if (!this.syncSearchForm.staffName && !this.syncSearchForm.mobilePhone) {
this.syncResultList = [];
return;
}
this.syncLoading = true;
const params = {
staffName: this.syncSearchForm.staffName,
mobilePhone: this.syncSearchForm.mobilePhone,
pageNum: 1,
pageSize: 9999
};
beiSenEmployeePageApi(params).then(res => {
this.syncLoading = false;
this.syncResultList = res.list || [];
this.selectedBeiSenUserId = "";
}).catch(() => {
this.syncLoading = false;
});
},
submitSyncBeiSen() {
if (!this.selectedBeiSenUserId) {
this.$message.warning("请选择北森员工");
return;
}
const params = {
staffId: this.satffId,
beiSenUserID: this.selectedBeiSenUserId
};
beiSenEmployeeSingleSyncApi(params).then(() => {
this.$message.success("同步成功");
this.visible = false;
this.$emit("refreshDetail");
});
},
},
};
</script>
<style scoped lang="scss">
.sync-beisen-dialog {
padding: 0 20px;
}
.search-container {
display: flex;
gap: 10px;
margin-bottom: 20px;
}
.search-input {
width: 200px;
}
.result-container {
background-color: #F5F7FA;
min-height: 100px;
max-height: 400px;
overflow-y: auto;
padding: 16px;
border: 1px solid #ECEEF5;
border-radius: 4px;
}
.empty-state {
margin-top: 16px;
display: flex;
flex-direction: column;
align-items: center;
}
.empty-img {
width: 64px;
margin-bottom: 10px;
display: block;
}
.empty-text {
color: #999999;
}
.radio-group-list {
display: flex;
flex-direction: column;
gap: 15px;
::v-deep .el-radio {
color: #333333;
}
}
</style>