import React, { Component } from 'react' import { connect } from 'react-redux' import { Input, Textarea, View, Text, Picker, Button } from '@tarojs/components' import Taro, { getCurrentInstance } from '@tarojs/taro'; import dayjs from 'dayjs'; import Skeleton from 'taro-skeleton' import ImagePicker from '../../components/common/imagePicker'; import { updateRecord, recordDetails } from '../../utils/servers/servers'; import { resourceAddress } from "../../utils/config"; import './index.less'; // import '../punchClock/index.less' import 'taro-ui/dist/style/components/noticebar.scss'; import 'taro-ui/dist/style/components/icon.scss'; import 'taro-ui/dist/style/components/list.scss'; import "taro-ui/dist/style/components/radio.scss"; import "taro-ui/dist/style/components/icon.scss"; class ReClockin extends Component { $instance = getCurrentInstance(); constructor(props) { super(props); this.state = { imgs: [], loading: false, selector: [{ value: 0, lable: "调研阶段" },], dateSel: dayjs().format('YYYY-MM-DD'), duration: "", selectorChecked: {}, content: "", data: {}, isOpened: false, } this.onChange = this.onChange.bind(this); this.updateRecordClockIn = this.updateRecordClockIn.bind(this); } componentDidMount() { this.getReleasetDails(); } componentWillMount() { } componentDidHide() { } // 项目详情 getReleasetDails() { recordDetails({ id: this.$instance.router.params.id, }).then((v) => { if (v.code === 200) { if (v.data) { let list = []; for (let i of (v.data.annexUrl || '').split(',')) { if (i) { list.push({ 'url': resourceAddress + i }) } } this.setState({ data: v.data, pid: v.data.pid, imgs: list, selectorChecked: this.state.selector[v.data.projectStatus], duration: v.data.duration, content: v.data.content, processStatus: v.data.processStatus, recordTime: v.data.recordTime, isOpened: true, }) } } else { Taro.showToast({ title: v.msg, icon: "none" }); } }).catch((err) => { Taro.showToast({ title: "系统错误,请稍后再试", icon: "none" }); }); } onChange(value, type) { let arr = this.state.imgs.concat([]); if (type === "add") { arr.push(value); } else if (type === "remove") { arr.splice(value, 1); } this.setState({ imgs: arr, }); } updateRecordClockIn() { let arr = [] for (let i of this.state.imgs) { if (!!i.url) { arr.push(i.url.split(resourceAddress).join("")); } else { arr.push(i) } } if (!this.state.dateSel) { Taro.showToast({ title: '请选择研发时间!', icon: 'none' }); return } if (!this.state.duration) { Taro.showToast({ title: '请填写工时!', icon: 'none' }); return } if (!this.state.selectorChecked) { Taro.showToast({ title: '请选择研发阶段!', icon: 'none' }); return } Taro.showLoading({ title: '打卡中...' }); updateRecord({ id: this.$instance.router.params.id, pid: this.state.data.pid, projectStatus: this.state.selectorChecked.value, duration: this.state.duration, content: this.state.content, annexUrl: arr.join(','), processStatus: 1, recordTime: this.state.dateSel, }).then(v => { Taro.hideLoading() if (v.code === 200) { Taro.showToast({ title: '打卡成功', icon: 'none' }); Taro.navigateBack({ delta: 1 }); } else { Taro.showToast({ title: v.msg, icon: 'none' }) } }).catch(() => { Taro.hideLoading() Taro.showToast({ title: '系统错误,请稍后再试', icon: 'none' }) }) } render() { const { data } = this.state; return ( {data.name} {/* { Taro.switchTab({ url: "/pages/project/index", }); }}>切换 */} *研发时间: { this.setState({ dateSel: e.detail.value }) }}> {!!this.state.dateSel ? this.state.dateSel : "请选择"} *研发工时: { this.setState({ duration: e.detail.value }) }} />小时  注:工时可含1个小数点 *研发阶段: { this.setState({ selectorChecked: this.state.selector[e.detail.value] }) }}> {!!this.state.selectorChecked ? this.state.selectorChecked.lable : "请选择"} 研发记录: