Browse Source

上传记录页接口

suxinf 4 years ago
parent
commit
fc2d87d5da
4 changed files with 131 additions and 117 deletions
  1. 1 1
      src/App.vue
  2. 0 3
      src/request/api.js
  3. 128 111
      src/views/data/UploadRecord.vue
  4. 2 2
      src/views/data/components/UploadRecordTable.vue

+ 1 - 1
src/App.vue

@@ -36,7 +36,7 @@ export default {
     return {
       navTitle1: ' > 数据管理',
       navTitle2: '',
-      isManufacturer: 'distributor', // distributor 经销商 manufacturer 厂商
+      isManufacturer: 'manufacturer', // distributor 经销商 manufacturer 厂商
     }
   },
   methods: {

+ 0 - 3
src/request/api.js

@@ -15,9 +15,6 @@ axios.interceptors.request.use((config) => {
     if (config.url === '/firmsUpload') { //针对上传文件的接口 data不做转义 否则会造成传值为空
         config.data = baseData
         console.log(baseData)
-        config.headers = {
-            'content-Type': 'multipart/form-data'
-        }
     }
     return config;
 }, (err) => {

+ 128 - 111
src/views/data/UploadRecord.vue

@@ -1,38 +1,36 @@
 <template>
   <div class="upload_record">
     <div v-if="!isShowDetail">
-    <div class="search">
-      <div class="input">
-        <img src="../../img/search.png">
-        <input type="text" @focus="focusInput" v-model="inputValue">
+      <div class="search">
+        <div class="input">
+          <img src="../../img/search.png" />
+          <input type="text" @focus="focusInput" v-model="inputValue" />
+        </div>
+        <div class="current_button" @click="search">搜索</div>
       </div>
-      <div class="current_button" @click="search">
-        搜索
+      <div class="sort">
+        <Count :sum="sum" />
+        <p>排序</p>
+        <select v-model="order" @change="sort">
+          <option value="">按时间降序</option>
+          <option value="DESC">按时间升序</option>
+        </select>
       </div>
-    </div>
-    <div class="sort">
-      <Count :sum='sum'/>
-      <p>排序</p>
-      <select v-model="order" @change="sort">
-        <option value="">按时间降序</option>
-        <option value="DESC">按时间升序</option>
-      </select>
-    </div>
-    <div class="table">
-      <Table
-        :tableData='tableData'
-        @download='download'
-        @delet='delet'
-        @detail='detail'
-      >
-      </Table>
-    </div>
-    <TablePage
-      :currentPage='currentPage'
-      :totalPage='totalPage'
-      @change_page='changePage'
-      @jump_page='jumpPage'
-    ></TablePage>
+      <div class="table">
+        <Table
+          :tableData="tableData"
+          @download="download"
+          @delet="delet"
+          @detail="detail"
+        >
+        </Table>
+      </div>
+      <TablePage
+        :currentPage="currentPage"
+        :totalPage="totalPage"
+        @change_page="changePage"
+        @jump_page="jumpPage"
+      ></TablePage>
     </div>
     <div v-else>
       <Detail></Detail>
@@ -41,65 +39,66 @@
 </template>
 
 <script>
-import Count from '../../components/Count';
-import Table from './components/UploadRecordTable';
-import TablePage from '../../components/TablePage';
-import Detail from './components/UploadRecordDetail';
+import Count from "../../components/Count";
+import Table from "./components/UploadRecordTable";
+import TablePage from "../../components/TablePage";
+import Detail from "./components/UploadRecordDetail";
 export default {
   components: {
     Count,
     Table,
     TablePage,
-    Detail
+    Detail,
   },
   data() {
     return {
-      inputValue: '请输入要搜索的资料名',
-      order: '', // 排序方式
+      inputValue: "请输入要搜索的资料名",
+      order: "", // 排序方式
       sum: 100, // 表格总数据
       currentPage: 1,
       pageSize: 20,
       tableData: [],
-    }
+    };
   },
-  computed:{
+  computed: {
     // 表格总页数
     totalPage() {
-      return Math.ceil(this.sum/this.pageSize);
+      return Math.ceil(this.sum / this.pageSize);
     },
     isShowDetail() {
-      return (this.$route.query && this.$route.query.id) ? true : false
-    }
+      return this.$route.query && this.$route.query.id ? true : false;
+    },
   },
   methods: {
-    focusInput: function() {
-      this.inputValue = '';
+    focusInput: function () {
+      this.inputValue = "";
     },
-    search: function() {
+    search: function () {
       console.log(this.inputValue);
-      let data = {
-        name: this.inputValue,
-        asc: true
+      let data = {};
+      if (this.inputValue !== "请输入要搜索的资料名") {
+        data = {
+          informationName: this.inputValue,
+        };
       }
       this.getFirmsUploadList(data);
-      this.inputValue = '请输入要搜索的资料名'
+      this.inputValue = "请输入要搜索的资料名";
     },
-    sort: function(){
+    sort: function () {
       // ASC降序
-      let asc = this.order === 'DESC' ? false : true;
+      let asc = this.order === "DESC" ? false : true;
       let data = {
-        name: this.inputValue,
-        asc: asc
-      }
+        asc: asc,
+      };
       this.getFirmsUploadList(data);
     },
-    changePage: function(page) {
+    changePage: function (page) {
       this.currentPage = page;
       console.log(page);
     },
     // 点击上一页,下一页,首页,尾页
-    jumpPage: function(item) {
-      switch(item) {
+    jumpPage: function (item) {
+      switch (item) {
         case 1:
           this.currentPage = 1;
           break;
@@ -115,84 +114,102 @@ export default {
       }
       console.log(this.currentPage);
     },
-    download: function(i) {
-      this.selectInformationAgentList(i);
+    download: function (i) {
+      let id = this.tableData[i].id;
+      console.log(id);
+      this.selectInformationAgentList(id);
     },
-    delet: function(i) {
-      this.deleteInformationInfo(i);
+    delet: function (i) {
+      let id = this.tableData[i].id;
+      this.deleteInformationInfo(id);
+      setTimeout(() => {
+        this.getFirmsUploadList();
+      }, 2000)
     },
-    detail: function(i) {
-      let id = this.tableData[i].id || i
+    detail: function (i) {
+      let id = this.tableData[i].id || i;
       this.$router.push({ query: { id: id } });
     },
     // 上传记录列表接口
-    getFirmsUploadList: function() {
+    getFirmsUploadList: function (data = {}) {
       this.$http({
-        method: 'post',
-        url: '/firmsUploadList',
-        data: {}
-      }).then((res) => {
-        if(res.data && res.data.code === 200) {
-          console.log(res.data.data);
-          this.tableData = res.data.data;
-        }
-      }).catch((err) => {
-        console.log(err);
+        method: "post",
+        url: "/firmsUploadList",
+        data: data,
       })
+        .then((res) => {
+          if (res.data && res.data.code === 200) {
+            this.tableData = res.data.data;
+            this.sum = res.data.count;
+          } else {
+            console.log(res);
+          }
+        })
+        .catch((err) => {
+          console.log(err);
+        });
     },
     // 下载资料接口
-    selectInformationAgentList: function(dataId) {
+    selectInformationAgentList: function (dataId) {
       this.$http({
-        methods: 'post',
-        url: '/selectInformationAgentList',
+        method: "post",
+        url: "/selectInformationAgentList",
         data: {
-          id: dataId
-        }
-      }).then((res) => {
-        console.log(res);
-      }).catch((err) => {
-        console.log(err);
+          id: dataId,
+        },
       })
+        .then((res) => {
+          console.log(res);
+        })
+        .catch((err) => {
+          console.log(err);
+        });
     },
     // 删除记录接口
-    deleteInformationInfo: function(dataId) {
+    deleteInformationInfo: function (dataId) {
       this.$http({
-        method: 'post',
-        url: '/deleteInformationInfo',
+        method: "post",
+        url: "/deleteInformationInfo",
         data: {
-          dataId: dataId
-        }
-      }).then((res) => {
-        console.log(res);
-      }).catch((err) => {
-        console.log(err);
+          id: dataId,
+        },
       })
-    }
+        .then((res) => {
+          if(res.data && res.data.code === 200){
+            alert('删除成功');
+          }else{
+            console.log(res.message)
+          }
+        })
+        .catch((err) => {
+          console.log(err);
+        });
+    },
   },
   created() {
     this.getFirmsUploadList();
-  }
-}
+  },
+};
 </script>
 
 <style scoped lang="less">
-.upload_record{
-  .search{
+.upload_record {
+  .search {
     border: 1px solid #ccc;
     padding: 10px;
     display: flex;
     align-items: center;
-    .input{
+    .input {
       background-color: #fff;
       border: 1px solid #ccc;
       padding: 2px;
       display: flex;
-      img{
+      img {
         width: 28px;
         height: 28px;
         border: 1px solid #ccc;
       }
-      input{
+      input {
         background-color: #fff;
         border: 1px solid #ccc;
         margin-left: 3px;
@@ -201,38 +218,38 @@ export default {
       }
     }
   }
-  .sort{
+  .sort {
     display: flex;
     justify-content: flex-end;
     margin-top: 10px;
     height: 30px;
-    p{
+    p {
       margin: 10px 5px 0 15px;
       text-align: center;
       height: 20px;
     }
-    select{
+    select {
       border: 1px solid #ccc;
       font-size: 12px;
       height: 30px;
     }
   }
 }
-input{
+input {
   outline: none;
   border: 1px solid #ccc;
 }
-input:focus{
+input:focus {
   animation: shadowAni 200ms linear forwards;
 }
-@keyframes shadowAni{
-  0%{
+@keyframes shadowAni {
+  0% {
     border-color: #cccccc;
     box-shadow: inset 0px 0px 0 #ccc;
-  };
-  100%{
-    border-color: #75b9F0;
-    box-shadow: 0px 0px 5px #75b9F0;
+  }
+  100% {
+    border-color: #75b9f0;
+    box-shadow: 0px 0px 5px #75b9f0;
   }
 }
 </style>

+ 2 - 2
src/views/data/components/UploadRecordTable.vue

@@ -19,9 +19,9 @@
         >
           <td style="width: 20%">{{ obj.informationName }}</td>
           <td style="width: 10%">{{ obj.filePulishTime }}</td>
-          <td style="width: 10%">{{ obj.accountScope }}</td>
+          <td style="width: 10%">{{ obj.accountScope === 1 ? "共同" : "部分" }}</td>
           <td style="width: 10%">
-            <span>{{ obj.download1 }}</span
+            <span>{{ obj. totalCount }}</span
             >/<span style="color: #A30014">{{ obj.downloadCount }}</span>
           </td>
           <td style="width: 15%">{{ obj.fileUploadDate }}</td>