index.vue 1.81 KB
<template>
  <div>
    <BasicTable :clickToRowSelect="false" @register="registerTable">
      <template #toolbar>
        <Authority value="api:yt:product:category:post">
          <Button type="primary" @click="handleCreate">
            {{ t('inspection.servicePlan.createCategoryText') }}
          </Button>
        </Authority>
      </template>
      <template #status="{ record }">
        <Tag
          :color="
            record.status == 'NOTSTART'
              ? 'red'
              : record.status == 'UNDERWAY'
              ? 'blue': record.status == 'COMPLETED'
              ? 'green': 'yellow'
          "
          class="ml-2"
        >
          {{ t(`inspection.servicePlan.${record.status}`) }}
        </Tag>
      </template>
    </BasicTable>
  </div>
</template>
<script setup lang="ts">
  import { BasicTable, useTable } from '/@/components/Table';
  import { getServicePlanList } from '/@/api/inspection/servicePlan';
  import { columns, searchFormSchema } from './index';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { Button, Tag } from 'ant-design-vue';
  const { t } = useI18n();

  const [
    registerTable,
    { reload, setLoading, getSelectRowKeys, setSelectedRowKeys, getRowSelection },
  ] = useTable({
    title: t('inspection.servicePlan.listText'),
    api: getServicePlanList,
    columns,
    formConfig: {
      labelWidth: 100,
      schemas: searchFormSchema,
    },
    immediate: true,
    useSearchForm: true,
    showTableSetting: true,
    bordered: true,
    showIndexColumn: false,
    clickToRowSelect: false,
    rowKey: 'id',
    actionColumn: {
      width: 230,
      title: t('common.actionText'),
      slots: { customRender: 'action' },
      fixed: 'right',
    },
    rowSelection: {
      type: 'checkbox',
      getCheckboxProps: (record: any) => {},
    },
  });
</script>