From 585fb0bbd4a7bc7f8f333ecba7c5fecd2ee5cbc2 Mon Sep 17 00:00:00 2001 From: qushaowei <qushaowei@163.com> Date: 星期四, 28 三月 2024 09:46:44 +0800 Subject: [PATCH] Merge branch 'master' of http://117.34.109.166:18448/r/vue_mdc_430 into develop --- src/views/eam/UploadList.vue | 486 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 486 insertions(+), 0 deletions(-) diff --git a/src/views/eam/UploadList.vue b/src/views/eam/UploadList.vue new file mode 100644 index 0000000..3d1da92 --- /dev/null +++ b/src/views/eam/UploadList.vue @@ -0,0 +1,486 @@ +<template> + <a-card + :bordered="false" + title="妯℃澘绠$悊" + > + <!-- 鏌ヨ鍖哄煙 --> + <div class="table-page-search-wrapper"> + <a-form + layout="inline" + @keyup.enter.native="searchQuery" + > + <a-row :gutter="24"> + <a-col + :md="6" + :sm="8" + > + <a-form-item label="鍚嶇О"> + <j-input + placeholder="璇疯緭鍏ュ悕绉版绱�" + v-model="queryParam.name" + ></j-input> + </a-form-item> + </a-col> + </a-row> + </a-form> + </div> + + <!-- 鎿嶄綔鎸夐挳鍖哄煙 --> + <div class="table-operator"> + <a-button + type="primary" + @click="searchQuery" + icon="search" + >鏌ヨ</a-button> + <a-button + @click="searchReset" + icon="reload" + >閲嶇疆</a-button> + <a-button + @click="handleAdd" + type="primary" + icon="upload" + >鏍囧噯妯℃澘涓婁紶</a-button> + <a-dropdown v-if="selectedRowKeys.length > 0"> + <a-menu slot="overlay"> + <a-menu-item + key="1" + @click="batchDel" + > + <a-icon type="delete" />鍒犻櫎 + </a-menu-item> + </a-menu> + <a-button style="margin-left: 8px"> + 鎵归噺鎿嶄綔 + <a-icon type="down" /> + </a-button> + </a-dropdown> + </div> + + <!-- table鍖哄煙-begin --> + <div> + <div + class="ant-alert ant-alert-info" + style="margin-bottom: 16px" + > + <i class="anticon anticon-info-circle ant-alert-icon"></i> 宸查�夋嫨 + <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>椤� + <a + style="margin-left: 24px" + @click="onClearSelected" + >娓呯┖</a> + </div> + + <a-table + ref="table" + size="middle" + bordered + rowKey="id" + :columns="columns" + :dataSource="dataSource" + :pagination="ipagination" + :loading="loading" + :rowSelection="{ + selectedRowKeys: selectedRowKeys, + onChange: onSelectChange, + getCheckboxProps: getCheckboxProps, + }" + @change="handleTableChange" + > + <!--瀛楃涓茶秴闀挎埅鍙栫渷鐣ュ彿鏄剧ず--> + <span + slot="description" + slot-scope="text" + > + <j-ellipsis + :value="text" + :length="20" + /> + </span> + + <span + slot="size" + slot-scope="text" + class="error" + > + {{ sizeConvert(text) }} + </span> + + <span + slot="format" + slot-scope="text" + class="success" + > + <a-icon + v-if="text == 'pdf'" + type="file-pdf" + /> + <a-icon + v-else-if="text == 'xls' || text == 'xlsx'" + type="file-excel" + /> + <a-icon + v-else-if="text == 'doc' || text == 'docx'" + type="file-word" + /> + <a-icon + v-else-if=" + text == 'jpg' || + text == 'bmp' || + text == 'gif' || + text == 'png' || + text == 'jpeg' || + text == 'tiff' || + text == 'psd' || + text == 'raw' || + text == 'tif' || + text == 'pcx' || + text == 'tga' || + text == 'exif' || + text == 'fpx' || + text == 'svg' || + text == 'cdr' || + text == 'pcd' || + text == 'dxf' || + text == 'ufo' || + text == 'eps' + " + type="file-image" + /> + <a-icon + v-else-if="text == 'ppt'" + type="file-ppt" + /> + <a-icon + v-else-if="text == 'text'" + type="file-text" + /> + <a-icon + v-else-if="text == 'zip' || text == 'rar'" + type="file-zip" + /> + <a-icon + v-else + type="file-unknown" + /> + {{ text }} + </span> + + <span + slot="action" + slot-scope="text, record" + > + <Tooltip + placement="top" + title="棰勮鍥剧墖" + > + <img + v-if=" + record.path && (record.format.toLowerCase()=='jpg'||record.format.toLowerCase()=='bmp'||record.format.toLowerCase()=='png'||record.format.toLowerCase()=='jpeg'||record.format.toLowerCase()=='gif') + " + width="30" + height="14" + border="1" + draggable="false" + :preview="record.id" + :preview-text="record.name" + :src="record.src" + /> + </Tooltip> + <!-- :src="'http://127.0.0.1:8090/mes/sys/common/static//2022-03/30/051ce6948b96dc2eed0d66a838eb443e468b1990919a8fafd9f145869f587c38'" --> + + <a + v-if="record.path && record.format.toLowerCase() == 'pdf'" + href="javascript:;" + @click="view(record)" + > + 棰勮 + </a> + + <a-divider + v-if=" + record.path && + (record.format.toLowerCase() == 'jpg' || + record.format.toLowerCase() == 'bmp' || + record.format.toLowerCase() == 'png' || + record.format.toLowerCase() == 'jpeg' || + record.format.toLowerCase() == 'gif' || + record.format.toLowerCase() == 'pdf') + " + type="vertical" + /> + + <a + href="javascript:;" + @click="handleDownload(record)" + >涓嬭浇</a> + + <a-divider type="vertical" /> + <a-popconfirm + title="纭畾鍒犻櫎鍚�?" + @confirm="() => handleDelete(record.id)" + > + <a :disabled="record.uploadRelaCount != 0">鍒犻櫎</a> + </a-popconfirm> + </span> + </a-table> + </div> + <!-- table鍖哄煙-end --> + <pdf-view ref="pdfview"></pdf-view> + <!-- 琛ㄥ崟鍖哄煙 --> + <upload-model + ref="modalForm" + @ok="modalFormOk" + ></upload-model> + </a-card> +</template> + +<script> +import UploadModel from './modules/uploadModel/UploadModel' +import { JeecgListMixin } from '@/mixins/JeecgListMixin' +import JDictSelectTag from '@/components/dict/JDictSelectTag' +import JSearchSelectTag from '@/components/dict/JSearchSelectTag' +import { initDictOptions, filterDictText } from '@/components/dict/JDictSelectUtil' +import { getAction, requestPut, downFile, getFileAccessHttpUrl } from '@/api/manage' +import JInput from '@/components/jeecg/JInput' +import JEllipsis from '@/components/jeecg/JEllipsis' +import Tooltip from 'ant-design-vue/es/tooltip' + +import { preview } from 'vue-photo-preview' +import { ACCESS_TOKEN } from '@/store/mutation-types' +import Vue from 'vue' +import PdfView from '../common/PdfView' //PDF棰勮 + +export default { + name: 'UploadList', + mixins: [JeecgListMixin], + components: { + UploadModel, + JDictSelectTag, + JInput, + JEllipsis, + JSearchSelectTag, + Tooltip, + PdfView, + preview, + }, + data() { + return { + columns: [ + { + title: '#', + dataIndex: '', + key: 'rowIndex', + width: 50, + align: 'center', + customRender: function (t, r, index) { + return parseInt(index) + 1 + }, + }, + { + title: '鍚嶇О', + align: 'center', + dataIndex: 'name', + sorter: true, + }, + { + title: '鏍煎紡', + align: 'center', + dataIndex: 'format', + scopedSlots: { customRender: 'format' }, + sorter: true, + }, + { + title: '澶у皬', + align: 'center', + dataIndex: 'size', + scopedSlots: { customRender: 'size' }, + sorter: true, + }, + { + title: '鎻忚堪', + align: 'center', + dataIndex: 'description', + scopedSlots: { customRender: 'description' }, + sorter: true, + }, + { + title: '涓婁紶浜�', + align: 'center', + dataIndex: 'createBy', + sorter: true, + }, + { + title: '涓婁紶鏃堕棿', + align: 'center', + dataIndex: 'createTime', + sorter: true, + }, + + { + width: 150, + title: '鎿嶄綔', + dataIndex: 'action', + align: 'center', + scopedSlots: { customRender: 'action' }, + }, + ], + url: { + list: '/sys/upload/listByType', + uploadRelaListByUploadId: '/sys/uploadRela/listByUploadId', + delete: '/sys/upload/delete', + deleteBatch: '/sys/upload/deleteBatch', + urlDownload: '/sys/common/static', + download: '/sys/upload/downloadFile', + // download: '/sys/upload/downloadFileByType', + realityUrl: 'sys/upload/realityUrl', + }, + path: '', + } + }, + methods: { + getCheckboxProps(record) { + return { + props: { + disabled: record.uploadRelaCount != 0, + }, + } + }, + view(record) { + // let realPath; + // //鑾峰彇褰撳墠鏂囦欢鐪熷疄璺緞 + // getAction(this.url.realityUrl, { id: record.id }).then((res) => { + // if (res.success) { + // let path = res.message; + // console.log("鑾峰彇鍚庡彴璺緞path---------------->" + path); + // realPath = this.url.urlDownload + '/' + path; + // } + // }).then(() => { + // this.$refs.pdfview.showPdf(realPath); + // }) + // this.$refs.pdfview.showPdf('http://127.0.0.1:8090/mes/sys/common/static//2022-03/30/8bc6d02e2421bf94ff73afedc422cf42b9f8c868c8dbb0689f598e87902ed2fd') + this.$refs.pdfview.showPdf(record.src); + }, + loadData(arg) { + if (arg === 1) { + this.ipagination.current = 1 + } + + var params = this.getQueryParams() //鏌ヨ鏉′欢 + this.loading = true + getAction(this.url.list, params).then((res) => { + if (res.success) { + for (let i = 0; i < res.result.records.length; i++) { + let r = res.result.records[i] + r.src = this.getSrc(res.result.records[i]) + } + this.dataSource = res.result.records + console.log('dataSource', this.dataSource); + this.ipagination.total = res.result.total + } + this.loading = false + }) + }, + //鎷艰src + getSrc(record) { + if (!record.path) { + return '' + } + //鏈湴锛歭ocal\Minio锛歮inio\闃块噷浜戯細alioss + if (record.uploadType == 'local') { + //鏍规嵁鍙戝竷鐘舵�佷慨鏀筯ttps 鎴� http + // return getFileAccessHttpUrl(record.path + record.encodeName, this.url.urlDownload, window._CONFIG['hyperTextTransfer']) + return window._CONFIG['domianURL'] + this.url.urlDownload + "/" + record.path + record.encodeName; + // return window._CONFIG['domianURL'] + this.url.urlDownload + "/" + record.path + record.encodeName; + } else if (record.uploadType == 'alioss') { + const OSS = require('ali-oss') + const client = new OSS({ + // region浠ユ澀宸炰负渚嬶紙oss-cn-hangzhou锛夛紝鍏朵粬region鎸夊疄闄呮儏鍐靛~鍐欍�� + region: window._CONFIG['region'], + // 闃块噷浜戜富璐﹀彿AccessKey鎷ユ湁鎵�鏈堿PI鐨勮闂潈闄愶紝椋庨櫓寰堥珮銆傚己鐑堝缓璁偍鍒涘缓骞朵娇鐢≧AM璐﹀彿杩涜API璁块棶鎴栨棩甯歌繍缁达紝璇风櫥褰昍AM鎺у埗鍙板垱寤篟AM璐﹀彿銆� + accessKeyId: window._CONFIG['accessKeyId'], + accessKeySecret: window._CONFIG['accessKeySecret'], + bucket: window._CONFIG['bucket'], + }) + // object-key琛ㄧず浠嶰SS涓嬭浇鏂囦欢鏃堕渶瑕佹寚瀹氬寘鍚枃浠跺悗缂�鍦ㄥ唴鐨勫畬鏁磋矾寰勶紝渚嬪abc/efg/123.jpg銆� + return client.signatureUrl(record.path) + } + }, + handleDownload(record) { + downFile(this.url.download, { id: record.id }).then((res) => { + if (!res) { + this.$message.warning('鏂囦欢涓嬭浇澶辫触') + return + } else { + let fileName = record.name + if (typeof window.navigator.msSaveBlob !== 'undefined') { + window.navigator.msSaveBlob(new Blob([res]), fileName) + } else { + let url = window.URL.createObjectURL(new Blob([res])) + let link = document.createElement('a') + link.style.display = 'none' + link.href = url + link.setAttribute('download', fileName) + document.body.appendChild(link) + link.click() + document.body.removeChild(link) //涓嬭浇瀹屾垚绉婚櫎鍏冪礌 + window.URL.revokeObjectURL(url) //閲婃斁鎺塨lob瀵硅薄 + } + } + }) + }, + sizeConvert(limit) { + var size = '' + if (limit < 0.1 * 1024) { + size = parseFloat(limit).toFixed(2) + 'B' //灏忎簬0.1KB锛屽垯杞寲鎴怋 + } else if (limit < 0.1 * 1024 * 1024) { + size = (parseFloat(limit) / 1024).toFixed(2) + 'KB' //灏忎簬0.1MB锛屽垯杞寲鎴怟B + } else if (limit < 0.1 * 1024 * 1024 * 1024) { + size = (parseFloat(limit) / (1024 * 1024)).toFixed(2) + 'MB' //灏忎簬0.1GB锛屽垯杞寲鎴怣B + } else { + size = (parseFloat(limit) / (1024 * 1024 * 1024)).toFixed(2) + 'GB' //鍏朵粬杞寲鎴怗B + } + var sizeStr = size + '' //杞垚瀛楃涓� + var index = sizeStr.indexOf('.') //鑾峰彇灏忔暟鐐瑰鐨勭储寮� + var dou = sizeStr.substr(index + 1, 2) //鑾峰彇灏忔暟鐐瑰悗涓や綅鐨勫�� + if (dou == '00') { + //鍒ゆ柇鍚庝袱浣嶆槸鍚︿负00锛屽鏋滄槸鍒欏垹闄�00 + return sizeStr.substring(0, index) + sizeStr.substr(index + 3, 2) + } + return size + }, + handleAdd: function () { + this.$refs.modalForm.add() + this.$refs.modalForm.title = '鏂囦欢涓婁紶' + this.$refs.modalForm.disableSubmit = false + }, + }, + computed: { + importExcelUrl: function () { + console.log('璇锋眰鍦板潃涓猴細锛�', `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`) + return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}` + }, + }, + mounted() { + this.$previewRefresh() + this.$preview.on('close', () => { + this.isShow = false + }) + }, +} +</script> +<style> +@import '~@assets/less/common.less'; +.frozenRowClass { + color: #c9c9c9; +} +.success { + color: green; +} +.error { + color: red; +} +.fontweight { + font-weight: bold; +} +</style> \ No newline at end of file -- Gitblit v1.9.3