index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col
  5. :span="24"
  6. class="main animate__animated animate__backInRight"
  7. v-loading="loadings"
  8. element-loading-text="拼命加载中"
  9. element-loading-spinner="el-icon-loading"
  10. >
  11. <span v-show="view === 'list'">
  12. <el-col :span="24" class="one"> <span>商品评价</span> </el-col>
  13. <el-col :span="24" class="two">
  14. <search-1 :form="searchForm" @onSubmit="search" @toReset="toClose"></search-1>
  15. </el-col>
  16. <el-col :span="24" class="four">
  17. <data-table :fields="fields" :opera="opera" @query="search" :data="list" :total="total" @edit="toEdit"> </data-table>
  18. </el-col>
  19. </span>
  20. <detail v-if="view === 'info'" :id="id" @toBack="toBack"></detail>
  21. </el-col>
  22. </el-row>
  23. </div>
  24. </template>
  25. <script>
  26. const _ = require('lodash');
  27. import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
  28. const { mapActions: goods } = createNamespacedHelpers('goods');
  29. const { mapActions: dictData } = createNamespacedHelpers('dictData');
  30. export default {
  31. name: 'index',
  32. props: {},
  33. components: {
  34. search1: () => import('@/components/rateParts/parts/search-1.vue'),
  35. detail: () => import('@/components/rateParts/detail.vue'),
  36. },
  37. data: function () {
  38. const that = this;
  39. return {
  40. loadings: true,
  41. view: 'list',
  42. // 列表
  43. opera: [{ label: '查看评价', method: 'edit' }],
  44. fields: [
  45. { label: '商品名称', model: 'name', showTip: false },
  46. // { label: '店铺名称', model: 'shop.name' },
  47. ],
  48. list: [],
  49. total: 0,
  50. // 查询
  51. searchForm: {},
  52. id: '',
  53. };
  54. },
  55. async created() {
  56. await this.searchOther();
  57. await this.search();
  58. },
  59. methods: {
  60. ...dictData({ getDict: 'query' }),
  61. ...goods(['query', 'delete', 'fetch', 'update', 'create']),
  62. // 查询
  63. async search({ skip = 0, limit = this.$limit, ...info } = {}) {
  64. let condition = _.cloneDeep(this.searchForm);
  65. let res = await this.query({ skip, limit, ...condition, ...info, shop: this.user.shop.id });
  66. if (this.$checkRes(res)) {
  67. this.$set(this, 'list', res.data);
  68. this.$set(this, 'total', res.total);
  69. }
  70. this.loadings = false;
  71. },
  72. // 查看评价
  73. async toEdit({ data }) {
  74. this.$set(this, `id`, data._id);
  75. this.$set(this, `view`, 'info');
  76. },
  77. toBack() {
  78. this.view = 'list';
  79. },
  80. // 重置
  81. toClose() {
  82. this.searchForm = {};
  83. this.search();
  84. },
  85. async searchOther() {},
  86. },
  87. computed: {
  88. ...mapState(['user']),
  89. },
  90. metaInfo() {
  91. return { title: this.$route.meta.title };
  92. },
  93. watch: {
  94. test: {
  95. deep: true,
  96. immediate: true,
  97. handler(val) {},
  98. },
  99. },
  100. };
  101. </script>
  102. <style lang="less" scoped>
  103. .main {
  104. .one {
  105. margin: 0 0 10px 0;
  106. span:nth-child(1) {
  107. font-size: 20px;
  108. font-weight: 700;
  109. margin-right: 10px;
  110. }
  111. }
  112. .two {
  113. margin: 0 0 10px 0;
  114. }
  115. .thr {
  116. margin: 0 0 10px 0;
  117. }
  118. }
  119. </style>