import React,{Component} from "react"; import { View,Image,Button } 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 Modify from './modify'; import {examinePublicRelease,getReleasetDails,updatePublicRelease} 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 Rejected from '../../image/rejected.png'; import Passed from '../../image/passed.png'; import Reviewed from '../../image/reviewed.png'; import Wx from '../../image/wx.png'; import Revoke from '../../image/revoke.png'; import ImagePicker from "../../components/common/imagePicker"; import MessageNoticebar from "../../components/common/messageNoticebar"; import {getClockState} from "../../utils/tools"; import HistoricalClock from "../../components/historicalClock"; class EgressDetails extends Component{ $instance = getCurrentInstance() constructor(props) { super(props); this.state={ dtails:{}, opinion:'', publicReleaseLog:[], isDetailedOpened:false, isModifyOpened:false, selectArrderLocation:{} } this.examinePublicRelease= this.examinePublicRelease.bind(this); this.getReleasetDails= this.getReleasetDails.bind(this); this.oidApplication= this.oidApplication.bind(this); } componentDidMount() { this.getReleasetDails(); } componentDidShow() { //获取地区选定数据 const chooseLocation = requirePlugin('chooseLocation'); const location = chooseLocation.getLocation(); if(location){ this.setState({ selectArrderLocation: location }) } } getReleasetDails(){ getReleasetDails({ id:this.$instance.router.params.id }).then(v=>{ if(v.error.length === 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.longitude), latitude:parseFloat(v.data.latitude), name:v.data.userName } }) }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) }) } examinePublicRelease(status){ if(!this.state.opinion){ Taro.showToast({title:'请填写审批意见',icon:'none'}) return; } examinePublicRelease({ status, remarks:this.state.opinion, id:this.state.dtails.id }).then(v=>{ if(v.error.length === 0){ Taro.showToast({title:status===0?'驳回成功':'通过成功',icon:'none'}); this.state.dtails.status=status; this.setState({ dtails:this.state.dtails }) Taro.eventCenter.trigger('listOperation',{ type:this.state.dtails.permission, index:this.$instance.router.params.index, status:status===0?0:2 }) }else{ Taro.showToast({title:v.error[0].message,icon:'none'}) } }).catch(()=>{ Taro.showToast({title:'系统错误,请稍后再试',icon:'none'}) }) } onShareAppMessage(){ return { title: this.state.dtails.status === 3 ? this.state.dtails.aname+ '撤销了前往' + this.state.dtails.userName + '的公出' : this.state.dtails.aname+ '将要去' + this.state.dtails.userName, path: 'pages/egressDetails/index?id='+this.$instance.router.params.id } } oidApplication(){ if(!this.state.reasonsInvalidation){ Taro.showToast({title:'请填写撤销原因',icon:'none'}) return; } this.setState({ loading:true }) updatePublicRelease({ id:this.$instance.router.params.id, status:3, reason:this.state.reasonsInvalidation, }).then(v=>{ this.setState({ loading:false }) if(v.error.length === 0){ Taro.showToast({ title:'修改成功', }) this.setState({ isInquiryOpened:false, inquiryTitle:'', inquiryContent:'', },()=>{ this.getReleasetDails(); }) Taro.eventCenter.trigger('listOperation',{ type:this.state.dtails.permission, index:this.$instance.router.params.index, status: 3, }) }else{ Taro.showToast({ title:v.error[0].message, icon:'none' }) } }).catch(()=>{ this.setState({ loading:false }) }); } render() { const {dtails} = this.state; return ( {Object.keys(dtails).length === 0? : {dtails.aname}提交的公出申请 申请时间: {dtails.createTimes} { getClockState(dtails.status).title } } {Object.keys(dtails).length === 0? : 公出地点: {dtails.permission === 0 && dtails.status === 0 ? { this.setState({ isModifyOpened:true, }) }}> : null} {dtails.userName} 公出{dtails.duration}小时 { e.stopPropagation(); this.setState({ isDetailedOpened:true }) }}>明细 {dtails.releaseStarts} {dtails.releaseEnds} { this.setState({ isDetailedOpened:false }) }} isOpened={this.state.isDetailedOpened}> {dtails.validDate ? : null } 公出企业 {dtails.nickname} 公出原因 {dtails.remarks} {dtails.annexUrl && dtails.annexUrl.length > 0 ? 附件 : null} { dtails.permission === 1 && dtails.status === 1 ? 填写审批意见 { this.setState({ opinion:value }) }} maxLength={20} placeholder='请填写审批意见' /> : null } { dtails.permission === 1 && dtails.status === 1 ? { this.setState({ isInquiryOpened:true, inquiryTitle:'提醒', inquiryContent:'您确定要驳回此申请吗?', inquiryFn:()=>{ this.examinePublicRelease(0); } }) }}> 驳回 { if(this.state.loading){return;} this.setState({ isInquiryOpened:true, inquiryTitle:'提醒', inquiryContent:'您确定要同意此申请吗?', inquiryFn:()=>{ this.examinePublicRelease(2); } }) }}> 同意 : null } { dtails.permission === 0 && dtails.status !== 3 ? 撤销申请 { this.setState({ reasonsInvalidation:value }) }} maxLength={20} placeholder='请填写撤销申请原因' /> : null } { dtails.permission === 0 && dtails.status !== 3 ? : null } } {Object.keys(dtails).length === 0? : { e.stopPropagation(); this.setState({ historicalIsOpened:true }) }}> 查看公出申请日志 } {Object.keys(dtails).length === 0? : 微信分享 } {this.state.isModifyOpened ? { this.setState({ isModifyOpened:false, }) }} onClose={()=>{ this.setState({ isModifyOpened:false, dtails:{} },()=>{ this.getReleasetDails(); }) }}/> : null} { this.setState({ isInquiryOpened:false, inquiryTitle:'', inquiryContent:'', }) }} onDetermine={()=>{ this.state.inquiryFn(); this.setState({ isInquiryOpened:false, inquiryTitle:'', inquiryContent:'', inquiryFn:()=>{} }) }} /> {this.state.historicalIsOpened ? { this.setState({ historicalIsOpened:false }) }} /> : null} ) } } export default EgressDetails;