import React from "react";
import Taro from "@tarojs/taro";
import { View } from "@tarojs/components";
import { Cell, Tag, Notify } from "@antmjs/vantui";
import Page from "@/layouts/index";
import PowerList from "@/components/PowerList";
import { getTaCheckStand } from "@/services/tacheckstand";
import { ROLE_INSPECTOR } from "@/utils/user";

const sid1 = Math.random().toString(36).substring(2, 8);

export default (props) => {
  const router = Taro.useRouter();
  const { checkId } = router.params;

  const [loading, setLoading] = React.useState(false);

  const params = React.useMemo(
    () => ({
      checkId,
      itemType: "loc",
      pageSize: 500,
      mustValid: true,
    }),
    [checkId]
  );

  const onClick = (item) => {
    // if (item.answerNum >= item.num) {
    //   Notify.show({
    //     message: "当前测评问卷已收齐",
    //     type: "warning",
    //   });
    //   return;
    // }

    Taro.navigateTo({
      url: `/pages/checkStand/detail/index?id=${item.statndId}`,
    });
  };

  return (
    <Page tabBar="check" loading={loading}>
      <PowerList
        sid={sid1}
        request={getTaCheckStand}
        params={params}
        renderItem={(item) => {
          return (
            <Cell
              isLink
              key={item.statndId}
              title={item.locName}
              onClick={() => onClick(item)}
            ></Cell>
          );
        }}
        onLoadingChange={setLoading}
      />
    </Page>
  );
};
