import { ContentConfig } from "/@/components/PageContent";
import { httpList } from "/@/api/invoiceInOut/summary";
import { renderIconLabelLeftValue } from "/@/utils/columnRenderHelper";
import { h } from "vue";
import { ElTag } from "element-plus";
import { statusOptions } from "./columns";

const columns = [
  {
    label: "封帐编号",
    prop: "fzCode",
    minWidth: 150
  },
  {
    label: "记帐月份",
    prop: "fz_date",
    minWidth: 70
  },
  {
    label: "业务公司名称",
    minWidth: 160,
    ...renderIconLabelLeftValue(
      row => row.company_code,
      row => row.company_name,
      '业务公司纳税号:'
    )
  },
  {
    label: "状态",
    width: 100,
    cellRenderer({ row }){
      return h(ElTag, { type: statusOptions.find(item => item.value == row.status)?.type || '--', size: 'small' }, {
        default: () => statusOptions.find(item => item.value == row.status)?.label || '--'
      })
    }
  },
  {
    label: "备注",
    width: 150,
    prop: 'remark'
  },
  {
    label: "封装操作人",
    prop: "apply_name",
    minWidth: 100
  },

  {
    label: "封装时间",
    prop: "create_time",
    minWidth: 120
  },

  {
    label: "操作",
    fixed: "right",
    slot: "operation",
    width: 160
  }
];

const contentConfig: ContentConfig = {
  columns,
  title: "商品管理",
  permissions: ["007"],
  companyProp: 'company_code',
  apis: {
    httpList: (parameter = {}) => {
      let { fz_date, ...other } = parameter
    
      if(Array.isArray(fz_date) && fz_date.length === 0){
        fz_date = ''
      }

      return httpList({ fz_date, ...other })
    },
    httpAdd: true
  }
};

export default contentConfig;
