<template>
|
<a-card :bordered="false">
|
<div>
|
<a-table
|
ref="table"
|
size="middle"
|
:scroll="{x:true}"
|
bordered
|
rowKey="id"
|
:columns="columns"
|
:dataSource="dataSource"
|
:pagination="ipagination"
|
:loading="loading"
|
class="j-table-force-nowrap"
|
@change="handleTableChange"
|
>
|
<!-- :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" -->
|
|
<span
|
slot="size"
|
slot-scope="text"
|
class="error"
|
>
|
{{sizeConvert(text)}}
|
</span>
|
|
<span
|
slot="action"
|
slot-scope="text, record"
|
>
|
<Tooltip
|
placement="top"
|
title="预览图片"
|
>
|
<img
|
v-if="record.upload.path && (record.upload.format.toLowerCase()=='jpg'||record.upload.format.toLowerCase()=='bmp'||record.upload.format.toLowerCase()=='png'||record.upload.format.toLowerCase()=='jpeg'||record.upload.format.toLowerCase()=='gif')"
|
width="30"
|
height="14"
|
border="1"
|
draggable="false"
|
preview="1"
|
:preview-text="''"
|
:src="record.upload.src"
|
/>
|
</Tooltip>
|
|
<a
|
v-if="record.upload.path && record.upload.format.toLowerCase()=='pdf'"
|
href="javascript:;"
|
@click="view(record)"
|
>
|
预览
|
</a>
|
<a-divider
|
v-if="record.upload.path && (record.upload.format.toLowerCase()=='jpg'||record.upload.format.toLowerCase()=='bmp'||record.upload.format.toLowerCase()=='png'||record.upload.format.toLowerCase()=='jpeg'||record.upload.format.toLowerCase()=='gif'||record.upload.format.toLowerCase()=='pdf')"
|
type="vertical"
|
/>
|
|
<a
|
href="javascript:;"
|
@click="handleDownload(record)"
|
>下载</a>
|
</span>
|
|
</a-table>
|
</div>
|
<!-- 表单区域 -->
|
<pdf-view ref="pdfview"></pdf-view>
|
</a-card>
|
</template>
|
|
<script>
|
|
import '@/assets/less/TableExpand.less'
|
import { mixinDevice } from '@/utils/mixin'
|
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
import JInput from '@/components/jeecg/JInput'
|
import Tooltip from 'ant-design-vue/es/tooltip'
|
import JEllipsis from "@/components/jeecg/JEllipsis";
|
import { initDictOptions, filterDictText } from '@/components/dict/JDictSelectUtil'
|
import { ajaxGetDictItems } from '@/api/api'
|
import { getAction, requestPut, deleteAction, downFile } from '@/api/manage'
|
import { preview } from 'vue-photo-preview'
|
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
import Vue from 'vue'
|
import PdfView from '@views/common/PdfView'
|
import { getFileAccessHttpUrl } from '@/api/manage';
|
import store from '@/store/'
|
|
export default {
|
name: "EquipmentCalibrationOrderReportList",
|
mixins: [JeecgListMixin, mixinDevice],
|
components: {
|
JInput,
|
Tooltip,
|
JEllipsis,
|
PdfView,
|
preview,
|
},
|
data() {
|
return {
|
description: '检定报告',
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key: 'rowIndex',
|
width: 60,
|
align: "center",
|
customRender: function (t, r, index) {
|
return parseInt(index) + 1;
|
}
|
},
|
{
|
title: '文档编码',
|
align: 'center',
|
dataIndex: 'num'
|
},
|
|
{
|
title: '文档名称',
|
align: 'center',
|
dataIndex: 'name'
|
},
|
{
|
title: '文档类型',
|
align: 'center',
|
dataIndex: 'typeName'
|
},
|
{
|
title: '文档大小',
|
align: 'center',
|
dataIndex: 'size',
|
scopedSlots: { customRender: 'size' },
|
},
|
{
|
title: '判定结果',
|
align: 'center',
|
dataIndex: 'judgmentResultName'
|
},
|
{
|
title: '操作',
|
align: 'center',
|
dataIndex: 'action',
|
scopedSlots: {
|
customRender: 'action'
|
},
|
}
|
],
|
url: {
|
list: "/eam/calibrationOrderReport/getCalibrationOrderReportList",
|
urlDownload: window._CONFIG['staticDomainURL'],
|
download: '/sys/upload/downloadFile',
|
},
|
// partRoute: {},
|
// equipmentSelectionRows: [],
|
calibrationOrderId: '',
|
}
|
},
|
|
watch: {
|
calibrationOrderId() {
|
this.queryParam = {};
|
this.queryParam.calibrationOrderId = this.calibrationOrderId;
|
this.loadData(1);
|
},
|
},
|
// mounted() {
|
// this.$bus.$on('equipmentSelectionRows', (data) => {
|
// this.equipmentSelectionRows = data
|
// })
|
// },
|
methods: {
|
loadData(arg) {
|
if (!this.url.list) {
|
this.$message.error("请设置url.list属性!")
|
return
|
}
|
//加载数据 若传入参数1则加载第一页的内容
|
if (arg === 1) {
|
this.ipagination.current = 1;
|
}
|
var params = this.getQueryParams();//查询条件
|
if (this.equipmentId == '') {
|
params.equipmentId = '-1';
|
}
|
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].upload;
|
r.src = this.getSrc(res.result.records[i].upload);
|
}
|
this.dataSource = res.result.records || res.result;
|
if (res.result.total) {
|
this.ipagination.total = res.result.total;
|
} else {
|
this.ipagination.total = 0;
|
}
|
//update-end---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
|
} else {
|
this.$message.warning(res.message)
|
}
|
}).finally(() => {
|
this.loading = false
|
})
|
},
|
|
//拼装src
|
getSrc(record) {
|
|
if (!record.path) {
|
return '';
|
}
|
//本地:local\Minio:minio\阿里云:alioss
|
if (record.uploadType == 'local') {
|
|
let ssoLoginFlag = Vue.ls.get("ssoLoginFlag");
|
let deployMode = Vue.ls.get("deployMode");
|
|
if (ssoLoginFlag && deployMode == "container") {
|
var baseProject = Vue.ls.get("baseProject");
|
console.log("baseProject==>" + baseProject)
|
|
var hostname = window.location.protocol + "//" + window.location.host;
|
var url = hostname + '/' + baseProject + '/sys/common/static';
|
return getFileAccessHttpUrl(record.path + record.encodeName, url, window._CONFIG['hyperTextTransfer'])
|
} else {
|
//根据发布状态修改https 或 http
|
return getFileAccessHttpUrl(record.path + record.encodeName, this.url.urlDownload, window._CONFIG['hyperTextTransfer'])
|
}
|
|
} else if (record.uploadType == 'alioss') {
|
|
const OSS = require('ali-oss')
|
const client = new OSS({
|
// region以杭州为例(oss-cn-hangzhou),其他region按实际情况填写。
|
region: window._CONFIG['region'],
|
// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录RAM控制台创建RAM账号。
|
accessKeyId: window._CONFIG['accessKeyId'],
|
accessKeySecret: window._CONFIG['accessKeySecret'],
|
bucket: window._CONFIG['bucket'],
|
})
|
// object-key表示从OSS下载文件时需要指定包含文件后缀在内的完整路径,例如abc/efg/123.jpg。
|
return client.signatureUrl(record.path)
|
}
|
},
|
|
|
sizeConvert(limit) {
|
var size = "";
|
if (limit < 0.1 * 1024) {
|
size = parseFloat(limit).toFixed(2) + "B";//小于0.1KB,则转化成B
|
} else if (limit < 0.1 * 1024 * 1024) {
|
size = (parseFloat(limit) / 1024).toFixed(2) + "KB";//小于0.1MB,则转化成KB
|
} else if (limit < 0.1 * 1024 * 1024 * 1024) {
|
size = (parseFloat(limit) / (1024 * 1024)).toFixed(2) + "MB";//小于0.1GB,则转化成MB
|
} else {
|
size = (parseFloat(limit) / (1024 * 1024 * 1024)).toFixed(2) + "GB";//其他转化成GB
|
}
|
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;
|
},
|
|
view(record) {
|
this.$refs.pdfview.showPdf(record.upload.src);
|
},
|
|
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) //释放掉blob对象
|
}
|
}
|
})
|
},
|
|
},
|
|
}
|
</script>
|
|
<style lang="less" scoped>
|
@import '~@assets/less/common.less';
|
/deep/ .frozenRowClass {
|
color: #c9c9c9;
|
}
|
.success {
|
color: green;
|
}
|
.error {
|
color: red;
|
}
|
.fontweight {
|
font-weight: bold;
|
}
|
.ant-card {
|
margin-left: -30px;
|
margin-right: -30px;
|
}
|
</style>
|