<script setup lang="tsx">
import { NButton, NPopconfirm, NTag } from "naive-ui";
import {
fetchGetChangeLedgerList,fetchBatchDeleteChange,fetchDeleteChange,getDeptOptions,clearDeptCache
} from "@/service/api";
import { $t } from "@/locales";
import { useAppStore } from "@/store/modules/app";
import { useTable, useTableOperate } from "@/hooks/common/table";
import { useAuth } from "@/hooks/business/auth";
import LedgerOperateDrawer from "./modules/ledger-operate-drawer.vue";
import LedgerSearch from "./modules/ledger-search.vue";
import LedgerUploadDrawer from "./modules/ledger-upload-drawer.vue";
import { useBoolean } from "@sa/hooks";
import { canUpgradeRecord } from "@/constants/business";
import { ref, onMounted } from "vue";
import {useDepartment} from "@/hooks/common/useDepartment"
import { exportXlsx, SheetData } from "@/utils/export-excel";
// 使用封装的部门功能
const {
deptLoading,
deptOptions,
} = useDepartment();
const appStore = useAppStore();
const {
columns,
columnChecks,
data,
getData,
loading,
mobilePagination,
searchParams,
resetSearchParams,
} = useTable({
apiFn: fetchGetChangeLedgerList,
showTotal: true,
apiParams: {
current: 1,
size: 10,
// if you want to use the searchParams in Form, you need to define the following properties, and the value is null
// the value can not be undefined, otherwise the property in Form will not be reactive
source: null,
pecoName: null,
peco: null,
softwareChange: null,
projectno: null,
dept: null,
canUpgrade: null,
softResponsiblePerson: null,
elecResponsiblePerson: null,
changeResponsiblePerson: null,
customerDemandTime: null,
softCompletionTime:null,
hardCompletionTime: null,
fmtCustomerDemandTime:null,
fmtSoftCompletionTime:null,
fmtHardCompletionTime: null,
},
columns: () => [
{
type: "selection",
align: "center",
width: 48,
},
{
key: "index",
title: $t("common.index"),
align: "center",
width: 64,
},
{
key: "hwswcoId",
title: $t("page.change.ledger.hwswcoId"),
align: "center",
minWidth: 50,
},
{
key: "source",
title: $t("page.change.ledger.source"),
align: "center",
width: 50,
},
{
key: "pecoName",
title: $t("page.change.ledger.pecoName"),
align: "center",
minWidth: 50,
},
{
key: "peco",
title: $t("page.change.ledger.peco"),
align: "center",
minWidth: 50,
},
{
key: "softwareChange",
title: $t("page.change.ledger.softwareChange"),
align: "center",
minWidth: 150,
},
{
key: "projectno",
title: $t("page.change.ledger.projectno"),
align: "center",
minWidth: 50,
},
{
key: "dept",
title: $t("page.change.ledger.dept"),
align: "center",
width: 130,
render: (row) => {
// 使用部门选项映射部门名称
if (row.dept && deptOptions.value.length > 0) {
const dept = deptOptions.value.find(option => option.value === row.dept);
if (dept) {
return <NTag type="info">{dept.label}</NTag>;
}
}
return null;
},
},
{
key: "softResponsiblePersonName",
title: $t("page.change.ledger.softResponsiblePersonName"),
align: "center",
minWidth: 50,
},
{
key: "elecResponsiblePersonName",
title: $t("page.change.ledger.elecResponsiblePersonName"),
align: "center",
minWidth: 50,
},
// {
// key: "changeResponsiblePerson",
// title: $t("page.change.ledger.changeResponsiblePerson"),
// align: "center",
// minWidth: 50,
// },
{
key: "canUpgrade",
title: $t("page.change.ledger.canUpgrade"),
align: "center",
minWidth: 50,
render: (row) => {
if (row.canUpgrade) {
console.log( row.canUpgrade, canUpgradeRecord[
row.canUpgrade as Api.Change.canUpgrade
])
const label = $t(
canUpgradeRecord[
row.canUpgrade as Api.Change.canUpgrade
]
);
return <NTag type="default">{label}</NTag>;
}
return null;
},
},
{
key: "fmtCustomerDemandTime",
title: $t("page.change.ledger.customerDemandTime"),
align: "center",
minWidth: 50,
},
{
key: "fmtSoftCompletionTime",
title: $t("page.change.ledger.softCompletionTime"),
align: "center",
minWidth: 50,
},
{
key: "fmtHardCompletionTime",
title: $t("page.change.ledger.hardCompletionTime"),
align: "center",
minWidth: 50,
},
// {
// key: "fmtPlanCompletionTime",
// title: $t("page.change.ledger.planCompletionTime"),
// align: "center",
// minWidth: 50,
// },
{
key: "operate",
title: $t("common.operate"),
align: "center",
width: 130,
render: (row) => (
<div class="flex-center gap-8px">
{hasAuth("B_ChangeLedger_Upgrade") ? (
<NButton
type="primary"
ghost
size="small"
onClick={() => window.open (`http://192.168.100.63/pro/hwswco-upgrade-${row.hwswcoId}.html`,"_blank")}
>
{$t("common.upgrade")}
</NButton>
) : null}
{hasAuth("B_ChangeLedger_Assign") ? (
<NButton
type="primary"
ghost
size="small"
onClick={() => window.open(`http://192.168.100.63/pro/hwswco-view-${row.hwswcoId}.html`,"_blank")}
>
{$t("common.assign")}
</NButton>
) : null}
</div>
),
},
],
});onClick跳转的地址内嵌到前端