index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24">
  5. <el-col :span="24" class="leftTop"> <span>|</span> <span>我的发布</span> </el-col>
  6. <el-col :span="24" class="info">
  7. <el-col :span="24" class="infoOne" v-if="display">
  8. <el-tabs v-model="activeName" type="card">
  9. <el-tab-pane label="待发布" name="first">
  10. <stay @editBtn="editBtn"></stay>
  11. </el-tab-pane>
  12. <el-tab-pane label="审核中" name="second">
  13. <statusIn></statusIn>
  14. </el-tab-pane>
  15. <el-tab-pane label="已发布" name="third">
  16. <already></already>
  17. </el-tab-pane>
  18. </el-tabs>
  19. <el-button type="primary" size="mini" class="add" @click="add">信息发布</el-button>
  20. </el-col>
  21. <el-col :span="24" class="infoTwo" v-else>
  22. <infoRelease @back="back" :form="form" @draftBtn="draftBtn" @submitBtn="submitBtn"></infoRelease>
  23. </el-col>
  24. </el-col>
  25. </el-col>
  26. </el-row>
  27. </div>
  28. </template>
  29. <script>
  30. import stay from './part/stay.vue';
  31. import statusIn from './part/statusIn.vue';
  32. import already from './part/already.vue';
  33. import infoRelease from './part/infoRelease.vue';
  34. import { mapState, createNamespacedHelpers } from 'vuex';
  35. const { mapActions: mapMarketproduct } = createNamespacedHelpers('marketproduct');
  36. export default {
  37. name: 'index',
  38. props: {},
  39. components: {
  40. stay, //待发布
  41. statusIn, //审核中
  42. already, //已发布
  43. infoRelease, //信息发布
  44. },
  45. data: function() {
  46. return {
  47. activeName: 'first',
  48. // 发布信息
  49. display: true,
  50. form: {},
  51. };
  52. },
  53. created() {},
  54. methods: {
  55. ...mapMarketproduct({ productFetch: 'fetch', productCreate: 'create', productUpdate: 'update' }),
  56. // 保存草稿
  57. async draftBtn({ data }) {
  58. data.userid = this.user.uid;
  59. if (data.id) {
  60. let res = await this.productUpdate(data);
  61. if (this.$checkRes(res)) {
  62. this.$message({
  63. message: '草稿修改成功',
  64. type: 'success',
  65. });
  66. window.location.reload();
  67. } else {
  68. this.$message.error('草稿保存失败');
  69. }
  70. } else {
  71. let res = await this.productCreate(data);
  72. if (this.$checkRes(res)) {
  73. this.$message({
  74. message: '草稿创建成功',
  75. type: 'success',
  76. });
  77. window.location.reload();
  78. } else {
  79. this.$message.error('草稿创建失败');
  80. }
  81. }
  82. },
  83. // 信息发布
  84. async submitBtn({ data }) {
  85. if (data.id) {
  86. data.status = '0';
  87. data.userid = this.user.uid;
  88. let res = await this.productUpdate(data);
  89. if (this.$checkRes(res)) {
  90. this.$message({
  91. message: '信息发布成功',
  92. type: 'success',
  93. });
  94. window.location.reload();
  95. } else {
  96. this.$message.error('信息发布失败');
  97. }
  98. } else {
  99. data.status = '0';
  100. data.userid = this.user.uid;
  101. let res = await this.productCreate(data);
  102. if (this.$checkRes(res)) {
  103. this.$message({
  104. message: '信息发布成功',
  105. type: 'success',
  106. });
  107. window.location.reload();
  108. } else {
  109. this.$message.error('信息发布失败');
  110. }
  111. }
  112. },
  113. // 信息发布
  114. add() {
  115. this.display = false;
  116. },
  117. // 返回
  118. back() {
  119. this.display = true;
  120. },
  121. // 修改信息
  122. editBtn(data) {
  123. this.$set(this, `form`, data);
  124. this.$set(this, `product_args`, data.product_args);
  125. this.display = false;
  126. },
  127. },
  128. computed: {
  129. ...mapState(['user']),
  130. pageTitle() {
  131. return `${this.$route.meta.title}`;
  132. },
  133. },
  134. metaInfo() {
  135. return { title: this.$route.meta.title };
  136. },
  137. };
  138. </script>
  139. <style lang="less" scoped>
  140. .leftTop {
  141. font-size: 18px;
  142. width: 96%;
  143. height: 41px;
  144. line-height: 35px;
  145. border-bottom: 1px solid #e5e5e5;
  146. position: relative;
  147. bottom: 1px;
  148. margin: 10px;
  149. font-weight: 600;
  150. color: #22529a;
  151. }
  152. .info {
  153. padding: 0 40px 0 10px;
  154. .infoOne {
  155. position: relative;
  156. .add {
  157. position: absolute;
  158. top: 0;
  159. right: 0;
  160. }
  161. }
  162. }
  163. </style>