123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <!-- 供应商附件管理 -->
- <script>
- import { referFile, download } from "@/api/purchase/supAtttachment";
- import useColumns from "./columns";
- export default {
- name: "SupAtttachment",
- components: {
- ElSuperUxTable: () => import("@/components/super-ux-table/index.vue"),
- },
- data() {
- const page = this.$init.page();
- const { TableColumns } = useColumns();
- return {
- page,
- size: "mini",
- TableColumns,
- loading: false,
- tableData: [],
- };
- },
- methods: {
- async getList(params) {
- try {
- this.loading = true;
- let { code, msg, rows, total } = await referFile(params);
- if (code == 200) {
- this.tableData = rows;
- this.page.total = total;
- }
- } catch (error) {
- console.log(error);
- } finally {
- this.loading = false;
- }
- },
- // 下载
- async useDownload(row) {
- try {
- this.$modal.loading("请稍候...");
- let formData = new FormData();
- formData.append("url", row.url);
- await download(formData).then((res) => {
- var blob = new Blob([res], {
- type: "image/jpeg",
- });
- const link = document.createElement("a");
- link.href = URL.createObjectURL(blob);
- link.download = row.name; // 这里填保存成的文件名
- link.click();
- URL.revokeObjectURL(link.href);
- });
- } catch (error) {
- } finally {
- this.$modal.closeLoading();
- }
- },
- useDbclick(row) {
- window.open(row.url);
- },
- },
- async created() {
- let { code } = this.$route.query;
- await this.getList({ ...this.page, code });
- },
- };
- </script>
- <template>
- <el-card
- v-loading="loading"
- :body-style="{
- height: '100%',
- padding: 0,
- display: 'flex',
- 'flex-direction': 'column',
- }"
- >
- <el-super-ux-table
- v-model="tableData"
- :size="size"
- :page="page"
- :columns="TableColumns"
- index
- pagination
- storage-key="SupAtttachmentSuperTable"
- @row-dblclick="useDbclick"
- @pagination="getList(page)"
- >
- <ux-table-column fixed="right" title="操作" align="center" width="100">
- <template slot-scope="scope">
- <el-button type="text" @click="useDownload(scope.row)" :size="size"
- >下载</el-button
- >
- </template>
- </ux-table-column>
- </el-super-ux-table>
- </el-card>
- </template>
- <style scoped lang="scss">
- .el-card {
- width: calc(100% - 32px);
- height: calc(100vh - 32px);
- margin: 16px;
- padding: 16px;
- border-radius: 8px;
- }
- .el-button-group + .el-button-group {
- margin: 0 0 0 8px;
- }
- </style>
|