import { ContentConfig } from "/@/components/PageContent";
import { httpList } from "/@/api/invCategory/invCategory";
import { h } from "vue";
import { ElTag } from "element-plus";
import { statusOptions } from "./_options";

const columns = [
  {
    label: '税收分类编码',
    prop: 'merge_code',
    minWidth: '160px'
  },
  {
    label: '货物和劳务名称',
    prop: 'cat_name',
    minWidth: '200px'
  },
  {
    label: '税目',
    prop: 'short_name',
    minWidth: '200px'
  },
  {
    label: '税率',
    prop: 'supplierName',
    minWidth: '80px',
    cellRenderer({ row }){
      return row.tax.join('、')
    }
  },
  {
    label: '元隆是否能开票',
    prop: 'status',
    width: '110px',
    align: 'center',
    cellRenderer({row}){
      return h(ElTag,{
        type: statusOptions.find(({value}) => String(value) === String(row.status))?.type || 'danger'
      }, {
        default: () => statusOptions.find(({value}) => String(value) === String(row.status))?.label || '--'
      })
    }
  },
  {
    label: '建议开票税目',
    prop: 'cat_desc',
    minWidth: '200px'
  },
  {
    label: '备注',
    prop: 'remark',
    minWidth: '200px'
  },
];



const contentConfig: ContentConfig = {
  title: "元隆可开票类目",
  columns,
  superUserNoAction: true,
  apis: {
    httpList:(params = {} as any) => {
      if(params.status === '3'){
        params.status = ['3']
      }else  if(params.status === '2'){
        params.status = ['2']
      } else {
        params.status = ['2', '3']
      }

      return httpList(params)
    }
  }
};

export default contentConfig;
