botabs.vue 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div class="app-container">
  3. <el-table v-loading="loading" :data="filetemplateList" @selection-change="handleSelectionChange">
  4. <el-table-column type="index" label="序号" width="55" align="center"/>
  5. <el-table-column label="模板名称" align="center" prop="name" />
  6. <el-table-column label="上传者" align="center" prop="createByName" />
  7. <el-table-column label="上传时间" align="center" prop="createTime" />
  8. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  9. <template slot-scope="scope">
  10. <el-button
  11. type="success"
  12. plain
  13. icon="el-icon-download"
  14. size="small"
  15. @click="downloadAccessory(scope.row)"
  16. >下载</el-button>
  17. </template>
  18. </el-table-column>
  19. </el-table>
  20. <pagination
  21. v-show="total>0"
  22. :total="total"
  23. :page.sync="queryParams.pageNum"
  24. :limit.sync="queryParams.pageSize"
  25. @pagination="getList"
  26. />
  27. </div>
  28. </template>
  29. <script>
  30. import { listFiletemplate } from "@/api/business/spd/bo/filetemplate";
  31. import axios from "axios";
  32. export default {
  33. name: "Filetemplate",
  34. props:["botype"],
  35. data() {
  36. return {
  37. // 遮罩层
  38. loading: true,
  39. // 总条数
  40. total: 0,
  41. // 文件模板表格数据
  42. filetemplateList: [],
  43. // 查询参数
  44. queryParams: {
  45. pageNum: 1,
  46. pageSize: 10,
  47. boType: null,
  48. url: null,
  49. name: null,
  50. },
  51. };
  52. },
  53. created() {
  54. this.queryParams.boType = this.botype;
  55. this.getList();
  56. },
  57. methods: {
  58. /** 查询文件模板列表 */
  59. getList() {
  60. this.loading = true;
  61. listFiletemplate(this.queryParams).then(response => {
  62. this.filetemplateList = response.rows;
  63. this.total = response.total;
  64. this.loading = false;
  65. });
  66. },
  67. //下载附件
  68. downloadAccessory(row) {
  69. console.log('row',row);
  70. var resUrl = "https://sy.derom.com/document-center/fastdfs/download?id=" + row.url;
  71. axios
  72. .create({
  73. timeout: 3000,
  74. responseType: "blob", // 响应类型, 将响应数据转换为二进制数据
  75. headers: {},
  76. })
  77. .get(resUrl)
  78. .then((res) => {
  79. console.log(res);
  80. // 地址转换
  81. let url = window.URL.createObjectURL(res.data);
  82. const a = document.createElement("a");
  83. a.setAttribute("href", url);
  84. a.setAttribute("download", row.name);
  85. document.body.append(a);
  86. a.click();
  87. document.body.removeChild(a);
  88. });
  89. },
  90. }
  91. };
  92. </script>