<!--
|
* @Date: 2025-06-18 09:17:09
|
* @LastEditors: gaoshp
|
* @LastEditTime: 2025-07-20 20:29:18
|
* @FilePath: /mdmweb/src/views/tasks/dncreturnfiles.vue
|
-->
|
<template>
|
<basic-container>
|
<avue-crud :option="option" :table-loading="loading" :data="data" v-model:page="page" v-model="form" ref="crud"
|
@search-change="searchChange" @search-reset="searchReset" @current-change="currentChange"
|
@size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad"
|
@selection-change="selectionChange">
|
<template #menu-left>
|
<el-button type="primary" plain @click="exportWebSite">导出回传涉密网</el-button>
|
<el-button type="primary" plain @click="reassign">挂载车床程序库</el-button>
|
<el-button type="primary" plain @click="exportExcel">导出到EXCEL</el-button>
|
</template>
|
<template #menu="scope">
|
<el-button type="primary" text size="default" @click.stop="handleAction(scope.row, scope.index, 1)">接受
|
</el-button>
|
<el-button type="danger" text size="default" @click.stop="handleAction(scope.row, scope.index, 0)">拒绝
|
</el-button>
|
</template>
|
</avue-crud>
|
</basic-container>
|
</template>
|
|
<script>
|
import { getList, reject, accept } from '@/api/tasks/dncreturnfiles.js';
|
import { exportBlob } from '@/api/common';
|
import { getToken } from '@/utils/auth';
|
import NProgress from 'nprogress';
|
import { downloadXls } from '@/utils/util';
|
import 'nprogress/nprogress.css';
|
export default {
|
name: 'MachineReturnFileOp',
|
data() {
|
return {
|
page: {
|
pageSize: 10,
|
currentPage: 1,
|
total: 0,
|
},
|
form: {},
|
query: {},
|
loading: true,
|
data: [],
|
option: {
|
addBtn: false,
|
editBtn: false,
|
delBtn: false,
|
columnBtn: false,
|
tip: false,
|
// simplePage: true,
|
searchShow: true,
|
searchMenuSpan: 6,
|
dialogWidth: '60%',
|
// tree: true,
|
border: true,
|
index: true,
|
selection: true,
|
viewBtn: false,
|
menuWidth: 200,
|
// menu: false,
|
dialogClickModal: false,
|
column: [
|
{
|
label: '确认时间',
|
prop: 'confirmTime',
|
type: 'datetime',
|
format: 'YYYY-MM-DD HH:mm:ss',
|
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
search: true,
|
searchRange: true,
|
searchSpan: 8,
|
hide: true,
|
},
|
|
{
|
label: '程序编号',
|
prop: 'code',
|
},
|
{
|
label: '回传机床',
|
prop: 'machineCode',
|
},
|
|
{
|
label: '文件名称',
|
prop: 'name'
|
},
|
{
|
label: '文件固化状态',
|
prop: 'isCured',
|
formatter: (val, value, label) => {
|
return `${val == 0 ? '未固化' : "已固化"}`;
|
},
|
},
|
{
|
label: '文件到达时间',
|
prop: 'arrivedTime',
|
type: 'datetime',
|
format: 'YYYY-MM-DD HH:mm:ss',
|
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
}
|
],
|
selectedList: [],
|
}
|
}
|
},
|
methods: {
|
handleAction(row, index, flag) {
|
// 处理接受或拒绝操作
|
let ids = [row.id].toString();
|
if (flag) {
|
accept({ ids }).then(() => {
|
this.$message.success(`操作成功: ${row.name}`);
|
this.$refs.crud.toggleSelection();
|
this.onLoad(this.page);
|
}).catch(() => {
|
this.$message.error(`操作失败: ${row.name}`);
|
this.$refs.crud.refreshChange();
|
});
|
} else {
|
this.$confirm('确定拒绝?', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning',
|
})
|
.then(() => {
|
reject({ ids }).then(() => {
|
this.$message.success(`操作成功: ${row.name}`);
|
}).catch(() => {
|
this.$message.error(`操作失败: ${row.name}`);
|
this.$refs.crud.toggleSelection();
|
this.onLoad(this.page);
|
});
|
})
|
|
}
|
},
|
selectionChange(list) {
|
this.selectedList = list;
|
},
|
exportWebSite() {
|
if (this.selectedList.length === 0) {
|
this.$message.warning('请先选择需要导出的数据');
|
return;
|
}
|
this.$confirm('是否导出?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning',
|
}).then(() => {
|
NProgress.start();
|
exportBlob(
|
`/blade-mdm/machineback/filehandle/export-to-inner`,
|
{
|
ids: this.selectedList.map(item => item.id).join(','),
|
}
|
).then(res => {
|
downloadXls(res.data, `导出回传涉密网${this.$dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`);
|
NProgress.done();
|
});
|
});
|
},
|
exportExcel() {
|
if (this.selectedList.length === 0) {
|
this.$message.warning('请先选择需要导出的数据');
|
return;
|
}
|
this.$confirm('是否导出?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning',
|
}).then(() => {
|
NProgress.start();
|
exportBlob(
|
`/blade-mdm/machineback/filehandle/export-excel?${this.website.tokenHeader}=${getToken()}`
|
).then(res => {
|
downloadXls(res.data, `导出机床回传程序${this.$dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`);
|
NProgress.done();
|
});
|
});
|
},
|
searchChange(params, done) {
|
let data = {}
|
this.query = params;
|
this.page.currentPage = 1;
|
console.log('searchChange', params);
|
params.confirmTimeBegin = params?.confirmTime?.[0] || '';
|
params.confirmTimeEnd = params?.confirmTime?.[1] || '';
|
console.log(params);
|
// data = {
|
// createTimeBegin: dayjs(params.createTimeBegin).isValid() ? dayjs(params.createTimeBegin).format('YYYY-MM-DD') : '',
|
// createTimeEnd: dayjs(params.createTimeEnd).isValid() ? dayjs(params.createTimeEnd).format('YYYY-MM-DD') : '',
|
// keyword: params.keyword || ''
|
// }
|
data = {
|
confirmTimeBegin: params.confirmTimeBegin,
|
confirmTimeEnd: params.confirmTimeEnd,
|
}
|
this.query = data
|
this.onLoad(this.page, data);
|
done();
|
},
|
searchReset() {
|
let data = {}
|
this.query = params;
|
this.page.currentPage = 1;
|
data = {
|
createTimeBegin: params.createTimeBegin,
|
createTimeEnd: params.createTimeEnd,
|
keyword: params.keyword || ''
|
}
|
this.onLoad(this.page, data);
|
done();
|
},
|
currentChange(currentPage) {
|
this.page.currentPage = currentPage;
|
// this.onLoad();
|
},
|
sizeChange(pageSize) {
|
this.page.pageSize = pageSize;
|
},
|
refreshChange() {
|
this.onLoad(this.page, this.query);
|
},
|
/** * 页面加载时获取数据
|
*/
|
onLoad(page, params = {}) {
|
console.log('onLoad', page, params);
|
const query = {
|
...this.query,
|
// category: params.category ? flowCategory(params.category) : null,
|
mode: this.mode,
|
};
|
try {
|
delete query.confirmTime; // 删除不必要的查询条件
|
} catch (error) {
|
console.error('日期格式化错误', error);
|
}
|
|
this.loading = true;
|
getList(page.currentPage, page.pageSize, Object.assign(query, params)).then(res => {
|
const data = res.data.data;
|
this.page.total = data.total;
|
this.data = data.records;
|
this.loading = false;
|
}, () => {
|
this.data = [];
|
this.loading = false;
|
}).catch(err => {
|
this.data = [];
|
this.loading = false;
|
});
|
}
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped></style>
|