lrf402788946 4 years ago
parent
commit
0a9a4668fc

+ 28 - 1
src/views/market/list/achieve.vue

@@ -4,7 +4,7 @@
       <component :is="model" :list="list"></component>
     </list-page>
     <template v-else>
-      <dmodel :displayBtn="true" :data="detail" v-if="detail">
+      <dmodel :displayBtn="true" :data="detail" v-if="detail" @submit="toSubmit">
         <el-button size="mini" type="primary" @click="$router.push({ path: './list', query: { index: $route.query.index } })"> 返回</el-button>
       </dmodel>
     </template>
@@ -12,10 +12,12 @@
 </template>
 
 <script>
+const _ = require('lodash');
 import listPage from '@c/list/list-page.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: product } = createNamespacedHelpers('product');
 const { mapActions: code } = createNamespacedHelpers('code');
+const { mapActions: transaction } = createNamespacedHelpers('transaction');
 export default {
   name: 'achieve',
   props: ['listModel'],
@@ -38,6 +40,7 @@ export default {
     this.search();
   },
   methods: {
+    ...transaction({ getTran: 'query', createTran: 'create' }),
     ...product(['query', 'fetch']),
     ...code({ codeQuery: 'query' }),
     // 查询相关
@@ -87,6 +90,30 @@ export default {
         this.$set(this, `dropList`, newRes);
       }
     },
+    //供求对接
+    async toSubmit(data) {
+      const obj = {
+        supplier: _.get(data, 'user_id'),
+        s_name: _.get(data, 'contacts'),
+        s_phone: _.get(data, 'phone'),
+        product_id: _.get(data, 'id'),
+        product: _.get(data, 'name'),
+        demander: _.get(this.user, 'id'),
+        d_name: _.get(this.user, 'name'),
+        d_phone: _.get(this.user, 'phone'),
+      };
+      if (obj.demander === obj.supplier) {
+        this.$message.error('您不能对自己的成果进行对接!');
+        return;
+      }
+      const list = await this.getTran({ product_id: obj.product_id, demander: obj.demander });
+      if (list.total > 0) {
+        this.$message.warning('您已申请供求对接,无需再次申请!');
+        return;
+      }
+      const res = await this.createTran(obj);
+      this.$checkRes(res, '对接成功', res.errmsg || '对接失败');
+    },
   },
   computed: {
     ...mapState(['user', 'menuParams']),

+ 28 - 1
src/views/market/list/business.vue

@@ -4,7 +4,7 @@
       <component :is="model" :list="list"></component>
     </list-page>
     <template v-else>
-      <dmodel :displayBtn="true" :data="detail" v-if="detail">
+      <dmodel :displayBtn="true" :data="detail" v-if="detail" @submit="toSubmit">
         <el-button size="mini" type="primary" @click="$router.push({ path: './list', query: { index: $route.query.index } })"> 返回</el-button>
       </dmodel>
     </template>
@@ -15,6 +15,7 @@
 import listPage from '@c/list/list-page.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: product } = createNamespacedHelpers('product');
+const { mapActions: transaction } = createNamespacedHelpers('transaction');
 export default {
   name: 'business',
   props: ['listModel'],
@@ -34,6 +35,7 @@ export default {
     this.search();
   },
   methods: {
+    ...transaction({ getTran: 'query', createTran: 'create' }),
     ...product(['query', 'fetch']),
     // 查询相关
     async search({ skip = 0, limit = 10, ...info } = {}) {
@@ -63,6 +65,31 @@ export default {
         this.$set(this, `detail`, res.data);
       }
     },
+    //供求对接
+    async toSubmit(data) {
+      console.log(data);
+      const obj = {
+        supplier: _.get(data, 'user_id'),
+        s_name: _.get(data, 'contacts'),
+        s_phone: _.get(data, 'phone'),
+        product_id: _.get(data, 'id'),
+        product: _.get(data, 'name'),
+        demander: _.get(this.user, 'id'),
+        d_name: _.get(this.user, 'name'),
+        d_phone: _.get(this.user, 'phone'),
+      };
+      if (obj.demander === obj.supplier) {
+        this.$message.error('您不能对自己的服务进行对接!');
+        return;
+      }
+      const list = await this.getTran({ product_id: obj.product_id, demander: obj.demander });
+      if (list.total > 0) {
+        this.$message.warning('您已申请,无需再次申请!');
+        return;
+      }
+      const res = await this.createTran(obj);
+      this.$checkRes(res, '对接成功', res.errmsg || '对接失败');
+    },
   },
   computed: {
     ...mapState(['user', 'menuParams']),

+ 1 - 1
src/views/market/list/detail-model/model-1.vue

@@ -239,7 +239,7 @@ export default {
     // 对接
     onSubmit() {
       // TODO 提交申请即可
-      // this.$emit('onSubmit', { data: this.data });
+      this.$emit('submit', _.cloneDeep(this.data));
     },
   },
   computed: {

+ 1 - 1
src/views/market/list/detail-model/model-3.vue

@@ -161,7 +161,7 @@ export default {
     },
     // 对接
     onSubmit() {
-      this.$emit('onSubmit', { data: this.data });
+      this.$emit('submit', _.cloneDeep(this.data));
     },
     // 隐藏手机号
     getphone(value) {

+ 1 - 1
src/views/market/list/detail-model/model-4.vue

@@ -191,7 +191,7 @@ export default {
     },
     // 对接
     onSubmit() {
-      this.$emit('onSubmit', { data: this.data });
+      this.$emit('submit', _.cloneDeep(this.data));
     },
     // 隐藏手机号
     getphone(value) {

+ 1 - 1
src/views/market/list/detail-model/model-5.vue

@@ -212,7 +212,7 @@ export default {
     },
     // 对接
     onSubmit() {
-      this.$emit('onSubmit', { data: this.detailInfo });
+      this.$emit('submit', _.cloneDeep(this.data));
     },
     // 隐藏手机号
     getphone(value) {

+ 27 - 1
src/views/market/list/expert.vue

@@ -4,7 +4,7 @@
       <component :is="model" :list="list"></component>
     </list-page>
     <template v-else>
-      <dmodel :displayBtn="true" :data="detail" v-if="detail">
+      <dmodel :displayBtn="true" :data="detail" v-if="detail" @submit="toSubmit">
         <el-button size="mini" type="primary" @click="$router.push({ path: './list', query: { index: $route.query.index } })"> 返回</el-button>
       </dmodel>
     </template>
@@ -16,6 +16,7 @@ import listPage from '@c/list/list-page.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: expert } = createNamespacedHelpers('expert');
 const { mapActions: code } = createNamespacedHelpers('code');
+const { mapActions: transaction } = createNamespacedHelpers('transaction');
 export default {
   name: 'expert',
   props: ['listModel'],
@@ -38,6 +39,7 @@ export default {
     this.search();
   },
   methods: {
+    ...transaction({ getTran: 'query', createTran: 'create' }),
     ...expert(['query', 'fetch']),
     ...code({ codeQuery: 'query' }),
     // 查询相关
@@ -78,6 +80,30 @@ export default {
         this.$set(this, `dropList`, newRes);
       }
     },
+    //供求对接
+    async toSubmit(data) {
+      const obj = {
+        supplier: _.get(data, 'id'),
+        s_name: _.get(data, 'name'),
+        s_phone: _.get(data, 'phone'),
+        product_id: _.get(data, 'id'),
+        product: _.get(data, 'name'),
+        demander: _.get(this.user, 'id'),
+        d_name: _.get(this.user, 'name'),
+        d_phone: _.get(this.user, 'phone'),
+      };
+      if (obj.demander === obj.supplier) {
+        this.$message.error('您不能对自己进行对接!');
+        return;
+      }
+      const list = await this.getTran({ product_id: obj.product_id, demander: obj.demander });
+      if (list.total > 0) {
+        this.$message.warning('您已申请供求对接,无需再次申请!');
+        return;
+      }
+      const res = await this.createTran(obj);
+      this.$checkRes(res, '对接成功', res.errmsg || '对接失败');
+    },
   },
   computed: {
     ...mapState(['user', 'menuParams']),

+ 5 - 1
src/views/market/list/roadshow.vue

@@ -18,7 +18,11 @@ const { mapActions: mapRoadShow } = createNamespacedHelpers('roadShow');
 export default {
   name: 'roadshow',
   props: ['listModel'],
-  components: { listPage, model5: () => import('@c/list/list-model/model-5.vue'), dmodel: () => import('./detail-model/model-6.vue') },
+  components: {
+    listPage,
+    model5: () => import('@c/list/list-model/model-5.vue'),
+    dmodel: () => import('./detail-model/model-6.vue'),
+  },
   data: function() {
     return {
       list: [],

+ 32 - 3
src/views/market/list/technolgy.vue

@@ -4,7 +4,7 @@
       <component :is="model" :list="list"></component>
     </list-page>
     <template v-else>
-      <dmodel :displayBtn="true" :data="detail" v-if="detail">
+      <dmodel :displayBtn="true" :data="detail" v-if="detail" @submit="toSubmit">
         <el-button size="mini" type="primary" @click="$router.push({ path: './list', query: { index: $route.query.index } })"> 返回</el-button>
       </dmodel>
     </template>
@@ -15,10 +15,15 @@
 import listPage from '@c/list/list-page.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: product } = createNamespacedHelpers('product');
+const { mapActions: transaction } = createNamespacedHelpers('transaction');
 export default {
   name: 'technolgy',
   props: ['listModel'],
-  components: { listPage, model3: () => import('@c/list/list-model/model-3.vue'), dmodel: () => import('./detail-model/model-5.vue') },
+  components: {
+    listPage,
+    model3: () => import('@c/list/list-model/model-3.vue'),
+    dmodel: () => import('./detail-model/model-5.vue'),
+  },
   data: function() {
     return {
       list: [],
@@ -30,6 +35,7 @@ export default {
     this.search();
   },
   methods: {
+    ...transaction({ getTran: 'query', createTran: 'create' }),
     ...product(['query', 'fetch']),
     // 查询相关
     async search({ skip = 0, limit = 10, ...info } = {}) {
@@ -54,12 +60,35 @@ export default {
     },
     // 查询详情
     async searchInfo() {
-      console.log(this.id);
       let res = await this.fetch(this.id);
       if (this.$checkRes(res)) {
         this.$set(this, `detail`, res.data);
       }
     },
+    //供求对接
+    async toSubmit(data) {
+      const obj = {
+        supplier: _.get(data, 'user_id'),
+        s_name: _.get(data, 'contacts'),
+        s_phone: _.get(data, 'phone'),
+        product_id: _.get(data, 'id'),
+        product: _.get(data, 'name'),
+        demander: _.get(this.user, 'id'),
+        d_name: _.get(this.user, 'name'),
+        d_phone: _.get(this.user, 'phone'),
+      };
+      if (obj.demander === obj.supplier) {
+        this.$message.error('您不能对自己的成果进行对接!');
+        return;
+      }
+      const list = await this.getTran({ product_id: obj.product_id, demander: obj.demander });
+      if (list.total > 0) {
+        this.$message.warning('您已申请供求对接,无需再次申请!');
+        return;
+      }
+      const res = await this.createTran(obj);
+      this.$checkRes(res, '对接成功', res.errmsg || '对接失败');
+    },
   },
   computed: {
     ...mapState(['user', 'menuParams']),