index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div id="index">
  3. <admin-frame @search="search" :limit="limit" :total="total" topType="2" @back="back" @add="toAdd" :useNav="false">
  4. <template v-slot:info>
  5. <list-1 :list="list" @toView="toView"></list-1>
  6. </template>
  7. </admin-frame>
  8. <van-dialog class="dialog" v-model="dialog.show" :title="dialog.title" :show-confirm-button="false" show-cancel-button cancel-button-text="返回">
  9. <info-1 :info="info" v-if="dialog.type == '1'"></info-1>
  10. <search-1 :form="searhForm" v-else-if="dialog.type == '2'" @reseat="reseat" @onSubmit="onSubmit"></search-1>
  11. </van-dialog>
  12. </div>
  13. </template>
  14. <script>
  15. import list1 from '@/layout/learning/report/list-1.vue';
  16. import info1 from '@/layout/learning/report/info-1.vue';
  17. import search1 from '@/layout/learning/report/search-1.vue';
  18. import adminFrame from '@common/src/components/mobile-frame/mobile-main.vue';
  19. import { mapState, createNamespacedHelpers } from 'vuex';
  20. const { mapActions } = createNamespacedHelpers('report');
  21. export default {
  22. name: 'index',
  23. props: {},
  24. components: {
  25. adminFrame,
  26. list1,
  27. info1,
  28. search1,
  29. },
  30. data: function () {
  31. return {
  32. list: [],
  33. total: 0,
  34. limit: 5,
  35. // 查询
  36. searhForm: {},
  37. // 弹框
  38. dialog: { show: false, title: '详细信息', type: '1' },
  39. // 详细信息
  40. info: {},
  41. };
  42. },
  43. async created() {
  44. await this.search();
  45. },
  46. methods: {
  47. ...mapActions(['query', 'fetch']),
  48. async search({ skip = 0, limit = this.limit, ...info } = {}) {
  49. const res = await this.query({ skip, limit, ...info });
  50. if (this.$checkRes(res)) {
  51. this.$set(this, `list`, res.rows);
  52. this.$set(this, `total`, res.total);
  53. }
  54. },
  55. // 查看信息
  56. async toView(data) {
  57. this.$set(this, `info`, data);
  58. this.dialog = { show: true, title: '详细信息', type: '1' };
  59. },
  60. // 添加查询条件
  61. toAdd() {
  62. this.dialog = { show: true, title: '查询条件', type: '2' };
  63. },
  64. // 重置条件
  65. reseat() {
  66. this.searhForm = {};
  67. this.dialog = { show: false, title: '查询条件', type: '2' };
  68. this.search();
  69. },
  70. // 提交查询
  71. onSubmit({ data }) {
  72. this.search(data);
  73. this.dialog = { show: false, title: '查询条件', type: '2' };
  74. },
  75. // 返回
  76. back() {
  77. this.$router.push({ path: '/learning/index' });
  78. },
  79. },
  80. computed: {
  81. ...mapState(['user']),
  82. },
  83. metaInfo() {
  84. return { title: this.$route.meta.title };
  85. },
  86. watch: {
  87. test: {
  88. deep: true,
  89. immediate: true,
  90. handler(val) {},
  91. },
  92. },
  93. };
  94. </script>
  95. <style lang="less" scoped>
  96. .dialog {
  97. /deep/.van-dialog__content {
  98. max-height: 350px;
  99. overflow-y: auto;
  100. }
  101. }
  102. </style>