import { FontColorsOutlined, PlusOutlined, DownOutlined } from '@ant-design/icons';
import { Modal, Form, Input, Button, Select, TreeSelect, Space, Checkbox, Col, Row, DatePicker, Card, List, Tree, message, Drawer, Divider, Tag, Tabs } 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 moment from 'moment';
import {
  addintegraltype,
  editintegraltype,
  getintegraltype,
  addintegralrule,
  editintegralrule,
  getintegralrule,
  smallgoodstype,
  biggoodstype,
  getdevicetree,
  getintegral,
  editintegral,
  addintegral,
  testaddinteg,
  getStoreList,
  getallrule
} from './service';

import CreateTypeForm from './components/CreateTypeForm';
import CommonRuleForm from './components/CommonRuleForm';
import { set } from 'lodash';
import record from '@/pages/crm/coupon/coupon-Batch/components/ShowRecord';
const { TabPane } = Tabs;

const allruleChilData = [];


const Demo = () => {

  function GetTypeName(type) {
    var typeName = "未定义规则";
    switch (type) {
      case 1:
        typeName = "按消费金额积分规则";
        break;
      case 2:
        typeName = "按大类积分规则";
        break;
      case 3:
        typeName = "按小类积分规则";
        break;
      case 4:
        typeName = "按消费次数积分规则";
        break;
      case 5:
        typeName = "按消费人数积分规则";
        break;
      case 6:
        typeName = "按出品数量积分规则";
        break;
      default:
        break;
    }
    return typeName;
  }

  /**
   * 类别
   */
  const allTypes = {
    price: 1,
    big: 2,
    small: 3,
    count: 4,
    persons: 5,
    number: 6
  };

  /**
   * 表头
   */
  const pricecolumns = [
    {
      title: '规则id',
      dataIndex: 'id',
      tip: '规则名称是唯一的 key',
      hideInSearch: true,
      hideInTable: true,
    },
    {
      title: '金额',
      dataIndex: 'thresholdPriceKey',
    },
    {
      title: '积分',
      dataIndex: 'rulethresholdValue',
    },
    {
      title: '积分取整',
      dataIndex: 'isUnFloor',
      render: (_, record) => {
        return record.isUnFloor == 1 ? '已开启' : '未开启'
      }
    },
    {
      title: '阈值',
      dataIndex: 'thresholds',
    },
    {
      title: '规则描述',
      dataIndex: 'ruleRemark',
    },
    {
      title: '操作',
      dataIndex: 'option',
      valueType: 'option',
      render: (_, record) => [
        <a
          key="primary"
          onClick={() => {
            handlepriceModalVisible(true);
            setpriceCurrentRow(record);
          }}
        >
          {' '}
          修改
        </a>,
        <a
          key="primary"
          onClick={() => {
            record.status = record.status == 0 ? 1 : 0;
            handleUpdate(record);
          }}
        >
          {' '}
          {record.status == 0 ? '停用' : '启用'}
        </a>,

      ],
    },
  ];

  const bigTypecolumns = [
    {
      title: '规则id',
      dataIndex: 'id',
      tip: '规则名称是唯一的 key',
      hideInSearch: true,
      hideInTable: true,
    },
    {
      title: '金额',
      dataIndex: 'thresholds',
    },
    {
      title: '积分',
      dataIndex: 'rulethresholdValue',
    },
    {
      title: '大类编码',
      dataIndex: 'thresholdBigKey',
    },
    {
      title: '规则描述',
      dataIndex: 'ruleRemark',
    },
    {
      title: '操作',
      dataIndex: 'option',
      valueType: 'option',
      render: (_, record) => [
        <a
          key="primary"
          onClick={() => {
            handlebigModalVisible(true);
            setbigCurrentRow(record);
          }}
        >
          {' '}
          修改
        </a>,
        <a
          key="primary"
          onClick={() => {
            record.status = record.status == 0 ? 1 : 0;
            handleUpdate(record);
          }}
        >
          {' '}
          {record.status == 0 ? '停用' : '启用'}
        </a>,

      ],
    },
  ];

  const smallTypecolumns = [
    {
      title: '规则id',
      dataIndex: 'id',
      tip: '规则名称是唯一的 key',
      hideInSearch: true,
      hideInTable: true,
    },
    {
      title: '金额',
      dataIndex: 'thresholds',
    },
    {
      title: '积分',
      dataIndex: 'rulethresholdValue',
    },
    {
      title: '小类编码',
      dataIndex: 'thresholdSmallKey',
    },
    {
      title: '规则描述',
      dataIndex: 'ruleRemark',
    },
    {
      title: '操作',
      dataIndex: 'option',
      valueType: 'option',
      render: (_, record) => [
        <a
          key="primary"
          onClick={() => {
            handlesmallModalVisible(true);
            setsmallCurrentRow(record);
          }}
        >
          {' '}
          修改
        </a>,
        <a
          key="primary"
          onClick={() => {
            record.status = record.status == 0 ? 1 : 0;
            handleUpdate(record);
          }}
        >
          {' '}
          {record.status == 0 ? '停用' : '启用'}
        </a>,

      ],
    },
  ];

  const countcolumns = [
    {
      title: '规则id',
      dataIndex: 'id',
      tip: '规则名称是唯一的 key',
      hideInSearch: true,
      hideInTable: true,
    },
    {
      title: '次数',
      dataIndex: 'thresholdCountKey',
    },
    {
      title: '积分',
      dataIndex: 'rulethresholdValue',
    },
    {
      title: '积分阈值',
      dataIndex: 'thresholds',
    },
    {
      title: '规则描述',
      dataIndex: 'ruleRemark',
    }, {
      title: '操作',
      dataIndex: 'option',
      valueType: 'option',
      render: (_, record) => [
        <a
          key="primary"
          onClick={() => {
            handlecountModalVisible(true);
            setcountCurrentRow(record);
          }}
        >
          {' '}
          修改
        </a>,
        <a
          key="primary"
          onClick={() => {
            record.status = record.status == 0 ? 1 : 0;
            handleUpdate(record);
          }}
        >
          {' '}
          {record.status == 0 ? '停用' : '启用'}
        </a>,

      ],
    },
  ];

  const personscolumns = [
    {
      title: '规则id',
      dataIndex: 'id',
      tip: '规则名称是唯一的 key',
      hideInSearch: true,
      hideInTable: true,
    },
    {
      title: '人数',
      dataIndex: 'thresholdPersonsKey',
    },
    {
      title: '积分',
      dataIndex: 'rulethresholdValue',
    },
    {
      title: '积分阈值',
      dataIndex: 'thresholds',
    },
    {
      title: '规则描述',
      dataIndex: 'ruleRemark',
    }, {
      title: '操作',
      dataIndex: 'option',
      valueType: 'option',
      render: (_, record) => [
        <a
          key="primary"
          onClick={() => {
            handlepersonsModalVisible(true);
            setpersonsCurrentRow(record);
          }}
        >
          {' '}
          修改
        </a>,
        <a
          key="primary"
          onClick={() => {
            record.status = record.status == 0 ? 1 : 0;
            handleUpdate(record);
          }}
        >
          {' '}
          {record.status == 0 ? '停用' : '启用'}
        </a>,

      ],
    },
  ];

  const numbercolumns = [
    {
      title: '规则id',
      dataIndex: 'id',
      tip: '规则名称是唯一的 key',
      hideInSearch: true,
      hideInTable: true,
    },
    {
      title: '数量',
      dataIndex: 'thresholdNumberKey',
    },
    {
      title: '积分',
      dataIndex: 'rulethresholdValue',
    },
    {
      title: '积分阈值',
      dataIndex: 'thresholds',
    },
    {
      title: '规则描述',
      dataIndex: 'ruleRemark',
    }, {
      title: '操作',
      dataIndex: 'option',
      valueType: 'option',
      render: (_, record) => [
        <a
          key="primary"
          onClick={() => {
            handlenumberModalVisible(true);
            setnumberCurrentRow(record);
          }}
        >
          {' '}
          修改
        </a>,
        <a
          key="primary"
          onClick={() => {
            record.status = record.status == 0 ? 1 : 0;
            handleUpdate(record);
          }}
        >
          {' '}
          {record.status == 0 ? '停用' : '启用'}
        </a>,

      ],
    },
  ];

  const commoncolumns = [
    {
      title: '规则id',
      dataIndex: 'id',
      tip: '规则名称是唯一的 key',
      hideInSearch: true,
      hideInTable: true,
    },
    {
      title: '规则名称',
      dataIndex: 'name',
    },
    {
      title: '规则说明',
      dataIndex: 'ruleRemark',
    },
    {
      title: '操作',
      dataIndex: 'option',
      valueType: 'option',
      render: (_, record) => [
        <a
          key="primary"
          onClick={() => {
            handleAllRuleModalVisible(true);
            setcommoncurrentRow(record);
          }}
        >
          {' '}
          修改
        </a>,
        <a
          key="primary"
          onClick={() => {
            record.status = record.status == 0 ? 1 : 0;
            handleCommonUpdate(record);
          }}
        >
          {' '}
          {record.status == 0 ? '停用' : '启用'}
        </a>,

      ],
    },
  ];





  /**
   * 数据操作
   */
  /**
     * 添加节点
     *
     * @param fields
     */
  function handleAdd(fields) {
    try {
      addintegraltype(fields)
        .then((r) => {
          if (r.data) {
            message.success('添加成功');
            //刷新数据
            actionRef.current.reload();
          } else {
            message.error('添加失败请重试！');
          }
        });
      return true;
    } catch (error) {
      message.error('添加失败请重试！');
      return false;
    }
  }

  function handleCommonAdd(fields) {
    try {
      addintegralrule(fields)
        .then((r) => {
          if (r.data) {
            message.success('添加成功');
            //刷新数据
            actionRef.current.reload();
          } else {
            message.error('添加失败请重试！');
          }
        });
      return true;
    } catch (error) {
      message.error('添加失败请重试！');
      return false;
    }
  }

  /**
   * 更新节点
   *
   * @param fields
   */

  function handleUpdate(fields) {
    try {
      editintegraltype(fields)
        .then((r) => {
          if (r.data) {
            message.success('配置成功');
          } else {
            message.error('配置失败请重试！');
          }
          //刷新数据
          actionRef.current.reload();
        });
      return true;
    } catch (error) {
      message.error('配置失败请重试！');
      return false;
    }
  }

  function handleCommonUpdate(fields) {
    try {
      editintegralrule(fields)
        .then((r) => {
          if (r.data) {
            message.success('配置成功');
          } else {
            message.error('配置失败请重试！');
          }
          //刷新数据
          actionRef.current.reload();
        });
      return true;
    } catch (error) {
      message.error('配置失败请重试！');
      return false;
    }
  }



  /**
   * 事件声明
   */
  /** 新建窗口的弹窗 */
  const [createpriceModalVisible, handlepriceModalVisible] = useState();
  const [createbigModalVisible, handlebigModalVisible] = useState();
  const [createsmallModalVisible, handlesmallModalVisible] = useState();
  const [createcountModalVisible, handlecountModalVisible] = useState();
  const [createpersonsModalVisible, handlepersonsModalVisible] = useState();
  const [createnumberModalVisible, handlenumberModalVisible] = useState();

  const [createAllRuleModalVisible, handleAllRuleModalVisible] = useState();

  const [BigData, setBigData] = useState([]);
  const [SmallData, setSmallData] = useState([]);
  const [pricecurrentRow, setpriceCurrentRow] = useState();
  const [bigcurrentRow, setbigCurrentRow] = useState();
  const [smallcurrentRow, setsmallCurrentRow] = useState();
  const [personscurrentRow, setpersonsCurrentRow] = useState();
  const [countcurrentRow, setcountCurrentRow] = useState();
  const [numbercurrentRow, setnumbercurrentRow] = useState();
  const [commoncurrentRow, setcommoncurrentRow] = useState();

  const [thisRuleId, SetthisRuleId] = useState();
  const [thisRuleType, SetthisRuleType] = useState();

  const [allRuleData, setallRuleData] = useState([]);

  const [StoreData, SetStoreData] = useState();
  const [AllRuleTree, setAllRuleTree] = useState([]);
  const [AllStoreRule, setAllStoreRule] = useState([]);

  const [dwselected, setdwselected] = useState([]);
  const [tableselected, settableselected] = useState([]);



  const onSelect = (_, record) => {
    console.log(_[0]);
    SetthisRuleId(_[0]);
    SetthisRuleType(record.node.type);
  };

  /**
   * 绑定数据
   */
  /*绑定数据 */
  const actionRef = useRef();
  // 监控数据变化
  useEffect(() => {
    const parmar = {
      current: 1,
      pagesize: 30
    };

    biggoodstype(parmar).then((r) => {
      setBigData(r.data.data);
    });

     smallgoodstype(parmar).then((r) => {
      setSmallData(r.data.data);
    });

      getStoreList(parmar).then((r) => {
        SetStoreData(r.data);
    });

     getallrule({ current: 0, pagesize: 0 }).then((r) => {
      setallRuleData(r.data);
      var source = [];
      var allCommonSource = [];
      (r.data.allCommon || []).map((item, index) => {
        allCommonSource.push({
          title: item.name,
          key: item.id,
          parentId: 0,
          type: 0,
          children: []
        });
      });
      source.push({
        title: '通用规则',
        key: 0,
        parentId: 0,
        type: 0,
        children: allCommonSource
      });

      (r.data.allChild || []).map((item, index) => {
        var parTitle = GetTypeName(item.typeId);
        var childSource = [];
        item.child.map((itemChild, index) => {
          childSource.push({
            title: itemChild.ruleRemark,
            key: itemChild.id,
            parentId: item.typeId,
            type: item.typeId,
            children: []
          });
        });
        source.push({
          title: parTitle,
          key: item.typeId,
          parentId: 0,
          type: item.typeId,
          children: childSource
        });
      });
      setAllRuleTree(source);
    });

     getintegral({ current: 0, pagesize: 0 }).then((r) => {
      setAllStoreRule(r.data);
    });

  }, []);




  return (
    <Tabs defaultActiveKey="1" >

      <CommonRuleForm
        onFinish={async (value) => {
          var success = false;
          if (value.id) {
            success = handleUpdate(value);
          } else {
            success = handleAdd(value);
          }
          if (success) {
            handlepriceModalVisible(false);
            setpriceCurrentRow(undefined);
            if (actionRef.current) {
              actionRef.current.reload();
            }
          }
        }}
        onCancel={() => {
          handlepriceModalVisible(false);
          actionRef.current.reload();
        }}
        Data={{ type: 'price', ruleType: allTypes.price, Big: BigData || [], Small: SmallData || [] }}
        createModalVisible={createpriceModalVisible}
        values={pricecurrentRow || {}}
      >
      </CommonRuleForm>

      <CommonRuleForm
        onFinish={async (value) => {
          var success = false;
          if (value.id) {
            success = handleUpdate(value);
          } else {
            success = handleAdd(value);
          }
          if (success) {
            handlebigModalVisible(false);
            setbigCurrentRow(undefined);
            if (actionRef.current) {
              actionRef.current.reload();
            }
          }
        }}
        onCancel={() => {
          handlebigModalVisible(false);
          actionRef.current.reload();
        }}
        Data={{ type: 'big', ruleType: allTypes.big, Big: BigData || [], Small: SmallData || [] }}
        createModalVisible={createbigModalVisible}
        values={bigcurrentRow || {}}
      >
      </CommonRuleForm>

      <CommonRuleForm
        onCancel={() => {
          handlesmallModalVisible(false);
          actionRef.current.reload();
        }}
        onFinish={async (value) => {
          var success = false;
          if (value.id) {
            success = handleUpdate(value);
          } else {
            success = handleAdd(value);
          }
          if (success) {
            handlesmallModalVisible(false);
            setsmallCurrentRow(undefined);
            if (actionRef.current) {
              handlesmallModalVisible(false);
              actionRef.current.reload();
            }
          }
        }}
        Data={{ type: 'small', ruleType: allTypes.small, Big: BigData || [], Small: SmallData || [] }}
        createModalVisible={createsmallModalVisible}
        values={smallcurrentRow || {}}
      >
      </CommonRuleForm>

      <CommonRuleForm

        onCancel={() => {
          handlecountModalVisible(false);
          actionRef.current.reload();
        }}
        onFinish={async (value) => {
          var success = false;
          if (value.id) {
            success = handleUpdate(value);
          } else {
            success = handleAdd(value);
          }
          if (success) {
            handlecountModalVisible(false);
            setcountCurrentRow(undefined);
            if (actionRef.current) {
              handlecountModalVisible(false);
              actionRef.current.reload();
            }
          }
        }}
        Data={{ type: 'count', ruleType: allTypes.count, Big: BigData || [], Small: SmallData || [] }}
        createModalVisible={createcountModalVisible}
        values={countcurrentRow || {}}
      >
      </CommonRuleForm>

      <CommonRuleForm
        onCancel={() => {
          handlepersonsModalVisible(false);
          actionRef.current.reload();
        }}
        onFinish={async (value) => {
          var success = false;
          if (value.id) {
            success = handleUpdate(value);
          } else {
            success = handleAdd(value);
          }
          if (success) {
            handlepersonsModalVisible(false);
            setpersonsCurrentRow(undefined);
            if (actionRef.current) {
              handlepersonsModalVisible(false);
              actionRef.current.reload();
            }
          }
        }}
        Data={{ type: 'persons', ruleType: allTypes.persons, Big: BigData || [], Small: SmallData || [] }}
        createModalVisible={createpersonsModalVisible}
        values={personscurrentRow || {}}
      >
      </CommonRuleForm>

      <CommonRuleForm
        onCancel={() => {
          handlenumberModalVisible(false);
          actionRef.current.reload();
        }}
        onFinish={async (value) => {
          var success = false;
          if (value.id) {
            success = handleUpdate(value);
          } else {
            success = handleAdd(value);
          }
          if (success) {
            handlenumberModalVisible(false);
            setnumbercurrentRow(undefined);
            if (actionRef.current) {
              handlenumberModalVisible(false);
              actionRef.current.reload();
            }
          }
        }}
        Data={{ type: 'number', ruleType: allTypes.number, Big: BigData || [], Small: SmallData || [] }}
        createModalVisible={createnumberModalVisible}
        values={numbercurrentRow || {}}
      >
      </CommonRuleForm>

      <CreateTypeForm
        onCancel={() => {
          handleAllRuleModalVisible(false);
          setcommoncurrentRow(undefined);
          actionRef.current.reload();
        }}
        onFinish={async (value) => {
          var success = false;
          if (value.id) {
            success = handleCommonUpdate(value);
          } else {
            success = handleCommonAdd(value);
          }
          if (success) {
            handleAllRuleModalVisible(false);
            setcommoncurrentRow(undefined);
            if (actionRef.current) {
              handleAllRuleModalVisible(false);
              actionRef.current.reload();
            }
          }
        }}
        Data={allRuleData || { allChild: [], allCommon: [] }}
        createModalVisible={createAllRuleModalVisible}
        values={commoncurrentRow || {}}
      >
      </CreateTypeForm>

      <TabPane tab="通用设置" key="1" style={{ float: 'left' }}>
        <ProTable
          actionRef={actionRef}
          rowKey="id"
          search={{
            labelWidth: 120,
          }}
          toolBarRender={() => [
            <Button
              type="primary"
              key="primary"
              onClick={() => {
                handleAllRuleModalVisible(true);
              }}
            >
              <PlusOutlined /> 添加
            </Button>
          ]}
          params={{
            thisRuleId,
          }}
          request={async (params) => {
            var datas = [];
            var total = 0;
            await getintegralrule(params).then((r) => {
              var olddata = r.data.data;
              olddata.map((item, index) => {
                var dateArr = [];
                var dateArr2 = [];
                if (item.effectiveDate != null) {
                  dateArr = [moment(item.effectiveDate[0], "YYYY-MM-DD HH:mm:ss"), moment(item.effectiveDate[1], "YYYY-MM-DD HH:mm:ss")];
                  item.effectiveDate = dateArr;
                }
                if (item.multipleDate != null) {
                  dateArr2 = [moment(item.multipleDate[0], "YYYY-MM-DD HH:mm:ss"), moment(item.multipleDate[1], "YYYY-MM-DD HH:mm:ss")];
                  item.multipleDate = dateArr2;
                }
                if (item.fixedDay != null) {
                  item.fixedDay = moment(item.fixedDay, "YYYY-MM-DD HH:mm:ss");
                }
              });

              datas = olddata;
              total = r.data.total;
            });
            return {
              data: datas,
              success: true,
              total: total,
            };
          }}
          modalVisible={createAllRuleModalVisible}
          columns={commoncolumns}
          rowSelection={{
            onChange: (_, selectedRows) => {
              //setSelectedRows(selectedRows);
            },
          }}
        />
      </TabPane>

      <TabPane tab="按金额积分" key="2">
        <ProTable
          actionRef={actionRef}
          rowKey="id"
          search={{
            labelWidth: 120,
          }}
          toolBarRender={() => [
            <Button
              type="primary"
              key="primary"
              onClick={() => {
                handlepriceModalVisible(true);
              }}
            >
              <PlusOutlined /> 添加
            </Button>
          ]}
          params={{
            RuleType: 1,
          }}
          request={async (params) => {
            var datas = [];
            var total = 0;
            await getintegraltype(params).then((r) => {
              datas = r.data.data;
              total = r.data.total;
            });
            return {
              data: datas,
              success: true,
              total: total,
            };
          }}
          modalVisible={createpriceModalVisible}
          columns={pricecolumns}
          rowSelection={{
            onChange: (_, selectedRows) => {
              //setSelectedRows(selectedRows);
            },
          }}
        />
      </TabPane>

      <TabPane tab="按大类积分" key="3">
        <ProTable
          actionRef={actionRef}
          rowKey="id"
          search={{
            labelWidth: 120,
          }}
          toolBarRender={() => [
            <Button
              type="primary"
              key="primary"
              onClick={() => {
                handlebigModalVisible(true);
              }}
            >
              <PlusOutlined /> 添加
            </Button>
          ]}
          params={{
            RuleType: 2,
          }}
          request={async (params) => {
            var datas = [];
            var total = 0;
            await getintegraltype(params).then((r) => {
              datas = r.data.data;
              total = r.data.total;
            });
            return {
              data: datas,
              success: true,
              total: total,
            };
          }}
          modalVisible={createbigModalVisible}
          columns={bigTypecolumns}
          rowSelection={{
            onChange: (_, selectedRows) => {
              //setSelectedRows(selectedRows);
            },
          }}
        />
      </TabPane>

      <TabPane tab="按小类积分" key="4">
        <ProTable
          actionRef={actionRef}
          rowKey="id"
          search={{
            labelWidth: 120,
          }}
          toolBarRender={() => [
            <Button
              type="primary"
              key="primary"
              onClick={() => {
                handlesmallModalVisible(true);
              }}
            >
              <PlusOutlined /> 添加
            </Button>
          ]}
          params={{
            RuleType: 3,
          }}
          request={async (params) => {
            var datas = [];
            var total = 0;
            await getintegraltype(params).then((r) => {
              datas = r.data.data;
              total = r.data.total;
            });
            return {
              data: datas,
              success: true,
              total: total,
            };

          }}
          modalVisible={createsmallModalVisible}
          columns={smallTypecolumns}
          rowSelection={{
            onChange: (_, selectedRows) => {
              //setSelectedRows(selectedRows);
            },
          }}
        />
      </TabPane>

      <TabPane tab="按消费次数积分" key="5">
        <ProTable
          actionRef={actionRef}
          rowKey="id"
          search={{
            labelWidth: 120,
          }}
          toolBarRender={() => [
            <Button
              type="primary"
              key="primary"
              onClick={() => {
                handlecountModalVisible(true);
              }}
            >
              <PlusOutlined /> 添加
            </Button>
          ]}
          params={{
            RuleType: 4,
          }}
          request={async (params) => {

            var datas = [];
            var total = 0;
            await getintegraltype(params).then((r) => {
              datas = r.data.data;
              total = r.data.total;
            });
            return {
              data: datas,
              success: true,
              total: total,
            };
          }}
          modalVisible={createcountModalVisible}
          columns={countcolumns}
          rowSelection={{
            onChange: (_, selectedRows) => {
              //setSelectedRows(selectedRows);
            },
          }}
        />
      </TabPane>

      <TabPane tab="按消费人数积分" key="6">
        <ProTable
          actionRef={actionRef}
          rowKey="id"
          search={{
            labelWidth: 120,
          }}
          toolBarRender={() => [
            <Button
              type="primary"
              key="primary"
              onClick={() => {
                handlepersonsModalVisible(true);
              }}
            >
              <PlusOutlined /> 添加
            </Button>
          ]}
          params={{
            RuleType: 5,
          }}
          request={async (params) => {
            var datas = [];
            var total = 0;
            await getintegraltype(params).then((r) => {
              datas = r.data.data;
              total = r.data.total;
            });
            return {
              data: datas,
              success: true,
              total: total,
            };

          }}
          modalVisible={createpersonsModalVisible}
          columns={personscolumns}
          rowSelection={{
            onChange: (_, selectedRows) => {
              //setSelectedRows(selectedRows);
            },
          }}
        />
      </TabPane>

      <TabPane tab="按出品数量积分" key="7">
        <ProTable
          actionRef={actionRef}
          rowKey="id"
          search={{
            labelWidth: 120,
          }}
          toolBarRender={() => [
            <Button
              type="primary"
              key="primary"
              onClick={() => {
                handlenumberModalVisible(true);
              }}
            >
              <PlusOutlined /> 添加
            </Button>
          ]}
          params={{
            RuleType: 6,
          }}
          request={async (params) => {
            var datas = [];
            var total = 0;
            await getintegraltype(params).then((r) => {
              datas = r.data.data;
              total = r.data.total;
            });
            return {
              data: datas,
              success: true,
              total: total,
            };

          }}
          modalVisible={createnumberModalVisible}
          columns={numbercolumns}
          rowSelection={{
            onChange: (_, selectedRows) => {
              //setSelectedRows(selectedRows);
            },
          }}
        />
      </TabPane>
    </Tabs>
  );

}
export default Demo;
