import React, { Component } from "react"; import { Modal, Form, Row, Col, Table, Spin, message, Button, Input, Select, DatePicker, Popconfirm, Tooltip } from "antd"; import $ from "jquery/src/ajax"; import moment from 'moment'; import ReminderLog from "../../customer/NEW/crm/reminderLog"; import { getPatentType } from "@/tools.js"; import { patentTypeList } from '@/dataDic.js'; const FormItem = Form.Item; const formItemLayout = { labelCol: { span: 10 }, wrapperCol: { span: 14 }, }; class PatentDetails extends Component { constructor(props) { super(props); this.state = { columns: [ { title: "序号", dataIndex: "key", key: "key", width: '50px' }, { title: "费用种类", dataIndex: "years", key: "years", width: '150px', render: (text) => ( {getPatentType(this.props.detailsInfor.type)} 第 {text} 年年费 ) }, { title: "金额", dataIndex: "patentAmount", key: "patentAmount", width: '100px' }, { title: "缴费日", dataIndex: "endDate", key: "endDate", width: '100px', render: (text) => ( moment(text).format('YYYY-MM-DD') ) }, ], dataSource: [], loading: false, detailsInfor: {}, } this.payLoadData = this.payLoadData.bind(this); this.onChange = this.onChange.bind(this); } componentDidMount() { this.payLoadData(); const { detailsInfor, readOnly } = this.props; if (!readOnly) { this.setState({ patentNo: detailsInfor.patentNo, tid: detailsInfor.tid, email: detailsInfor.email, name: detailsInfor.name, type: detailsInfor.type, holders: detailsInfor.holders, inventor: detailsInfor.inventor, applyDates: detailsInfor.applyDates, authorizationDates: detailsInfor.authorizationDates, annualFeeStatus: detailsInfor.annualFeeStatus, delayingAmount: detailsInfor.delayingAmount, recoveryAmount: detailsInfor.recoveryAmount, }) } } payLoadData() { this.setState({ loading: true, }); const { detailsInfor } = this.props; $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/patentNew/patentPaymentDetails", data: { id: detailsInfor.id }, success: function (data) { if (data.error.length === 0) { for (let i = 0; i < data.data.length; i++) { data.data[i].key = i + 1; } this.setState({ dataSource: data.data, }); } else { message.warning(data.error[0].message); } }.bind(this), }).always( function () { this.setState({ loading: false, }); }.bind(this) ); } onChange() { if (!this.state.patentNo) { message.warning('请输入专利号') return; } if (!this.state.name) { message.warning('请输入专利名称') return; } if (isNaN(parseInt(this.state.type))) { message.warning('请选择专利类型') return; } if (!this.state.applyDates) { message.warning('请选择申请日期') return; } if (!isNaN(parseInt(this.state.delayingAmount)) && this.state.delayingAmount < 0) { message.warning('滞纳金不能小于零') return; } if (!isNaN(parseInt(this.state.recoveryAmount)) && this.state.recoveryAmount < 0) { message.warning('权利恢复费不能小于零') return; } this.setState({ loading: true, }); const { detailsInfor } = this.props; $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/patentNew/updatePatentNew", data: { id: detailsInfor.id, patentNo: this.state.patentNo, name: this.state.name, type: this.state.type, applyDates: this.state.applyDates, tid: this.state.tid || undefined, email: this.state.email || undefined, holders: this.state.holders || undefined, inventor: this.state.inventor || undefined, authorizationDates: this.state.authorizationDates || undefined, annualFeeStatus: isNaN(parseInt(this.state.annualFeeStatus)) ? undefined : this.state.annualFeeStatus, delayingAmount: isNaN(parseInt(this.state.delayingAmount)) ? undefined : this.state.delayingAmount, recoveryAmount: isNaN(parseInt(this.state.recoveryAmount)) ? undefined : this.state.recoveryAmount, }, success: function (data) { if (data.error.length === 0) { message.success('修改成功'); this.props.onRefresh(); this.props.onCancel(); } else { message.warning(data.error[0].message); } }.bind(this), }).always( function () { this.setState({ loading: false, }); }.bind(this) ); } render() { const { detailsInfor, readOnly } = this.props; return ( { this.setState({ visible: true, id: detailsInfor.id }) }} style={{ position: 'absolute', top: '9px', right: '49px', }} type='primary'> 查看专利日志 { readOnly ? detailsInfor.patentNo : { this.setState({ patentNo: e.target.value }) }} /> } { readOnly ? detailsInfor.name : { this.setState({ name: e.target.value }) }} /> } { readOnly ? getPatentType(detailsInfor.type) : { this.setState({ type: e }); }} > {patentTypeList.map(function (item) { return ( {item.key} ); })} } { readOnly ? detailsInfor.applyDates : { this.setState({ applyDates: date ? moment(date).format('YYYY-MM-DD') : '', }) }} /> } { readOnly ? detailsInfor.tid : { this.setState({ tid: e.target.value }) }} /> } { readOnly ? detailsInfor.authorizationDates : { this.setState({ authorizationDates: date ? moment(date).format('YYYY-MM-DD') : '', }) }} /> } { readOnly ? {detailsInfor.email}} > {detailsInfor.email} : { this.setState({ email: e.target.value }) }} /> } { readOnly ? detailsInfor.delayingAmount : { this.setState({ delayingAmount: e.target.value }) }} /> } { readOnly ? detailsInfor.recoveryAmount : { this.setState({ recoveryAmount: e.target.value }) }} /> } { readOnly ? ( detailsInfor.annualFeeStatus === 0 ? '待缴费' : detailsInfor.annualFeeStatus === 1 ? '已缴费' : '' ) : { this.setState({ annualFeeStatus: e }) }}> 待缴费 已缴费 } { readOnly ? {detailsInfor.holders} : { this.setState({ holders: e.target.value }) }} /> } { readOnly ? {detailsInfor.inventor} : { this.setState({ inventor: e.target.value }) }} /> } {detailsInfor.patentAmount} {detailsInfor.tid ? (detailsInfor.costReduction === 1 ? '有费减' : detailsInfor.costReduction === 0 ? '无费减' : '') : '无'} { detailsInfor.salesmanRemind === 0 ? '未通知' : detailsInfor.salesmanRemind === 1 ? '已通知' : '' } {!readOnly ? { e.stopPropagation(); this.onChange(); }} okText="确定" cancelText="取消"> { e.stopPropagation(); }} > 确定提交 : null} { this.state.visible ? { this.setState({ visible: false, id: undefined }) }} /> : null } ) } } export default PatentDetails;