guhongwei 3 yıl önce
ebeveyn
işleme
130a7b9970
3 değiştirilmiş dosya ile 136 ekleme ve 120 silme
  1. 1 0
      src/main.js
  2. 12 0
      src/plugins/components.js
  3. 123 120
      src/views/userCenter/menuParst/matterInfo.vue

+ 1 - 0
src/main.js

@@ -11,6 +11,7 @@ import '@/plugins/loading';
 import '@/plugins/var';
 import '@/plugins/methods';
 import '@/plugins/setting';
+import '@/plugins/components';
 import InitStomp from '@/plugins/stomp';
 Vue.config.productionTip = false;
 new Vue({

+ 12 - 0
src/plugins/components.js

@@ -0,0 +1,12 @@
+import Vue from 'vue';
+import dataTable from '@common/src/components/frame/filter-page-table.vue';
+import dataForm from '@common/src/components/frame/form.vue';
+import eUpload from '@common/src/components/frame/upload.vue';
+const Plugin = vue => {
+  vue.prototype.$dev_mode = process.env.NODE_ENV === 'development';
+  vue.component('data-table', dataTable);
+  vue.component('data-form', dataForm);
+  vue.component('eUpload', eUpload);
+};
+
+Vue.use(Plugin);

+ 123 - 120
src/views/userCenter/menuParst/matterInfo.vue

@@ -7,98 +7,90 @@
         </el-col>
         <el-col :span="24" class="two">
           <el-tabs v-model="active" type="card" @tab-click="tabChange">
-            <el-tab-pane label="我的全部" name="all">
-              <data-table
-                :fields="fields"
-                :opera="opera"
-                :data="listall"
-                :total="totalall"
-                @query="search"
-                @check="data => toStep(data, '1')"
-                @keep="toKeep"
-              ></data-table>
+            <el-tab-pane label="洽谈合作" name="0">
+              <data-table :fields="fields" :opera="opera" :data="list0" :total="total0" @query="search" @refuse="torefuse" @inten="toInten"></data-table>
             </el-tab-pane>
-            <el-tab-pane label="我的洽谈" name="0">
-              <data-table
-                :fields="fields"
-                :opera="opera"
-                :data="list0"
-                :total="total0"
-                @query="data => search(data, '0')"
-                @check="data => toStep(data, '1')"
-              ></data-table>
+            <el-tab-pane label="达成意向" name="1">
+              <data-table :fields="fields" :opera="opera" :data="list1" :total="total1" @query="search" @refuse="torefuse" @keep="toKeep"></data-table>
             </el-tab-pane>
-            <el-tab-pane label="我的意向" name="1">
-              <data-table :fields="fields" :opera="opera" :data="list1" :total="total1" @query="data => search(data, '1')" @keep="toKeep"></data-table>
+            <el-tab-pane label="交易备案" name="2">
+              <data-table :fields="fields" :opera="opera" :data="list2" :total="total2" @query="search" @refuse="torefuse"></data-table>
             </el-tab-pane>
-            <el-tab-pane label="我的交易" name="2">
-              <data-table :fields="fields" :opera="[]" :data="list2" :total="total2" @query="data => search(data, '2')"></data-table>
+            <el-tab-pane label="交易完成" name="3">
+              <data-table :fields="fields" :opera="opera" :data="list3" :total="total3" @query="search" @refuse="torefuse"></data-table>
+            </el-tab-pane>
+            <el-tab-pane label="交易失败" name="4">
+              <data-table :fields="fields" :opera="opera" :data="list4" :total="total4" @query="search"></data-table>
             </el-tab-pane>
           </el-tabs>
         </el-col>
       </el-col>
     </el-row>
-    <el-dialog title="上传合同备案" :visible.sync="dialog" width="40%" @close="toClose" destroy-on-close>
-      <el-form>
-        <el-form-item label="合同图片" required>
-          <upload
-            :limit="1"
-            :data="keep.file_path"
-            type="file_path"
-            listType=""
-            :url="'/files/platform/transaction_pact/upload'"
-            @upload="uploadSuccess"
-            @delete="uploadDelete"
-          ></upload>
+    <el-dialog class="dialog" title="合同备案" :visible.sync="dialog" width="40%" @close="toClose" destroy-on-close>
+      <el-form ref="form" :model="form" label-width="90px">
+        <el-form-item label="产品名称">
+          <el-input v-model="form.product.name" disabled></el-input>
+        </el-form-item>
+        <el-form-item label="供给者姓名">
+          <el-input v-model="form.s_name" disabled></el-input>
+        </el-form-item>
+        <el-form-item label="供给者电话">
+          <el-input v-model="form.s_phone" disabled></el-input>
+        </el-form-item>
+        <el-form-item label="需求者姓名">
+          <el-input v-model="form.d_name" disabled></el-input>
+        </el-form-item>
+        <el-form-item label="需求者电话">
+          <el-input v-model="form.d_phone" disabled></el-input>
         </el-form-item>
-        <el-form-item label="描述" required>
-          <el-input type="textarea" v-model="keep.desc" :autosize="{ minRows: 3, maxRows: 5 }"></el-input>
+        <el-form-item label="合同图片">
+          <e-upload url="/files/platlive/tranContact/upload" :limit="1" v-model="form.contact" type="contact" @upload="upload" @delete="onDelete"></e-upload>
         </el-form-item>
       </el-form>
-      <div slot="footer">
-        <el-button @click="dialog = false">取 消</el-button>
-        <el-button type="primary" @click="stepKeep">确 定</el-button>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="toClose">取消备案</el-button>
+        <el-button type="primary" @click="onSubmit">提交备案</el-button>
       </div>
     </el-dialog>
   </div>
 </template>
 
 <script>
-import upload from '@common/src/components/frame/upload.vue';
-import dataTable from '@common/src/components/frame/filter-page-table.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
-const { mapActions: transaction } = createNamespacedHelpers('transaction');
+const { mapActions: dockTranscation } = createNamespacedHelpers('dockTranscation');
+const _ = require('lodash');
 export default {
-  metaInfo() {
-    return { title: this.$route.meta.title };
-  },
   name: 'matterInfo',
   props: {},
-  components: {
-    dataTable,
-    upload,
-  },
+  components: {},
   data: function() {
     return {
-      active: 'all',
+      active: '0',
       opera: [
         {
-          label: '意向',
-          method: 'check',
+          label: '达成意向',
+          method: 'inten',
           display: item => {
-            return item.status == '0';
+            return item.status == '0' && item.s_id == this.user.id;
           },
         },
         {
-          label: '备案',
+          label: '交易备案',
           method: 'keep',
           display: item => {
-            return item.status == '1';
+            return item.status == '1' && item.s_id == this.user.id;
+          },
+        },
+        {
+          label: '拒绝交易',
+          method: 'refuse',
+          display: item => {
+            return item.status == '0' || item.status == '1' || item.status == '2';
           },
         },
       ],
       fields: [
-        { label: '产品名称', prop: 'product', showTip: true },
+        { label: '产品名称', prop: 'product.name', showTip: true },
         { label: '供给者姓名', prop: 's_name', showTip: true },
         { label: '供给者电话', prop: 's_phone', showTip: true },
         { label: '需求者姓名', prop: 'd_name', showTip: true },
@@ -107,102 +99,100 @@ export default {
           label: '交易状态',
           prop: 'status',
           format: item => {
-            return item === '0' ? '正在洽谈' : item === '1' ? '达成意向' : item === '2' ? '交易备案' : item === '3' ? '交易完成' : '交易失败';
+            return item === '0' ? '正在洽谈' : item === '1' ? '达成意向' : item === '2' ? '备案' : item === '3' ? '交易完成' : '交易失败';
           },
         },
       ],
-      // 我的全部
-      listall: [],
-      totalall: 0,
-      // 我的洽谈
+      // 洽谈合作
       list0: [],
       total0: 0,
-      // 我的意向
+      // 达成意向
       list1: [],
       total1: 0,
-      // 交易完成
+      //  交易备案
       list2: [],
       total2: 0,
+      // 交易完成
+      list3: [],
+      total3: 0,
+      // 交易失败
+      list4: [],
+      total4: 0,
+      // 合同备案
       dialog: false,
-      keep: {},
+      form: {
+        product: {},
+      },
     };
   },
-  async created() {
-    await this.search();
+  created() {
+    this.search();
   },
   methods: {
-    ...transaction(['query', 'step']),
-    async search({ skip = 0, limit = 10, ...info } = {}, status = 'all') {
-      const query = { skip, limit, user_id: this.user.id };
-      if (status != 'all') query.status = status == '2' ? '2,3' : status;
-      const res = await this.query(query);
+    ...dockTranscation(['userList', 'update']),
+    async search({ skip = 0, limit = 10, ...info } = {}, status = '0') {
+      info.status = status;
+      info.user_id = this.user.id;
+      let res = await this.userList({ skip, limit, ...info });
       if (this.$checkRes(res)) {
         this.$set(this, `list${status}`, res.data);
         this.$set(this, `total${status}`, res.total);
       }
     },
-    async toStep({ data }, status) {
-      console.log(status);
-      this.$confirm('您确定双方已达成意向?', '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning',
-      })
-        .then(async () => {
-          const { id } = data;
-          const res = await this.step({ id, status });
-          if (this.$checkRes(res, '达成意向!', res.errmsg || '操作失败')) this.research();
-        })
-        .catch(() => {});
+    tabChange(tab) {
+      const status = _.get(tab, 'name', 0);
+      this.search({}, status);
+    },
+    // 达成意向
+    async toInten({ data }) {
+      data.status = '1';
+      let res = await this.update(data);
+      if (this.$checkRes(res, '意向提交成功', res.errmsg || '操作失败')) this.search();
     },
+    // 交易备案
     async toKeep({ data }) {
-      this.keep = _.cloneDeep(data);
-      this.keep.status = '2';
+      this.$set(this, `form`, data);
       this.dialog = true;
     },
-    async stepKeep() {
-      const { id, file_path, desc } = this.keep;
-      if (!(id && file_path && desc)) {
-        this.$message.error('需要上传合同图片及填写描述内容');
-        return;
-      }
-      const dup = { id, pact: { file_path, desc }, status: '2' };
-      const res = await this.step(dup);
-      if (this.$checkRes(res, '备案成功,请等待审核', res.errmsg || '备案失败')) this.research();
-    },
-    tabChange(tab) {
-      const status = _.get(tab, 'name', 0);
-      if (this[`list${status}`].length <= 0) {
-        this.search({}, status);
-      }
+    // 提交备案
+    async onSubmit() {
+      let data = this.form;
+      data.status = '2';
+      let res = await this.update(data);
+      if (this.$checkRes(res, '交易备案提交成功', res.errmsg || '操作失败')) this.toClose();
+      this.search();
     },
+    // 关闭交易备案
     toClose() {
-      this.keep = {};
-    },
-    research() {
-      this.search();
-      if (this.active !== 'all') this.search({}, this.active);
       this.dialog = false;
     },
-    uploadSuccess({ type, data }) {
-      this.$set(this.keep, `${type}`, data.uri);
-      this.$message({
-        message: '上传成功',
-        type: 'success',
-      });
+    // 拒绝交易
+    async torefuse({ data }) {
+      data.status = '4';
+      let res = await this.update(data);
+      if (this.$checkRes(res, '交易失败提交成功', res.errmsg || '操作失败')) this.search();
+    },
+    // 上传图片
+    upload({ type, data }) {
+      this.$set(this.form, `${type}`, data.uri);
     },
-    uploadDelete(index) {
-      this.$set(this.keep, `file_path`, null);
-      this.$message({
-        message: '删除成功',
-        type: 'success',
-      });
+    onDelete(data) {
+      this.$set(this.form, `${data.type}`, '');
     },
   },
   computed: {
     ...mapState(['user']),
   },
-  watch: {},
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
 };
 </script>
 
@@ -219,5 +209,18 @@ export default {
     color: #22529a;
     margin: 0 0 10px 0;
   }
+  .two {
+    /deep/.el-tabs__header {
+      margin: 0 0 10px 0;
+    }
+  }
+}
+.dialog {
+  /deep/.el-dialog__footer {
+    text-align: center;
+  }
+  /deep/.el-dialog__body {
+    padding: 5px 10px;
+  }
 }
 </style>