<script lang="ts" setup>
/**
 * 同步中药 ERP 日志
 */
import { Page, useVbenModal } from '@vben/common-ui';

import { Tag } from 'ant-design-vue';

import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { TableAction } from '#/components/table-action';

import DetailModal from './components/detail-modal.vue';
import { formOptions } from './config/search';
import { gridOptions } from './config/table';

defineOptions({ name: 'SyncChinaOrderLog' });

const [Grid] = useVbenVxeGrid({ formOptions, gridOptions });
const [DetailModalComp, detailModalApi] = useVbenModal({
  connectedComponent: DetailModal,
});

function openDetail(row: any) {
  detailModalApi.setData({ id: Number(row?.id || 0), values: row });
  detailModalApi.open();
}
</script>

<template>
  <Page auto-content-height title="同步中药 ERP 日志">
    <DetailModalComp />
    <Grid>
      <template #is_success="{ row }">
        <Tag :color="Number(row.is_success) === 0 ? 'success' : 'error'">
          {{ row.is_success_txt }}
        </Tag>
      </template>
      <template #action="{ row }">
        <TableAction
          :actions="[
            { label: '详情', type: 'link', size: 'small', onClick: () => openDetail(row) },
          ]"
        />
      </template>
    </Grid>
  </Page>
</template>
