Commit bb564df8 by Lin

refactor(allocation): 重构课程分配组件,优化模板结构与数据绑定,增加课程总数支持

1 parent 0a884eef
<template> <template>
<d2-dialog <d2-dialog title="新增课程"
title="新增课程"
:is-visible.sync="isVisible" :is-visible.sync="isVisible"
width="1040px" width="1040px"
btn-ok-label="确定" btn-ok-label="确定"
@confirmDialog="handleConfirm" @confirmDialog="handleConfirm"
@closeDialog="handleClose" @closeDialog="handleClose">
> <CurriculaVariable ref="curriculaVariable"
<curricula-variable :course-list="courseList"
ref="curriculaVariable" :course-total="courseTotal"
:courseList="courseList" :selected-rows="selectedDialogRows"
:selectedRows="selectedDialogRows"
@handleCourse="handleCourse" @handleCourse="handleCourse"
@fromAllocation="fromAllocation" @fromAllocation="fromAllocation">
></curricula-variable> </CurriculaVariable>
</d2-dialog> </d2-dialog>
</template> </template>
<script> <script>
import curriculaVariable from "./allocation" import { getStaffTagCourseList } from "@/api/serviceCentre";
import { getStaffTagCourseList } from "@/api/serviceCentre" import curriculaVariable from "./allocation";
export default { export default {
data() {
return {
selectData: [],
courseList: []
}
},
components: { components: {
curriculaVariable CurriculaVariable: curriculaVariable,
}, },
props: { props: {
isVisible: { isVisible: {
type: Boolean, type: Boolean,
default: false default: false,
}, },
selectedRows: { selectedRows: {
type: Array, type: Array,
default: () => [] default: () => [],
}, },
staffItem: { staffItem: {
type: Object, type: Object,
default: () => {} default: () => {},
} },
},
data() {
return {
selectData: [],
courseList: [],
courseTotal: 0,
};
},
computed: {
selectedDialogRows() {
console.log(2323232323);
return this.selectedRows.map((item) => {
return item;
});
},
}, },
watch: { watch: {
isVisible: { isVisible: {
handler(val) { handler(val) {
if (val) { if (val) {
this.getStaffTagCourseList() this.getStaffTagCourseList();
} }
}, },
immediate: true immediate: true,
}, },
selectedRows: { selectedRows: {
type: Array, type: Array,
default: () => [] default: () => [],
}
}, },
computed: {
selectedDialogRows() {
console.log(2323232323)
return this.selectedRows.map((item) => {
return item
})
}
}, },
methods: { methods: {
getStaffTagCourseList(courseForm = {}) { getStaffTagCourseList(courseForm = {}) {
let params = { let params = {
staffPhone: this.staffItem.phone, staffPhone: this.staffItem.phone,
currentPage: 1, currentPage: 1,
pageSize: 99999, pageSize: 5,
queryAll: false, queryAll: false,
...courseForm ...courseForm,
} };
getStaffTagCourseList(params).then((res) => { getStaffTagCourseList(params).then((res) => {
this.courseList = res ? res.list : [] this.courseList = res ? res.list : [];
}) this.courseTotal = res ? res.total : 0;
});
}, },
handleCourse(data) { handleCourse(data) {
this.selectData = data this.selectData = data;
}, },
fromAllocation(val) { fromAllocation(val) {
this.getStaffTagCourseList(val) this.getStaffTagCourseList(val);
}, },
// 确认仅返回整条数据数组 // 确认仅返回整条数据数组
handleConfirm() { handleConfirm() {
this.$emit("handleConfirm", this.selectData) this.$emit("handleConfirm", this.selectData);
}, },
handleClose() { handleClose() {
this.$emit("handleClose") this.$emit("handleClose");
} },
} },
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.relateEmp { .relateEmp {
::v-deep .el-dialog__header { ::v-deep .el-dialog__header {
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
<div class="configureCourse"> <div class="configureCourse">
<div class="left-wrap"> <div class="left-wrap">
<div class="header"> <div class="header">
<img class="staff-icon" src="../../images/staff-icon.png" alt="" /> <img class="staff-icon"
src="../../images/staff-icon.png"
alt="" />
<div class="title"> <div class="title">
员工列表 员工列表
<div class="num"> <div class="num">
...@@ -15,59 +17,62 @@ ...@@ -15,59 +17,62 @@
</div> </div>
</div> </div>
<div class="staff-list"> <div class="staff-list">
<div <div v-for="(item, index) in staffList"
v-for="(item, index) in staffList"
:key="item.staffUUID" :key="item.staffUUID"
:class="['staff-item', staffIndex == index ? 'active' : '']" class="staff-item"
@click="handleClick(index)" :class="[staffIndex == index ? 'active' : '']"
> @click="handleClick(index)">
<div class="employeeName">{{ item.employeeName }}</div> <div class="employeeName">
<div class="end" v-if="item.taskStatus == 2">已结束</div> {{ item.employeeName }}
<div </div>
class="config" <div v-if="item.taskStatus == 2" class="end">
v-if="item.taskStatus != 2 && item.courseConfigFlag == 1" 已结束
> </div>
<div v-if="item.taskStatus != 2 && item.courseConfigFlag == 1"
class="config">
已配置 已配置
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="right-wrap" v-loading="loading"> <div v-loading="loading" class="right-wrap">
<div class="nav-tabs"> <div class="nav-tabs">
<div <div v-for="(item, index) in tabPaneList"
:class="['nav-item', activeName == index ? 'active' : '']"
v-for="(item, index) in tabPaneList"
:key="index" :key="index"
@click="handleTabClick(index)" class="nav-item"
> :class="[activeName == index ? 'active' : '']"
@click="handleTabClick(index)">
{{ item.label }} {{ item.label }}
</div> </div>
</div> </div>
<components <components :is="tabName"
ref="components" ref="components"
:is="tabName" :ai-jy="aiJy"
:aiJy="aiJy" :staff-item="staffItem"
:staffItem="staffItem" :staff-list="staffList"
@handleConfigureCourse="handleConfigureCourse" @handleConfigureCourse="handleConfigureCourse">
:staffList="staffList" </components>
></components>
</div> </div>
</div> </div>
<div class="end-configuration" @click="handleEndConfigure">结束配置</div> <div class="end-configuration" @click="handleEndConfigure">
结束配置
</div>
</div> </div>
</template> </template>
<script>
import staffDetail from "./staffDetail"
import couseAllocation from "./couseAllocation"
<script>
import { import {
customizeList, customizeList,
findStaffByMerchantNo, findStaffByMerchantNo,
findStoreEmployeePerformance findStoreEmployeePerformance,
} from "@/api/serviceCentre" } from "@/api/serviceCentre";
import couseAllocation from "./couseAllocation";
import staffDetail from "./staffDetail";
export default { export default {
name: "configureCourse", name: "ConfigureCourse",
components: { staffDetail, couseAllocation }, components: { StaffDetail: staffDetail, CouseAllocation: couseAllocation },
data() { data() {
return { return {
loading: false, loading: false,
...@@ -75,11 +80,11 @@ export default { ...@@ -75,11 +80,11 @@ export default {
activeName: "0", activeName: "0",
tabPaneList: [ tabPaneList: [
{ {
label: "员工详情" label: "员工详情",
}, },
{ {
label: "课程配置" label: "课程配置",
} },
], ],
tabName: "staffDetail", tabName: "staffDetail",
aiJy: "", aiJy: "",
...@@ -89,49 +94,49 @@ export default { ...@@ -89,49 +94,49 @@ export default {
staffDetailInfo: {}, staffDetailInfo: {},
statisticsObj: { statisticsObj: {
total: 0, total: 0,
complete: 0 complete: 0,
} },
} };
}, },
created() { created() {
//课程搜索功能 // 课程搜索功能
// this.$EventBus.$on("fromAllocation", (courseForm) => { // this.$EventBus.$on("fromAllocation", (courseForm) => {
// console.log("父组件接收到孙组件事件:", courseForm) // console.log("父组件接收到孙组件事件:", courseForm)
// this.getStaffTagCourseList(courseForm) // this.getStaffTagCourseList(courseForm)
// }) // })
}, },
async mounted() { async mounted() {
this.queryData = this.$route.query this.queryData = this.$route.query;
//获取员工列表 // 获取员工列表
this.staffList = await this.getStaffInfoData() this.staffList = await this.getStaffInfoData();
this.staffItem = this.staffList[this.staffIndex] this.staffItem = this.staffList[this.staffIndex];
//查询员工详情 // 查询员工详情
// this.findStoreEmployeePerformanceData() // this.findStoreEmployeePerformanceData()
}, },
methods: { methods: {
//提交本员工配置回调 // 提交本员工配置回调
async handleConfigureCourse() { async handleConfigureCourse() {
this.staffIndex = 0 this.staffIndex = 0;
//获取员工列表 // 获取员工列表
this.staffList = await this.getStaffInfoData() this.staffList = await this.getStaffInfoData();
this.handleTabClick(1) this.handleTabClick(1);
this.staffItem = this.staffList[0] this.staffItem = this.staffList[0];
this.findStoreEmployeePerformanceData() this.findStoreEmployeePerformanceData();
}, },
//查询员工详情 // 查询员工详情
findStoreEmployeePerformanceData() { findStoreEmployeePerformanceData() {
this.loading = true this.loading = true;
let { staffItem, queryData } = this let { staffItem, queryData } = this;
findStoreEmployeePerformance({ findStoreEmployeePerformance({
// phone: "18978849947", // phone: "18978849947",
phone: staffItem.phone, phone: staffItem.phone,
scene: queryData.scene scene: queryData.scene,
}).then((res) => { }).then((res) => {
this.loading = false this.loading = false;
// console.log(res.aiJy) // console.log(res.aiJy)
this.aiJy = res.aiJy this.aiJy = res.aiJy;
}) });
}, },
// getStaffTagCourseList(courseForm = {}) { // getStaffTagCourseList(courseForm = {}) {
// console.log(this.staffItem, " this.staffItem") // console.log(this.staffItem, " this.staffItem")
...@@ -147,83 +152,84 @@ export default { ...@@ -147,83 +152,84 @@ export default {
// }) // })
// }, // },
handleStatistics(res) { handleStatistics(res) {
let total = 0, let total = 0;
complete = 0 let complete = 0;
res.forEach((item) => { res.forEach((item) => {
if (item.courseConfigFlag == 1) { if (item.courseConfigFlag == 1) {
complete++ complete++;
} }
total++ total++;
}) });
this.statisticsObj = { this.statisticsObj = {
total, total,
complete complete,
} };
console.log(this.statisticsObj) console.log(this.statisticsObj);
}, },
getStaffInfoData() { getStaffInfoData() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let { unionOrAndType } = this.queryData let { unionOrAndType } = this.queryData;
let methods = unionOrAndType ? customizeList : findStaffByMerchantNo let methods = unionOrAndType ? customizeList : findStaffByMerchantNo;
methods(this.queryData).then((res) => { methods(this.queryData).then((res) => {
console.log(res) console.log(res);
if (res) { if (res) {
resolve(res) resolve(res);
} }
//员工统计 // 员工统计
this.handleStatistics(res) this.handleStatistics(res);
}) });
}) });
}, },
handleClick(index) { handleClick(index) {
this.staffIndex = index this.staffIndex = index;
this.staffItem = this.staffList[this.staffIndex] this.staffItem = this.staffList[this.staffIndex];
this.findStoreEmployeePerformanceData() this.findStoreEmployeePerformanceData();
}, },
handleTabClick(index) { handleTabClick(index) {
this.activeName = index this.activeName = index;
const arr = { const arr = {
0: "staffDetail", 0: "staffDetail",
1: "couseAllocation" 1: "couseAllocation",
} };
this.tabName = arr[+this.activeName] this.tabName = arr[+this.activeName];
this.$nextTick(() => { this.$nextTick(() => {
console.log(this.$refs.components) console.log(this.$refs.components);
if (index == 0) { if (index == 0) {
//查询员工详情 // 查询员工详情
this.$refs.components?.findStoreEmployeePerformanceData() this.$refs.components?.findStoreEmployeePerformanceData();
// this.findStoreEmployeePerformanceData() // this.findStoreEmployeePerformanceData()
} else { } else {
//获取配置课程列表 // 获取配置课程列表
// this.getStaffTagCourseList() // this.getStaffTagCourseList()
this.$refs.components?.getStaffTagCourseList() this.$refs.components?.getStaffTagCourseList();
} }
}) });
}, },
handleEndConfigure() { handleEndConfigure() {
if (this.statisticsObj.total != this.statisticsObj.complete) { if (this.statisticsObj.total != this.statisticsObj.complete) {
this.$confirm("还有员工未完成课程配置,是否确定结束配置?", "提示", { this.$confirm("还有员工未完成课程配置,是否确定结束配置?", "提示", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning",
}) })
.then(() => { .then(() => {
this.$router.push({ this.$router.push({
name: "longCourse" name: "longCourse",
}) });
}) })
.catch(() => {}) .catch(() => {});
} else { } else {
this.$router.push({ this.$router.push({
name: "longCourse" name: "longCourse",
}) });
} }
} },
} },
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.configureCourse { .configureCourse {
height: calc(100vh - 190px); height: calc(100vh - 190px);
......
...@@ -140,6 +140,7 @@ ...@@ -140,6 +140,7 @@
<div> <div>
<CurriculaVariable ref="curriculaVariable" <CurriculaVariable ref="curriculaVariable"
:course-list="courseList" :course-list="courseList"
:course-total="courseTotal"
:selected-rows="selectStaffCourseList" :selected-rows="selectStaffCourseList"
@fromAllocation="fromAllocation" @fromAllocation="fromAllocation"
@handleCourse="handleCourse"> @handleCourse="handleCourse">
...@@ -308,6 +309,7 @@ export default { ...@@ -308,6 +309,7 @@ export default {
], ],
staffListData: [], staffListData: [],
courseList: [], courseList: [],
courseTotal: 0,
staffTagCourseList: [], // 已配置的课程列表不可以删除 staffTagCourseList: [], // 已配置的课程列表不可以删除
selectStaffCourseList: [], // 已配置的课程列表可以删除 selectStaffCourseList: [], // 已配置的课程列表可以删除
allStaffCourseList: [], // 合并的数据 allStaffCourseList: [], // 合并的数据
...@@ -417,12 +419,13 @@ export default { ...@@ -417,12 +419,13 @@ export default {
let params = { let params = {
staffPhone: this.staffItem.phone, staffPhone: this.staffItem.phone,
currentPage: 1, currentPage: 1,
pageSize: 99999, pageSize: 5,
queryAll: false, queryAll: false,
...courseForm, ...courseForm,
}; };
getStaffTagCourseList(params).then((res) => { getStaffTagCourseList(params).then((res) => {
this.courseList = res ? res.list : []; this.courseList = res ? res.list : [];
this.courseTotal = res ? res.total : 0;
}); });
}, },
// 查询员工已配置课程 // 查询员工已配置课程
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!