Blame view

src/views/zd/fjcl/fjcl.vue 6.29 KB
1 2 3 4 5
<template>
    <div class="main">
        <el-upload
                class="upload-demo"
                action="/api/file/uploadList"
6
                :data="fileData"
7 8 9 10 11
                :on-preview="handlePreview"
                :on-remove="handleRemove"
                :before-remove="beforeRemove"
                :on-success="uploadSuccess"
                :on-error="uploadError"
12
                :show-file-list="false"
13 14 15 16 17 18 19
                multiple
                :on-exceed="handleExceed"
        >
            <el-button size="small" type="primary">上传</el-button>
        </el-upload>
        <table border="2">
            <tr>
20 21 22 23
                <th class="xh">序号</th>
                <th class="mc">文件名称</th>
                <th class="lx">文件类型</th>
                <th class="cz">操作</th>
24
            </tr>
25 26 27 28 29 30 31 32 33 34 35
            <tr v-if="list.length==0">
                <td colspan="4" class="noData" >
                    <span>暂无数据</span>
                </td>
            </tr>
            <tr v-else v-for="(item,index) in list"  :key="index" >
                <td class="xh">{{index+1}}</td>
                <td class="mc">{{item.filename}}</td>
                <td class="lx">{{item.filepostfix}}</td>
                <td class="cz">
                    <span @click="downloadFile(item.fileurl)">下载</span>
36
                    <span>/</span>
weimo934 committed
37
                    <span @click="loadFile(item.bsm)">预览</span>
38 39
                    <span>/</span>
                    <span @click="deleteFile(item.bsm)">删除</span>
40 41 42 43 44 45 46
                </td>
            </tr>
        </table>
    </div>
</template>

<script>
杨威 committed
47
    import {insertFile, getFileLis, downloadFile,loadFile,deleteFile} from "@api/common"
48
    import {Message} from "element-ui"
49

50 51 52 53
    export default {
        name: "fjcl",
        data() {
            return {
54 55 56 57
                fileData:{
                    glbsm:'',
                    dylx:''
                },
58 59
                list: [
                ],
60
         /*       filesData: {
61 62 63 64 65 66
                    dylx: "",
                    glbsm: "",
                    list: [
                        {
                            filename: "",
                            filepostfix: "",
weimo934 committed
67 68
                            fileurl: "",
                            preViewUrl:""
69 70
                        }
                    ]
71
                },*/
72 73
            }
        },
74
        mounted() {
75
            this.getFileList()
76 77
        },
        methods: {
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
            deleteFile(bsm){
                this.$confirm('将删除该文件, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    deleteFile(bsm).then(res=>{
                        if (res.success) {
                            this.getFileList();
                        }else {
                            this.$message.error("删除失败")
                        }
                    })
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消'
                    });
                });
            },
weimo934 committed
98 99
            loadFile(bsm){
                loadFile(bsm).then(res=>{
100 101 102 103 104
                    if (res.success) {
                        window.open(res.message)
                    }
                })
            },
105 106 107
            downloadFile(url) {
                window.open(`/api/file/download?url=`+url);
            },
108 109 110
            getFileList() {
                switch (this.$route.name) {
                    case "宗地":
111 112
                        this.fileData.dylx = 'zd';
                        this.fileData.glbsm = this.$store.state.zdbsm
113 114
                        break;
                    case "自然幢":
115 116
                        this.fileData.dylx = 'zrz';
                        this.fileData.glbsm = this.$store.state.zrzbsm
117
                        break
118
                    case "多幢":
119 120
                        this.fileData.dylx = 'dz';
                        this.fileData.glbsm = this.$store.state.dzbsm
121 122
                        break
                    case "户":
123 124
                        this.fileData.dylx = 'h';
                        this.fileData.glbsm = this.$store.state.hbsm
125
                        break;
126 127 128
                    default:
                        break
                }
129
                getFileLis(this.fileData.glbsm ).then(res => {
130 131 132 133 134 135 136 137 138
                    if (res.success) {
                        this.list = res.result;
                    } else {

                    }
                })
            },
            uploadError(err, file, fileList) {
                console.log("上传文件失败", err)
139 140
            },
            uploadSuccess(res, file, fileList) {
141
                this.getFileList();
142 143 144 145 146 147 148 149 150
            },
            handleRemove(file, fileList) {
                console.log(file, fileList);
            },
            handlePreview(file) {
                console.log(file);
            },
            handleExceed(files, fileList) {
                console.log(fileList)
151 152
               // this.$message.warning(`当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
                this.$message.warning("上传失败")
153 154 155 156 157
            },
            beforeRemove(file, fileList) {
                return this.$confirm(`确定移除 ${ file.name }?`);
            }
        },
158
        watch: {}
159 160 161 162 163 164 165 166
    }
</script>

<style scoped lang="less">
    .main {
        box-sizing: border-box;
        padding: 18px;
        height: auto;
167
        width: 100%;
168 169 170 171
    }

    table {
        margin-top: 10px;
172
        cursor: pointer;
173 174 175 176 177 178 179 180
        background-color: #fff;
        font-size: 14px;
        width: 100%;
        td, th {
            text-align: center;
            height: 36px;
            min-width: 50px;
        }
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
        td span {
            color: blue;
        }
        .cz span:hover {
            color: blue;
            text-decoration: underline;
        }
        .xh{
            width: 100px;
        }
        .mc{
            width: 300px;
        }
        .lx{
            width: 120px;
        }
        .cz{
            width: 150px;
        }
        .noData span{
            color: #BBB;
        }
203 204 205 206
    }


</style>