/* eslint-disable prettier/prettier */
import { h } from "vue";
import { ContentConfig } from "/@/components/PageContent";

import { createHttpRequest } from "/@/views/time/_http";
import { ElTag } from "element-plus";
import { createTooltip } from "/@/utils/tootip";


const httpList = createHttpRequest("admin/DepartReport/list")
const httpStatus = createHttpRequest("/admin/DepartReport/status")

const options = [
  { value: "1", label: '部门报表' },
  { value: "2", label: '业务公司报表' }
]

const columns = [
  {
    label: "ID",
    prop: "id",
    width: '40px'
  },
  {
    label: "模板名称",
    width: 150,
    prop: "report_name"
  },
  {
    label: "微信模板名称",
    prop: "template_name",
    width: 140,
    cellRenderer({ row }) {
      return createTooltip(row.template_name, "微信模板ID: : " + row.template_id, 480)
    }
  },
  {
    label: "模板类型",
    width: '90px',
    cellRenderer({ row }) {
      return options.find(({ value }) => String(row.report_type) === String(value))?.label || '--'
    }
  },
  {
    label: "推送时间",
    prop: "",
    width: '65px',
    cellRenderer({ row }) { return "每天" }
  },
  {
    label: "推送人",
    prop: "pusher",
    minWidth: 160,
    cellRenderer({ row }) {
      return row.pusher.map(({ user_name }) => user_name).join(",")
    }
  },
  {
    label: "状态",
    width: '65px',
    prop: "status",
    cellRenderer({ row }) {
      return h(ElTag, {
        type: String(row.status) === "1" ? "success" : "danger"
      }, {
        default: () => String(row.status) === "1" ? "启用" : "禁用"
      })
    }
  },
  {
    label: "创建时间",
    prop: "createtime",
    width: '140px'
  },
  {
    label: "模板参数",
    prop: "template_param",
    width: 80
  },
  {
    width: 80,
    label: "操作",
    fixed: "right",
    slot: "operation"
  }
];


const contentConfig: ContentConfig = {
  superUserNoAction: false,
  columns,
  apis: {
    httpList,
    httpStatus,
    httpAdd: true,
    httpUpdate: true
  }
};

export default contentConfig;
