guhongwei 3 年 前
コミット
c534403d6b

BIN
public/专利交易信息数据模板.xlsx


+ 0 - 1
src/layout/patentInfo/list-1.vue

@@ -91,7 +91,6 @@ export default {
 
 <style lang="less" scoped>
 .main {
-  margin: 8px 0 0 0;
   .list {
     background-color: #fff;
     margin: 0 0 10px 0;

+ 1 - 1
src/layout/trans/list-1.vue

@@ -123,7 +123,7 @@ export default {
 
 <style lang="less" scoped>
 .main {
-  padding: 8px 8px 0 8px;
+  padding: 0 8px 0 8px;
   .list {
     background-color: #fff;
     margin: 0 0 8px 0;

+ 1 - 1
src/layout/trans/list-2.vue

@@ -59,7 +59,7 @@ export default {
 
 <style lang="less" scoped>
 .main {
-  padding: 8px 8px 0 8px;
+  padding: 0 8px 0 8px;
   .list {
     background-color: #fff;
     margin: 0 0 8px 0;

+ 5 - 0
src/router/index.js

@@ -416,6 +416,11 @@ const patent = [
     meta: { title: '专利交易' },
     component: () => import('../views/patent/admin/patent/trans.vue'),
   },
+  {
+    path: '/patent/admin/patent/trans_import',
+    meta: { title: '专利交易-信息导入' },
+    component: () => import('../views/patent/admin/patent/trans_import.vue'),
+  },
   {
     path: '/patent/admin/patent/safeg',
     meta: { title: '专利维权' },

+ 1 - 1
src/views/patent/admin/patent/import.vue

@@ -97,7 +97,7 @@ export default {
 
     // 返回
     back() {
-      this.$router.push({ path: '/patent/admin/patent/info' });
+      this.$router.push({ path: '/patent/admin/patent' });
     },
 
     async toUpload({ file }, model) {

+ 26 - 2
src/views/patent/admin/patent/trans.vue

@@ -2,7 +2,12 @@
   <div id="trans">
     <admin-frame @search="search" :limit="limit" :total="total" topType="2" :rightArrow="false" @back="back" :useNav="false">
       <template v-slot:info>
-        <list-2 :list="list" @toView="toView"></list-2>
+        <van-col span="24" class="one">
+          <van-button type="info" size="small" @click="toImport()">导入交易信息</van-button>
+        </van-col>
+        <span span="24" class="two">
+          <list-2 :list="list" @toView="toView"></list-2>
+        </span>
       </template>
     </admin-frame>
     <van-dialog class="dialog" v-model="dialog.show" :title="dialog.title" :show-confirm-button="false" show-cancel-button cancel-button-text="返回">
@@ -28,7 +33,7 @@ export default {
   data: function () {
     return {
       list: [],
-      limit: 5,
+      limit: 4,
       total: 0,
       // 弹框
       dialog: { show: false, title: '详细信息', type: '1' },
@@ -54,6 +59,10 @@ export default {
       let dialog = { show: true, title: '详细信息', type: '1' };
       this.$set(this, `dialog`, dialog);
     },
+    // 导入专利
+    toImport() {
+      this.$router.push({ path: '/patent/admin/patent/trans_import' });
+    },
     // 返回
     back() {
       this.$router.push({ path: '/patent/index' });
@@ -76,6 +85,21 @@ export default {
 </script>
 
 <style lang="less" scoped>
+.one {
+  text-align: center;
+  margin: 8px 0;
+  .van-button {
+    margin: 0 5px 5px 0;
+  }
+  p {
+    font-size: 16px;
+    margin: 5px 0 0 0;
+    span {
+      color: #000;
+      font-weight: bold;
+    }
+  }
+}
 .dialog {
   /deep/.van-dialog__content {
     max-height: 350px;

+ 129 - 0
src/views/patent/admin/patent/trans_import.vue

@@ -0,0 +1,129 @@
+<template>
+  <div id="index">
+    <admin-frame topType="2" @back="back" :usePage="false" :rightArrow="false" :useNav="false">
+      <template v-slot:info>
+        <van-col span="24" class="one">
+          <van-button type="info" size="small" @click="daownload()">下载导入模板</van-button>
+        </van-col>
+        <van-col span="24" class="two">
+          <van-form @submit="onSubmit">
+            <van-field name="uri" label="文件">
+              <template #input>
+                <van-uploader
+                  :fileList="form.uri"
+                  :max-count="1"
+                  :after-read="(file) => toUpload(file, 'uri')"
+                  @delete="(file) => toDelete(file, 'uri')"
+                  accept="file"
+                />
+              </template>
+            </van-field>
+            <div style="margin: 16px; text-align: center">
+              <van-button :loading="loading" type="info" size="small" native-type="submit" loading-text="加载中...">确认导入</van-button>
+            </div>
+          </van-form>
+        </van-col>
+        <van-col span="24" class="thr">
+          <van-col span="24" class="list" v-for="(item, index) in list" :key="index">
+            提示信息:<span>{{ item }}</span>
+          </van-col>
+        </van-col>
+      </template>
+    </admin-frame>
+  </div>
+</template>
+
+<script>
+import adminFrame from '@frame/src/components/mobile-frame/mobile-main.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: patenttrans } = createNamespacedHelpers('patenttrans');
+const { mapActions: upload } = createNamespacedHelpers('upload');
+export default {
+  name: 'index',
+  props: {},
+  components: {
+    adminFrame,
+  },
+  data: function () {
+    return {
+      form: {},
+      loading: false,
+      list: [],
+    };
+  },
+  created() {},
+  methods: {
+    ...upload(['upload']),
+    ...patenttrans(['toImport']),
+    // 提交导入
+    async onSubmit(values) {
+      values.uri = values.uri ? values.uri[0].uri : '';
+      this.loading = true;
+      let res = await this.toImport(values);
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$toast({ type: `success`, message: `导入成功` });
+        this.loading = false;
+      } else {
+        this.$toast({ type: `success`, message: `${res.errmsg}` });
+      }
+    },
+    // 下载模板
+    daownload() {
+      window.location.href = `${process.env.VUE_APP_HOST}/${process.env.VUE_APP_ROUTER}/专利交易信息数据模板.xlsx`;
+    },
+
+    // 返回
+    back() {
+      this.$router.push({ path: '/patent/admin/patent/trans' });
+    },
+
+    async toUpload({ file }, model) {
+      // 上传,赋值
+      const res = await this.upload({ file, dir: 'patent' });
+      if (this.$checkRes(res)) {
+        this.$set(this.form, model, [{ name: res.name, uri: res.uri }]);
+      }
+    },
+    toDelete(file, model) {
+      const index = this.form[model].findIndex((f) => _.isEqual(f, file));
+      this.form[model].splice(index, 1);
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.one {
+  text-align: center;
+  margin: 8px 0;
+  .van-button {
+    margin: 0 5px;
+  }
+}
+.thr {
+  .list {
+    padding: 10px;
+    background-color: #fff;
+    margin: 0 0 10px 0;
+    font-size: 15px;
+    color: #666;
+    span {
+      color: #000;
+    }
+  }
+}
+</style>