|
@@ -21,6 +21,8 @@ import dayjs from 'dayjs';
|
|
|
import TheEmpty from '/src/components/TheEmpty';
|
|
|
import requestOrigin from 'umi-request';
|
|
|
import { modalClickMask } from '/src/state';
|
|
|
+import TheTipDialog from "@/components/TheTipDialog"
|
|
|
+import router from '/src/router';
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'train-settings',
|
|
@@ -139,6 +141,52 @@ export default defineComponent({
|
|
|
trainForms.editStatus = true;
|
|
|
};
|
|
|
|
|
|
+ const tipDialog = reactive({
|
|
|
+ show: false,
|
|
|
+ msg:"",
|
|
|
+ confirmButtonText:"",
|
|
|
+ cancelBtn: false,
|
|
|
+ type: "CLASS" as "CLASS"|"PERSON"|"MUSIC"
|
|
|
+ })
|
|
|
+ function handleLessonAddErr(data:any){
|
|
|
+ const { type, errList } = data
|
|
|
+ tipDialog.type = type
|
|
|
+ if(type === "CLASS"){
|
|
|
+ // 班级乐器没有设置
|
|
|
+ tipDialog.cancelBtn = true
|
|
|
+ tipDialog.confirmButtonText = "去设置"
|
|
|
+ const msg = errList.map((item:any)=>{
|
|
|
+ return `<div><span style="color:#F44541">【${item.classGroupName}】</span>未设置乐器,请设置乐器后布置作业;</div>`
|
|
|
+ })
|
|
|
+ tipDialog.msg = msg.join("")
|
|
|
+ }else if(type === "PERSON"){
|
|
|
+ // 学生乐器没有设置
|
|
|
+ tipDialog.cancelBtn = true
|
|
|
+ tipDialog.confirmButtonText = "去设置"
|
|
|
+ const msg = errList.map((item:any)=>{
|
|
|
+ return `<div><span style="color:#F44541">【${item.studentName}】</span>所在<span style="color:#F44541">【${item.classGroupName}】</span>未设置乐器,请设置乐器后布置作业</div>`
|
|
|
+ })
|
|
|
+ tipDialog.msg = msg.join("")
|
|
|
+ }else if(type === "MUSIC"){
|
|
|
+ // 曲目和当前选择学生的乐器对不上的时候
|
|
|
+ tipDialog.cancelBtn = false
|
|
|
+ tipDialog.confirmButtonText = "我知道了"
|
|
|
+ const msg = errList.map((item:any)=>{
|
|
|
+ return `<div><span style="color:#F44541">【${item.musicSheetName}】</span>不支持<span style="color:#F44541">【${item.instrumentName}】</span>练习,请更换曲目或取消<span style="color:#F44541">【${item.instrumentName}】</span>的学生</div>`
|
|
|
+ })
|
|
|
+ tipDialog.msg = msg.join("")
|
|
|
+ }
|
|
|
+ tipDialog.show = true
|
|
|
+ }
|
|
|
+ function handleTipConfirm(){
|
|
|
+ if(["CLASS", "PERSON"].includes(tipDialog.type)){
|
|
|
+ router.push({
|
|
|
+ path: "/classList"
|
|
|
+ })
|
|
|
+ }else if(tipDialog.type === "MUSIC"){
|
|
|
+ tipDialog.show = false
|
|
|
+ }
|
|
|
+ }
|
|
|
const onSubmit = async () => {
|
|
|
// 训练内容不能为空
|
|
|
if (!trainForms.expireDate) {
|
|
@@ -166,11 +214,16 @@ export default defineComponent({
|
|
|
classGroupId: props.classGroupId,
|
|
|
courseScheduleId: props.courseScheduleId || null
|
|
|
};
|
|
|
- await lessonTrainingAdd(params);
|
|
|
- message.success('布置成功');
|
|
|
-
|
|
|
- emit('close');
|
|
|
- emit('confirm');
|
|
|
+ const lessonRes = await lessonTrainingAdd(params);
|
|
|
+ if(lessonRes.code === 200){
|
|
|
+ if(lessonRes.data.status){
|
|
|
+ message.success('布置成功');
|
|
|
+ emit('close');
|
|
|
+ emit('confirm');
|
|
|
+ }else{
|
|
|
+ handleLessonAddErr(lessonRes.data)
|
|
|
+ }
|
|
|
+ }
|
|
|
} catch {
|
|
|
//
|
|
|
}
|
|
@@ -322,6 +375,17 @@ export default defineComponent({
|
|
|
}}
|
|
|
/>
|
|
|
</NModal>
|
|
|
+ <TheTipDialog
|
|
|
+ show={tipDialog.show}
|
|
|
+ content={tipDialog.msg}
|
|
|
+ onClose={() => {
|
|
|
+ tipDialog.show = false
|
|
|
+ }}
|
|
|
+ onConfirm={handleTipConfirm}
|
|
|
+ cancelButtonText={"暂不设置"}
|
|
|
+ cancelBtn={tipDialog.cancelBtn}
|
|
|
+ confirmButtonText={tipDialog.confirmButtonText}
|
|
|
+ ></TheTipDialog>
|
|
|
</div>
|
|
|
);
|
|
|
}
|