import { httpList, httpStatus,httpDelete } from "/@/api/serviceParam/unit";

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

const columns = [
  {
    prop: "id",
    label: "ID",
  },
  {
    prop: "unit",
    label: "单位名称",
  },
  {
    prop: "status",
    label: "状态",
    width: "80px",
    cellRenderer: ({ row }) => {
      return h( ElTag, { 
        type: (statusOptions.find(({value}) => value === String(row.status)))?.type || 'info'
      }, { default: () => (statusOptions.find(({value}) => value === String(row.status)))?.label || '--'}
      );
    }
  },
  {
    prop: "addtime",
    label: "创建时间",
  },
  {
    prop: "",
    label: "操作",
    fixed: "right",
    slot: "operation",
    width: "150px",
  },
]

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

export default contentConfig;
