|
@@ -9,7 +9,7 @@
|
|
|
filterable
|
|
filterable
|
|
|
clearable
|
|
clearable
|
|
|
placeholder="请选择员工"
|
|
placeholder="请选择员工"
|
|
|
- :loading="staffLoading"
|
|
|
|
|
|
|
+ :loading="staffOptionsLoading"
|
|
|
>
|
|
>
|
|
|
<el-option
|
|
<el-option
|
|
|
v-for="item in staffOptions"
|
|
v-for="item in staffOptions"
|
|
@@ -29,7 +29,7 @@
|
|
|
</el-form>
|
|
</el-form>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
- <!-- 员工列表(前端分页) -->
|
|
|
|
|
|
|
+ <!-- 员工列表(后端分页) -->
|
|
|
<el-table
|
|
<el-table
|
|
|
v-loading="tableLoading"
|
|
v-loading="tableLoading"
|
|
|
:data="staffList"
|
|
:data="staffList"
|
|
@@ -106,6 +106,7 @@
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
import { getAllCompanyUserListNoParams } from "@/api/company/companyUser";
|
|
import { getAllCompanyUserListNoParams } from "@/api/company/companyUser";
|
|
|
|
|
+import { selectQwUserListByCondition } from "@/api/qw/qwUser";
|
|
|
import { listExternalContact } from "@/api/qw/externalContact";
|
|
import { listExternalContact } from "@/api/qw/externalContact";
|
|
|
import ConversationPanelPure from "./ConversationPanelPure.vue";
|
|
import ConversationPanelPure from "./ConversationPanelPure.vue";
|
|
|
import Pagination from "@/components/Pagination";
|
|
import Pagination from "@/components/Pagination";
|
|
@@ -115,13 +116,11 @@ export default {
|
|
|
components: { ConversationPanelPure, Pagination },
|
|
components: { ConversationPanelPure, Pagination },
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
- // 所有员工数据(全量)
|
|
|
|
|
- allStaffData: [],
|
|
|
|
|
- // 员工下拉选项
|
|
|
|
|
|
|
+ // 员工下拉选项(全量,用于查询条件)
|
|
|
staffOptions: [],
|
|
staffOptions: [],
|
|
|
- staffLoading: false,
|
|
|
|
|
|
|
+ staffOptionsLoading: false,
|
|
|
|
|
|
|
|
- // 员工查询参数(分页)
|
|
|
|
|
|
|
+ // 员工查询参数(后端分页)
|
|
|
queryParams: {
|
|
queryParams: {
|
|
|
userId: null,
|
|
userId: null,
|
|
|
qwUserName: "",
|
|
qwUserName: "",
|
|
@@ -152,16 +151,15 @@ export default {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
mounted() {
|
|
mounted() {
|
|
|
- this.loadAllStaff();
|
|
|
|
|
|
|
+ this.loadStaffOptions();
|
|
|
|
|
+ this.getStaffList();
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
- // 加载所有员工(无公司限制)
|
|
|
|
|
- async loadAllStaff() {
|
|
|
|
|
- this.staffLoading = true;
|
|
|
|
|
- this.tableLoading = true;
|
|
|
|
|
|
|
+ // 加载所有员工用于下拉选项(无公司限制)
|
|
|
|
|
+ async loadStaffOptions() {
|
|
|
|
|
+ this.staffOptionsLoading = true;
|
|
|
try {
|
|
try {
|
|
|
const res = await getAllCompanyUserListNoParams();
|
|
const res = await getAllCompanyUserListNoParams();
|
|
|
- // 兼容不同的返回格式
|
|
|
|
|
let data = [];
|
|
let data = [];
|
|
|
if (res.code === 200) {
|
|
if (res.code === 200) {
|
|
|
data = res.data || [];
|
|
data = res.data || [];
|
|
@@ -171,7 +169,7 @@ export default {
|
|
|
data = res.data;
|
|
data = res.data;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- this.allStaffData = data.map(item => ({
|
|
|
|
|
|
|
+ this.staffOptions = data.map(item => ({
|
|
|
userId: item.userId,
|
|
userId: item.userId,
|
|
|
nickName: item.nickName,
|
|
nickName: item.nickName,
|
|
|
qwUserName: item.qwUserName,
|
|
qwUserName: item.qwUserName,
|
|
@@ -179,60 +177,35 @@ export default {
|
|
|
departmentName: item.departmentName,
|
|
departmentName: item.departmentName,
|
|
|
corpId: item.corpId
|
|
corpId: item.corpId
|
|
|
}));
|
|
}));
|
|
|
-
|
|
|
|
|
- // 初始化员工下拉选项
|
|
|
|
|
- this.staffOptions = [...this.allStaffData];
|
|
|
|
|
-
|
|
|
|
|
- // 加载第一页数据
|
|
|
|
|
- this.queryParams.pageNum = 1;
|
|
|
|
|
- this.getStaffList();
|
|
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
- console.error("加载员工数据失败", e);
|
|
|
|
|
- this.allStaffData = [];
|
|
|
|
|
|
|
+ console.error("加载员工下拉选项失败", e);
|
|
|
this.staffOptions = [];
|
|
this.staffOptions = [];
|
|
|
- this.staffList = [];
|
|
|
|
|
- this.total = 0;
|
|
|
|
|
} finally {
|
|
} finally {
|
|
|
- this.staffLoading = false;
|
|
|
|
|
- this.tableLoading = false;
|
|
|
|
|
|
|
+ this.staffOptionsLoading = false;
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- // 获取员工列表(前端过滤 + 分页)
|
|
|
|
|
- getStaffList() {
|
|
|
|
|
- if (!this.allStaffData.length) {
|
|
|
|
|
- this.staffList = [];
|
|
|
|
|
- this.total = 0;
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // 获取员工列表(后端分页)
|
|
|
|
|
+ async getStaffList() {
|
|
|
this.tableLoading = true;
|
|
this.tableLoading = true;
|
|
|
try {
|
|
try {
|
|
|
- // 1. 过滤数据
|
|
|
|
|
- let filtered = [...this.allStaffData];
|
|
|
|
|
-
|
|
|
|
|
- // 按员工ID筛选
|
|
|
|
|
- if (this.queryParams.userId) {
|
|
|
|
|
- filtered = filtered.filter(item => item.userId === this.queryParams.userId);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 按企微昵称模糊筛选
|
|
|
|
|
- if (this.queryParams.qwUserName) {
|
|
|
|
|
- const keyword = this.queryParams.qwUserName.trim();
|
|
|
|
|
- filtered = filtered.filter(item =>
|
|
|
|
|
- item.qwUserName && item.qwUserName.includes(keyword)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ // 构建请求参数,不传 companyId 让后端返回所有公司的员工(需后端支持)
|
|
|
|
|
+ const params = {
|
|
|
|
|
+ userId: this.queryParams.userId,
|
|
|
|
|
+ qwUserName: this.queryParams.qwUserName,
|
|
|
|
|
+ pageNum: this.queryParams.pageNum,
|
|
|
|
|
+ pageSize: this.queryParams.pageSize
|
|
|
|
|
+ };
|
|
|
|
|
+ const res = await selectQwUserListByCondition(params);
|
|
|
|
|
+ if (res.code === 200 && res.data) {
|
|
|
|
|
+ this.staffList = res.data.list || [];
|
|
|
|
|
+ this.total = res.data.total || 0;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.staffList = [];
|
|
|
|
|
+ this.total = 0;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // 2. 更新总数
|
|
|
|
|
- this.total = filtered.length;
|
|
|
|
|
-
|
|
|
|
|
- // 3. 分页
|
|
|
|
|
- const start = (this.queryParams.pageNum - 1) * this.queryParams.pageSize;
|
|
|
|
|
- const end = start + this.queryParams.pageSize;
|
|
|
|
|
- this.staffList = filtered.slice(start, end);
|
|
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
- console.error("筛选员工数据失败", e);
|
|
|
|
|
|
|
+ console.error("获取员工列表失败", e);
|
|
|
this.staffList = [];
|
|
this.staffList = [];
|
|
|
this.total = 0;
|
|
this.total = 0;
|
|
|
} finally {
|
|
} finally {
|
|
@@ -275,8 +248,8 @@ export default {
|
|
|
const params = {
|
|
const params = {
|
|
|
pageNum: this.customerPageNum,
|
|
pageNum: this.customerPageNum,
|
|
|
pageSize: this.customerPageSize,
|
|
pageSize: this.customerPageSize,
|
|
|
- qwUserId: this.currentStaff.qwUserId, // 员工的企微userId
|
|
|
|
|
- corpId: this.currentStaff.corpId // 员工所属企业的corpId
|
|
|
|
|
|
|
+ qwUserId: this.currentStaff.it,
|
|
|
|
|
+ corpId: this.currentStaff.corpId
|
|
|
};
|
|
};
|
|
|
const res = await listExternalContact(params);
|
|
const res = await listExternalContact(params);
|
|
|
if (res.rows) {
|
|
if (res.rows) {
|