12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <template>
- <div class="app-container">
- <el-table v-loading="loading" :data="filetemplateList" @selection-change="handleSelectionChange">
- <el-table-column type="index" label="序号" width="55" align="center"/>
- <el-table-column label="模板名称" align="center" prop="name" />
- <el-table-column label="上传者" align="center" prop="createByName" />
- <el-table-column label="上传时间" align="center" prop="createTime" />
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
- <template slot-scope="scope">
- <el-button
- type="success"
- plain
- icon="el-icon-download"
- size="small"
- @click="downloadAccessory(scope.row)"
- >下载</el-button>
- </template>
- </el-table-column>
- </el-table>
- <pagination
- v-show="total>0"
- :total="total"
- :page.sync="queryParams.pageNum"
- :limit.sync="queryParams.pageSize"
- @pagination="getList"
- />
- </div>
- </template>
- <script>
- import { listFiletemplate } from "@/api/business/spd/bo/filetemplate";
- import axios from "axios";
- export default {
- name: "Filetemplate",
- props:["botype"],
- data() {
- return {
- // 遮罩层
- loading: true,
- // 总条数
- total: 0,
- // 文件模板表格数据
- filetemplateList: [],
- // 查询参数
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- boType: null,
- url: null,
- name: null,
- },
- };
- },
- created() {
- this.queryParams.boType = this.botype;
- this.getList();
- },
- methods: {
- /** 查询文件模板列表 */
- getList() {
- this.loading = true;
- listFiletemplate(this.queryParams).then(response => {
- this.filetemplateList = response.rows;
- this.total = response.total;
- this.loading = false;
- });
- },
- //下载附件
- downloadAccessory(row) {
- console.log('row',row);
- var resUrl = "https://sy.derom.com/document-center/fastdfs/download?id=" + row.url;
- axios
- .create({
- timeout: 3000,
- responseType: "blob", // 响应类型, 将响应数据转换为二进制数据
- headers: {},
- })
- .get(resUrl)
- .then((res) => {
- console.log(res);
- // 地址转换
- let url = window.URL.createObjectURL(res.data);
- const a = document.createElement("a");
- a.setAttribute("href", url);
- a.setAttribute("download", row.name);
- document.body.append(a);
- a.click();
- document.body.removeChild(a);
- });
- },
- }
- };
- </script>
|