index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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
  23. @back="back"
  24. :form="form"
  25. @draftBtn="draftBtn"
  26. @submitBtn="submitBtn"
  27. :addpatentform="addpatentform"
  28. @patentonSubmit="patentonSubmit"
  29. :diapatent="addpatent"
  30. ></infoRelease>
  31. </el-col>
  32. </el-col>
  33. </el-col>
  34. </el-row>
  35. </div>
  36. </template>
  37. <script>
  38. import stay from './part/stay.vue';
  39. import statusIn from './part/statusIn.vue';
  40. import already from './part/already.vue';
  41. import infoRelease from './part/infoRelease.vue';
  42. import { mapState, createNamespacedHelpers } from 'vuex';
  43. const { mapActions: mapMarketproduct } = createNamespacedHelpers('marketproduct');
  44. const { mapActions: market } = createNamespacedHelpers('market');
  45. const { mapActions: expertsuser } = createNamespacedHelpers('expertsuser');
  46. export default {
  47. name: 'index',
  48. props: {},
  49. components: {
  50. stay, //待发布
  51. statusIn, //审核中
  52. already, //已发布
  53. infoRelease, //信息发布
  54. },
  55. data: function() {
  56. return {
  57. activeName: 'first',
  58. // 发布信息
  59. display: true,
  60. form: {},
  61. // 企业信息&专家信息
  62. companyInfo: {},
  63. addpatentform: {},
  64. addpatent: [],
  65. };
  66. },
  67. created() {
  68. this.searchInfo();
  69. },
  70. methods: {
  71. ...mapMarketproduct({ productFetch: 'fetch', productCreate: 'create', productUpdate: 'update' }),
  72. ...market(['fetch', 'update']),
  73. ...expertsuser({ expertsuserFetch: 'fetch', expertsuserUpdate: 'update', expertsuserUpgrade: 'upgrade' }),
  74. // 查询信息
  75. async searchInfo() {
  76. if (this.user.role == '4' || this.user.role == '5') {
  77. let res = await this.fetch(this.user.userid);
  78. if (res.errcode === 0) {
  79. let message = {
  80. company: res.data.name,
  81. phone: res.data.phone,
  82. email: res.data.email,
  83. companytype: res.data.companytype,
  84. companydate: res.data.companydate,
  85. companycapital: res.data.companycapital,
  86. // contacts: '赵超',
  87. // qqwx: '0431-85262608',
  88. // achieveown: '中国科学院长春应用化学研究所',
  89. // field: '新材料技术',
  90. };
  91. console.log(message);
  92. this.$set(this, `form`, message);
  93. this.$set(this, `companyInfo`, res.data);
  94. }
  95. } else if (this.user.role == '6') {
  96. let res = await this.expertsuserFetch(this.user.userid);
  97. if (res.errcode === 0) {
  98. let message = {
  99. company: res.data.company,
  100. contacts: res.data.name,
  101. phone: res.data.phone,
  102. email: res.data.email,
  103. qqwx: res.data.qqwx,
  104. };
  105. this.$set(this, `form`, message);
  106. this.$set(this, `companyInfo`, res.data);
  107. }
  108. }
  109. },
  110. // 保存草稿
  111. async draftBtn({ data }) {
  112. if (data.id) {
  113. let res = await this.productUpdate(data);
  114. if (this.$checkRes(res)) {
  115. this.$message({
  116. message: '草稿修改成功',
  117. type: 'success',
  118. });
  119. window.location.reload();
  120. } else {
  121. this.$message.error('草稿保存失败');
  122. }
  123. } else {
  124. data.patent = this.addpatent;
  125. data.userid = this.user.uid;
  126. let res = await this.productCreate(data);
  127. if (this.$checkRes(res)) {
  128. this.$message({
  129. message: '草稿创建成功',
  130. type: 'success',
  131. });
  132. window.location.reload();
  133. } else {
  134. this.$message.error('草稿创建失败');
  135. }
  136. }
  137. },
  138. // 信息发布
  139. async submitBtn({ data }) {
  140. if (data.id) {
  141. data.status = '0';
  142. data.userid = this.user.uid;
  143. let res = await this.productUpdate(data);
  144. if (this.$checkRes(res)) {
  145. this.$message({
  146. message: '信息发布成功',
  147. type: 'success',
  148. });
  149. window.location.reload();
  150. } else {
  151. this.$message.error('信息发布失败');
  152. }
  153. } else {
  154. data.status = '0';
  155. data.userid = this.user.uid;
  156. let res = await this.productCreate(data);
  157. if (this.$checkRes(res)) {
  158. this.$message({
  159. message: '信息发布成功',
  160. type: 'success',
  161. });
  162. window.location.reload();
  163. } else {
  164. this.$message.error('信息发布失败');
  165. }
  166. }
  167. },
  168. // 信息发布
  169. add() {
  170. this.display = false;
  171. },
  172. // 返回
  173. back() {
  174. this.display = true;
  175. },
  176. // 修改信息
  177. editBtn(data) {
  178. this.$set(this, `form`, data);
  179. this.$set(this, `product_args`, data.product_args);
  180. this.display = false;
  181. },
  182. // 添加专利信息
  183. patentonSubmit({ data }) {
  184. this.addpatentform = {};
  185. this.addpatent.push(data);
  186. this.$message({
  187. message: '专利信息添加成功',
  188. type: 'success',
  189. });
  190. },
  191. },
  192. computed: {
  193. ...mapState(['user']),
  194. pageTitle() {
  195. return `${this.$route.meta.title}`;
  196. },
  197. },
  198. metaInfo() {
  199. return { title: this.$route.meta.title };
  200. },
  201. };
  202. </script>
  203. <style lang="less" scoped>
  204. .leftTop {
  205. font-size: 18px;
  206. width: 96%;
  207. height: 41px;
  208. line-height: 35px;
  209. border-bottom: 1px solid #e5e5e5;
  210. position: relative;
  211. bottom: 1px;
  212. margin: 10px;
  213. font-weight: 600;
  214. color: #22529a;
  215. }
  216. .info {
  217. padding: 0 40px 0 10px;
  218. .infoOne {
  219. position: relative;
  220. .add {
  221. position: absolute;
  222. top: 0;
  223. right: 0;
  224. }
  225. }
  226. }
  227. </style>