You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

203 lines
5.6 KiB

<template>
<div class="customer-css">
<el-table
:height="searchData.height"
:data="fileList"
border
v-loading="dataListLoading"
style="width: 100%;">
<el-table-column
fixed="right"
header-align="center"
align="center"
width="120"
:label="'Actions'">
<template slot-scope="scope">
<a class="customer-a" @click="handleDownload(scope.row)">View </a>
<!-- <a class="customer-a" @click="deleteFile(scope.row)"> Delete</a>-->
</template>
</el-table-column>
<el-table-column
v-for="(item,index) in attachmentColumnArray" :key="index"
:sortable="item.columnSortable"
:prop="item.columnProp"
:header-align="item.headerAlign"
:show-overflow-tooltip="item.showOverflowTooltip"
:align="item.align"
:fixed="item.fixed==''?false:item.fixed"
:min-width="item.columnWidth"
:label="item.columnLabel">
<template slot-scope="scope">
<span v-if="item.columnProp === 'createDate'">{{ formatDateTime(scope.row.createDate) }}</span>
<span v-else-if="item.columnProp === 'orderRef3'">
<span v-if="scope.row.orderRef3 === '0'">Task</span>
<span v-else>{{ scope.row.orderRef3 }}</span>
</span>
<span v-else-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
import { queryTaskFiles, previewOssFileById, removeOss } from '@/api/oss/oss.js'
export default {
data() {
return {
searchData: {
site: '',
buNo: '',
taskNo: '',
height: 200
},
fileList: [],
dataListLoading: false,
attachmentColumnArray: [
{
columnProp: "orderRef3",
headerAlign: "center",
align: "center",
columnLabel: "ItemNo",
columnWidth: '80',
columnHidden: false,
columnSortable: false,
fixed: false,
showOverflowTooltip: false
},
{
columnProp: "fileName",
headerAlign: "center",
align: "left",
columnLabel: "Filename",
columnWidth: '200',
columnHidden: false,
columnSortable: false,
fixed: false,
showOverflowTooltip: true
},
{
columnProp: "createdBy",
headerAlign: "center",
align: "center",
columnLabel: "CreatedBy",
columnWidth: '100',
columnHidden: false,
columnSortable: false,
fixed: false,
showOverflowTooltip: false
},
{
columnProp: "createDate",
headerAlign: "center",
align: "center",
columnLabel: "CreateDate",
columnWidth: '160',
columnHidden: false,
columnSortable: false,
fixed: false,
showOverflowTooltip: false
}
]
}
},
methods: {
init(data) {
this.searchData = Object.assign({}, this.searchData, data);
this.getFileList();
},
getFileList() {
if (!this.searchData.taskNo) return;
this.dataListLoading = true;
// 查询任务相关的所有文件
const queryData = {
orderRef1: this.searchData.site,
orderRef2: this.searchData.taskNo
};
queryTaskFiles(queryData).then(({data}) => {
if (data && data.code === 0) {
this.fileList = data.data || [];
} else {
this.$message.error('查询失败:' + (data ? data.msg : '网络错误'));
this.fileList = [];
}
this.dataListLoading = false;
}).catch((error) => {
this.$message.error('查询失败:' + error.message);
this.fileList = [];
this.dataListLoading = false;
});
},
handleDownload(row) {
let selectList = [];
selectList.push(row);
for (let i = 0; i < selectList.length; i++) {
let params = {
id: selectList[i].id,
}
previewOssFileById(params).then((response) => {
const blob = new Blob([response.data], { type: response.headers['content-type'] });
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.setAttribute('download', selectList[i].fileName);
link.target = '_blank';
link.click();
URL.revokeObjectURL(link.href);
});
}
},
deleteFile(row) {
this.$confirm('确定要删除该文件吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
removeOss([row.id]).then(({data}) => {
if (data && data.code === 0) {
this.$message.success('删除成功');
this.getFileList(); // 重新加载文件列表
} else {
this.$message.warning(data.msg);
}
}).catch((error) => {
this.$message.error('删除失败:' + error.message);
});
});
},
formatDateTime(dateTime) {
if (!dateTime) return '';
// 处理日期时间格式化
if (typeof dateTime === 'string') {
return dateTime.replace('T', ' ').substring(0, 19);
}
return dateTime;
}
}
}
</script>
<style scoped lang="scss">
.customer-bun-min {
min-width: 80px;
}
.customer-a {
color: #409EFF;
cursor: pointer;
text-decoration: none;
}
.customer-a:hover {
color: #66b1ff;
}
.rq .auto /deep/ .el-form-item__content {
height: auto;
line-height: 1.5;
}
</style>