<script setup lang="ts">
  import BasicModal from '/@/components/Modal/src/BasicModal.vue';
  import { useModalInner } from '/@/components/Modal';
  import BasicTable from '/@/components/Table/src/BasicTable.vue';
  import { useTable } from '/@/components/Table';
  const id = ref('');
  import { getWfTextbookSubscriptionItemHistoryPage } from '/@/services/apis/WfTextbookSubscriptionItemHistoryController';
  import { h, ref } from 'vue';
  const [registerModal, { closeModal }] = useModalInner((data) => {
    id.value = data;
    reload();
  });
  const [tableRef, { reload }] = useTable({
    api: getWfTextbookSubscriptionItemHistoryPage,
    bordered: true,
    immediate: false,
    columns: [
      {
        title: '变更类型',
        dataIndex: 'alterationType',
        customRender({ text }) {
          return text == 1 ? '变更数量' : '变更教材';
        },
      },
      {
        title: '变更时间',
        dataIndex: 'createDate',
      },
      {
        title: '操作人',
        dataIndex: 'createUserIdCn',
      },
      {
        title: '课程名称',
        dataIndex: 'courseName',
        customRender({ record, text }) {
          if (record.alterationType == 2) {
            return h('span', { style: 'color:red' }, text);
          }
        },
      },
      {
        title: '教材名称',
        dataIndex: 'bookName',
        customRender({ record, text }) {
          if (record.alterationType == 2) {
            return h('span', { style: 'color:red' }, text);
          }
        },
      },
      {
        title: '学生用书征订数量',
        dataIndex: 'studentSubscriptionNumber',
        customRender({ record, text }) {
          if (record.alterationType == 1) {
            return h('span', { style: 'color:red' }, text);
          }
        },
      },
      {
        title: '教师用书征订数量',
        dataIndex: 'teacherSubscriptionNumber',
        customRender({ record, text }) {
          if (record.alterationType == 1) {
            return h('span', { style: 'color:red' }, text);
          }
        },
      },
    ],
    title: '变更记录表',
    resizeHeightOffset: 200,
    beforeFetch: (params) => {
      return {
        ...params,
        wfTextbookSubscriptionId: id.value,
      };
    },
  });
</script>

<template>
  <BasicModal :footer="[]" @register="registerModal" default-fullscreen title="变更记录">
    <BasicTable @register="tableRef" />
  </BasicModal>
</template>

<style scoped lang="less"></style>
