123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- import React, { Component } from "react";
- import { message, Modal, Spin, Form, Select, Input, Button, Tag } from "antd";
- import $ from "jquery/src/ajax";
- // 发起投资
- class LaunchInvest extends Component {
- constructor(props) {
- super(props);
- this.state = {
- loading: false,
- alist: [
- { lable: "100万", value: "100" },
- { lable: "50万", value: "50" },
- { lable: "30万", value: "30" },
- { lable: "20万", value: "20" },
- { lable: "10万", value: "10" },
- ],
- list: [],
- };
- this.onChange = this.onChange.bind(this);
- this.onBlur = this.onBlur.bind(this);
- }
- componentDidMount() {
- const { details = false } = this.props
- this.getList()
- if (!!details) {
- this.setState({
- otherAmbId: details.acceptAmbId, // 对方阿米巴
- amount: details.amount.toString(), // 金额
- comment: details.comment, // 备注
- })
- }
- }
- // 获取下级列表信息
- getList() {
- $.ajax({
- method: "get",
- dataType: "json",
- crossDomain: false,
- url: globalConfig.context + "/api/admin/amb/Invest/getInvestAmbList",
- data: {
- id: this.props.myAmbId
- },
- success: function (data) {
- if (data.error && data.error.length === 0) {
- if (data.data) {
- this.setState({
- list: data.data || []
- });
- }
- } else {
- message.warning(data.error[0].message);
- }
- }.bind(this),
- }).always(
- function () {
- }.bind(this)
- );
- }
- onChange(e) {
- const { value } = e.target;
- const reg = /^-?(0|[1-9][0-9]*)(\.[0-9]*)?$/;
- if ((!isNaN(value) && reg.test(value)) || value === '') {
- this.setState({
- amount: value
- })
- }
- }
- onBlur() {
- const { amount } = this.state
- if (!!amount && amount.charAt(amount.length - 1) === '.') {
- this.setState({
- amount: amount.slice(0, -1)
- })
- }
- }
- onSubmit() {
- const { myAmbId, onCancel, details = false } = this.props
- const { otherAmbId, amount, comment } = this.state
- if (!otherAmbId) {
- message.warning("请选择您需投人的下级单位");
- return
- }
- if (!amount) {
- message.warning("请填写您的投资款");
- return
- }
- if (!comment) {
- message.warning("请填写备注说明");
- return
- }
- this.setState({
- loading: true
- })
- // 发起
- let infor = {
- myAmbId, // 我的阿米巴
- otherAmbId, // 对方阿米巴
- amount, // 金额
- comment, // 备注
- status: 1, // 状态 0草稿 1发起
- }
- // 重新发起
- let infor1 = {
- myAmbId, // 我的阿米巴
- otherAmbId, // 对方阿米巴
- amount, // 金额
- comment, // 备注
- status: 1, // 状态 0草稿 1发起
- id: details.id,
- }
- $.ajax({
- method: "POST",
- dataType: "json",
- crossDomain: false,
- url: globalConfig.context +
- (
- !!details
- ? "/api/admin/amb/Invest/updateTransfer"
- : "/api/admin/amb/Invest/addTransfer"
- ),
- data: !!details ? infor1 : infor,
- }).done(
- function (data) {
- this.setState({
- loading: false,
- });
- if (!data.error.length) {
- message.success("发起成功!");
- onCancel(true)
- } else {
- message.warning(data.error[0].message);
- }
- }.bind(this)
- );
- }
- render() {
- const { alist, list } = this.state
- const { visible, onCancel, details = false } = this.props
- const FormItem = Form.Item;
- const formItemLayout = {
- labelCol: { span: 4 },
- wrapperCol: { span: 16 },
- };
- return (
- <Modal
- maskClosable={false}
- visible={visible == "invest"}
- title=""
- footer=""
- width="800px"
- onCancel={() => { onCancel(false) }}
- >
- <Spin spinning={this.state.loading}>
- <div>
- <div style={{ textAlign: "center", fontSize: "20px", marginBottom: 40 }}>发起投资</div>
- <Form>
- <FormItem
- {...formItemLayout}
- label={<span><span style={{ color: "red" }}>*</span>投入单位</span>}
- >
- <Select
- showSearch
- style={{ width: 200 }}
- placeholder="请选择您需投人的下级单位"
- value={this.state.otherAmbId}
- optionFilterProp="children"
- onChange={e => { this.setState({ otherAmbId: e }) }}
- filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
- >
- {
- list.map((item) =>
- <Option value={item.id} key={item.id}>{item.name}</Option>
- )
- }
- </Select>
- </FormItem>
- <FormItem
- {...formItemLayout}
- label={<span><span style={{ color: "red" }}>*</span>投资款(万元)</span>}
- >
- <Input
- placeholder="请填写您的投资款"
- style={{ width: 200, marginRight: 20 }}
- value={this.state.amount}
- onChange={this.onChange}
- onBlur={this.onBlur}
- />
- {
- alist.map((item) =>
- <Tag
- key={item.value}
- color={this.state.amount == item.value && "#108ee9"}
- onClick={() => {
- this.setState({
- amount: item.value
- })
- }}
- >{item.lable}</Tag>
- )
- }
- </FormItem>
- <FormItem
- {...formItemLayout}
- label={<span><span style={{ color: "red" }}>*</span>备注</span>}
- >
- <Input
- type="textarea"
- placeholder="备注说明"
- autosize={{ minRows: 4 }}
- value={this.state.comment}
- onChange={(e) => {
- this.setState({ comment: e.target.value });
- }}
- />
- </FormItem>
- <FormItem
- wrapperCol={{ span: 12, offset: 9 }}
- >
- <div style={{ marginTop: 30 }}>
- <Button
- type="primary"
- onClick={() => {
- this.onSubmit();
- }}
- >
- {!!details ? "重新发起" : "确定投资"}
- </Button>
- <Button
- type="ghost"
- style={{ marginLeft: 20 }}
- onClick={() => { onCancel(false) }}
- >
- 取消
- </Button>
- </div>
- </FormItem>
- </Form>
- </div>
- </Spin>
- </Modal>
- );
- }
- }
- export default LaunchInvest;
|