import React, { Component } from "react"; import { Modal, Button, Input, Form, message } from "antd"; import $ from "jquery/src/ajax"; import { moneyVerify } from "@/tools.js"; class ReasonInput extends Component { constructor(props) { super(props); this.state = { visible: false, reason: this.props.reason, flag: false, flagS: false, }; this.reset = this.reset.bind(this); this.judge = this.judge.bind(this); this.onOk = this.onOk.bind(this); this.sendRequest = this.sendRequest.bind(this); this.inputAjax = this.inputAjax.bind(this); } // componentWillMount() { // let reason = this.props.reason // this.setState({ // reason // }) // // const data = this.props.data; // // const backData = this.props.backData; // // const ajaxData = this.props.ajaxData; // // Object.assign(backData, ajaxData); // // // this.sendRequest() // // this.onOk(data,backData) // // console.log("222222",this.props); // } // 理由请求 sendRequest(data, backData) { if (this.state.flagS) return this.setState({ flagS: true, loading: true, }); $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/orderChange/orderChangeAudit", data: { changeId: backData.id, remarks: this.props.reason, status: data.status, processState: this.props.processState, // 驳回位置 rejectState: this.props.rejectState }, success: function (data) { if (data.error.length === 0) { message.success("操作成功!"); this.props.visible(); this.props.onCancel(); this.setState({ flagS: !this.state.flagS }) } else { message.warning(data.error[0].message); this.setState({ flagS: !this.state.flagS, }); } }.bind(this) }).done( function () { // if (this.props.loadData) { // this.props.loadData("2"); // } this.setState({ loading: false, }) }.bind(this) ); } // 输入框请求 inputAjax(_data, backData) { if (this.state.flag) return; this.setState({ flag: true, loading: true, }) $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/orderChange/updateOrderChange", data: backData, success: function (data) { if (data.error.length === 0) { this.setState({ flag: !this.state.flag }); } else { message.warning(data.error[0].message); this.setState({ flag: !this.state.flag }); } }.bind(this) }).done( function () { this.sendRequest(this.props.data, backData); this.setState({ loading: false, }) }.bind(this) ); } reset() { this.setState({ reason: this.props.reason }); } changeModal() { this.setState( { visible: !this.state.visible }, () => { this.reset(); } ); const data = this.props.data; const backData = this.props.backData; backData.consultantExamine = [] backData.managerExamine = [] const ajaxData = this.props.ajaxData; if (ajaxData.ContactsLists) { ajaxData.ContactsLists = []; ajaxData.contactList = []; } Object.assign(backData, ajaxData); // this.sendRequest() this.onOk(data, backData) // this.setState({reason: this.props.reason}) // console.log(this.props,this.state) } judge() { if (!this.props.reason) { message.error("理由不能为空!"); return false; } if (!this.props.reason.replace(/\s+/g, '')) { message.error("理由不能为空!"); return; } } onOk(data, backData) { // console.log(this.props); if (!this.props.reason) { message.error("理由不能为空!"); return false; } if (!this.props.reason.replace(/\s+/g, '')) { message.error("理由不能为空!"); return; } if (this.props.data.status == 2 && this.props.processState == 6) { if ( moneyVerify(this.props.ajaxData.cwCost) || moneyVerify(this.props.ajaxData.cwIndirectCost) || moneyVerify(this.props.ajaxData.refundableAmount) ) { return; } } if ( this.props.processState <= 2 || this.props.processState == 5 || this.props.processState >= 7 ) { // 判断权限是否大于营销管理员 this.sendRequest(data, backData); } else { this.inputAjax(data, backData); } // data.onChange(this.state.reason); } render() { const { visible } = this.state; const data = this.props.data; const backData = this.props.backData; const ajaxData = this.props.ajaxData; Object.assign(backData, ajaxData); return (