import React from 'react';
import Taro from '@tarojs/taro';
import { View } from '@tarojs/components';
import { Tab, Tabs } from '@antmjs/vantui';
import Page from '@/layouts/index';
import PowerList from '@/components/PowerList';
import Card from '@/components/IssueCard';
import { getTaIssue } from '@/services/taissue';
import { ROLE_INSPECTOR, ROLE_MANAGER } from '@/utils/user';
import { useModel } from '@/store';
import { getIssueStatus, PROCESS_ASSIGNED, PROCESS_END, PROCESS_START } from '@/utils/biz';

// 只有督察员能看到当前页面
export default (props) => {
  // const { user } = useModel('user');

  const router = Taro.useRouter();
  const { mine = '' } = router.params;

  const onClick = (item) => {
    Taro.navigateTo({
      url: `/pages/issue/edit/index?id=${item.issueId}`
    })
  }
  
  return (
    <Page roles={[ROLE_INSPECTOR]}>
      <Tabs sticky>
        <Tab title="全部">
          <PowerList
            request={getTaIssue}
            params={{ mine }}
            renderItem={(item) => (
              <Card key={item.issueId} issue={item} onClick={() => onClick(item)} />
            )}
          />
        </Tab>
        <Tab title="未交办">
          <PowerList
            request={getTaIssue}
            params={{mine, bizStatus: PROCESS_START}}
            renderItem={(item) => (
              <Card key={item.issueId} issue={item} onClick={() => onClick(item)} />
            )}
          />
        </Tab>
        <Tab title="已交办">
          <PowerList
            request={getTaIssue}
            params={{mine, bizStatus: PROCESS_ASSIGNED}}
            renderItem={(item) => (
              <Card key={item.issueId} detail={item} onClick={() => onClick(item)} />
            )}
          />
        </Tab>
        <Tab title="已办结">
          <PowerList
            request={getTaIssue}
            params={{mine, bizStatus: PROCESS_END}}
            renderItem={(item) => (
              <Card key={item.issueId} detail={item} onClick={() => onClick(item)} />
            )}
          />
        </Tab>
        <Tab title="已逾期">
          <PowerList
            request={getTaIssue}
            params={{mine, bizStatus: 'expired'}}
            renderItem={(item) => (
              <Card key={item.issueId} detail={item} onClick={() => onClick(item)} />
            )}
          />
        </Tab>
        <Tab title="已打回">
          <PowerList
            request={getTaIssue}
            params={{mine, bizStatus: 'reject'}}
            renderItem={(item) => (
              <Card key={item.issueId} detail={item} onClick={() => onClick(item)} />
            )}
          />
        </Tab>
      </Tabs>
    </Page>
  )
}
