addPicModal.jsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import React from "react";
  2. import { Spin, Button, Tabs, Table, message, Modal, Upload, Form, Input } from "antd";
  3. import { splitUrl } from "@/tools";
  4. import PicturesWall from "./picturesWall";
  5. import "./remove.less"
  6. const FormItem = Form.Item;
  7. const AddPicModal = React.createClass({
  8. getInitialState() {
  9. return {
  10. newVisible: false,
  11. rotateDeg: 0,
  12. voucherUrl: [],
  13. };
  14. },
  15. componentWillReceiveProps(nextProps) {
  16. this.setState({
  17. newVisible: nextProps.ShowModal,
  18. });
  19. },
  20. handleOk() {
  21. this.setState({
  22. newVisible: false,
  23. });
  24. },
  25. add() {
  26. if(this.state.voucherUrl.length == 0) {
  27. message.warning("请上传图片")
  28. return
  29. }
  30. if(this.state.remarks == "" || this.state.remarks == undefined) {
  31. message.warning("请填写图片备注")
  32. return
  33. }
  34. this.props.add(this.state.voucherUrl[0].response.data, this.state.remarks);
  35. this.setState({
  36. voucherUrl: [],
  37. remarks: undefined,
  38. });
  39. },
  40. getVoucherUrl(e) {
  41. this.setState({
  42. voucherUrl: e,
  43. });
  44. },
  45. cancel() {
  46. this.props.cancel()
  47. this.setState({
  48. voucherUrl: [],
  49. remarks: undefined
  50. })
  51. },
  52. render() {
  53. return (
  54. <Modal
  55. maskClosable={false}
  56. visible={this.props.visible}
  57. width={400}
  58. okText={"保存"}
  59. style={{ zIndex: 9999 }}
  60. onOk={this.add}
  61. onCancel={this.cancel}
  62. >
  63. <div className="clearfix">
  64. <FormItem
  65. className="half-item"
  66. labelCol={{ span: 6 }}
  67. wrapperCol={{ span: 30 }}
  68. label="附件"
  69. >
  70. <PicturesWall
  71. domId={'addPicModal1'}
  72. fileList={this.getVoucherUrl}
  73. pictureUrl={this.state.voucherUrl}
  74. url="/api/admin/personnel/uploadFile"
  75. sign="personnel_file"
  76. />
  77. </FormItem>
  78. <FormItem
  79. className="half-item"
  80. labelCol={{ span: 6 }}
  81. wrapperCol={{ span: 30 }}
  82. label="备注"
  83. >
  84. <Input
  85. placeholder="输入备注"
  86. style={{ width: 80 }}
  87. value={this.state.remarks}
  88. onChange={(e) => {
  89. this.setState({
  90. remarks: e.target.value,
  91. });
  92. }}
  93. />
  94. </FormItem>
  95. </div>
  96. </Modal>
  97. );
  98. },
  99. });
  100. export default AddPicModal;