officialFees.js 8.7 KB

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