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

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

const columns = [
  {
    prop: "result_code",
    label: "原因编号",
    width: "120px",
  },
  {
    prop: "result",
    label: "原因标题",
  },
  {
    prop: "status",
    width: "140px",
    label: "原因类型",
    cellRenderer: ({ row }) => {
      return h( ElTag, { }, { default: () => (options.find(({value}) => value === String(row.type)))?.label || '--'}
      );
    }
  },
  {
    prop: "result_desc",
    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: "创建时间",
    width: "140px",
  },
  {
    prop: "",
    label: "操作",
    fixed: "right",
    slot: "operation",
    width: "150px",
  },
]

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

export default contentConfig;
