configureCourse.vue 8.78 KB
<!-- 配置课程 -->
<template>
    <div class="configureCourse-wrap">
        <div class="configureCourse">
            <div class="left-wrap">
                <div class="header">
                    <img class="staff-icon"
                         src="../../images/staff-icon.png"
                         alt="" />
                    <div class="title">
                        员工列表
                        <div class="num">
                            共{{ statisticsObj.total }}人,已配置{{
                                statisticsObj.complete
                            }}人
                        </div>
                    </div>
                </div>
                <div class="staff-list">
                    <div v-for="(item, index) in staffList"
                         :key="item.staffUUID"
                         class="staff-item"
                         :class="[staffIndex == index ? 'active' : '']"
                         @click="handleClick(index)">
                        <div class="employeeName">
                            {{ item.employeeName }}
                        </div>
                        <div v-if="item.taskStatus == 2" class="end">
                            已结束
                        </div>
                        <div v-if="item.taskStatus != 2 && item.courseConfigFlag == 1"
                             class="config">
                            已配置
                        </div>
                    </div>
                </div>
            </div>
            <div v-loading="loading" class="right-wrap">
                <div class="nav-tabs">
                    <div v-for="(item, index) in tabPaneList"
                         :key="index"
                         class="nav-item"
                         :class="[activeName == index ? 'active' : '']"
                         @click="handleTabClick(index)">
                        {{ item.label }}
                    </div>
                </div>
                <components :is="tabName"
                            ref="components"
                            :ai-jy="aiJy"
                            :staff-item="staffItem"
                            :staff-list="staffList"
                            @handleConfigureCourse="handleConfigureCourse">
                </components>
            </div>
        </div>
        <div class="end-configuration" @click="handleEndConfigure">
            结束配置
        </div>
    </div>
</template>

<script>
import {
	customizeList,
	findStaffByMerchantNo,
	findStoreEmployeePerformance,
} from "@/api/serviceCentre";
import couseAllocation from "./couseAllocation";

import staffDetail from "./staffDetail";

export default {
	name: "ConfigureCourse",
	components: { StaffDetail: staffDetail, CouseAllocation: couseAllocation },
	data() {
		return {
			loading: false,
			staffIndex: 0,
			activeName: "0",
			tabPaneList: [
				{
					label: "员工详情",
				},
				{
					label: "课程配置",
				},
			],
			tabName: "staffDetail",
			aiJy: "",
			staffItem: {},
			staffList: [],
			courseList: [],
			staffDetailInfo: {},
			statisticsObj: {
				total: 0,
				complete: 0,
			},
		};
	},
	created() {
		// 课程搜索功能
		// this.$EventBus.$on("fromAllocation", (courseForm) => {
		//   console.log("父组件接收到孙组件事件:", courseForm)
		//   this.getStaffTagCourseList(courseForm)
		// })
	},
	async mounted() {
		this.queryData = this.$route.query;
		// 获取员工列表
		this.staffList = await this.getStaffInfoData();
		this.staffItem = this.staffList[this.staffIndex];
		// 查询员工详情
		// this.findStoreEmployeePerformanceData()
	},
	methods: {
		// 提交本员工配置回调
		async handleConfigureCourse() {
			this.staffIndex = 0;

			// 获取员工列表
			this.staffList = await this.getStaffInfoData();
			this.handleTabClick(1);
			this.staffItem = this.staffList[0];
			this.findStoreEmployeePerformanceData();
		},
		// 查询员工详情
		findStoreEmployeePerformanceData() {
			this.loading = true;
			let { staffItem, queryData } = this;
			findStoreEmployeePerformance({
				// phone: "18978849947",
				phone: staffItem.phone,
				scene: queryData.scene,
			}).then((res) => {
				this.loading = false;
				// console.log(res.aiJy)
				this.aiJy = res.aiJy;
			});
		},
		// getStaffTagCourseList(courseForm = {}) {
		//   console.log(this.staffItem, " this.staffItem")
		//   let params = {
		//     staffPhone: this.staffItem.phone,
		//     currentPage: 1,
		//     pageSize: 99999,
		//     queryAll: false,
		//     ...courseForm
		//   }
		//   getStaffTagCourseList(params).then((res) => {
		//     this.courseList = res ? res.list : []
		//   })
		// },
		handleStatistics(res) {
			let total = 0;
			let complete = 0;
			res.forEach((item) => {
				if (item.courseConfigFlag == 1) {
					complete++;
				}
				total++;
			});
			this.statisticsObj = {
				total,
				complete,
			};
			console.log(this.statisticsObj);
		},
		getStaffInfoData() {
			return new Promise((resolve, reject) => {
				let { unionOrAndType } = this.queryData;
				let methods = unionOrAndType ? customizeList : findStaffByMerchantNo;
				methods(this.queryData).then((res) => {
					console.log(res);
					if (res) {
						resolve(res);
					}
					// 员工统计
					this.handleStatistics(res);
				});
			});
		},
		handleClick(index) {
			this.staffIndex = index;
			this.staffItem = this.staffList[this.staffIndex];

			this.findStoreEmployeePerformanceData();
		},
		handleTabClick(index) {
			this.activeName = index;
			const arr = {
				0: "staffDetail",
				1: "couseAllocation",
			};
			this.tabName = arr[+this.activeName];

			this.$nextTick(() => {
				console.log(this.$refs.components);
				if (index == 0) {
					// 查询员工详情
					this.$refs.components?.findStoreEmployeePerformanceData();
					// this.findStoreEmployeePerformanceData()
				} else {
					// 获取配置课程列表
					// this.getStaffTagCourseList()
					this.$refs.components?.getStaffTagCourseList();
				}
			});
		},
		handleEndConfigure() {
			if (this.statisticsObj.total != this.statisticsObj.complete) {
				this.$confirm("还有员工未完成课程配置,是否确定结束配置?", "提示", {
					confirmButtonText: "确定",
					cancelButtonText: "取消",
					type: "warning",
				})
					.then(() => {
						this.$router.push({
							name: "longCourse",
						});
					})
					.catch(() => {});
			} else {
				this.$router.push({
					name: "longCourse",
				});
			}
		},
	},
};
</script>

