277 lines
7.4 KiB
Vue
Raw Normal View History

2025-01-26 21:07:26 +08:00
<template>
2025-02-27 20:24:09 +08:00
<div>
<el-button
type="primary"
@click="dialogVisible1 = true"
v-if="!tableData.length && liveStatus === 2"
>嘉宾设置</el-button
>
<el-table :data="tableData" border style="width: 100%">
<el-table-column prop="" label="讲师名称" width="180">
2025-01-26 21:07:26 +08:00
<template slot-scope="scope">
{{ scope.row.guestInfo.showName }}
</template>
</el-table-column>
2025-02-27 20:24:09 +08:00
<el-table-column prop="" label="推流状态" width="180">
2025-01-26 21:07:26 +08:00
<template slot-scope="scope">
{{ streamStatusObj[scope.row.streamStatus] }}
</template>
</el-table-column>
<el-table-column prop="" label="连麦状态">
<template slot-scope="scope">
{{ statusObj[scope.row.status] }}
</template>
</el-table-column>
<el-table-column prop="" label="主画面显示">
<template slot-scope="scope">
<el-switch
2025-02-27 20:24:09 +08:00
:disabled="[2, 4].includes(liveStatus)"
2025-01-26 21:07:26 +08:00
v-model="scope.row.showMain"
active-color="#13ce66"
:active-value="1"
:inactive-value="2"
2025-02-27 20:24:09 +08:00
@change="showMain => changeShowMain({ showMain, item: scope.row })"
>
2025-01-26 21:07:26 +08:00
</el-switch>
</template>
</el-table-column>
2025-02-27 20:24:09 +08:00
<el-table-column prop="" label="操作">
2025-01-26 21:07:26 +08:00
<template slot-scope="scope">
2025-02-27 20:24:09 +08:00
<el-button
type="text"
@click="optFn({ type: 0, item: scope.row })"
v-if="liveStatus === 2"
>移除</el-button
>
<div
v-else-if="scope.row.streamStatus === 'active' && liveStatus === 1"
>
<el-button
type="text"
@click="optFn({ type: 2, item: scope.row })"
v-if="scope.row.status !== 2"
>开始连麦</el-button
>
<el-button
type="text"
@click="optFn({ type: 3, item: scope.row })"
v-if="scope.row.status === 2"
>结束连麦</el-button
>
2025-01-26 21:07:26 +08:00
</div>
</template>
</el-table-column>
</el-table>
<el-dialog
title="设置嘉宾"
:append-to-body="true"
:visible.sync="dialogVisible1"
width="30%"
>
<el-form ref="ruleForm" :model="form" label-width="120px" :rules="rules">
<el-form-item label="嘉宾名称" prop="guestId">
<adviser-select
v-model="form.guestId"
:dept-id="user.user.deptId"
:filterSelf="1"
></adviser-select>
</el-form-item>
<el-form-item label="嘉宾展示区域" prop="templateId">
2025-02-27 20:24:09 +08:00
<el-select
v-model="form.templateId"
placeholder="请选择嘉宾展示区域"
style="width: 100%;"
>
2025-01-26 21:07:26 +08:00
<el-option
2025-02-27 20:24:09 +08:00
v-for="(value, key) in mixQueryTemplateObj"
2025-01-26 21:07:26 +08:00
:key="key"
:label="value"
2025-02-27 20:24:09 +08:00
:value="key"
>
2025-01-26 21:07:26 +08:00
</el-option>
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible1 = false"> </el-button>
2025-02-27 20:24:09 +08:00
<el-button type="primary" @click="saveMixDataFn"> </el-button>
2025-01-26 21:07:26 +08:00
</span>
</el-dialog>
<el-dialog
title="提示"
:append-to-body="true"
:visible.sync="dialogVisible2"
width="30%"
>
<span>{{ tipText }}</span>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible2 = false"> </el-button>
2025-02-27 20:24:09 +08:00
<el-button type="primary" @click="updateStatus"> </el-button>
2025-01-26 21:07:26 +08:00
</span>
</el-dialog>
</div>
</template>
<script>
import { mapGetters } from "vuex";
2025-02-27 20:24:09 +08:00
import { mixQueryTemplateObj } from "@/utils/options";
import {
getMixData,
saveMixData,
updateMixShowMain,
updateMixStatus
} from "@/api/videoLive";
2025-01-26 21:07:26 +08:00
import AdviserSelect from "@/views/adviser/components/select";
export default {
components: {
AdviserSelect
},
computed: {
2025-02-27 20:24:09 +08:00
...mapGetters(["user"])
2025-01-26 21:07:26 +08:00
},
2025-02-27 20:24:09 +08:00
props: {
2025-01-26 21:07:26 +08:00
liveStatus: {
type: Number
}
},
data() {
return {
mixQueryTemplateObj,
dialogVisible1: false,
form: {
2025-02-27 20:24:09 +08:00
guestId: "",
templateId: "",
2025-01-26 21:07:26 +08:00
videoId: this.$route.query.id
},
rules: {
guestId: [{ required: true, message: "请选择嘉宾", trigger: "blur" }],
2025-02-27 20:24:09 +08:00
templateId: [
{ required: true, message: "请选择嘉宾展示区域", trigger: "blur" }
]
2025-01-26 21:07:26 +08:00
},
dialogVisible2: false,
streamStatusObj: {
2025-02-27 20:24:09 +08:00
active: "已推流",
inactive: "未推流",
forbid: "禁播"
2025-01-26 21:07:26 +08:00
},
statusObj: {
2025-02-27 20:24:09 +08:00
1: "未连麦",
2: "已连麦",
3: "已结束连麦"
2025-01-26 21:07:26 +08:00
},
tableData: [],
2025-02-27 20:24:09 +08:00
tipText: "",
2025-01-26 21:07:26 +08:00
optStatus: null,
time: null
};
},
async created() {
2025-02-27 20:24:09 +08:00
await this.getDetail();
this.timerGetDetail();
2025-01-26 21:07:26 +08:00
},
beforeDestroy() {
2025-02-27 20:24:09 +08:00
clearInterval(this.time);
2025-01-26 21:07:26 +08:00
},
watch: {
2025-02-27 20:24:09 +08:00
liveStatus() {
this.timerGetDetail();
2025-01-26 21:07:26 +08:00
},
dialogVisible1(value) {
2025-02-27 20:24:09 +08:00
if (!value) {
2025-01-26 21:07:26 +08:00
this.form = {
2025-02-27 20:24:09 +08:00
guestId: "",
templateId: "",
2025-01-26 21:07:26 +08:00
videoId: this.$route.query.id
2025-02-27 20:24:09 +08:00
};
2025-01-26 21:07:26 +08:00
}
}
},
methods: {
timerGetDetail() {
2025-02-27 20:24:09 +08:00
if (
[1, 3].includes(this.liveStatus) &&
this.tableData.length &&
this.$route.query.id
) {
clearInterval(this.time);
this.time = setInterval(() => {
this.getDetail();
}, 5000);
2025-01-26 21:07:26 +08:00
}
},
async getDetail() {
2025-02-27 20:24:09 +08:00
console.log("getDetail");
let ret = await getMixData({ id: this.$route.query.id });
if (ret && ret.code === 0 && ret.data) {
this.tableData = [ret.data];
} else if (ret && ret.code === 0 && !ret.data) {
clearInterval(this.time);
this.tableData = [];
2025-01-26 21:07:26 +08:00
}
},
2025-02-27 20:24:09 +08:00
optFn({ type, item }) {
this.optStatus = type;
let name = item.guestInfo.showName;
2025-01-26 21:07:26 +08:00
const textObj = {
0: `是否确认将${name}从嘉宾名单中移除?`,
2: `是否确认开始与嘉宾${name}连麦?`,
3: `是否确认结束与嘉宾${name}连麦?`
2025-02-27 20:24:09 +08:00
};
this.tipText = textObj[type];
this.dialogVisible2 = true;
2025-01-26 21:07:26 +08:00
},
async updateStatus() {
let ret = await updateMixStatus({
status: this.optStatus,
videoId: this.$route.query.id
2025-02-27 20:24:09 +08:00
});
if (ret && ret.code === 0) {
2025-01-26 21:07:26 +08:00
this.$message({
type: "success",
message: "操作成功!"
});
2025-02-27 20:24:09 +08:00
this.dialogVisible2 = false;
this.getDetail();
2025-01-26 21:07:26 +08:00
}
},
saveMixDataFn() {
this.$refs.ruleForm.validate(async valid => {
if (valid) {
2025-02-27 20:24:09 +08:00
let ret = await saveMixData(this.form);
if (ret && ret.code === 0) {
this.dialogVisible1 = false;
2025-01-26 21:07:26 +08:00
this.$message({
type: "success",
message: "设置成功!"
});
2025-02-27 20:24:09 +08:00
this.getDetail();
2025-01-26 21:07:26 +08:00
}
}
2025-02-27 20:24:09 +08:00
});
2025-01-26 21:07:26 +08:00
},
2025-02-27 20:24:09 +08:00
async changeShowMain({ showMain, item }) {
let ret = await updateMixShowMain({
2025-01-26 21:07:26 +08:00
showMain,
videoId: this.$route.query.id
2025-02-27 20:24:09 +08:00
});
if (ret && ret.code === 0) {
2025-01-26 21:07:26 +08:00
this.$message({
type: "success",
message: "设置成功!"
});
} else {
2025-02-27 20:24:09 +08:00
item.showMain = showMain === 1 ? 2 : 1;
2025-01-26 21:07:26 +08:00
}
}
2025-02-27 20:24:09 +08:00
}
2025-01-26 21:07:26 +08:00
};
</script>
<style scoped lang="scss">
.p20 {
padding: 20px;
}
.el-button {
margin-bottom: 10px;
}
</style>