import { ContentConfig } from "/@/components/PageContent";
import { httpList } 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: "inv_item_id", 
    width: 90 
  },
  
  { 
    label: '业务编号', 
    minWidth: 150,
    prop: 'invoiceCode' 
  },
  { 
    label: '商品名称', 
    prop: 'goodName', 
    minWidth: 140,
    ...renderIconLabelLeft('goodNo', 'goodName', '商品编号:')
  },
  
  { 
    label: '商品数量', 
    prop: 'num', 
    width: 100 
  },
  
  { 
    label: '税前单价', 
    prop: 'inv_subprice', 
    width: 120 
  },

  { 
    label: '税后单价', 
    prop: 'inv_price', 
    width: 120 
  },

  { 
    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'],
  apis: { 
    httpList: (parameter = {}) => httpList({ ...parameter, manager_status: '2' }),
    httpAdd: true
  }
};

export default contentConfig;
