import { httpList, httpStatus,httpDelete } from "/@/api/serviceParam/terrace";
import { ContentConfig } from "/@/components/PageContent";

import { platformOptions, statusOptions } from "./_options";
import { ElTag } from "element-plus";
import { h } from "vue";


const columns = [
  {
    prop: "id",
    label: "ID",
    width: "80px",
  },
  {
    prop: "platform_code",
    label: "平台编号",
    width: "160px",
  },
  {
    prop: "platform_name",
    label: "平台名称",
  },
  {
    prop: "platform_type",
    label: "对接平台",
    cellRenderer({ row }){
      return h(ElTag,null,{
        default: () => platformOptions.find(({value}) => String(value) === String(row.platform_type))?.label || '--'
      })
    }
  },
  {
    prop: "status",
    label: "状态",
    cellRenderer({ row }){
      return h(ElTag,{
        type: statusOptions.find(({value}) => String(value) === String(row.status))?.type || ''
      },{
        default: () => statusOptions.find(({value}) => String(value) === String(row.status))?.label || '--'
      })
    }
  },
  {
    prop: "desc",
    label: "排序权重",
    width: "80px",
  },
  {
    prop: "creater",
    label: "创建人",
  },
  {
    prop: "addtime",
    label: "创建时间",
    minWidth: "145px",
  },
  {
    prop: "",
    label: "操作",
    fixed: "right",
    width: "185px",
    slot: "operation",
  }
]

const contentConfig: ContentConfig = {
  title: "原因管理",
  columns,
  apis: {
    httpList,
    httpAdd: true,
    httpStatus,
    httpUpdate: true,
    httpDelete
  }
};

export default contentConfig;
