import {Modal } from 'antd';
import React, { useState} from 'react';
import ProTable from '@ant-design/pro-table';
import { GetStorePage } from '../service';
const CreateForm = (props) => {

  console.log("fdsfadsa",props.modalVisible);
  const [selectedRowsState, setSelectedRows] = useState([]);
  const columns = [
    {
      title: '商品id',
      dataIndex: 'id',
      tip: '规则名称是唯一的 key',
      hideInSearch: true,
      hideInTable: true,
    },
    {
      title: '门店名称',
      dataIndex: 'name',
    },
  ];
  return (
    <Modal
      width={700}
      bodyStyle={{ padding: '32px 40px 48px' }}
      destroyOnClose
      title="选择门店"
      visible={props.modalVisible}
      onCancel={() => props.onCancel()}
      onOk={() => props.onSubmit(selectedRowsState)}
      maskClosable={false}
    >
      <ProTable
        headerTitle="商品信息"
        rowKey="id"
        pagination={{ defaultPageSize: 20 }}
        search={false}
        toolBarRender={false}
        params={{
          FoodMenuId:props.values,
        }}
        //数据绑定
        request={async (params) => {
          var Data = [];
          var total = 0;
          await GetStorePage(params).then((r) => {

            Data = r.data.data;
            total = r.data.total;
          });
          return {
            data: Data,
            success: true,
            total: total,
          };
        }}
        columns={columns}
        rowSelection={{
          onChange: (_, selectedRows) => setSelectedRows(selectedRows),
        }}
      />
    </Modal>
  );
};

export default CreateForm;
