index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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" :product_args="product_args" @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. product_args: [],
  52. };
  53. },
  54. created() {},
  55. methods: {
  56. ...mapMarketproduct({ productFetch: 'fetch', productCreate: 'create', productUpdate: 'update' }),
  57. // 保存草稿
  58. async draftBtn({ data }) {
  59. data.product_args = this.product_args;
  60. data.userid = this.user.uid;
  61. if (data.id) {
  62. let res = await this.productUpdate(data);
  63. if (this.$checkRes(res)) {
  64. this.$message({
  65. message: '草稿修改成功',
  66. type: 'success',
  67. });
  68. window.location.reload();
  69. } else {
  70. this.$message.error('草稿保存失败');
  71. }
  72. } else {
  73. let res = await this.productCreate(data);
  74. if (this.$checkRes(res)) {
  75. this.$message({
  76. message: '草稿创建成功',
  77. type: 'success',
  78. });
  79. window.location.reload();
  80. } else {
  81. this.$message.error('草稿创建失败');
  82. }
  83. }
  84. },
  85. // 信息发布
  86. async submitBtn({ data }) {
  87. if (data.id) {
  88. data.status = '0';
  89. data.userid = this.user.uid;
  90. let res = await this.productUpdate(data);
  91. if (this.$checkRes(res)) {
  92. this.$message({
  93. message: '信息发布成功',
  94. type: 'success',
  95. });
  96. window.location.reload();
  97. } else {
  98. this.$message.error('信息发布失败');
  99. }
  100. } else {
  101. data.status = '0';
  102. data.userid = this.user.uid;
  103. let res = await this.productCreate(data);
  104. if (this.$checkRes(res)) {
  105. this.$message({
  106. message: '信息发布成功',
  107. type: 'success',
  108. });
  109. window.location.reload();
  110. } else {
  111. this.$message.error('信息发布失败');
  112. }
  113. }
  114. },
  115. // 信息发布
  116. add() {
  117. this.display = false;
  118. },
  119. // 返回
  120. back() {
  121. this.display = true;
  122. },
  123. // 修改信息
  124. editBtn(data) {
  125. this.$set(this, `form`, data);
  126. this.$set(this, `product_args`, data.product_args);
  127. this.display = false;
  128. },
  129. },
  130. computed: {
  131. ...mapState(['user']),
  132. pageTitle() {
  133. return `${this.$route.meta.title}`;
  134. },
  135. },
  136. metaInfo() {
  137. return { title: this.$route.meta.title };
  138. },
  139. };
  140. </script>
  141. <style lang="less" scoped>
  142. .leftTop {
  143. font-size: 18px;
  144. width: 96%;
  145. height: 41px;
  146. line-height: 35px;
  147. border-bottom: 1px solid #e5e5e5;
  148. position: relative;
  149. bottom: 1px;
  150. margin: 10px;
  151. font-weight: 600;
  152. color: #22529a;
  153. }
  154. .info {
  155. padding: 0 40px 0 10px;
  156. .infoOne {
  157. position: relative;
  158. .add {
  159. position: absolute;
  160. top: 0;
  161. right: 0;
  162. }
  163. }
  164. }
  165. </style>