officialFees.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. import React,{Component} from 'react';
  2. import {Button, Input, message, Select, Spin, Table, Modal, Popconfirm, Tabs} from "antd";
  3. import AddOfficialFeePrice from './addOfficialFeePrice'
  4. import $ from "jquery/src/ajax";
  5. import '../content.less';
  6. import {ChooseList} from "../../order/orderNew/chooseList";
  7. const TabPane = Tabs.TabPane;
  8. class OfficialFees extends Component{
  9. constructor(props) {
  10. super(props);
  11. this.state={
  12. type:'',
  13. dataSource: [],
  14. columns: [
  15. {
  16. title: '专利类型',
  17. dataIndex: 'type',
  18. key: 'type',
  19. render: (text) => {
  20. return text === 0 ? '实用新型' : text === 1 ? '外观专利' : '发明专利'
  21. }
  22. },
  23. {
  24. title: '全额(万元)',
  25. dataIndex: 'amount',
  26. key: 'amount',
  27. },
  28. {
  29. title: '减缴85%',
  30. dataIndex: 'proportion85',
  31. key: 'proportion85',
  32. },
  33. {
  34. title: '备注',
  35. dataIndex: 'remarks',
  36. key: 'remarks',
  37. },
  38. {
  39. title: '操作',
  40. dataIndex: 'id',
  41. key: 'id',
  42. render: (text) => {
  43. return <div>
  44. <Popconfirm
  45. title="是否删除?"
  46. onConfirm={() => {
  47. this.deleteOfficialFeePrice(text);
  48. }}
  49. okText="删除"
  50. cancelText="不删除"
  51. >
  52. <Button type="danger" onClick={(e) => {
  53. e.stopPropagation()
  54. }}>
  55. 删除
  56. </Button>
  57. </Popconfirm>
  58. </div>
  59. }
  60. },
  61. ],
  62. addSoftVisible: false,
  63. infor: {},
  64. }
  65. this.loadData = this.loadData.bind(this);
  66. this.tableRowClick = this.tableRowClick.bind(this);
  67. this.reset = this.reset.bind(this);
  68. this.changeList = this.changeList.bind(this);
  69. }
  70. componentDidMount() {
  71. this.loadData();
  72. }
  73. //搜索功能和初始列表加载
  74. loadData() {
  75. this.setState({
  76. loading: true,
  77. });
  78. $.ajax({
  79. method: "get",
  80. dataType: "json",
  81. crossDomain: false,
  82. url: globalConfig.context + '/api/admin/company/listOfficialFeePrice',
  83. data: {
  84. type:this.state.type, //名称
  85. },
  86. success: function (data) {
  87. if (!data.data || !data.data) {
  88. if (data.error && data.error.length) {
  89. message.warning(data.error[0].message);
  90. };
  91. } else {
  92. data.data.map((v,i)=>{v.key = i})
  93. this.setState({
  94. dataSource: data.data,
  95. });
  96. };
  97. }.bind(this),
  98. }).always(function () {
  99. this.setState({
  100. loading: false
  101. });
  102. }.bind(this));
  103. }
  104. tableRowClick(infor) {
  105. this.setState({
  106. addSoftVisible : true,
  107. infor: infor
  108. })
  109. }
  110. reset(){
  111. this.setState({
  112. type:'', //名称
  113. },()=>{
  114. this.loadData();
  115. })
  116. }
  117. //删除
  118. deleteOfficialFeePrice(id) {
  119. let _this = this;
  120. this.setState({
  121. loading: true
  122. });
  123. $.ajax({
  124. method: "post",
  125. dataType: "json",
  126. crossDomain: false,
  127. url:globalConfig.context + '/api/admin/company/deleteOfficialFeePrice',
  128. data:{
  129. id: id
  130. },
  131. }).done(function (data) {
  132. _this.setState({
  133. loading: false
  134. });
  135. if (!data.error.length) {
  136. message.success('删除成功!');
  137. _this.loadData();
  138. } else {
  139. message.warning(data.error[0].message);
  140. }
  141. }.bind(this));
  142. }
  143. changeList(arr) {
  144. const newArr = [];
  145. this.state.columns.forEach(item => {
  146. arr.forEach(val => {
  147. if (val === item.title) {
  148. newArr.push(item);
  149. }
  150. });
  151. });
  152. this.setState({
  153. changeList: newArr
  154. });
  155. }
  156. render() {
  157. return(
  158. <div className="user-content" >
  159. <div className="content-title">
  160. <Tabs defaultActiveKey="1" className="test">
  161. <TabPane tab="操作" key="1">
  162. <div className="user-search" style={{display:'flex',flexFlow:'row',marginBottom:'10px'}}>
  163. <span style={{marginLeft: 'auto'}}>
  164. <Button type="primary" size={'middle'} onClick={()=>{
  165. this.setState({
  166. addSoftVisible : true
  167. })
  168. }}>
  169. 增加
  170. </Button>
  171. </span>
  172. </div>
  173. </TabPane>
  174. <TabPane tab="更改表格显示数据" key="2">
  175. <div style={{ marginLeft: 10 }}>
  176. <ChooseList
  177. columns={this.state.columns}
  178. changeFn={this.changeList}
  179. changeList={this.state.changeList}
  180. top={55}
  181. margin={11}
  182. />
  183. </div>
  184. </TabPane>
  185. </Tabs>
  186. <div className="patent-table">
  187. <Spin spinning={this.state.loading}>
  188. <Table size="middle" columns={
  189. this.state.changeList
  190. ? this.state.changeList
  191. : this.state.columns
  192. }
  193. dataSource={this.state.dataSource}
  194. pagination={false}
  195. style={{
  196. cursor: 'pointer',
  197. }}
  198. onRowClick={this.tableRowClick}/>
  199. </Spin>
  200. </div>
  201. </div>
  202. {this.state.addSoftVisible ? <AddOfficialFeePrice
  203. infor={this.state.infor}
  204. visible={this.state.addSoftVisible}
  205. onCancel={()=>{
  206. this.setState({
  207. addSoftVisible : false,
  208. infor: {},
  209. })
  210. }}
  211. successFn={()=>{
  212. this.loadData();
  213. this.setState({
  214. addSoftVisible : false,
  215. infor: {}
  216. })
  217. }}/> : <div/>}
  218. </div>
  219. )
  220. }
  221. }
  222. export default OfficialFees