index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="main">
  5. <el-col :span="24" class="one">
  6. <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @edit="toEdit" @grant="toGrant"> </data-table>
  7. </el-col>
  8. </el-col>
  9. </el-row>
  10. </div>
  11. </template>
  12. <script>
  13. const moment = require('moment');
  14. const { ticketType } = require('@common/dict/index');
  15. import { mapState, createNamespacedHelpers } from 'vuex';
  16. const { mapActions: ticket } = createNamespacedHelpers('ticket');
  17. export default {
  18. name: 'index',
  19. props: {},
  20. components: {},
  21. data: function () {
  22. return {
  23. list: [],
  24. total: 0,
  25. opera: [
  26. {
  27. label: '审核/查看',
  28. method: 'edit',
  29. // display: (i) => i.status != '5',
  30. },
  31. ],
  32. fields: [
  33. { label: '企业', prop: 'name', filter: true },
  34. { label: '申请时间', prop: 'meta.createdAt', format: (i) => moment(i).format('YYYY-MM-DD HH:mm:ss') },
  35. {
  36. label: '状态',
  37. prop: 'status',
  38. format: (i) => {
  39. const r = ticketType.find((f) => f.value === i);
  40. if (r) return r.label;
  41. else return '';
  42. },
  43. },
  44. ],
  45. };
  46. },
  47. created() {},
  48. methods: {
  49. ...ticket(['query', 'delete']),
  50. async search({ skip = 0, limit = 10, ...info } = {}) {
  51. info.status = this.status;
  52. const res = await this.query({ skip, limit, ...info });
  53. if (this.$checkRes(res)) {
  54. this.$set(this, `list`, res.data);
  55. this.$set(this, `total`, res.total);
  56. }
  57. },
  58. toEdit({ data }) {
  59. this.$router.push({ path: '/adminCenter/ticket/detail', query: { id: data._id, status: data.status } });
  60. },
  61. toGrant({ data }) {
  62. this.$router.push({ path: '/adminCenter/ticket/toGrant', query: { id: data._id, status: data.status } });
  63. },
  64. },
  65. computed: {
  66. ...mapState(['user']),
  67. status() {
  68. return this.$route.query.status;
  69. },
  70. },
  71. metaInfo() {
  72. return { title: this.$route.meta.title };
  73. },
  74. watch: {
  75. status: {
  76. deep: true,
  77. immediate: true,
  78. handler(val) {
  79. this.search();
  80. },
  81. },
  82. },
  83. };
  84. </script>
  85. <style lang="less" scoped>
  86. .main {
  87. border-radius: 10px;
  88. box-shadow: 0 0 5px #cccccc;
  89. padding: 20px;
  90. }
  91. .main:hover {
  92. box-shadow: 0 0 5px #409eff;
  93. }
  94. </style>