index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="main">
  5. <el-col :span="24" class="add">
  6. <el-button type="primary" size="mini" @click="add">添加</el-button>
  7. </el-col>
  8. <el-col :span="24" class="list">
  9. <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @edit="toEdit" @delete="toDelete"></data-table>
  10. </el-col>
  11. </el-col>
  12. </el-row>
  13. </div>
  14. </template>
  15. <script>
  16. import dataTable from '@common/src/components/frame/filter-page-table.vue';
  17. import { mapState, createNamespacedHelpers } from 'vuex';
  18. const { mapActions: dock } = createNamespacedHelpers('dock');
  19. export default {
  20. metaInfo() {
  21. return { title: this.$route.meta.title };
  22. },
  23. name: 'index',
  24. props: {},
  25. components: {
  26. dataTable,
  27. },
  28. data: function() {
  29. return {
  30. opera: [
  31. {
  32. label: '编辑',
  33. method: 'edit',
  34. },
  35. {
  36. label: '删除',
  37. method: 'delete',
  38. },
  39. ],
  40. fields: [
  41. { label: '房间号', prop: 'room_id', filter: 'input' },
  42. { label: '展会标题', prop: 'title', filter: 'input' },
  43. { label: '负责人', prop: 'adminuser' },
  44. { label: '联系电话', prop: 'phone' },
  45. { label: '开始时间', prop: 'start_time' },
  46. { label: '结束时间', prop: 'end_time' },
  47. {
  48. label: '状态',
  49. prop: 'status',
  50. format: item => {
  51. return item === '0' ? '准备中' : item === '1' ? '开始' : '结束';
  52. },
  53. },
  54. ],
  55. list: [],
  56. total: 0,
  57. };
  58. },
  59. async created() {
  60. await this.search();
  61. },
  62. methods: {
  63. ...dock(['query', 'delete']),
  64. // 查询列表
  65. async search({ skip = 0, limit = 10, ...info } = {}) {
  66. let res = await this.query({ skip, limit, ...info });
  67. if (this.$checkRes(res)) {
  68. this.$set(this, `list`, res.data);
  69. this.$set(this, `total`, res.total);
  70. }
  71. },
  72. // 修改
  73. toEdit({ data }) {
  74. this.$router.push({ path: '/live/detail', query: { id: data.id } });
  75. },
  76. // 删除
  77. async toDelete({ data }) {
  78. let res = await this.delete(data.id);
  79. if (this.$checkRes(res)) {
  80. this.$message({
  81. message: '信息修改成功',
  82. type: 'success',
  83. });
  84. this.search();
  85. }
  86. },
  87. // 添加数据
  88. add() {
  89. this.$router.push({ path: '/live/detail' });
  90. },
  91. },
  92. computed: {
  93. ...mapState(['user']),
  94. },
  95. watch: {},
  96. };
  97. </script>
  98. <style lang="less" scoped>
  99. .main {
  100. .add {
  101. text-align: right;
  102. margin: 0 0 10px 0;
  103. }
  104. }
  105. </style>