import React, { Component } from "react"; import Taro, { getCurrentInstance } from "@tarojs/taro"; import { Text, View, Picker } from "@tarojs/components"; import ImagePicker from "../../components/common/imagePicker"; import InquiryModal from "../../components/common/inquiryModal"; import { getPridDetail, getAccountList, selectList, AccountExamine, } from "../../utils/servers/servers"; import { getAccountName, getTypeName, getVehicleName, commonAdd, } from "../../utils/tools"; import { AtTextarea, AtButton } from "taro-ui"; import { resourceAddress } from "../../utils/config"; import "taro-ui/dist/style/components/form.scss"; import "taro-ui/dist/style/components/button.scss"; import "taro-ui/dist/style/components/loading.scss"; import "taro-ui/dist/style/components/icon.scss"; import "taro-ui/dist/style/components/icon.scss"; import "taro-ui/dist/style/components/textarea.scss"; import "taro-ui/dist/style/components/input.scss"; import "../drafts/index.less"; class Drafts extends Component { $instance = getCurrentInstance(); constructor(props) { super(props); this.state = { data: {}, list: [], total: 0, bankData: {}, reason: "", }; } componentDidMount() { this.$instance.router.params && this.$instance.router.params.id && ( this.getDetail(), this.getAccountList() ) } // 报销账户列表 getMyList(id) { let data = { pageNo: 1, pageSize: 99, } selectList(data).then(v => { if (v.error.length === 0) { let list = v.data.list || [] for (var i = 0; i < list.length; i++) { if (list[i].aid == id) { this.setState({ bankData: list[i] }) } } } else { Taro.showToast({ title: v.error[0].message, icon: 'none' }) } }).catch(() => { Taro.showToast({ title: '系统错误,请稍后再试', icon: 'none' }) }) } // 报销单详情 getDetail() { getPridDetail({ id: this.$instance.router.params.id, }).then(v => { if (v.error.length === 0) { let list = []; for (let i of (v.data.attachmentUrl || '').split(',')) { if (i) { list.push({ 'url': resourceAddress + i }) } } this.setState({ data: v.data, rangeStartMinuteVal: v.data.releaseStartStr, rangeEndMinuteVal: v.data.releaseEndStr, totalDuration: v.data.duration, attachmentUrl: list, }) // v.data.aid && this.getMyList(v.data.aid) } else { Taro.showToast({ title: v.error[0].message, icon: 'none' }) } }).catch(() => { Taro.showToast({ title: '系统错误,请稍后再试', icon: 'none' }) }) } // 报销详情金额列表 getAccountList() { getAccountList({ eaid: this.$instance.router.params.id, }).then(v => { if (v.error.length === 0) { let sum = 0 for (var i = 0; i < v.data.length; i++) { // sum += v.data[i].amount sum = commonAdd(sum, v.data[i].amount) } this.setState({ list: v.data, total: sum, }) } else { Taro.showToast({ title: v.error[0].message, icon: 'none' }) } }).catch(() => { Taro.showToast({ title: '系统错误,请稍后再试', icon: 'none' }) }) } // 审批 examine(val) { Taro.showLoading({ title: '处理中...' }); AccountExamine({ id: this.state.data.id, reason: this.state.reason, status: val, }) .then((v) => { Taro.hideLoading(); if (v.error.length === 0) { Taro.showToast({ title: "操作成功", icon: "none", }); this.getDetail() } else { Taro.showToast({ title: v.error[0].message, icon: "none" }); } }) .catch((err) => { Taro.showToast({ title: "系统错误,请稍后再试", icon: "none" }); }); } render() { const { data, list, total, bankData, attachmentUrl } = this.state return ( {getAccountName(data.type, data.typeOther)} {data.type == 1 && 公出企业: {data.userNames} } {data.type == 1 && 公出地点: {data.districtName} } {data.type == 1 && 公出时间: { this.setState({ isPickerRender: true, }); }} > {this.state.rangeStartMinuteVal}   至   {this.state.rangeEndMinuteVal} } {data.type == 1 && 公出时长: {this.state.totalDuration}小时 } 申请类型: {getAccountName(data.type, data.typeOther)} {data.type != 4 && data.type != 5 && 报销至订单: {data.buyerName} {data.contractNo} } {(data.type == 4 || data.type == 5) ? "申请详细" : "报销详细"} 申请人: {data.aname} { data.type != 4 && data.type != 5 && 报销公司: {data.appDepName} } {data.type == 4 ? "预借支公司:" : data.type == 5 ? "抵扣公司:" : "支付公司:"} {data.payDepName} {(data.type == 4 || data.type == 5) ? "说明:" : "报销事由:"} {data.remarks} {data.type != 4 && data.type != 5 && "报销"}费用详细 {/* 差旅费显示 */} {data.type == 1 && list?.map(item => item.type == 1 ? 交通工具: {getVehicleName(item.vehicle, item.vehicleOther)} 时间: {item.startTimeStr}   至   {item.endTimeStr} 地点: {item.startDistrict}   至   {item.endDistrict} 金额(元): {item.amount}(元) : {getTypeName(item.type) + ":"} {item.amount}(元) ) } {/* 通用 */} {(data.type == 0 || data.type == 2 || data.type == 4 || data.type == 5) && list?.map(item => {data.type == 5 ? "支付时间:" : "需付款时间:"} {item.agreeTimeStr.slice(0, 10)} {data.type == 4 ? "预借支金额:" : data.type == 5 ? "抵扣金额:" : "金额:"} {item.amount}(元) ) } {/* 第三方付款 */} {data.type == 3 && list?.map(item => 需付款时间: {item.agreeTimeStr.slice(0, 10)} 付款方式: {["公对公转账"][item.payType]} 发票类型: {["普票", "专票"][item.invoiceType]} 发票号: {item.invoiceNo} 付款单位: {item.payerName} 开户银行: {item.openBank} 银行账户: {item.bankAccounts} 开户行地址: {item.openBankAddress} 金额(元): {item.amount} ) } { data.type != 4 && data.debitTotalAmount && 预借支: {data.debitTotalAmount}(元) } { data.type != 4 && data.type != 5 && 总金额: {total}(元) } { data.type != 4 && data.type != 5 && 实报金额: {(total > data.debitTotalAmount) ? commonAdd(total, -data.debitTotalAmount) : 0} (元) } 附件: {attachmentUrl && attachmentUrl.length > 0 && } {data.type != 3 && data.type != 5 && 报销至收款账户 } {data.type != 3 && data.type != 5 && { 收款人:{data.name} 收款银行:{data.bank} 收款账户:{data.accounts} } } { data.examine == 1 && 填写审批意见 { this.setState({ reason: value, }); }} maxLength={30} placeholder="请填写审批意见" /> { if (!this.state.reason) { Taro.showToast({ title: "请先填写审批意见", icon: "none" }); return; } this.setState({ isInquiryOpened: true, inquiryTitle: "提醒", inquiryContent: "您确定要驳回此申请吗?", inquiryFn: () => { this.examine(3); }, }); }} > 驳回 { if (!this.state.reason) { Taro.showToast({ title: "请先填写审批意见", icon: "none" }); return; } this.setState({ isInquiryOpened: true, inquiryTitle: "提醒", inquiryContent: "您确定要同意此申请吗?", inquiryFn: () => { this.examine(1); }, }); }} > 同意 } {/* 二级确认弹窗 */} { this.setState({ isInquiryOpened: false, inquiryTitle: "", inquiryContent: "", isNo: true, }); }} onDetermine={() => { this.state.inquiryFn(); this.setState({ isInquiryOpened: false, inquiryTitle: "", inquiryContent: "", isNo: true, inquiryFn: () => { }, }); }} /> ); } } export default Drafts;