From 5b805a057ebc3fb7dd18fc26ff152f768b5b74e6 Mon Sep 17 00:00:00 2001 From: 懒羊羊 <15939171744@163.com> Date: 星期四, 04 一月 2024 16:19:16 +0800 Subject: [PATCH] 优化 --- jcdm-ui/src/views/main/bs/processFile/index.vue | 73 ++++++++++++++++++++++++++++++++++-- 1 files changed, 69 insertions(+), 4 deletions(-) diff --git a/jcdm-ui/src/views/main/bs/processFile/index.vue b/jcdm-ui/src/views/main/bs/processFile/index.vue index c3f55db..b10a391 100644 --- a/jcdm-ui/src/views/main/bs/processFile/index.vue +++ b/jcdm-ui/src/views/main/bs/processFile/index.vue @@ -97,7 +97,10 @@ </el-table-column> <el-table-column label="鏂囦欢鍚嶇О" align="center" prop="fileName"> </el-table-column> - <el-table-column label="鏂囦欢鍦板潃" align="center" prop="fileAddress"> + <el-table-column :show-overflow-tooltip='true' width="150" label="鏂囦欢鍦板潃" align="center" prop="fileAddress"> + <template slot-scope="scope"> + <a :href="scope.row.fileAddress" target="_blank" style="color: #00afff" class="buttonText">{{scope.row.fileAddress}}</a> + </template> </el-table-column> <el-table-column label="鐘舵��" align="center" prop="status"> <template slot-scope="scope"> @@ -110,7 +113,7 @@ <!-- </el-table-column>--> <el-table-column label="澶囨敞" align="center" prop="remarks"> </el-table-column> - <el-table-column fixed="right" width="200" label="鎿嶄綔" align="center" class-name="small-padding fixed-width"> + <el-table-column fixed="right" width="300" label="鎿嶄綔" align="center" class-name="small-padding fixed-width"> <template slot-scope="scope"> <el-button size="mini" @@ -130,6 +133,14 @@ @click="handleDelete(scope.row)" v-hasPermi="['bs:processFile:remove']" >鍒犻櫎</el-button> + <el-button + size="mini" + plain + type="warning" + style="width: 72px" + icon="el-icon-download" + @click="handleDownload(scope.row)" + >涓嬭浇</el-button> </template> </el-table-column> </el-table> @@ -182,8 +193,23 @@ <el-input v-model="form.fileName" placeholder="璇疯緭鍏ユ枃浠跺悕绉�" /> </el-form-item> <el-form-item label="鏂囦欢鍦板潃" prop="fileAddress"> - <el-input v-model="form.fileAddress" placeholder="璇疯緭鍏ユ枃浠跺湴鍧�" /> +<!-- <el-input v-model="form.fileAddress" placeholder="璇疯緭鍏ユ枃浠跺湴鍧�" />--> + <el-upload + ref="upload" + :limit="1" + accept=".doc, .docx" + :action="upload.url" + :headers="upload.headers" + :file-list="upload.fileList" + :on-progress="handleFileUploadProgress" + :on-success="handleFileSuccess" + :auto-upload="false"> + <el-button slot="trigger" size="small" type="primary">閫夊彇鏂囦欢</el-button> + <el-button style="margin-left: 10px;" size="small" type="success" :loading="upload.isUploading" @click="submitUpload">涓婁紶鍒版湇鍔″櫒</el-button> + <div slot="tip" class="el-upload__tip">鍙兘涓婁紶doc/docx鏂囦欢锛屼笖涓嶈秴杩�10MB</div> + </el-upload> </el-form-item> + <el-form-item label="鐘舵��" prop="status"> <el-radio-group v-model="form.status"> <el-radio @@ -206,6 +232,7 @@ </template> <script> +import { getToken } from "@/utils/auth"; import { listProcessFile, getProcessFile, delProcessFile, addProcessFile, updateProcessFile } from "@/api/main/bs/processFile/processFile"; import {listProductBom} from "@/api/main/bs/ProductBom/ProductBom"; import {listProcesses} from "@/api/main/bs/processes/processes"; @@ -219,6 +246,17 @@ dicts: ['sys_normal_disable'], data() { return { + // 涓婁紶鍙傛暟 + upload: { + // 鏄惁绂佺敤涓婁紶 + isUploading: false, + // 璁剧疆涓婁紶鐨勮姹傚ご閮� + headers: { Authorization: "Bearer " + getToken() }, + // 涓婁紶鐨勫湴鍧� + url: process.env.VUE_APP_BASE_API + "/common/upload", + // 涓婁紶鐨勬枃浠跺垪琛� + fileList: [] + }, // 閬僵灞� loading: true, titleName: "", @@ -293,7 +331,32 @@ this.initProcesses(); }, methods: { - + // 鏂囦欢涓嬭浇澶勭悊 + handleDownload(row) { + console.log(row) + var name = row.fileName; + var url = row.fileAddress; + var suffix = url.substring(url.lastIndexOf("."), url.length); + const a = document.createElement('a') + a.setAttribute('download', name + suffix) + a.setAttribute('target', '_blank') + a.setAttribute('href', url) + a.click() + }, + // 鏂囦欢鎻愪氦澶勭悊 + submitUpload() { + this.$refs.upload.submit(); + }, + // 鏂囦欢涓婁紶涓鐞� + handleFileUploadProgress(event, file, fileList) { + this.upload.isUploading = true; + }, + // 鏂囦欢涓婁紶鎴愬姛澶勭悊 + handleFileSuccess(response, file, fileList) { + this.upload.isUploading = false; + this.form.fileAddress = response.url; + this.msgSuccess(response.msg); + }, handleSelectChangeprocessesCode(selectedOption) { this.processesCodeQueryParams.processesCode = selectedOption; listProcesses(this.queryParams).then(response => { @@ -383,12 +446,14 @@ }, /** 鏂板鎸夐挳鎿嶄綔 */ handleAdd() { + this.upload.fileList = []; this.reset(); this.open = true; this.titleName = "娣诲姞宸ヨ壓鏂囨。"; }, /** 淇敼鎸夐挳鎿嶄綔 */ handleUpdate(row) { + this.upload.fileList = [{ name: this.form.fileName, url: this.form.fileAddress }]; this.reset(); const id = row.id || this.ids getProcessFile(id).then(response => { -- Gitblit v1.9.3