import React from "react";
import List from "@/components/Page/List";
import { queryDict } from "@/utils/request";
import { getTdLineList } from "@/service/tdLine";
import { getTdSceneMgtList } from "@/service/tdSceneMgt";
import { getTaProjectList } from "@/service/taProject";
import { useNavigate } from "react-router-dom";
const getLine = queryDict(getTdLineList, {
  labelKey: "lineName",
  valueKey: "lineId",
});
const getScene = queryDict(getTdSceneMgtList, {
  labelKey: "sceneName",
  valueKey: "sceneId",
});

export default (props) => {
  const navigate = useNavigate();

  const columns = [
    { title: "项目编号", dataIndex: "projectCode", search: false },
    { title: "项目名称", dataIndex: "projectName" },
    { title: "项目类型", dataIndex: "typeCode" },
    // { title: "类型名称", dataIndex: "typeName" },
    { title: "发起人名称", dataIndex: "initiatorName" },
    { title: "发起机构名称", dataIndex: "initiatorOrgName" },
    { title: "申请说明", dataIndex: "applyRemark", search: false },
    { title: "项目流程", dataIndex: "currentNode" },
    { title: "归属条线名称", dataIndex: "lineName", request: getLine },
    { title: "归属场景名称", dataIndex: "sceneName", request: getScene },
    { title: "项目开始时间", dataIndex: "startDate", search: false },
    { title: "项目结束时间", dataIndex: "endDate", search: false },
    {
      title: "项目时间",
      dataIndex: "startDate",
      valueType: "dateRange",
      hideInTable: true,
      search: {
        transform: (val) => {
          return {
            startDate: val[0],
            endDate: val[1],
          };
        },
      },
    },
  ];

  const onAdd = () => {
    navigate("/projectList/edit");
  };
  return (
    <List
      search={{ labelWidth: 130 }}
      request={getTaProjectList}
      columns={columns}
      onAdd={onAdd}
    />
  );
};
