import React,{ Component } from 'react'; import {Button, DatePicker, Select, Table, Input, Modal, Spin, message} from "antd"; import moment from "moment"; import $ from "jquery"; const { Option } = Select; const confirm = Modal.confirm; class PatentSchedule extends Component{ constructor(props) { super(props); this.state={ columns: [ { title: '批次', dataIndex: 'key', key: 'key', render: (text, record,index) => { return index+1; } }, { title: props.bpType === 6 ? '商标号' : '专利号', dataIndex: 'patentNo', key: 'patentNo', render: (text, record,index) => { return !record.isChange ? text : { this.changeEvidence(e.target.value,index,'patentNo') }}/> } }, { title: props.bpType === 6 ? '商标名称' : '专利名称', dataIndex: 'patentName', key: 'patentName', render: (text, record,index) => { return !record.isChange ? text : { this.changeEvidence(e.target.value,index,'patentName') }}/> } }, { title: '受理时间', dataIndex: 'acceptTimes', key: 'acceptTimes', render: (text, record,index) => { return !record.isChange ? text : { this.changeEvidence(dataString,index,'acceptTimes') }} /> } }, { title: '下证时间', dataIndex: 'licenceTimes', key: 'licenceTimes', render: (text, record,index) => { return !record.isChange ? text : { this.changeEvidence(dataString,index,'licenceTimes') }} /> } }, { title: '状态', dataIndex: 'status', key: 'status', render: (text, record,index) => { return !record.isChange ? text === 0 ? '待审核' : text === 1 ? '通过' : '驳回' : { this.changeEvidence(v,index,'status') }}> 待审核 通过 驳回 } }, { title: '操作', dataIndex: 'h', key: 'h', render: (text, record,index) => { return ( !props.readOnly ? { let _this = this; if(record.isChange){ this.state.dataSource.splice(index,1) this.setState({ dataSource: this.state.dataSource }) }else{ confirm({ title: '提醒', content: '确定要删除吗?', onOk() { _this.delectTaskProgress(record.id) } }) } }} > 删除 {record.id && !record.isChange && { this.state.dataSource[index]['isChange'] = true this.setState({ dataSource: this.state.dataSource }) }}>修改} {record.isChange &&{ if(record.id){ this.changeTaskProgress(record); }else{ this.createTaskProgress(record); } }}>保存 } : null ) } } ], dataSource: [], visible: false, columnsA: [ { title: '时间', dataIndex: 'createTime', key: 'createTime', }, { title: '操作类型', dataIndex: 'status', key: 'status', render: (text, record) => { return text === 0 ? '新增' : text === 1 ? '删除' : '修改' } }, { title: '专利号', dataIndex: 'patentName', key: 'patentName', } ], dataSourceA: [], progressLogLoading: false, acceptCount: props.acceptCount || 0, certificatesCount: props.certificatesCount || 0, rejectCount: props.rejectCount || 0, }; this.changeEvidence = this.changeEvidence.bind(this); this.createTaskProgress = this.createTaskProgress.bind(this); this.selectTaskProgressLog = this.selectTaskProgressLog.bind(this); this.delectTaskProgress = this.delectTaskProgress.bind(this); this.changeTaskProgress = this.changeTaskProgress.bind(this); this.loaduserss = this.loaduserss.bind(this); } changeEvidence(value,index,key){ this.state.dataSource[index][key] = value; this.setState({ dataSource: this.state.dataSource }) } //新增申报进度 createTaskProgress(record) { if(!record.patentNo){ message.warning('请填写专利号'); return; } if(!record.patentName){ message.warning('请填写专利名称'); return; } if(typeof record.status !== 'number'){ message.warning('请选择状态'); return; } this.setState({ loading: true, }) let _this = this; let data = Object.assign({},record); delete data.isChange; delete data.key; data.taskId = this.props.taskId; data.alreadyNumber = 1; data.type = this.props.bpType === 1 ? 1 : this.props.bpType === 6 ? 2 : '';//0软著 1专利 2商标 $.ajax({ method: 'post', dataType: 'json', crossDomain: false, url: globalConfig.context + '/api/admin/orderProject/createTaskProgress', data: data, success: function (data) { if (data.error.length) { if (data.error && data.error.length) { message.warning(data.error[0].message) } }else{ message.success('添加成功'); delete record.isChange; delete record.key; _this.props.refresh && _this.props.refresh(); _this.loaduserss(); } }.bind(this), }).always( function () { this.setState({ loading: false, }) }.bind(this) ) } //申报进度日志 selectTaskProgressLog() { this.setState({ loading: true, }) $.ajax({ method: 'get', dataType: 'json', crossDomain: false, url: globalConfig.context + '/api/admin/orderProject/selectTaskProgressLog', data: { tid: this.props.taskId, }, success: function (data) { let theArr = [] if (data.error.length || data.data.list === '') { if (data.error && data.error.length) { message.warning(data.error[0].message) } } else { for (let i = 0; i < data.data.length; i++) { let thisdata = data.data[i]; thisdata.key = i; theArr.push(thisdata) } } this.setState({ dataSourceA: theArr, }) }.bind(this), }).always( function () { this.setState({ loading: false, }) }.bind(this) ) } //修改申报进度 changeTaskProgress(record) { if(!record.patentNo){ message.warning('请填写专利号'); return; } if(!record.patentName){ message.warning('请填写专利名称'); return; } if(typeof record.status !== 'number'){ message.warning('请选择状态'); return; } this.setState({ loading: true, }) let _this = this; let data = Object.assign({},record); delete data.isChange; delete data.key; data.taskId = this.props.taskId; data.alreadyNumber = 1; data.type = this.props.bpType === 1 ? 1 : this.props.bpType === 6 ? 2 : '';//0软著 1专利 2商标 for(let i in data){ if(typeof data[i] === 'object'){ delete data[i] } } $.ajax({ method: 'post', dataType: 'json', crossDomain: false, url: globalConfig.context + '/api/admin/orderProject/updateTaskProgress', data: data, success: function (data) { if (data.error.length) { if (data.error && data.error.length) { message.warning(data.error[0].message) } }else{ message.success('修改成功'); delete record.isChange; delete record.key; _this.props.refresh && _this.props.refresh(); _this.loaduserss(); } }.bind(this), }).always( function () { this.setState({ loading: false, }) }.bind(this) ) } // 删除申报进度 delectTaskProgress(id) { this.setState({ loading: true, }) let _this = this; $.ajax({ method: 'post', dataType: 'json', crossDomain: false, url: globalConfig.context + '/api/admin/orderProject/delectTaskProgress', data: { id }, success: function (data) { if (data.error.length) { if (data.error && data.error.length) { message.warning(data.error[0].message) } }else{ message.success('删除成功'); _this.loaduserss(); _this.props.refresh && this.props.refresh(); } }.bind(this), }).always( function () { this.setState({ loading: false, }) }.bind(this) ) } //查看下证信息 loaduserss() { this.setState({ progressLogLoading: true, }) $.ajax({ method: 'get', dataType: 'json', crossDomain: false, url: globalConfig.context + '/api/admin/orderProject/selectTaskProgress', data: { tid: this.props.taskId, }, success: function (data) { let thisData = [] if (!thisData) { if (data.error && data.error.length) { message.warning(data.error[0].message) } } else { this.setState({ dataSource: data.data, }) } }.bind(this), }).always( function () { this.setState({ progressLogLoading: false, }) }.bind(this) ) } componentDidMount() { this.loaduserss(); if(this.props.bpType === 1){ this.state.columns.splice(-2,0,{ title: '授权时间', dataIndex: 'authorizeTimes', key: 'authorizeTimes', render: (text, record,index) => { return !record.isChange ? text : { this.changeEvidence(dataString,index,'authorizeTimes') }} /> } }); this.setState({ columns:this.state.columns }) } } render() { return ( 派单项目数:{this.props.commodityQuantity} 受理数: {this.props.readOnly ? this.props.acceptCount: { this.setState({ acceptCount:e.target.value }) this.props.onChange('acceptCount',e.target.value); }}/> } 下证数(即授权数): {this.props.readOnly ? this.props.certificatesCount: { this.setState({ certificatesCount:e.target.value }) this.props.onChange('certificatesCount',e.target.value); }}/> } 驳回数: {this.props.readOnly ? this.props.rejectCount: { this.setState({ rejectCount:e.target.value }) this.props.onChange('rejectCount',e.target.value); }}/> } {!this.props.readOnly ? { let arr = this.state.dataSource.filter((v)=>v.isChange) if(arr.length > 0){ message.warning('已存在未保存项,请先保存!') return; } this.state.dataSource.push({ key: this.state.dataSource.length+1, isChange: true, }) this.setState({ dataSource: this.state.dataSource }) }} > {/* bpType: 0 正常 1专利 2软著 3审计 4双软 5高新 6商标*/} {this.props.bpType === 1 ? '增加专利信息' : this.props.bpType === 6 ? '增加商标信息' : ''} : null} { this.selectTaskProgressLog(); this.setState({ visible: true }) }} > 操作日志 {this.state.visible ? { this.setState({ visible: false }) }} title="操作日志" footer="" className="admin-desc-content" > : null} ) } } export default PatentSchedule;