index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="index">
  5. <el-col :span="24" class="top">
  6. <topInfo :topTitle="pageTitle"></topInfo>
  7. </el-col>
  8. <el-col :span="24" class="add" style="text-align:right">
  9. <el-button size="mini" type="primary" @click="$router.push({ path: './detail' })" icon="el-icon-plus">添加房间</el-button>
  10. </el-col>
  11. </el-col>
  12. <el-col :span="24" class="info">
  13. <data-table
  14. :fields="fields"
  15. @edit="toEdit"
  16. @stat="stat"
  17. @delete="toDelete"
  18. @order="order"
  19. :data="list"
  20. :opera="opera"
  21. :total="total"
  22. @query="search"
  23. :toFormat="toFormat"
  24. >
  25. <template #options="{item}">
  26. <template v-if="item.prop === 'anchorid'">
  27. <el-option v-for="(i, index) in clientList" :key="index" :label="i.name" :value="i.id"></el-option>
  28. </template>
  29. </template>
  30. </data-table>
  31. </el-col>
  32. </el-row>
  33. </div>
  34. </template>
  35. <script>
  36. import topInfo from '@/layout/public/top.vue';
  37. import dataTable from '@/components/data-table.vue';
  38. import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
  39. const { mapActions: room } = createNamespacedHelpers('room');
  40. const { mapActions: roomuser } = createNamespacedHelpers('roomuser');
  41. export default {
  42. name: 'index',
  43. props: {},
  44. components: {
  45. topInfo,
  46. dataTable,
  47. },
  48. data: () => ({
  49. clientList: [],
  50. opera: [
  51. {
  52. label: '审核',
  53. icon: 'el-icon-s-order',
  54. method: 'order',
  55. display: item => {
  56. return item.status == '0' ? true : item.status == '1' ? true : false;
  57. },
  58. },
  59. {
  60. label: '编辑',
  61. icon: 'el-icon-edit',
  62. method: 'edit',
  63. display: item => {
  64. return item.status == '0' ? true : false;
  65. },
  66. },
  67. {
  68. label: '统计',
  69. icon: 'el-icon-view',
  70. method: 'stat',
  71. },
  72. {
  73. label: '删除',
  74. icon: 'el-icon-delete',
  75. method: 'delete',
  76. confirm: true,
  77. },
  78. ],
  79. fields: [
  80. { label: '标题', prop: 'title' },
  81. { label: '房间号', prop: 'name', filter: 'index' },
  82. { label: '房间类型', prop: 'type', format: i => (i == '0' ? '直播' : i == '1' ? '会议' : '临时用户') },
  83. {
  84. label: '主播',
  85. prop: 'anchorid',
  86. filter: 'select',
  87. format: true,
  88. },
  89. { label: '房间状态', prop: 'status', format: i => (i == '0' ? '未开始' : i == '1' ? '开始' : '结束') },
  90. ],
  91. list: [],
  92. total: 0,
  93. }),
  94. created() {
  95. this.search();
  96. this.searchinfo();
  97. },
  98. methods: {
  99. ...room(['query', 'delete', 'update', 'fetch']),
  100. ...roomuser({ roomuserquery: 'query' }),
  101. async search({ skip = 0, limit = 10, ...info } = {}) {
  102. let res = await this.query({ skip, limit, ...info });
  103. this.$set(this, `list`, res.data);
  104. this.$set(this, `total`, res.total);
  105. },
  106. async searchinfo() {
  107. let res = await this.roomuserquery({ skip: 0, limit: 100000, role: 3 });
  108. this.$set(this, `clientList`, res.data);
  109. },
  110. toFormat(data) {
  111. let { model, value } = data;
  112. let res = '';
  113. if (model === 'anchorid') {
  114. let findRes = this.clientList.find(f => f.id === value);
  115. if (findRes) res = findRes.name;
  116. }
  117. return res;
  118. },
  119. toEdit({ data }) {
  120. this.$router.push({ path: './detail', query: { id: data.id } });
  121. },
  122. // 统计查看
  123. stat({ data }) {
  124. this.$router.push({ path: './statList', query: { id: data.id, name: data.name } });
  125. console.log(data);
  126. },
  127. async toDelete({ data }) {
  128. const res = await this.delete(data.id);
  129. this.$checkRes(res, '删除成功', '删除失败');
  130. this.search();
  131. },
  132. // 审核
  133. async order({ data }) {
  134. this.$router.push({ path: './detailStatus', query: { id: data.id } });
  135. },
  136. },
  137. computed: {
  138. ...mapState(['user']),
  139. pageTitle() {
  140. return `${this.$route.meta.title}`;
  141. },
  142. },
  143. metaInfo() {
  144. return { title: this.$route.meta.title };
  145. },
  146. };
  147. </script>
  148. <style lang="less" scoped>
  149. .add {
  150. height: 40px;
  151. line-height: 35px;
  152. padding: 0 15px;
  153. }
  154. </style>