123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- import React,{Component} from 'react';
- import {Button, Input, message, Select, Spin, Table, Modal, Popconfirm, Tabs} from "antd";
- import AddPatentPrice from './addPatentPrice'
- import $ from "jquery/src/ajax";
- import '../content.less';
- import {ChooseList} from "../../order/orderNew/chooseList";
- const TabPane = Tabs.TabPane;
- class PatentFees extends Component{
- constructor(props) {
- super(props);
- this.state={
- type:'',
- dataSource: [],
- columns: [
- {
- title: '公司名称',
- dataIndex: 'companyName',
- key: 'companyName',
- },
- {
- title: '实用新型(万元)',
- dataIndex: 'utilityModel',
- key: 'utilityModel',
- },
- {
- title: '外观专利(万元)',
- dataIndex: 'appearancePatent',
- key: 'appearancePatent',
- },
- {
- title: '发明专利(万元)',
- dataIndex: 'inventionPatent',
- key: 'inventionPatent',
- },
- {
- title: '备注',
- dataIndex: 'remarks',
- key: 'remarks',
- },
- {
- title: '操作',
- dataIndex: 'id',
- key: 'id',
- render: (text) => {
- return <div>
- <Popconfirm
- title="是否删除?"
- onConfirm={() => {
- this.deleteOfficialFeePrice(text);
- }}
- okText="删除"
- cancelText="不删除"
- >
- <Button type="danger" onClick={(e) => {
- e.stopPropagation()
- }}>
- 删除
- </Button>
- </Popconfirm>
- </div>
- }
- },
- ],
- addSoftVisible: false,
- infor: {},
- }
- this.loadData = this.loadData.bind(this);
- this.tableRowClick = this.tableRowClick.bind(this);
- this.reset = this.reset.bind(this);
- this.changeList = this.changeList.bind(this);
- }
- componentDidMount() {
- this.loadData();
- }
-
- loadData() {
- this.setState({
- loading: true,
- });
- $.ajax({
- method: "get",
- dataType: "json",
- crossDomain: false,
- url: globalConfig.context + '/api/admin/company/listPatentPrice',
- data: {
- type:this.state.type,
- },
- success: function (data) {
- if (!data.data || !data.data) {
- if (data.error && data.error.length) {
- message.warning(data.error[0].message);
- };
- } else {
- data.data.map((v,i)=>{v.key = i})
- this.setState({
- dataSource: data.data,
- });
- };
- }.bind(this),
- }).always(function () {
- this.setState({
- loading: false
- });
- }.bind(this));
- }
- tableRowClick(infor) {
- this.setState({
- addSoftVisible : true,
- infor: infor
- })
- }
- reset(){
- this.setState({
- type:'',
- },()=>{
- this.loadData();
- })
- }
-
- deleteOfficialFeePrice(id) {
- let _this = this;
- this.setState({
- loading: true
- });
- $.ajax({
- method: "post",
- dataType: "json",
- crossDomain: false,
- url:globalConfig.context + '/api/admin/company/deletePatentPrice',
- data:{
- id: id
- },
- }).done(function (data) {
- _this.setState({
- loading: false
- });
- if (!data.error.length) {
- message.success('删除成功!');
- _this.loadData();
- } else {
- message.warning(data.error[0].message);
- }
- }.bind(this));
- }
- changeList(arr) {
- const newArr = [];
- this.state.columns.forEach(item => {
- arr.forEach(val => {
- if (val === item.title) {
- newArr.push(item);
- }
- });
- });
- this.setState({
- changeList: newArr
- });
- }
- render() {
- return(
- <div className="user-content" >
- <div className="content-title">
- <Tabs defaultActiveKey="1" className="test">
- <TabPane tab="搜索" key="1">
- <div className="user-search" style={{display:'flex',flexFlow:'row',marginBottom:'10px'}}>
- <span style={{marginLeft: 'auto'}}>
- <Button type="primary" size={'middle'} onClick={()=>{
- this.setState({
- addSoftVisible : true
- })
- }}>
- 增加
- </Button>
- </span>
- </div>
- </TabPane>
- <TabPane tab="更改表格显示数据" key="2">
- <div style={{ marginLeft: 10 }}>
- <ChooseList
- columns={this.state.columns}
- changeFn={this.changeList}
- changeList={this.state.changeList}
- top={55}
- margin={11}
- />
- </div>
- </TabPane>
- </Tabs>
- <div className="patent-table">
- <Spin spinning={this.state.loading}>
- <Table size="middle" columns={
- this.state.changeList
- ? this.state.changeList
- : this.state.columns
- }
- dataSource={this.state.dataSource}
- pagination={false}
- style={{
- cursor: 'pointer',
- }}
- onRowClick={this.tableRowClick}/>
- </Spin>
- </div>
- </div>
- {this.state.addSoftVisible ? <AddPatentPrice
- infor={this.state.infor}
- visible={this.state.addSoftVisible}
- onCancel={()=>{
- this.setState({
- addSoftVisible : false,
- infor: {},
- })
- }}
- successFn={()=>{
- this.loadData();
- this.setState({
- addSoftVisible : false,
- infor: {}
- })
- }}/> : <div/>}
- </div>
- )
- }
- }
- export default PatentFees
|