import { DropboxOutlined, PlusOutlined,UploadOutlined  } from '@ant-design/icons';
import { Button, message, Input, Upload, Modal, Popconfirm } from 'antd';
import React, { useState, useRef, useEffect } from 'react';
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
import ProTable from '@ant-design/pro-table';
import ProDescriptions from '@ant-design/pro-descriptions';
// import CreateForm from './CreateForm';
import ActionForm from './ActionForm';

//页面 相当于 class
const bomtechnology = (props) => {
  /** 新建/更新窗口的弹窗 */
  const [createModalVisible, handleModalVisible] = useState(false);
  /** 分布更新窗口的弹窗 */
  
  const [actionFormModalVisible, setactionFormModalVisible] = useState(false);
  const [showDetail, setShowDetail] = useState(false);
  //绑定
  const actionRef = useRef();
  const [currentRow, setCurrentRow] = useState();
  //选中的行
  const [selectedRowsState, setSelectedRows] = useState([]);
  const [DeviceVesionData, setDeviceVesionData] = useState([]);
  /** 国际化配置 */
  const [DictData, setDictData] = useState([]);
  const columns = [
    {
      title: '主键',
      dataIndex: 'id',
      tip: '规则名称是唯一的 key',
      hideInSearch: true,
      hideInTable: true,
      render: (dom, entity) => {
        return (
          <a
            onClick={() => {
              setCurrentRow(entity);
              setShowDetail(true);
            }}
          >
            {dom}
          </a>
        );
      },
    },
    {
      title: '名称',
      dataIndex: 'name',
      valueType: 'textarea',
      ellipsis: true,
      search: true,
    },
    
    {
      title: '创建时间',
      dataIndex: 'createAt',
      valueType: 'date',
      hideInSearch: true,
    },
    {
      title: '操作',
      dataIndex: 'option',
      valueType: 'option',
      render: (_, record) => [
     
        <a
        key="config"
        onClick={() => {
          setactionFormModalVisible(true);
          setCurrentRow(record.technologyActionInfo);
          actionRef.current?.reloadAndRest?.();
        }}
      >
        模型配置
      </a>,
        // <Popconfirm
        //   type="primary"
        //   key="primary"
        //   title="确认删除吗？"
        //   okText="是"
        //   cancelText="否"
        //   onConfirm={() => {
        //     handleRemove([record.id]);
        //     actionRef.current?.reloadAndRest();
        //   }}
        //   onCancel={() => {}}
        // >
        //   <a href="#">删除</a>
        // </Popconfirm>,
      ],
    },
  ];
  useEffect(() => {
    // GetDicList('DeviceClientType').then((r) => {
    //     var arr = r.data;
    //     let data = {};
    //     if (r.succeeded) {
    //       var list = [];
    //       arr.forEach((item) => {
    //         data[item.code] = { text: item.code };
    //         list.push({
    //           code: item.code,
    //           value: item.code,
    //         });
    //       });
    //       //setDicDataAny(data);
    //       setDictData(list);
    //     }
    //   });
  }, [])
  return (
    <Modal
    title={'工艺详情'}
    width={1040}
    visible={props.createModalVisible}
    bodyStyle={{ padding: '32px 40px 48px' }}
    footer={null}
    onCancel={() => {
      props.onCancel();
    }}
    maskClosable={false}
    destroyOnClose
  >
      <ProTable
        headerTitle="工艺"
        actionRef={actionRef}
        rowKey="id"
        search={{
          labelWidth: 120,
        }}
        columns={columns}
        toolBarRender={false}
        dataSource={props.dataSource}
        // 每行选择点击事件
        rowSelection={false}
      ></ProTable>
      <ActionForm actionFormModalVisible={actionFormModalVisible}
      dataSource={currentRow || {} }
      onCancel={() => {
        setCurrentRow(undefined);
        setactionFormModalVisible(false);
      }}
      />
    </Modal>
  );
};

export default bomtechnology;
