ソースを参照

增加导出功能

曹冬冬 5 年 前
コミット
f94c5f69d9

+ 6 - 1
src/api/test.js

@@ -18,6 +18,11 @@ const queryTestTheme = (param) => {
   return http.post('/testTheme/queryTestTheme', param)
 }
 
+// 报表导出
+const exportExcelPath = (param) => {
+  return http.post('/excel/exportExcelPath', param)
+}
+
 module.exports = {
-  testList, deleteTest, copyTest, queryTestTheme
+  testList, deleteTest, copyTest, queryTestTheme, exportExcelPath
 }

BIN
src/assets/images/more_nor.png


BIN
src/assets/images/more_sel.png


+ 15 - 3
src/views/myHistoryTest/myHistoryTest.html

@@ -28,7 +28,8 @@
   </div>
   <!-- 列表 -->
   <div class="test-list" v-infinite-scroll="getTestList" infinite-scroll-disabled="disabled">
-    <div class="item" v-for="(item,index) in dataList" :key="item.created" :class="{ itemCopy: isCopy && index == 0 }">
+    <div class="item" v-for="(item,index) in dataList" :key="item.created"
+      :class="[ (isCopy && index == 0) ? itemCopyClass :'', item.isMore ? morehoverClass : '' ]">
       <!-- <img  mode="" :src="" alt=""> -->
       <el-image class="item-img" :src="item.coverImg" fit="cover">
         <div slot="error" class="outline">
@@ -37,9 +38,20 @@
         </div>
       </el-image>
       <div class="tools">
-        <div v-if="item.canDelete" class="item-img delete" src="" alt="" @click="deleteTest(item,index)"></div>
+        <el-dropdown placement="bottom" trigger="click" class="item-img"
+          @command="command=>operationCommand(command, item, index)" @visible-change="isShow=>more(isShow,item,index)">
+          <div class="more"></div>
+          <el-dropdown-menu slot="dropdown">
+            <el-dropdown-item command="download" v-if="!item.canDelete">下载数据表格</el-dropdown-item>
+            <el-dropdown-item command="share">设置分享链接</el-dropdown-item>
+            <el-dropdown-item command="del" v-if="item.canDelete">删除</el-dropdown-item>
+          </el-dropdown-menu>
+        </el-dropdown>
+        <!-- <div v-if="item.canDelete" class="item-img delete" src="" alt="" @click="deleteTest(item,index)"></div>
+        <div class="item-img copy" src="" alt="" @click="copyTest(item)"></div> -->
+        <!-- <div class="item-img share" src="" alt="" @click="shareTest(item)"></div> -->
+        <!-- <div v-if="item.canDelete == false" class="item-img share" src="" alt="" @click="excelReport(item)"></div> -->
         <div class="item-img copy" src="" alt="" @click="copyTest(item)"></div>
-        <div class="item-img share" src="" alt="" @click="shareTest(item)"></div>
         <div class="item-img edit" @click="editTest(item)" style="float:right;margin-right:10px;"></div>
       </div>
       <div class="title">{{item.title}}</div>

+ 66 - 1
src/views/myHistoryTest/myHistoryTest.js

@@ -40,7 +40,9 @@ export default {
       shareModel: "",
       pageNo: 1,
       dataList: [],
-      total: 0
+      total: 0,
+      itemCopyClass: "itemCopy",
+      morehoverClass: "morehover"
     }
   },
   computed: {
@@ -73,6 +75,22 @@ export default {
     this.getTestList(true);
   },
   methods: {
+    more(isShow, item, index) {
+      item.isMore = isShow;
+      this.dataList.splice(index, 1, item);
+    },
+    operationCommand(command, item, index) {
+      if (command == "download") {
+        console.log("下载");
+        this.download(item);
+      } else if (command == "share") {
+        console.log("分享");
+        this.shareTest(item);
+      } else if (command == "del") {
+        console.log("删除");
+        this.deleteTest(item, index);
+      }
+    },
     dataformat(val) {
       return timeFormat.dateStr(val);
     },
@@ -128,6 +146,30 @@ export default {
     createTest() {
       this.$router.push({ path: '/cncTestLists' });
     },
+    download(item) {
+      let data = {
+        "id": item._id
+      }
+      console.log("下载数据", data);
+      api.exportExcelPath(data).then((res) => {
+        if (res.success) {
+          console.log("下载数据", res);
+          this.$message.success("下载成功");
+          var tempLink = document.createElement("a");
+          tempLink.style.display = "none";
+          tempLink.href = res.data.single;
+          tempLink.setAttribute("download", "用户来源导出表");
+          if (typeof tempLink.download === "undefined") {
+            tempLink.setAttribute("target", "_blank");
+          }
+          document.body.appendChild(tempLink);
+          tempLink.click();
+          document.body.removeChild(tempLink);
+        } else {
+          this.$message.error("下载失败,请重试");
+        }
+      })
+    },
     deleteTest(item, index) {
       const h = this.$createElement;
       this.$msgbox({
@@ -207,6 +249,29 @@ export default {
         }
       })
     },
+    excelReport(item) {
+      console.log(item);
+      let maindata = {
+        houseId: this.houseId
+      };
+      console.log("***expot***", maindata);
+      editorApi.exportStaffSource(maindata).then((res) => {
+        if (res.success) {
+          var tempLink = document.createElement("a");
+          tempLink.style.display = "none";
+          tempLink.href = result.data.single.url;
+          tempLink.setAttribute("download", "用户来源导出表");
+          if (typeof tempLink.download === "undefined") {
+            tempLink.setAttribute("target", "_blank");
+          }
+          document.body.appendChild(tempLink);
+          tempLink.click();
+          document.body.removeChild(tempLink);
+        } else {
+          this.$message.error(result.data.message);
+        }
+      })
+    },
     closeShare() {
       this.currItem = "";
       this.isShareSetting = false;

+ 25 - 0
src/views/myHistoryTest/myHistoryTest.scss

@@ -72,6 +72,11 @@
     display: flex;
     flex-direction: column;
     color:rgba(153,160,182,1);
+    .morelist{
+      position: absolute;
+      top: 40px;
+      left: 0px;
+    }
     .tools {
       display: none;
       position:absolute;
@@ -84,7 +89,18 @@
         height: 28px;
         cursor:pointer;
         margin-right: 5px;
+        .more{
+          width: 28px;
+          height: 28px;
+          background: url(../../assets/images/more_nor.png) center no-repeat;
+          background-size: cover;
+        }
+        .more:hover {
+          background: url(../../assets/images/more_sel.png) center no-repeat;
+          background-size: cover;
+        }
       }
+      
       .delete {
         background: url(../../assets/images/delete_nor.png) center no-repeat;
         background-size: cover;
@@ -153,6 +169,15 @@
       justify-content: space-between;
     }
   }
+  .morehover {
+    box-shadow:0px 5px 11px 0px rgba(78,93,255,0.42);
+    .tools {
+      display: block;
+    }
+    .title {
+      color: rgba(78,93,255,1);
+    }
+  }
   .item:hover{
     box-shadow:0px 5px 11px 0px rgba(78,93,255,0.42);
     .tools {