Basic.tsx 1.47 KB
Newer Older
涂茜's avatar
涂茜 committed
1 2 3 4 5
import React from 'react';
import PandaDeviceTree from '../index';
import { service } from '@wisdom-utils/utils';

const REQUEST_HTTP = 'http';
涂茜's avatar
涂茜 committed
6
const REQUEST_METHOD_POST = 'post';
涂茜's avatar
涂茜 committed
7

涂茜's avatar
涂茜 committed
8
const GET_DEVICE_LIST =
涂茜's avatar
涂茜 committed
9
  'https://www.fastmock.site/mock/162c15dca15c4dba9ba51e0a0b76929b/api/Publish/GCK/Device/DeviceTree'; //获取设备树列表
涂茜's avatar
涂茜 committed
10

涂茜's avatar
涂茜 committed
11 12
// const GET_DEVICE_LIST = '/api/Publish/GCK/Device/DeviceTree'; //获取设备树列表

涂茜's avatar
涂茜 committed
13
const deviceTreeService = {
涂茜's avatar
涂茜 committed
14 15 16
  getDeviceList: {
    url: GET_DEVICE_LIST,
    method: REQUEST_METHOD_POST,
涂茜's avatar
涂茜 committed
17 18 19 20 21 22
    type: REQUEST_HTTP,
  },
};

const dtService = service(deviceTreeService);

涂茜's avatar
涂茜 committed
23
const getDeviceList = dtService.getDeviceList;
涂茜's avatar
涂茜 committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

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}
涂茜's avatar
涂茜 committed
40 41 42 43 44 45
        deviceTreeService={getDeviceList}
        serviceParams={{
          pageIndex: 1,
          pageSize: 20,
          // deviceTypes: '二供泵房,二供机组',
          getChild: true,
涂茜's avatar
涂茜 committed
46
          userID: 1,
涂茜's avatar
涂茜 committed
47 48 49 50 51 52
          // queryInfo: '',
          // sortFields: '',
          // direction: '',
          // isTop: true,
        }}
        // pagination={false}
涂茜's avatar
涂茜 committed
53 54 55 56 57 58
      />
    </div>
  );
};

export default Demo;