<style lang="scss" scoped>
.configureCourse {
	height: calc(100vh - 190px);
	display: flex;
	margin: 0 20px;
	margin-bottom: 16px;
	.left-wrap {
		min-width: 200px;
		width: 200px;
		height: 100%;
		min-height: 100%;
		background: #ffffff;
		margin-right: 16px;
		box-sizing: border-box;
		.header {
			display: flex;
			align-items: flex-start;
			margin: 12px 0 12px 13px;
			.staff-icon {
				width: 16px;
				height: 16px;
				margin-right: 8px;
				margin-top: 3px;
			}
			.title {
				color: #333333;
				font-size: 16px;
				font-weight: 400;
				.num {
					color: #999999;
					font-size: 12px;
					font-weight: 400;
					margin-top: 2px;
				}
			}
		}
		.staff-list {
			height: calc(100% - 62px);
			overflow-y: auto;
			.staff-item {
				color: #666666;
				font-size: 14px;
				font-weight: 400;
				padding: 10px 12px 10px 36px;
				position: relative;
				.employeeName {
					width: 90px;
					white-space: wrap;
				}
				.config {
					position: absolute;
					border-radius: 2px;
					border: 1px solid #95e4b9;
					// background: #e9eef7;
					padding: 2px 6px;
					color: #2cca74;
					font-size: 11px;
					font-weight: 500;
					top: 10px;
					right: 12px;
				}
				.end {
					position: absolute;
					border-radius: 2px;
					border: 1px solid #cccccc;
					// background: #e9eef7;
					padding: 2px 6px;
					color: #999999;
					font-size: 11px;
					font-weight: 500;
					top: 10px;
					right: 12px;
				}
			}
			.active {
				color: #2a58ad;
				background: #e9eef7;
				border-right: 3px solid #2a58ad;
			}
		}
	}
	.right-wrap {
		min-height: 100%;
		width: calc(100% - 216px);
		min-width: 984px;
		overflow-x: auto;
		.nav-tabs {
			display: flex;
			align-items: center;
			.nav-item {
				width: 112px;
				height: 44px;
				border-radius: 4px 4px 0 0;
				color: #666666;
				font-size: 16px;
				font-weight: 400;
				line-height: 44px;
				box-sizing: border-box;
				text-align: center;
				margin-right: 2px;
				// border: 1px solid #e5e5e5;
				background: #f8f8f8;
			}
			.active {
				color: #2a58ad;
				font-size: 16px;
				font-weight: 500;
				// border: 1px solid #e5e5e5;
				background: #ffffff;
			}
		}
		// background: #ffffff;
	}
}
.end-configuration {
	width: 120px;
	height: 36px;
	border-radius: 4px;
	background: #2a58ad;
	color: #ffffff;
	font-size: 16px;
	font-weight: 400;
	text-align: center;
	line-height: 36px;
	margin: 0 auto;
}
</style>