<template>
  <ns-view-list-table v-bind="tableConfig" :model="data" ref="mainRef" />
</template>

<script  lang="ts" setup>
  import { ref } from 'vue';
  import { http } from '/nerv-lib/util/http';
  import { carbonEmissionFactorLibrary } from '/@/api/carbonEmissionFactorLibrary';
  defineOptions({ name: 'CarbonInventoryCheck' });
  const orgId = ref('');
  const result = JSON.parse(sessionStorage.getItem('ORGID')!);
  orgId.value = result;
  const fetch = (api, params = { orgId }) => {
    return http.post(api, params);
  };
  const tableConfig = ref({
    title: '数据库',
    api: carbonEmissionFactorLibrary.getTableList,
    params: {
      orgId
    },
    headerActions: [
      {
        label: '新增',
        name: 'userAdd',
        type: 'primary',
        handle: () => {
        },
      },
    ],
    columns: [
      {
        title: '序号',
        customRender: (text: any) => {
          return text.index + 1;
        },
      },
      {
        title: '企业名称',
        dataIndex: 'emissionSources',
      },
      {
        title: '报告名称',
        dataIndex: 'emissionTypeColumn',
      },
      {
        title: '报告年度',
        dataIndex: 'emissionGas',
      },
      {
        title: '适用标准',
        dataIndex: 'emissionProcess',
      },
      {
        title: '更新人',
        dataIndex: 'emissionFactors',
      },
      {
        title: '更新时间',
        dataIndex: 'emissionFactorUnits',
      },
    ],
    columnActions: {
      title: '操作',
      actions: [
        {
          label: '编辑',
          name: 'userEdit',
          handle: (record: any) => {
          },
        },
        {
          label: '填报',
          name: 'fillIn',
          handle: (record: any) => {
          },
        },
        {
          label: '下载',
          name: 'download',
          handle: (record: any) => {
          },
        },
        {
          label: '删除',
          name: 'userDelete',
          dynamicParams: { ids: 'id[]' },
          confirm: true,
          isReload: true,
          api: carbonEmissionFactorLibrary.del,
        },
      ],
    },

    formConfig: {
      schemas: [
        {
          field: 'emissionSources',
          label: '报告名称',
          component: 'NsInput',
          componentProps: {
            placeholder: '请输入报告名称',
            maxLength: 30,
          },
        },
      ],
      params: {},
    },
    rowKey: 'id',
  });
</script>

<style lang="less" scoped>

</style>