| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522 | import React, { Component } from "react";import { Button, Modal, message, Input, Form, Spin, } from "antd";import $ from "jquery/src/ajax";import "./index.less";import { splitUrl } from '@/tools';import ImgList from "../imgList";/** *  */const PicturesWall = React.createClass({  getInitialState() {    return {      previewVisible: false,      previewImage: "",      fileList: this.props.pictureUrl,    };  },  getDefaultProps() {    return {      changeClick: this.modifyChange,    };  },  handleCancel() {    this.setState({ previewVisible: false });  },  handlePreview(file) {    this.setState({      previewImage: file.url || file.thumbUrl,      previewVisible: true,    });  },  handleChange(info) {    let fileList = info.fileList;    this.setState({ fileList });    this.props.fileList(fileList);  },  componentWillReceiveProps(nextProps) {    this.state.fileList = nextProps.pictureUrl;  },  render() {    const { fileList } = this.state;    return (      <div style={{ display: "inline-block" }}>        <ImgList          domId={this.props.domId}          uploadConfig={{            action: globalConfig.context + "/api/admin/orderProject/uploadStopFile",            data: { sign: "projectStopFile" },            multiple: true,            listType: "picture-card",          }}          onChange={(infor) => {            this.handleChange(infor);          }}          fileList={fileList}        />      </div>    );  },});class MySuspend extends Component {  constructor(props) {    super(props);    this.state = {      reason: "", //原因      orgCodeUrl: [], //附件      loading: false,      logList: [], //日志      emVisible: false, //审核弹窗      emReason: "", //审核说明    };    this.onOks = this.onOks.bind(this);    this.getOrgCodeUrl = this.getOrgCodeUrl.bind(this);  }  componentDidMount() {    const { rowData, type, again = false } = this.props    type == "details" && !!rowData && !!rowData.id && this.getLog(rowData.id)    if (again) {      this.setState({        reason: rowData.reason,        orgCodeUrl: splitUrl(rowData.annexUrl, ",", globalConfig.avatarHost + "/upload"),      })    }  }  // 日志  getLog(id) {    this.setState({      loading: true,    });    $.ajax({      method: "get",      dataType: "json",      url: globalConfig.context + "/api/admin/orderProject/projectStopList",      data: {        taskStopId: id,      },      success: function (data) {        if (data.error.length === 0) {          this.setState({            logList: data.data || [],          });        } else {          message.warning(data.error[0].message);        }      }.bind(this),    }).always(      function () {        this.setState({          loading: false,        });      }.bind(this)    );  }  // 确定  onOks() {    const { selectedRowKeys, subClose, title } = this.props    let annexUrl = []    if (this.state.orgCodeUrl.length) {      let annexArr = [];      this.state.orgCodeUrl.map(function (item) {        if (          item.response &&          item.response.data &&          item.response.data.length        ) {          annexArr.push(item.response.data);        }      });      annexUrl = annexArr.join(",");    }    if (typeof annexUrl !== "string") {      message.warning("请上传附件!");      return    }    if (!this.state.reason) {      message.warning("请填写原因!");      return    }    if (!this.state.reason.replace(/\s+/g, '')) {      message.warning("请填写原因!");      return;    }    this.setState({      loading: true,    });    let infor = {      ids: selectedRowKeys.toString(),      type: title == "项目重启" ? 1 : 0, //0=项目暂停,1=项目重启      reason: this.state.reason, //原因      annexUrl: annexUrl.length ? annexUrl : undefined,//附件,    }    $.ajax({      method: "POST",      dataType: "json",      crossDomain: false,      url: globalConfig.context + "/api/admin/orderProject/addProjectStop",      data: infor,    }).done(      function (data) {        this.setState({          loading: false,        });        if (!data.error.length) {          message.success("操作成功!");          subClose()        } else {          message.warning(data.error[0].message);        }      }.bind(this)    );  }  // 重新  onAgain() {    const { subClose, title, rowData } = this.props    let annexUrl = []    if (this.state.orgCodeUrl.length) {      let annexArr = [];      this.state.orgCodeUrl.map(function (item) {        if (          item.response &&          item.response.data &&          item.response.data.length        ) {          annexArr.push(item.response.data);        }      });      annexUrl = annexArr.join(",");    }    if (typeof annexUrl !== "string") {      message.warning("请上传附件!");      return    }    if (!this.state.reason) {      message.warning("请填写原因!");      return    }    if (!this.state.reason.replace(/\s+/g, '')) {      message.warning("请填写原因!");      return;    }    this.setState({      loading: true,    });    let infor = {      stopId: rowData.id, //暂停编号      type: title == "项目重启" ? 1 : 0, //0=项目暂停,1=项目重启      reason: this.state.reason, //原因      annexUrl: annexUrl.length ? annexUrl : undefined,//附件,    }    $.ajax({      method: "POST",      dataType: "json",      crossDomain: false,      url: globalConfig.context + "/api/admin/orderProject/updateProjectStop",      data: infor,    }).done(      function (data) {        this.setState({          loading: false,        });        if (!data.error.length) {          message.success("重新发起成功!");          subClose()        } else {          message.warning(data.error[0].message);        }      }.bind(this)    );  }  // 图片添加  getOrgCodeUrl(e) {    this.setState({ orgCodeUrl: e });  }  // 关闭审核弹窗  emCancel() {    const { subClose } = this.props    this.setState({      emVisible: false,      emReason: "",    }, () => {      subClose()    })  }  // 项目审核  examineProjectStop(status) {    if (!this.state.emReason) {      message.warning("请填写审核说明~");      return;    }    if (!this.state.emReason.replace(/\s+/g, '')) {      message.warning("请填写审核说明~");      return;    }    this.setState({      loading: true,    });    $.ajax({      method: "POST",      dataType: "json",      crossDomain: false,      url: globalConfig.context + "/api/admin/orderProject/examineProjectStop",      data: {        taskStopId: this.props.rowData.id,        reason: this.state.emReason,        status,      },    }).done(      function (data) {        if (!data.error.length) {          this.setState({            loading: false,          })          message.success("审核成功!");          this.emCancel()        } else {          message.warning(data.error[0].message);        }      }.bind(this)    );  }  render() {    const { visible, title, orderNo, userName, contractNo, isApproved = false,      subClose, selectedRows, type, reason, annexUrl, rowData,    } = this.props    const { logList } = this.state    const FormItem = Form.Item;    const formItemLayout = {      labelCol: { span: 3 },      wrapperCol: { span: 20 },    };    return (      <Modal        maskClosable={false}        visible={visible}        width={"700px"}        title=""        footer=""        onCancel={subClose}      >        <Spin spinning={this.state.loading}>          <div className="clearfix">            <div className="tittle">{title}</div>            <div style={{ marginLeft: 20 }}>              <div style={{ marginBottom: 10 }}>                {type != "details" && "请您确定,是否将"}                订单号:{orderNo},客户:{userName},合同编号:{contractNo}                {type != "details" && ("的项目进行" + (title == "项目重启" ? "重启" : "暂停"))}              </div>              <div>{title == "项目重启" ? "重启" : "暂停"}项目清单:</div>              {                selectedRows.length > 0 && selectedRows.map((item, index) =>                  <div                    key={item.id}                    style={{ marginLeft: 20 }}                  >{index + 1}{"、" + item.commodityName + "-" + item.id}</div>                )              }            </div>            <Form>              <div className="clearfix" style={{ marginTop: 20 }}>                {                  type == "details" ?                    <FormItem                      {...formItemLayout}                      label={title == "项目重启" ? "重启原因" : "暂停原因"}                    >                      {reason}                    </FormItem> :                    <FormItem                      {...formItemLayout}                      label={<span><span style={{ color: "red" }}>*</span>{title == "项目重启" ? "重启原因" : "暂停原因"}</span>}                    >                      <Input                        type="textarea"                        placeholder=""                        autosize={{ minRows: 3 }}                        value={this.state.reason}                        onChange={(e) => {                          this.setState({ reason: e.target.value });                        }}                      />                      <span>                        点击“确定{title == "项目重启" ? "重启" : "暂停"}”,                        审核通过后,项目状态更改为“{title == "项目重启" ? "正常" : "暂停"}”,                        技术人员将暂停此项目的相关服务!                      </span>                    </FormItem>                }              </div>              <div className="clearfix">                {                  type == "details" ?                    <FormItem                      {...formItemLayout}                      label="附件"                    >                      <ImgList fileList={splitUrl(annexUrl, ",", globalConfig.avatarHost + "/upload")} domId={"details"} />                    </FormItem> :                    <FormItem                      {...formItemLayout}                      label={<span><span style={{ color: "red" }}>*</span>上传附件</span>}                    >                      <PicturesWall                        fileList={this.getOrgCodeUrl}                        pictureUrl={this.state.orgCodeUrl}                      />                      <p>图片建议:要清晰。</p>                      <p style={{ color: "red" }}>可上传与客户协议或截图等信息</p>                    </FormItem>                }              </div>              {                type != "details" &&                <div className="clearfix">                  <FormItem                    wrapperCol={{ span: 12, offset: 7 }}                    className="half-middle"                  >                    <Button                      className="submitSave"                      type="primary"                      onClick={() => {                        this.props.again                          ? this.onAgain()                          : this.onOks()                      }}                    >                      {                        this.props.again                          ? "重新发起"                          : (title == "项目重启" ? "确定重启" : "确定暂停")                      }                    </Button>                    <Button                      className="submitSave"                      type="primary"                      onClick={subClose}                    >                      取消                    </Button>                  </FormItem>                </div>              }              {                // 日志                type == "details" &&                <div style={{ marginLeft: 20, marginBottom: 20 }}>                  {                    logList.map((item) =>                      <div key={item.id}>                        {item.createName + ":" + item.createTimes + " "}                        <span style={{ color: ["", "green", "red"][item.status], fontWeight: "bold" }}>                          {" " + ["【发起】", "【通过】", "【拒绝】"][item.status] + " "}                        </span>                        {"备注:" + item.reason}                      </div>                    )                  }                </div>              }              {                !!rowData && rowData.stopStatus == 0 && isApproved &&                <div className="clearfix">                  <FormItem                    wrapperCol={{ span: 12, offset: 10 }}                    className="half-middle"                  >                    <Button                      type="primary"                      onClick={() => {                        this.setState({                          emVisible: true,                        })                      }}                    >                      审核                    </Button>                  </FormItem>                </div>              }            </Form>          </div>        </Spin >        {          // 项目审核          this.state.emVisible &&          <Modal            visible={this.state.emVisible}            width="500px"            title="项目审核"            footer=""            onCancel={() => { this.setState({ emVisible: false }) }}          >            <Form>              <Spin spinning={this.state.loading}>                <FormItem                  labelCol={{ span: 5 }}                  wrapperCol={{ span: 16 }}                  label={                    <span>                      <strong style={{ color: "#f00" }}>*</strong>                      备注                    </span>                  }                >                  <Input                    type="textarea"                    rows={4}                    placeholder="请填写审核说明"                    value={this.state.emReason}                    onChange={(e) => {                      this.setState({ emReason: e.target.value });                    }}                  />                </FormItem>                <FormItem wrapperCol={{ span: 12, offset: 5 }}>                  <Button                    type="primary"                    onClick={() => { this.examineProjectStop(1) }}                    style={{ marginRight: 20 }}                  >                    同意                  </Button>                  <Button                    type="primary"                    onClick={() => { this.examineProjectStop(2) }}                    style={{ marginRight: 20 }}                  >                    驳回                  </Button>                  <Button                    type="default"                    onClick={() => { this.setState({ emVisible: false }) }}                  >                    取消                  </Button>                </FormItem>              </Spin>            </Form>          </Modal>        }      </Modal >    );  }}export default MySuspend;
 |