123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- 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 (
- <div style={{ display: "inline-block" }}>
- <Button
- type={data.type}
- loading={this.state.loading}
- onClick={() => {
- this.changeModal();
- }}
- >
- {data.name}
- </Button>
- <Modal
- maskClosable={false}
- title={data.title}
- visible={false}
- onCancel={() => {
- this.changeModal();
- }}
- // onOk={_e => {
- // this.onOk(data, backData);
- // }}
- >
- <Form.Item>
- <Input.TextArea
- rows={4}
- placeholder={data.placeholder}
- value={this.state.reason}
- onChange={e => {
- // console.log(this.props);
- this.setState({
- reason: e.target.value
- });
- }}
- />
- </Form.Item>
- </Modal>
- </div>
- );
- }
- }
- const AgreeButton = Form.create()(ReasonInput);
- export default AgreeButton;
|