DetectionTemplatePage.vue 3.5 KB
<template>
    <a-card class="tabs-card" :bordered="false">
        <div
            class="table-operations"
            style="margin-bottom: 16px; width: 100%; float: left"
        >
            <div class="flex justify-end" style="float: left">检测模板管理</div>
        </div>

        <a-table
            :columns="columns"
            :data-source="pagination.content"
            :loading="loading"
            :bordered="false"
            @change="pageRefresh"
            @resizeColumn="this.$filters.tableResizeColumn"
            size="small"
            :pagination="pageState"
            :row-key="(record) => record.id"
            :scroll="{ y: 'calc(100vh - 350px)' }"
        >
            <template #bodyCell="{ column, record }">
                <template v-if="column.key === 'action'">
                    <router-link
                        :to="{
                            path: '/detection/template/preview',
                            query: { id: record.id },
                        }"
                    >
                        <a-button type="link" size="small">预览</a-button>
                    </router-link>
                </template>
            </template>
        </a-table>
    </a-card>
</template>
<script lang="ts">
import { Component } from "vue-facing-decorator";
import { TableColumnsType } from "ant-design-vue";
import { PaginationComponent } from "@/components/PaginationComponent";
import { DetectionController } from "@/api/DetectionController";

interface InspectionTemplate {
    id: number;
    templateName: string;
    templateType: number;
    description: string;
}

@Component({})
export default class DetectionTemplatePage extends PaginationComponent<InspectionTemplate> {
    /**
     * 表格列配置
     */
    columns: TableColumnsType = [
        {
            title: "序号",
            key: "index",
            width: 70,
            align: "center",
            fixed: "left",
            sorter: false,
            customRender: ({ index }) => {
                const pager = this.getPagination();
                return (pager.pageIndex - 1) * pager.pageSize + index + 1;
            },
        },
        {
            title: "模板ID",
            dataIndex: "templateCode",
            key: "templateCode",
            align: "center",
        },
        {
            title: "模板名称",
            dataIndex: "templateName",
            key: "templateName",
            align: "center",
        },
        {
            title: "适配车型",
            dataIndex: "templateType",
            key: "templateType",
            align: "center",
            customRender: ({ text }) => {
                return (
                    {
                        1: "燃油车",
                        2: "新能源车",
                    }[Number(text)] || "-"
                );
            },
        },
        {
            title: "备注说明",
            dataIndex: "description",
            key: "description",
            align: "center",
            width: 370,
            resizable: true,
            ellipsis: true,
        },
        {
            title: "操作",
            key: "action",
            width: 170,
            align: "center",
            fixed: "right",
        },
    ];

    getPagination() {
        return this.pagination;
    }

    /**
     * 初始化配置
     */
    created(): void {
        const url = DetectionController.PAGE_INSPECTOR_REPORT_INSPECTOR;
        this.init(this.axios, url);
        this.pageLoad();
    }
}
</script>