import React, { Component } from "react";
import { View, Image, Button, Input, Textarea } from "@tarojs/components";
import Taro, { getCurrentInstance } from "@tarojs/taro";
import {
  AtButton,
  AtCalendar,
  AtIcon,
  AtTextarea,
  AtModal,
  AtModalContent,
  AtModalAction,
} from "taro-ui";
import Skeleton from "taro-skeleton";

import InquiryModal from "../../components/common/inquiryModal";

import {
  projectAdd,
} from "../../utils/servers/servers";
import { resourceAddress } from "../../utils/config";
import "./index.less";

import "taro-ui/dist/style/components/icon.scss";
import "taro-ui/dist/style/components/textarea.scss";
import "taro-ui/dist/style/components/modal.scss";
import "taro-ui/dist/style/components/timeline.scss";
import "taro-ui/dist/style/components/icon.scss";
import "taro-ui/dist/style/components/calendar.scss";

import { getClockState, unique } from "../../utils/tools";

class ProjectAdd extends Component {
  $instance = getCurrentInstance();

  constructor(props) {
    super(props);
    this.state = {

    };

  }

  componentDidMount() {

  }

  componentDidShow() {

  }

  // 新增
  Add(sta) {
    if (!this.state.opinion) {
      Taro.showToast({ title: "请填写审批意见", icon: "none" });
      return;
    }
    projectAdd({
      name: "",
      adminName:"",
    })
      .then((v) => {
        if (v.error.length === 0) {
          //如果在审核期间修改过
          if (
            v.data.updateTime != null &&
            this.state.dtails.updateTime !== v.data.updateTime
          ) {
            this.setState({
              isInquiryOpened: true,
              isNo: false,
              inquiryTitle: "提醒",
              inquiryContent: "当前公出申请已修改，请重新审核",
            });
          } else {
            sta === 2
              ? this.examinePublicRelease(2)
              : this.examinePublicRelease(0);
          }
          if (v.data) {
            let list = [];
            for (let i of v.data.annexUrl.split(",")) {
              if (i) {
                list.push({ url: resourceAddress + i });
              }
            }
            v.data.annexUrl = list;
            this.setState({
              dtails: v.data,
              selectArrderLocation: {
                longitude: parseFloat(v.data.prdList[0]?.longitude),
                latitude: parseFloat(v.data.prdList[0]?.latitude),
                name: v.data.prdList[0]?.districtName,
              },
            });
          } else {
            setTimeout(() => {
              Taro.switchTab({
                url: "/pages/punchClock/index",
              });
            }, 1800);
            Taro.showToast({
              title: "您没有权限查看此公出详情",
              icon: "none",
              duration: 1800,
            });
          }
        } else {
          Taro.showToast({ title: v.error[0].message, icon: "none" });
        }
      })
      .catch((err) => {
        Taro.showToast({ title: "系统错误,请稍后再试", icon: "none" });
        // console.log(err);
      });
  }

  render() {
    const { } = this.state;
    return (
      <View className="add">
        <View className="count">
          <View className="inputItem">
            <View className="title">项目名称</View>
            <Input />
          </View>
          <View className="inputItem">
            <View className="title">项目负责人</View>
          </View>
          <View className="inputItem">
            <View className="title">研发人员</View>
          </View>
          <View className="inputItem">
            <View className="title">项目说明</View>
            <Textarea />
          </View>
        </View>
      </View>
    );
  }
}

export default ProjectAdd;
