import { ContentConfig } from "/@/components/PageContent";
import { httpJTList } from "/@/api/invoiceInOut/provisionOut";
import { renderIconLabelLeft } from "/@/utils/columnRenderHelper";
import { statusOptions } from "./shared"
import { ElTag } from "element-plus";
import { h } from "vue";

const columns = [
  { label: "发票明细ID",  prop: "manager__inv_item_id",  width: 90  },
  { label: '业务编号', minWidth: 150, prop: 'manager__invoiceCode' },
  { label: '购买方公司', width: 150, ...renderIconLabelLeft('manager__buyer_code', 'manager__buyer_name', '购买方公司纳税号:')  },
  { label: '销售方公司', prop: 'seller_code', width: 150, ...renderIconLabelLeft('manager__seller_code', 'manager__seller_name', '销售方公司纳税号:') },
  { 
    label: '商品名称',  
    prop: 'goodName',   
    minWidth: 140,
    ...renderIconLabelLeft('manager__goodNo', 'manager__goodName', '商品编号:')
  },
  
  { 
    label: '商品数量', 
    prop: 'num', 
    width: 100 
  },
  
  { 
    label: '税前单价', 
    prop: 'manager__inv_subprice', 
    width: 120 
  },

  { 
    label: '税后单价', 
    prop: 'manager__inv_price', 
    width: 120 
  },
  { label: '发票购买方公司', width: 150, ...renderIconLabelLeft('manager__inv_buyer_code', 'manager__inv_buyer_name', '购买方公司纳税号:') },
  { label: '发票销售方公司', prop: 'seller_code', width: 150, ...renderIconLabelLeft('manager__inv_seller_code', 'manager__inv_seller_name', '销售方公司纳税号:') },
  { 
    label: "状态", 
    width: 80,
    cellRenderer({ row }){ 
      return h(ElTag, { size: 'small', type: statusOptions.find(item => row.status == item.value)?.type }, {
        default: () => statusOptions.find(item => row.status == item.value)?.label
      }) 
    }
  },
  
  { 
    label: "创建人", 
    prop: "apply_name", 
    width: 120 
  },
  
  { 
    label: "创建时间", 
    prop: "create_time", 
    width: 120 
  },
  
  { 
    label: "操作", 
    fixed: "right", 
    slot: "operation",
    width: 45
  }
];

const contentConfig: ContentConfig = {
  columns,
  title: "商品管理",
  permissions: ['007'],
  companyProp: 'seller_code',
  apis: { 
    httpList: (parameter = {}) => httpJTList({ ...parameter }),
    httpAdd: true
  }
};

export default contentConfig;
