直播外链活动讨论阶段里关卡里编辑

This commit is contained in:
zhangyc
2022-11-10 20:10:26 +08:00
parent 31234d2574
commit cbddd79d4b
9 changed files with 608 additions and 987 deletions

View File

@@ -10,7 +10,7 @@
>
<div class="drawerMain">
<div class="header">
<div class="headerTitle">添加直播</div>
<div class="headerTitle">{{edit?'编辑':'添加'}}直播</div>
<img
style="width: 29px; height: 29px; cursor: pointer"
src="../../assets/images/basicinfo/close.png"
@@ -80,10 +80,14 @@
<span style="margin-right: 3px">直播时长</span>
</div>
<div class="btnbox">
<a-input
v-model:value="inputV2"
style="width: 388px; height: 32px"
/>
<a-input-number
:min="0"
:max="300"
:precision="0"
style=" width: 388px; height: 32px; border-radius: 8px;overflow: hidden; "
v-model:value="inputV2"
></a-input-number>
<span style="margin-left: 5px">分钟</span>
</div>
</div>
@@ -110,6 +114,9 @@
<span style="margin-right: 3px">直播封面</span>
</div>
<div class="textarea" style="overflow: hidden">
<a-upload
v-model:file-list="fileList"
name="avatar"
@@ -120,7 +127,7 @@
:before-upload="beforeUpload"
@change="handleChange"
>
<img v-if="imageUrl" :src="imageUrl" alt="avatar" />
<img v-if="imageUrl" :src="imageUrl" alt="avatar" style=width100pxheight:100px;/>
<div v-else>
<loading-outlined v-if="loading"></loading-outlined>
<plus-outlined v-else></plus-outlined>
@@ -170,7 +177,7 @@
<span style="margin-right: 3px">评价</span>
</div>
<div class="btnbox">
<a-checkbox v-model:checked="checkedC1">需要评估</a-checkbox>
<a-checkbox v-model:checked="checkedC1" @onclick = 'checkedC1=!checkedC1'>需要评估</a-checkbox>
</div>
</div>
<div class="main_item" style="margin-top: -25px">
@@ -201,12 +208,7 @@
:min="0"
:max="30"
:precision="0"
style="
width: 88px;
height: 32px;
border-radius: 8px;
overflow: hidden;
"
style="width: 88px; height: 32px; border-radius: 8px;overflow: hidden; "
v-model:value="inputV6"
></a-input-number>
<span style="color: #999999; margin-left: 8px">分钟</span>
@@ -217,12 +219,7 @@
:min="0"
:max="30"
:precision="0"
style="
width: 88px;
height: 32px;
border-radius: 8px;
overflow: hidden;
"
style="width: 88px;height: 32px;border-radius: 8px; overflow: hidden;"
v-model:value="inputV7"
></a-input-number>
<span style="color: #999999; margin-left: 8px">分钟</span>
@@ -238,12 +235,7 @@
:min="0"
:max="30"
:precision="0"
style="
width: 88px;
height: 32px;
border-radius: 8px;
overflow: hidden;
"
style=" width: 88px;height: 32px;border-radius: 8px; overflow: hidden; "
v-model:value="inputV8"
></a-input-number>
<span style="color: #999999; margin-left: 8px"
@@ -271,7 +263,7 @@
<span style="margin-right: 3px">其他设置</span>
</div>
<div class="btnbox">
<a-checkbox v-model:checked="checkedC2"
<a-checkbox v-model:checked="checkedC2" @onclick = "checkedC2 = !checkedC2"
>学员请假后记为任务完成</a-checkbox
>
</div>
@@ -280,7 +272,7 @@
</div>
<div class="main_btns">
<button class="btn1" @click="closeDrawer">取消</button>
<button class="btn2" @click="createLiveBroadcast">确定</button>
<button class="btn2" @click="updateLiveBroadcast">确定</button>
</div>
</div>
</a-drawer>
@@ -292,6 +284,7 @@ import * as api from "../../api/indexLiveBroadcast";
import * as apiTask from "../../api/indexTaskadd";
import { toDate } from "@/api/method";
import { RouterEditTask } from "@/api/indexTask";
import dayjs from 'dayjs';
// import { useRouter } from "vue-router";
function getBase64(img, callback) {
const reader = new FileReader();
@@ -330,10 +323,15 @@ export default {
type: Boolean,
default: false,
},
isStudy: {
EditLiveId: {
type: Number,
default: null,
},
edit: { // 是否为编辑
type: Boolean,
default: null,
},
projectId: {
type: Number,
default: null,
@@ -342,6 +340,31 @@ export default {
type: Number,
default: null,
},
routerTaskId: {
type: Number,
default: 0,
},
isLevel: { // 是否是关卡页面触发
type: Boolean,
default: null,
},
EditWorkId: { // 要编辑的workId
type: Number,
default: null,
},
projectTaskId: { // 要编辑的projectId
type: Number,
default: null,
},
routerId: {
type: Number,
default: null,
},
isactive: {
type: Number,
default: null,
}
},
setup(props, ctx) {
// const router = useRouter();
@@ -447,13 +470,15 @@ export default {
imageUrl: "", //上传图片地址
loading: false,
switchC1: "",
checkedC1: "",
checkedC2: true,
checkedC1: false,
checkedC2: false,
playback: false,
assessmentId:"0",
obj: {}, //要传的obj数据
});
const closeDrawer = () => {
ctx.emit("update:addliveVisible", false);
ctx.emit("update:addliveVisible", false);
ctx.emit("update:edit", false);
console.log(props, "props");
state.radioV1 = "";
state.playback = false;
@@ -471,7 +496,37 @@ export default {
state.imageUrl = "";
};
const afterVisibleChange = (bool) => {
console.log("state", bool);
console.log("props.edit===================", props.edit,bool);
if(props.edit){
queryLive();
}
};
const queryLive = () => {
let d =props.EditLiveId;
console.log("直播查询=======",d);
api
.getLiveBroadcastInfor({liveId:d}).then((res) => {
// console.log(dayjs(res.data.data.submitStartTime).format("YYYY-MM-DD"));
state.inputV1 = res.data.data.liveName;
state.time = [dayjs(res.data.data.liveStartTime, "YYYY-MM-DD"), dayjs(res.data.data.liveEndTime, "YYYY-MM-DD")]
state.inputV2= res.data.data.liveDuration;
state.inputV3= res.data.data. liveTeacherId;
//state.fileList= res.data.data
state.inputV4= res.data.data.liveLink;
state.inputV5= res.data.data.livePlaybackLink;
state.inputV6= res.data.data.beforeSignIn;
state.inputV7= res.data.data.afterSignIn;
state.inputV8= res.data.data.signOutTime;
state.textV1= res.data.data.liveExplain;
state.radioV1= res.data.data.standardSettings
//state.= res.data.data
console.log("查询成功=====inputv1",state.inputV1);
}).catch(() => {
message.error(`查询失败`)
})
};
const PlayBack = () => {
state.playback = !state.playback;
@@ -482,6 +537,7 @@ export default {
state.radioV1 = "";
}
};
const handleChange = (info) => {
if (info.file.status === "uploading") {
state.loading = true;
@@ -519,9 +575,50 @@ export default {
return isJpgOrPng && isLt2M;
};
const updateTask =(res)=>{
if(props.isLevel){
RouterEditTask({
chapterId: props.isactive,
courseId: res.data.data.liveId,
duration: res.data.data.duration,
name: res.data.data.liveName,
routerId: props.routerId,
routerTaskId: props.routerTaskId || 0,
type: 6,
})
.then((res) => {
console.log(res, 11111);
message.success(`${props.edit ? '编辑' : '新增'}关卡任务成功`)
ctx.emit("changeData", false);
})
.catch((err) => {
console.log(err, 1111);
});
}else{
apiTask
.addTask({
courseId: res.data.data.liveId,
duration: res.data.data.duration,
name: res.data.data.liveName,
projectId: props.projectId,
projectTaskId: props.projectTaskId || 0,
stageId: props.chooseStageId,
type: 6,
})
.then((res) => {
console.log("调用项目添加接口后", res.data);
message.success(`${props.edit ? '编辑' : '新增'}关卡任务成功`)
ctx.emit("changeData", false);
})
.catch((err) => {
console.log(err);
});
}
}
//创建直播
const createLiveBroadcast = () => {
const updateLiveBroadcast = () => {
if (!state.inputV1) {
message.destroy();
return message.warning("请输入直播名称");
@@ -541,11 +638,8 @@ export default {
}
if (!state.inputV3) return message.warning("请输入授课老师");
let check = state.checkedC2 * 1;
// let startTime = state.time[0].$d;
// let endTime = state.time[1].$d;
// console.log(startTime); //时间需要处理
// console.log(endTime);
//let check = state.checkedC2 ;
let startTime = toDate(
new Date(state.time[0].$d).getTime() / 1000,
"Y-M-D"
@@ -554,90 +648,61 @@ export default {
new Date(state.time[1].$d).getTime() / 1000,
"Y-M-D"
);
state.obj = {
afterSignIn: state.inputV6,
beforeSignIn: state.inputV7,
assessmentId: 0,
createTime: "",
createUser: 0,
// liveCover: state.fileList,//直播封面
liveDuration: state.inputV2,
liveEndTime: endTime,
liveStartTime: startTime,
liveExplain: state.textV1,
liveFlag: "",
liveId: 0,
liveId: props.edit?props.EditLiveId:0,
liveLink: state.inputV4,
liveName: state.inputV1,
livePlayback: "",
livePlaybackLink: state.inputV5,
liveTag: "",
liveTeacherId: 0,
otherSettings: check, //1或0
liveTeacherId: state.inputV3,
otherSettings:0, //1或0
signOutTime: state.inputV8,
standardSettings: state.radioV1, //1或2
updateTime: "",
updateUser: 0,
};
let name = state.inputV1;
api
console.log("zhibo-==========",props.EditLiveId);
if(props.edit){
api
.updateLiveBroadcastMessage(state.obj)
.then((res) => {
console.log("直播编辑成功", res.data.data);
message.success("提交成功");
updateTask(res);
closeDrawer();
})
.catch((err) => {
console.log(err, 2222);
});
}else{
api
.createLiveBroadcast(state.obj)
.then((res) => {
console.log("调用添加直播接口后", res.data.data);
// console.log(state, 2222);
message.success("提交成功");
closeDrawer();
if (props.isStudy == 1) {
console.log("hhhhh", name);
let objj = {
chapterId: 36,
courseId: 0,
duration: state.obj.liveDuration,
flag: true,
name: name,
routerId: 92,
routerTaskId: 0,
type: 6,
};
RouterEditTask(objj)
.then((res) => {
console.log(res, 11111);
})
.catch((err) => {
console.log(err, 1111);
});
} else {
apiTask
.addTask({
courseId: 0,
duration: state.obj.liveDuration,
flag: true,
name: state.obj.liveName,
projectId: props.projectId,
projectTaskId: 0,
stageId: props.chooseStageId,
type: 6,
})
.then((res) => {
console.log("调用项目添加接口后", res.data);
//自定义事件给父组件传值
ctx.emit("changeData", false);
//重新获取任务列表
// apiTask.getTask({ projectId: 28 });
// router.push("/taskadd");
})
.catch((err) => {
console.log(err);
});
}
updateTask(res);
closeDrawer();
})
.catch((err) => {
console.log(err, 2222);
});
}
};
return {
...toRefs(state),
afterVisibleChange,
@@ -647,9 +712,9 @@ export default {
// columns1,
rowSelection,
cloradio1,
createLiveBroadcast,
handleChange,
beforeUpload,
updateLiveBroadcast,
};
},
};