123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- <template>
- <div id="index">
- <el-row>
- <el-col :span="24" class="index">
- <el-col :span="24" class="top">
- <topInfo :topTitle="pageTitle"></topInfo>
- </el-col>
- <el-col :span="24" class="add" style="text-align:right">
- <el-button size="mini" type="primary" @click="$router.push({ path: './detail' })" icon="el-icon-plus">添加房间</el-button>
- </el-col>
- </el-col>
- <el-col :span="24" class="info">
- <data-table
- :fields="fields"
- @edit="toEdit"
- @stat="stat"
- @delete="toDelete"
- @order="order"
- :data="list"
- :opera="opera"
- :total="total"
- @query="search"
- :toFormat="toFormat"
- >
- <template #options="{item}">
- <template v-if="item.prop === 'anchorid'">
- <el-option v-for="(i, index) in clientList" :key="index" :label="i.name" :value="i.id"></el-option>
- </template>
- </template>
- </data-table>
- </el-col>
- </el-row>
- </div>
- </template>
- <script>
- import topInfo from '@/layout/public/top.vue';
- import dataTable from '@/components/data-table.vue';
- import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
- const { mapActions: room } = createNamespacedHelpers('room');
- const { mapActions: roomuser } = createNamespacedHelpers('roomuser');
- export default {
- name: 'index',
- props: {},
- components: {
- topInfo,
- dataTable,
- },
- data: () => ({
- clientList: [],
- opera: [
- {
- label: '审核',
- icon: 'el-icon-s-order',
- method: 'order',
- display: item => {
- return item.status == '0' ? true : item.status == '1' ? true : false;
- },
- },
- {
- label: '编辑',
- icon: 'el-icon-edit',
- method: 'edit',
- display: item => {
- return item.status == '0' ? true : false;
- },
- },
- {
- label: '统计',
- icon: 'el-icon-view',
- method: 'stat',
- },
- {
- label: '删除',
- icon: 'el-icon-delete',
- method: 'delete',
- confirm: true,
- },
- ],
- fields: [
- { label: '标题', prop: 'title' },
- { label: '房间号', prop: 'name', filter: 'index' },
- { label: '房间类型', prop: 'type', format: i => (i == '0' ? '直播' : i == '1' ? '会议' : '临时用户') },
- {
- label: '主播',
- prop: 'anchorid',
- filter: 'select',
- format: true,
- },
- { label: '房间状态', prop: 'status', format: i => (i == '0' ? '未开始' : i == '1' ? '开始' : '结束') },
- ],
- list: [],
- total: 0,
- }),
- created() {
- this.search();
- this.searchinfo();
- },
- methods: {
- ...room(['query', 'delete', 'update', 'fetch']),
- ...roomuser({ roomuserquery: 'query' }),
- async search({ skip = 0, limit = 10, ...info } = {}) {
- let res = await this.query({ skip, limit, ...info });
- this.$set(this, `list`, res.data);
- this.$set(this, `total`, res.total);
- },
- async searchinfo() {
- let res = await this.roomuserquery({ skip: 0, limit: 100000, role: 3 });
- this.$set(this, `clientList`, res.data);
- },
- toFormat(data) {
- let { model, value } = data;
- let res = '';
- if (model === 'anchorid') {
- let findRes = this.clientList.find(f => f.id === value);
- if (findRes) res = findRes.name;
- }
- return res;
- },
- toEdit({ data }) {
- this.$router.push({ path: './detail', query: { id: data.id } });
- },
- // 统计查看
- stat({ data }) {
- this.$router.push({ path: './statList', query: { id: data.id, name: data.name } });
- console.log(data);
- },
- async toDelete({ data }) {
- const res = await this.delete(data.id);
- this.$checkRes(res, '删除成功', '删除失败');
- this.search();
- },
- // 审核
- async order({ data }) {
- this.$router.push({ path: './detailStatus', query: { id: data.id } });
- },
- },
- computed: {
- ...mapState(['user']),
- pageTitle() {
- return `${this.$route.meta.title}`;
- },
- },
- metaInfo() {
- return { title: this.$route.meta.title };
- },
- };
- </script>
- <style lang="less" scoped>
- .add {
- height: 40px;
- line-height: 35px;
- padding: 0 15px;
- }
- </style>
|