goods.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="main animate__animated animate__backInRight">
  5. <el-col :span="24" class="one"> <span>活动标题</span> </el-col>
  6. <el-col :span="24" class="two">
  7. <!-- <search-1 :form="searchForm" @onSubmit="search" @toReset="toClose"></search-1> -->
  8. </el-col>
  9. <el-col :span="24" class="thr">
  10. <el-button type="primary" size="mini" @click="toAdd()">新增</el-button>
  11. </el-col>
  12. <el-col :span="24" class="four">
  13. <data-table
  14. :select="true"
  15. :selected="selected"
  16. @handleSelect="handleSelect"
  17. :fields="fields"
  18. :opera="opera"
  19. @query="search"
  20. :data="list"
  21. :total="total"
  22. @del="toDel"
  23. >
  24. </data-table>
  25. </el-col>
  26. </el-col>
  27. </el-row>
  28. </div>
  29. </template>
  30. <script>
  31. const _ = require('lodash');
  32. import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
  33. const { mapActions } = createNamespacedHelpers('goodsJoinAct');
  34. const { mapActions: dictData } = createNamespacedHelpers('dictData');
  35. export default {
  36. name: 'index',
  37. props: {},
  38. components: {
  39. // search1: () => import('./parts/search-1.vue'),
  40. },
  41. data: function () {
  42. const that = this;
  43. return {
  44. // 列表
  45. opera: [{ label: '删除', method: 'del', confirm: true, type: 'danger' }],
  46. fields: [
  47. { label: '活动标题', model: 'title' },
  48. { label: '活动时间', model: 'act_time.value' },
  49. ],
  50. list: [],
  51. total: 0,
  52. // 查询
  53. searchForm: {},
  54. // 多选值
  55. selected: [],
  56. };
  57. },
  58. async created() {
  59. await this.search();
  60. },
  61. methods: {
  62. ...dictData({ dictQuery: 'query' }),
  63. ...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
  64. // 查询
  65. async search({ skip = 0, limit = 10, ...info } = {}) {
  66. const condition = _.cloneDeep(this.searchForm);
  67. let res = await this.query({ skip, limit, ...condition, ...info });
  68. if (this.$checkRes(res)) {
  69. this.$set(this, 'list', res.data);
  70. this.$set(this, 'total', res.total);
  71. }
  72. },
  73. // 新增
  74. toAdd() {
  75. this.$router.push({ path: '/platActivi/act/goosDetail' });
  76. },
  77. // 删除
  78. async toDel({ data }) {
  79. let res = await this.delete(data._id);
  80. if (this.$checkRes(res)) {
  81. this.$message({ type: `success`, message: `刪除信息成功` });
  82. this.search();
  83. }
  84. },
  85. // // 重置
  86. // toClose() {
  87. // this.searchForm = {};
  88. // this.search();
  89. // },
  90. // 多选
  91. handleSelect(data) {
  92. this.$set(this, `selected`, data);
  93. },
  94. },
  95. computed: {
  96. ...mapState(['user']),
  97. },
  98. metaInfo() {
  99. return { title: this.$route.meta.title };
  100. },
  101. watch: {
  102. test: {
  103. deep: true,
  104. immediate: true,
  105. handler(val) { },
  106. },
  107. },
  108. };
  109. </script>
  110. <style lang="less" scoped>
  111. .main {
  112. .one {
  113. margin: 0 0 10px 0;
  114. span:nth-child(1) {
  115. font-size: 20px;
  116. font-weight: 700;
  117. margin-right: 10px;
  118. }
  119. }
  120. .two {
  121. margin: 0 0 10px 0;
  122. }
  123. .thr {
  124. margin: 0 0 10px 0;
  125. }
  126. }
  127. </style>