import React, { Component } from "react"; import { View, Image, Button, Text } 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, addAssistant, deleteAssistant, } 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, unique } from "../../utils/tools"; import HistoricalClock from "../../components/historicalClock"; import UserQuery from "../../components/common/userquery"; //选择协单人弹窗 class EgressDetails extends Component { $instance = getCurrentInstance(); constructor(props) { super(props); this.state = { dtails: {}, opinion: "", publicReleaseLog: [], isDetailedOpened: false, isModifyOpened: false, reasonsInvalidation: "", isVerify: false, //判断是否在审核中修改 selectArrderLocation: {}, current: "", isNo: true, foc: false, coorderList: [], cList: [], popup: false, selid: "", }; this.examinePublicRelease = this.examinePublicRelease.bind(this); this.getReleasetDails = this.getReleasetDails.bind(this); this.oidApplication = this.oidApplication.bind(this); } componentDidMount() { this.setState({ current: this.$instance.router.params.status || "", }); 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, coorderList: v.data.assistantName != null && v.data.assistantName != "" ? v.data.assistantName.split(",") : [], cList: v.data.assistantAid != null && v.data.assistantName != "" ? v.data.assistantAid.split(",") : [], 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); }); } // 同意/驳回 agree(sta) { if (!this.state.opinion) { Taro.showToast({ title: "请填写审批意见", icon: "none" }); return; } getReleasetDails({ id: this.$instance.router.params.id, }) .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); }); } examinePublicRelease(status) { if (!this.state.opinion) { Taro.showToast({ title: "请填写审批意见", icon: "none" }); return; } Taro.showLoading({ title: "加载中..." }); let isSuperior = this.state.current == "他人公出" ? false : true examinePublicRelease( isSuperior, { status, remarks: this.state.opinion, id: this.state.dtails.id, } ) .then((v) => { Taro.hideLoading(); if (v.error.length === 0) { Taro.showToast({ title: "操作成功", icon: "none", }); this.getReleasetDails(); // 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.hideLoading(); Taro.showToast({ title: "系统错误,请稍后再试", icon: "none" }); }); } onShareAppMessage() { return { title: this.state.dtails.status === 3 ? this.state.dtails.aname + "撤销了前往" + this.state.dtails.prdList[0]?.districtName + "的公出" : this.state.dtails.aname + "将要去" + this.state.dtails.prdList[0]?.districtName, 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, uids: this.state.dtails.uids, 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, }); }); } // 弹窗开关 popupClick(id) { !this.state.popup && this.setState({ selid: id }) this.setState({ popup: !this.state.popup }) } //增加协单助力 addA(aid) { const { selid } = this.state addAssistant({ id: selid, aid, }).then((v) => { if (v.error.length === 0) { this.popupClick(); this.getReleasetDails(); } else { Taro.showToast({ title: v.error[0].message, icon: "none" }); } }).catch((err) => { Taro.showToast({ title: "系统错误,请稍后再试", icon: "none" }); }); } //删除协单助力 deleteA(id, aid) { Taro.showLoading({ title: '操作中...' }) deleteAssistant({ id, aid, }).then((v) => { Taro.hideLoading(); if (v.error.length === 0) { this.getReleasetDails(); } else { Taro.showToast({ title: v.error[0].message, icon: "none" }); } }).catch((err) => { Taro.hideLoading(); Taro.showToast({ title: "系统错误,请稍后再试", icon: "none" }); }); } render() { const { dtails, current, cList, coorderList, popup } = this.state; return ( {Object.keys(dtails).length === 0 ? ( ) : ( {dtails.type === 3 ? dtails.mainName : dtails.aname}提交的公出申请 {dtails.updateStatus == 1 && } 申请时间: {dtails.createTimes} {getClockState(dtails.status).title} { dtails.peList?.map(item => {item.aname + `(${["审核中", "已审核"][item.status]})`} ) } )} {Object.keys(dtails).length === 0 ? ( ) : ( { dtails.status != 3 && dtails.type == 3 && (current === "查看协单" || current === "我的协单") ? 协单助手(助手无成本) { coorderList.length == 0 ? : coorderList.map((item, index) => {item} { this.setState({ isInquiryOpened: true, inquiryTitle: "温馨提示", inquiryContent: "您确定要移除此协单助手吗?", inquiryFn: () => { this.deleteA(dtails.id, cList[index]) }, }); }} > ) } {cList.length < 5 && } : coorderList.length != 0 && 协单助手(助手无成本) { coorderList.map((item, index) => {item} ) } } 公出地点: {current !== "审核" && dtails.permission === 0 && dtails.type !== 3 && dtails.type !== 4 ? ( { Taro.pageScrollTo({ selector: "#reasons" }) this.setState({ foc: true, }); }} > 修改 ) : null} {/* {dtails.districtName} */} { unique(dtails.prdList, "districtName")?.map((item, index) => {item.districtName} ) } 公出{dtails.duration}小时 { e.stopPropagation(); this.setState({ isDetailedOpened: true, }); }} > 明细 {dtails.releaseStarts} {dtails.releaseEnds} { this.setState({ isDetailedOpened: false, }); }} isOpened={this.state.isDetailedOpened} > {dtails.validDate ? ( ) : null} 公出类型 {dtails.type == 0 ? "业务公出" : dtails.type == 1 ? "技术公出" : dtails.type == 2 ? "行政公出" : dtails.type == 3 ? "技术协单" : dtails.type == 4 ? "协单助手" : ""} {dtails.type == 1 ? ( 合同编号 {dtails.contractNo} ) : ( "" )} 公出企业 {/* {dtails.nickname} */} { !!dtails.userNames && dtails.userNames.indexOf(',') > -1 ? dtails.userNames.split(',')?.map((item, index) => {item}) : dtails.userNames } { dtails.assistAidName != null && dtails.assistAidName != "" && 技术协单(技术协单,将统计相关的公出成本等) {dtails.assistAidName.replace(/,/g, " ")} } {/* 公出目标 */} 公出目标 {dtails.remarks} {/* 公出计划 */} {dtails.type != 2 && ( 公出计划 {dtails.plan} )} {/* 预计效果 */} {dtails.type != 2 && ( 预计效果 {dtails.expectedEffect} )} {dtails.annexUrl && dtails.annexUrl.length > 0 ? ( 附件 ) : null} {((dtails.status === 1 && current === "审核") || (dtails.publicType == 1 && current === "他人公出" && dtails.myExamine == 0)) && 填写审批意见 根据公出申请记录指导怎么沟通?并提出详细指导建议 { this.setState({ opinion: value, }); }} maxLength={20} placeholder="请填写审批意见" /> { this.setState({ isInquiryOpened: true, inquiryTitle: "提醒", inquiryContent: "您确定要驳回此申请吗?", inquiryFn: () => { this.agree(0); // this.examinePublicRelease(0); }, }); }} > 驳回 { if (this.state.loading) { return; } this.setState({ isInquiryOpened: true, inquiryTitle: "提醒", inquiryContent: "您确定要同意此申请吗?", inquiryFn: () => { this.agree(2); // this.examinePublicRelease(2); }, }); }} > 同意 } {current !== "审核" && dtails.permission === 0 && dtails.type !== 3 && dtails.type !== 4 ? ( 修改/撤销 { this.setState({ reasonsInvalidation: value, }); }} maxLength={20} placeholder="请填写修改或撤销的详细原因" /> ) : null} {current !== "审核" && dtails.permission === 0 && dtails.type !== 3 && dtails.type !== 4 ? ( ) : 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: {}, reasonsInvalidation: "", }, () => { this.getReleasetDails(); } ); }} /> ) : null} { this.setState({ isInquiryOpened: false, inquiryTitle: "", inquiryContent: "", isNo: true, }); }} onDetermine={() => { this.state.inquiryFn(); this.setState({ isInquiryOpened: false, inquiryTitle: "", inquiryContent: "", isNo: true, inquiryFn: () => { }, }); }} /> {this.state.historicalIsOpened ? ( { this.setState({ historicalIsOpened: false, }); }} /> ) : null} {popup && } ); } } export default EgressDetails;