import React from 'react';
import PandaDeviceTree from '../index';
import { service } from '@wisdom-utils/utils';

const REQUEST_HTTP = 'http';
const REQUEST_METHOD_POST = 'post';

const GET_DEVICE_LIST =
  'https://www.fastmock.site/mock/162c15dca15c4dba9ba51e0a0b76929b/api/Publish/GCK/Device/DeviceTree'; //获取设备树列表

// const GET_DEVICE_LIST = '/api/Publish/GCK/Device/DeviceTree'; //获取设备树列表

const deviceTreeService = {
  getDeviceList: {
    url: GET_DEVICE_LIST,
    method: REQUEST_METHOD_POST,
    type: REQUEST_HTTP,
  },
};

const dtService = service(deviceTreeService);

const getDeviceList = dtService.getDeviceList;

const Demo = () => {
  const onTreeCheck = (checkedKeysValue) => {
    console.log('onTreeCheck', checkedKeysValue);
  };

  const onTreeSelect = (selectedKeysValue) => {
    console.log('onTreeSelect', selectedKeysValue);
  };

  return (
    <div style={{ width: '200px', height: '400px', border: '1px solid #eee' }}>
      <PandaDeviceTree
        checkable
        onTreeCheck={onTreeCheck}
        onTreeSelect={onTreeSelect}
        deviceTreeService={getDeviceList}
        serviceParams={{
          pageIndex: 1,
          pageSize: 20,
          // deviceTypes: '二供泵房,二供机组',
          getChild: true,
          userID: 1,
          // queryInfo: '',
          // sortFields: '',
          // direction: '',
          // isTop: true,
        }}
        // pagination={false}
      />
    </div>
  );
};

export default Demo;
