import React from 'react';
import Page from '@/layouts/index';
import { Tab, Tabs, Button } from '@antmjs/vantui';
import { ROLE_INSPECTOR, ROLE_MANAGER } from '@/utils/user';
import { View } from '@tarojs/components';
import Taro from '@tarojs/taro';
import PowerList from '@/components/PowerList';
import { getTaCheck } from '@/services/tacheck';
import Card from './components/Card';

const queryParams = { isValid: true };
const sid1 = Math.random().toString(36).substring(2, 8);

export default (props) => {

  const onClick = (typ, item) => {
    if (typ == 'loc') {
      // console.log('------xiaofang----->');
      Taro.navigateTo({
        url: `/pages/check/loc/list/index?checkId=${item.checkId}`
      })
    } else {
      Taro.navigateTo({
        url: `/pages/check/edit/index?checkId=${item.checkId}&typ=${typ}`
      })
    }
  }

  return (
    <Page roles={[ROLE_INSPECTOR]}>
      <PowerList
        sid={sid1}
        request={getTaCheck}
        params={queryParams}
        renderItem={item => (
          <Card key={item.checkId} detail={item} onClick={(e) => onClick(e, item)} />
        )}
      />
    </Page>
  )
}