Commit bb564df8 by Lin

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

1 parent 0a884eef
<template>
<d2-dialog
title="新增课程"
:is-visible.sync="isVisible"
width="1040px"
btn-ok-label="确定"
@confirmDialog="handleConfirm"
@closeDialog="handleClose"
>
<curricula-variable
ref="curriculaVariable"
:courseList="courseList"
:selectedRows="selectedDialogRows"
@handleCourse="handleCourse"
@fromAllocation="fromAllocation"
></curricula-variable>
</d2-dialog>
<d2-dialog title="新增课程"
:is-visible.sync="isVisible"
width="1040px"
btn-ok-label="确定"
@confirmDialog="handleConfirm"
@closeDialog="handleClose">
<CurriculaVariable ref="curriculaVariable"
:course-list="courseList"
:course-total="courseTotal"
:selected-rows="selectedDialogRows"
@handleCourse="handleCourse"
@fromAllocation="fromAllocation">
</CurriculaVariable>
</d2-dialog>
</template>
<script>
import curriculaVariable from "./allocation"
import { getStaffTagCourseList } from "@/api/serviceCentre"
import { getStaffTagCourseList } from "@/api/serviceCentre";
import curriculaVariable from "./allocation";
export default {
data() {
return {
selectData: [],
courseList: []
}
},
components: {
curriculaVariable
},
props: {
isVisible: {
type: Boolean,
default: false
},
selectedRows: {
type: Array,
default: () => []
},
staffItem: {
type: Object,
default: () => {}
}
},
watch: {
isVisible: {
handler(val) {
if (val) {
this.getStaffTagCourseList()
}
},
immediate: true
},
selectedRows: {
type: Array,
default: () => []
}
},
computed: {
selectedDialogRows() {
console.log(2323232323)
return this.selectedRows.map((item) => {
return item
})
}
},
methods: {
getStaffTagCourseList(courseForm = {}) {
let params = {
staffPhone: this.staffItem.phone,
currentPage: 1,
pageSize: 99999,
queryAll: false,
...courseForm
}
getStaffTagCourseList(params).then((res) => {
this.courseList = res ? res.list : []
})
},
handleCourse(data) {
this.selectData = data
},
fromAllocation(val) {
this.getStaffTagCourseList(val)
},
// 确认仅返回整条数据数组
handleConfirm() {
this.$emit("handleConfirm", this.selectData)
},
handleClose() {
this.$emit("handleClose")
}
}
}
components: {
CurriculaVariable: curriculaVariable,
},
props: {
isVisible: {
type: Boolean,
default: false,
},
selectedRows: {
type: Array,
default: () => [],
},
staffItem: {
type: Object,
default: () => {},
},
},
data() {
return {
selectData: [],
courseList: [],
courseTotal: 0,
};
},
computed: {
selectedDialogRows() {
console.log(2323232323);
return this.selectedRows.map((item) => {
return item;
});
},
},
watch: {
isVisible: {
handler(val) {
if (val) {
this.getStaffTagCourseList();
}
},
immediate: true,
},
selectedRows: {
type: Array,
default: () => [],
},
},
methods: {
getStaffTagCourseList(courseForm = {}) {
let params = {
staffPhone: this.staffItem.phone,
currentPage: 1,
pageSize: 5,
queryAll: false,
...courseForm,
};
getStaffTagCourseList(params).then((res) => {
this.courseList = res ? res.list : [];
this.courseTotal = res ? res.total : 0;
});
},
handleCourse(data) {
this.selectData = data;
},
fromAllocation(val) {
this.getStaffTagCourseList(val);
},
// 确认仅返回整条数据数组
handleConfirm() {
this.$emit("handleConfirm", this.selectData);
},
handleClose() {
this.$emit("handleClose");
},
},
};
</script>
<style lang="scss" scoped>
.relateEmp {
::v-deep .el-dialog__header {
border-bottom: 1px solid #e5e5e5;
}
::v-deep .d2-search .d2-search-block {
padding: 0px !important;
}
::v-deep .el-dialog__header {
font-size: 20px;
line-height: 24px;
}
.select-text {
color: #333333;
font-size: 14px;
position: relative;
right: 65%;
margin-bottom: 8px;
}
.online-status {
display: flex;
justify-content: center;
align-items: center;
::v-deep .el-dialog__header {
border-bottom: 1px solid #e5e5e5;
}
::v-deep .d2-search .d2-search-block {
padding: 0px !important;
}
::v-deep .el-dialog__header {
font-size: 20px;
line-height: 24px;
}
.select-text {
color: #333333;
font-size: 14px;
position: relative;
right: 65%;
margin-bottom: 8px;
}
.online-status {
display: flex;
justify-content: center;
align-items: center;
.dot {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
margin-right: 8px;
}
}
.dot {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
margin-right: 8px;
}
}
}
</style>
......@@ -140,6 +140,7 @@
<div>
<CurriculaVariable ref="curriculaVariable"
:course-list="courseList"
:course-total="courseTotal"
:selected-rows="selectStaffCourseList"
@fromAllocation="fromAllocation"
@handleCourse="handleCourse">
......@@ -308,6 +309,7 @@ export default {
],
staffListData: [],
courseList: [],
courseTotal: 0,
staffTagCourseList: [], // 已配置的课程列表不可以删除
selectStaffCourseList: [], // 已配置的课程列表可以删除
allStaffCourseList: [], // 合并的数据
......@@ -417,12 +419,13 @@ export default {
let params = {
staffPhone: this.staffItem.phone,
currentPage: 1,
pageSize: 99999,
pageSize: 5,
queryAll: false,
...courseForm,
};
getStaffTagCourseList(params).then((res) => {
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!