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"
> :course-list="courseList"
<curricula-variable :course-total="courseTotal"
ref="curriculaVariable" :selected-rows="selectedDialogRows"
:courseList="courseList" @handleCourse="handleCourse"
:selectedRows="selectedDialogRows" @fromAllocation="fromAllocation">
@handleCourse="handleCourse" </CurriculaVariable>
@fromAllocation="fromAllocation" </d2-dialog>
></curricula-variable>
</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() { components: {
return { CurriculaVariable: curriculaVariable,
selectData: [], },
courseList: [] props: {
} isVisible: {
}, type: Boolean,
components: { default: false,
curriculaVariable },
}, selectedRows: {
props: { type: Array,
isVisible: { default: () => [],
type: Boolean, },
default: false staffItem: {
}, type: Object,
selectedRows: { default: () => {},
type: Array, },
default: () => [] },
}, data() {
staffItem: { return {
type: Object, selectData: [],
default: () => {} courseList: [],
} courseTotal: 0,
}, };
watch: { },
isVisible: { computed: {
handler(val) { selectedDialogRows() {
if (val) { console.log(2323232323);
this.getStaffTagCourseList() return this.selectedRows.map((item) => {
} return item;
}, });
immediate: true },
}, },
selectedRows: { watch: {
type: Array, isVisible: {
default: () => [] handler(val) {
} if (val) {
}, this.getStaffTagCourseList();
computed: { }
selectedDialogRows() { },
console.log(2323232323) immediate: true,
return this.selectedRows.map((item) => { },
return item selectedRows: {
}) type: Array,
} default: () => [],
}, },
methods: { },
getStaffTagCourseList(courseForm = {}) { methods: {
let params = { getStaffTagCourseList(courseForm = {}) {
staffPhone: this.staffItem.phone, let params = {
currentPage: 1, staffPhone: this.staffItem.phone,
pageSize: 99999, currentPage: 1,
queryAll: false, pageSize: 5,
...courseForm queryAll: false,
} ...courseForm,
getStaffTagCourseList(params).then((res) => { };
this.courseList = res ? res.list : [] getStaffTagCourseList(params).then((res) => {
}) this.courseList = res ? res.list : [];
}, this.courseTotal = res ? res.total : 0;
handleCourse(data) { });
this.selectData = data },
}, handleCourse(data) {
fromAllocation(val) { this.selectData = data;
this.getStaffTagCourseList(val) },
}, fromAllocation(val) {
// 确认仅返回整条数据数组 this.getStaffTagCourseList(val);
handleConfirm() { },
this.$emit("handleConfirm", this.selectData) // 确认仅返回整条数据数组
}, handleConfirm() {
handleClose() { this.$emit("handleConfirm", this.selectData);
this.$emit("handleClose") },
} 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 {
border-bottom: 1px solid #e5e5e5; border-bottom: 1px solid #e5e5e5;
} }
::v-deep .d2-search .d2-search-block { ::v-deep .d2-search .d2-search-block {
padding: 0px !important; padding: 0px !important;
} }
::v-deep .el-dialog__header { ::v-deep .el-dialog__header {
font-size: 20px; font-size: 20px;
line-height: 24px; line-height: 24px;
} }
.select-text { .select-text {
color: #333333; color: #333333;
font-size: 14px; font-size: 14px;
position: relative; position: relative;
right: 65%; right: 65%;
margin-bottom: 8px; margin-bottom: 8px;
} }
.online-status { .online-status {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
.dot { .dot {
display: inline-block; display: inline-block;
width: 8px; width: 8px;
height: 8px; height: 8px;
border-radius: 50%; border-radius: 50%;
margin-right: 8px; margin-right: 8px;
} }
} }
} }
</style> </style>
...@@ -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!