detail.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <div id="detail">
  3. <el-row>
  4. <el-col :span="24" class="style">
  5. <el-col :span="24" class="top">
  6. <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
  7. </el-col>
  8. <el-col :span="24" class="main">
  9. <van-tabs v-model="active" @click="clickbtn">
  10. <van-tab title="科技需求">
  11. <producInfo
  12. :type="type"
  13. :form="form"
  14. @onSubmit="onSubmit"
  15. :fieldList="fieldList"
  16. :achievestatusList="achievestatusList"
  17. :cooperationList="cooperationList"
  18. ></producInfo>
  19. </van-tab>
  20. <van-tab title="技术成果">
  21. <producInfo
  22. :type="type"
  23. :form="form"
  24. @onSubmit="onSubmit"
  25. :fieldList="fieldList"
  26. :achievestatusList="achievestatusList"
  27. :cooperationList="cooperationList"
  28. ></producInfo>
  29. </van-tab>
  30. <van-tab title="商务服务">
  31. <producInfo
  32. :type="type"
  33. :form="form"
  34. @onSubmit="onSubmit"
  35. :fieldList="fieldList"
  36. :achievestatusList="achievestatusList"
  37. :cooperationList="cooperationList"
  38. ></producInfo>
  39. </van-tab>
  40. </van-tabs>
  41. </el-col>
  42. </el-col>
  43. </el-row>
  44. </div>
  45. </template>
  46. <script>
  47. import producInfo from './parts/producInfo.vue';
  48. import NavBar from '@/layout/common/topInfo.vue';
  49. import { mapState, createNamespacedHelpers } from 'vuex';
  50. const { mapActions: markettype } = createNamespacedHelpers('markettype');
  51. const { mapActions: marketuser } = createNamespacedHelpers('marketuser');
  52. const { mapActions: exportuser } = createNamespacedHelpers('exportuser');
  53. const { mapActions: product } = createNamespacedHelpers('product');
  54. export default {
  55. name: 'detail',
  56. props: {},
  57. components: {
  58. NavBar,
  59. producInfo,
  60. },
  61. data: function() {
  62. return {
  63. // 头部标题
  64. title: '',
  65. // meta为true
  66. isleftarrow: '',
  67. // 返回
  68. navShow: true,
  69. active: 0,
  70. type: '0',
  71. form: {},
  72. // 字典表
  73. fieldList: [],
  74. achievestatusList: [],
  75. cooperationList: [],
  76. };
  77. },
  78. async created() {
  79. await this.searchtype();
  80. await this.searchinfo();
  81. if (this.id) {
  82. await this.searchproductinfo();
  83. }
  84. },
  85. methods: {
  86. ...markettype({ markettypeList: 'query' }),
  87. ...marketuser({ marketuserfetch: 'fetch' }),
  88. ...exportuser({ exportuserfetch: 'fetch' }),
  89. ...product({ productFetch: 'fetch', productCreate: 'create', productUpdate: 'update' }),
  90. // 查询企业详情
  91. async searchinfo() {
  92. let user = this.user;
  93. if (user.role == '4' || user.role == '5') {
  94. let res = await this.marketuserfetch(user.userid);
  95. if (res.errcode === 0) {
  96. let message = {
  97. company: res.data.name,
  98. phone: res.data.phone,
  99. email: res.data.email,
  100. companytype: res.data.companytype,
  101. companydate: res.data.companydate,
  102. companycapital: res.data.companycapital,
  103. };
  104. this.$set(this, `form`, message);
  105. }
  106. } else {
  107. let res = await this.exportuserfetch(user.userid);
  108. if (res.errcode === 0) {
  109. let message = {
  110. company: res.data.name,
  111. phone: res.data.phone,
  112. email: res.data.email,
  113. qqwx: res.data.qqwx,
  114. };
  115. this.$set(this, `form`, message);
  116. }
  117. }
  118. },
  119. // 查询产品详情
  120. async searchproductinfo() {
  121. let res = await this.productFetch(this.id);
  122. if (this.$checkRes(res)) {
  123. this.$set(this, `form`, res.data);
  124. }
  125. },
  126. // 查询字典表
  127. async searchtype() {
  128. // 所属领域;
  129. let res = await this.markettypeList({ category: '01' });
  130. if (this.$checkRes(res)) {
  131. this.$set(this, `fieldList`, res.data);
  132. }
  133. // 成果状态;
  134. res = await this.markettypeList({ category: '02' });
  135. if (this.$checkRes(res)) {
  136. this.$set(this, `achievestatusList`, res.data);
  137. }
  138. // 合作方式;
  139. res = await this.markettypeList({ category: '03' });
  140. if (this.$checkRes(res)) {
  141. this.$set(this, `cooperationList`, res.data);
  142. }
  143. },
  144. // 选择类型
  145. clickbtn(name) {
  146. this.$set(this, `type`, String(name));
  147. },
  148. // 提交
  149. async onSubmit({ data }) {
  150. data.type = this.type;
  151. data.userid = this.user.uid;
  152. let res = await this.productCreate(data);
  153. if (this.$checkRes(res)) {
  154. this.$notify({
  155. message: '保存草稿成功',
  156. type: 'success',
  157. });
  158. this.$router.push({ path: '/userCenter/myProduct/index' });
  159. }
  160. },
  161. // 监听显示类型
  162. changetype() {
  163. let type = this.producttype;
  164. this.$set(this, `active`, Number(type));
  165. this.$set(this, `type`, type);
  166. },
  167. },
  168. computed: {
  169. ...mapState(['user']),
  170. id() {
  171. return this.$route.query.id;
  172. },
  173. producttype() {
  174. return this.$route.query.type;
  175. },
  176. },
  177. watch: {
  178. producttype: {
  179. immediate: true,
  180. deep: true,
  181. handler(val) {
  182. this.changetype();
  183. },
  184. },
  185. },
  186. mounted() {
  187. this.title = this.$route.meta.title;
  188. this.isleftarrow = this.$route.meta.isleftarrow;
  189. },
  190. metaInfo() {
  191. return { title: this.$route.meta.title };
  192. },
  193. };
  194. </script>
  195. <style lang="less" scoped>
  196. .style {
  197. width: 100%;
  198. min-height: 667px;
  199. position: relative;
  200. background-color: #f9fafc;
  201. }
  202. .top {
  203. height: 46px;
  204. overflow: hidden;
  205. }
  206. .main {
  207. min-height: 570px;
  208. }
  209. </style>