<template>
|
<PageWrapper
|
:title="bt('工具保养项目资料',[BILLCODE])"
|
:content="bt('这是工具保养项目详情页面。')"
|
contentBackground
|
@back="goBack"
|
>
|
<template #footer>
|
<a-tabs default-active-key="detail" v-model:activeKey="currentKey" @tabClick="tabClkcallback">
|
<a-tab-pane key="detail" :tab="bt('单据详情')" />
|
</a-tabs>
|
</template>
|
<div>
|
<div v-if="currentKey == 'detail'">
|
<BasicTable @register="detailTable">
|
<template #toolbar>
|
<a-button preIcon="OutR|svg" ghost color="success" @click="aoaToExceldtl"> 导出 </a-button>
|
</template>
|
</BasicTable>
|
</div>
|
</div>
|
<Loading :loading="compState.loading" :tip="compState.tip" />
|
</PageWrapper>
|
</template>
|
|
<script lang="ts" setup>
|
import { aoaToSheetXlsx } from '/@/components/Excel';
|
import { ref,reactive } from 'vue';
|
import { useRoute } from 'vue-router';
|
import { PageWrapper } from '/@/components/Page';
|
import { useTabs } from '/@/hooks/web/useTabs';
|
import { Tabs } from 'ant-design-vue';
|
import { useGo } from '/@/hooks/web/usePage';
|
//详情列表
|
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
import {
|
getDetailListByPage,
|
} from '/@/api/tigerapi/mes/smt/smtmaintain';
|
import { Loading } from '/@/components/Loading';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
import { columns_D, searchFormSchema_D } from './smt_mt_maintain.data';
|
//ATabs: Tabs, ATabPane: Tabs.TabPane
|
import { useI18n } from '/@/hooks/web/useI18n';
|
const compState = reactive({
|
absolute: false,
|
loading: false,
|
tip: '加载中...',
|
});
|
const ATabs = ref(Tabs);
|
const ATabPane = ref(Tabs.TabPane);
|
const route = useRoute();
|
var ITEM_CODE = ref('');
|
const go = useGo();
|
|
const { t: bt } = useI18n('');
|
const { createMessage } = useMessage();
|
//获取JobId
|
const ID = ref(route.params?.ID);
|
const [detailTable, { getForm: DataDtl, getPaginationRef: DataPDtl }] = useTable({
|
title: bt('单据详情列表'),
|
api: getDetailListByPage,
|
columns: columns_D,
|
useSearchForm: true,
|
showTableSetting: true,
|
bordered: true,
|
canResize:true,
|
showIndexColumn: false,
|
formConfig: {
|
labelWidth: 120,
|
schemas: searchFormSchema_D,
|
},
|
actionColumn: {
|
width: 80,
|
title: bt('操作'),
|
dataIndex: 'action',
|
slots: { customRender: 'action' },
|
fixed: 'right', //undefined,
|
},
|
searchInfo: { ID },
|
});
|
|
let arrdtl: any[] = [];
|
function aoaToExceldtl() {
|
const totals = DataPDtl().total
|
if (totals < 30000) {
|
arrdtl = [];
|
compState.loading = true;
|
const col = DataDtl().getFieldsValue()
|
//col.BILLCODE = BILLCODE.value
|
getDetailListByPage(col).then((res) => {
|
res.items.forEach(element => {
|
|
arrdtl.push({
|
'保养记录ID': element.MT_ID,
|
'工具编码': element.TOOL_CODE,
|
'保养项目编码': element.PROJ_CODE,
|
'保养记录值1': element.VALUE01,
|
'保养记录值2': element.VALUE02,
|
'保养记录值3': element.VALUE03,
|
'保养记录值4': element.VALUE04,
|
'保养记录值5': element.VALUE05,
|
'保养记录值6': element.VALUE06,
|
'保养记录值7': element.VALUE07,
|
'保养记录值8': element.VALUE08,
|
'保养记录值9': element.VALUE09,
|
'保养记录值10': element.VALUE10,
|
'保养记录值11': element.VALUE11,
|
'保养记录值12': element.VALUE12,
|
'保养记录值13': element.VALUE13,
|
'保养记录值14': element.VALUE14,
|
'保养记录值15': element.VALUE15,
|
'保养记录值16': element.VALUE16,
|
'保养记录值17': element.VALUE17,
|
'保养记录值18': element.VALUE18,
|
'保养记录值19': element.VALUE19,
|
'保养记录值20': element.VALUE20,
|
'备注': element.REMARK,
|
'创建人': element.CREATE_USER,
|
'创建时间': element.CREATE_TIME,
|
});
|
});
|
const arrHeader = columns_D.map((column) => column.title);
|
const arrData = arrdtl.map((item) => {
|
return Object.keys(item).map((key) => item[key]);
|
});
|
// 保证data顺序与header一致
|
|
if (arrdtl.length < 30000) {
|
aoaToSheetXlsx({
|
data: arrData,
|
header: arrHeader,
|
filename: '调拨单明细.xlsx',
|
});
|
} else {
|
createMessage.error(bt('导出数据不能超过三万条,如需要更多的请联系管理员'));
|
}
|
})
|
}else{
|
createMessage.error(bt('导出数据不能超过三万条,如需要更多的请联系管理员'));
|
}
|
compState.loading=false;
|
}
|
|
|
// 此处可以得到用户ID
|
//const BILLCODE = ref(route.params?.BILLCODE.split(',')[1]);
|
var currentKey = ref('detail');
|
const { setTitle } = useTabs();
|
// TODO
|
// 本页代码仅作演示,实际应当通过userId从接口获得用户的相关资料
|
|
// 设置Tab的标题(不会影响页面标题)
|
setTitle(bt('详情:单据') + ID.value);
|
|
// 页面左侧点击返回链接时的操作
|
function goBack() {
|
// 本例的效果时点击返回始终跳转到账号列表页,实际应用时可返回上一页
|
go('/Maintain');
|
}
|
const tabClkcallback = (val: string) => {
|
if (val == 'detail') {
|
ITEM_CODE.value = '';
|
}
|
};
|
</script>
|