import { PlusOutlined, ProfileOutlined, SearchOutlined } from '@ant-design/icons';
import {Button, Card, Col, DatePicker, Input, Menu, Row, Select, Space, Tree} from 'antd';
import React, { useState } from 'react';
import CancelCrud from '../../../../components/crud/CancelCrud';
import useCrud from '../../../../components/crud/useCrud';
import usePageTable from '../../../../components/crud/usePageTable';
import {QualityManageTab2, PageResult, SearchOption, Role} from '../../../../service/def';
import { demoDate } from '../../../../utils/utils';
import DataForm from './DataForm';
import DataTable from './DataTable';

const { Option } = Select;

async function demofind(): Promise<PageResult<QualityManageTab2>> {
  return {
    list: [
      {
        dwgcName: "单位工程一",
        fbgcName: '/',
        sgdw: '建筑公司',
        gclx: '枢纽工程',
        pdrq:'2月1号',
      },
      {
        dwgcName: "单位工程一",
        fbgcName: '/',
        sgdw: '建筑公司',
        gclx: '堤防工程',
        pdrq:'2月10号',
      },
      {
        dwgcName: "单位工程一",
        fbgcName: '/',
        sgdw: '建筑公司',
        gclx: '引水（渠道）工程',
        pdrq:'2月10号',
      },
      {
        dwgcName: "单位工程一",
        fbgcName: '分部工程1',
        sgdw: '建筑公司',
        gclx: '其他工程',
        pdrq:'2月10号',
      }
    ],
    totalRow: 4
  };
}

const DesignPackagePage: React.FC = () => {

  const crud = useCrud();

  const pager = usePageTable<QualityManageTab2>(demofind);

  return (
    <div className="content-root">
      {
        crud.mode === 'new' ? (
          <Card key="new" title="新增招标信息" extra={<CancelCrud crudCtx={crud} confirm />} >
            <DataForm crudCtx={crud} />
          </Card>
        ) : null
      }
      {
        !crud.mode ? (
          <>
            <Card>
              <Space size="large" wrap>
                <Space>
                  单位工程:
                  <Select defaultValue="单位工程一" style={{ width: 288 }}>
                    <Option value="单位工程一">单位工程一</Option>
                  </Select>
                </Space>
                <Space>施工时间:<DatePicker.RangePicker /></Space>
                <Space>
                  <Button icon={<SearchOutlined />} type="primary">查询</Button>
                  <Button icon={<PlusOutlined />} >新增</Button>
                </Space>
              </Space>
            </Card>
            <div className="card-h-margin" />
            <DataTable crudCtx={crud} pagerCtx={pager} />
          </>
        ) : null
      }

    </div>
  )
}

export default DesignPackagePage
