bonusList.jsx 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. import React from "react";
  2. import $ from "jquery/src/ajax";
  3. import { Spin, Button, Tabs, Table, message, Modal, Input, Form } from "antd";
  4. import "@/manageCenter/financialManage/distribute/public.less";
  5. import { splitUrl } from "@/tools";
  6. import {ChooseList} from "../../order/orderNew/chooseList";
  7. const FormItem = Form.Item;
  8. const { TabPane } = Tabs;
  9. const BonusList = React.createClass({
  10. getInitialState() {
  11. return {
  12. columns: [
  13. {
  14. title: "职位名称",
  15. dataIndex: "jobsName",
  16. key: "jobsName",
  17. },
  18. {
  19. title: "级别",
  20. dataIndex: "lvlName",
  21. key: "lvlName",
  22. },
  23. {
  24. title: "研究生津贴",
  25. dataIndex: "allowance",
  26. key: "allowance",
  27. },
  28. {
  29. title: "在职奖励",
  30. dataIndex: "aliveRewards",
  31. key: "aliveRewards",
  32. },
  33. {
  34. title: "奖励",
  35. dataIndex: "rewards",
  36. key: "rewards",
  37. },
  38. {
  39. title: "二级奖励",
  40. dataIndex: "twoRewards",
  41. key: "twoRewards",
  42. },
  43. {
  44. title: "三级奖励",
  45. dataIndex: "threeRewards",
  46. key: "threeRewards",
  47. },
  48. {
  49. title: "操作",
  50. dataIndex: "caozuo",
  51. key: "caozuo",
  52. render: (text, record) => {
  53. return <Button type="primary" onClick={e => {this.editMoney(record)}}>修改金额</Button>
  54. }
  55. }
  56. ],
  57. pagination: {
  58. defaultCurrent: 1,
  59. defaultPageSize: 10,
  60. showQuickJumper: true,
  61. pageSize: 10,
  62. onChange: function (page) {
  63. this.loadData(page);
  64. }.bind(this),
  65. showTotal: function (total) {
  66. return "共" + total + "条数据";
  67. },
  68. },
  69. };
  70. },
  71. componentWillMount() {
  72. this.loadData()
  73. },
  74. loadData(pageNo) {
  75. this.state.data = [];
  76. this.setState({
  77. loading: true,
  78. });
  79. $.ajax({
  80. method: "get",
  81. dataType: "json",
  82. crossDomain: false,
  83. url: globalConfig.context + "/api/admin/personnel/selectLvlList",
  84. data: {
  85. pageNo: pageNo || 1,
  86. pageSize: this.state.pagination.pageSize,
  87. },
  88. success: function (data) {
  89. let theArr = [];
  90. if (!data.data) {
  91. if (data.error && data.error.length) {
  92. message.warning(data.error[0].message);
  93. }
  94. } else {
  95. for (let i = 0; i < data.data.length; i++) {
  96. let thisdata = data.data[i];
  97. thisdata.key = thisdata.id;
  98. theArr.push(thisdata);
  99. }
  100. }
  101. this.state.pagination.current = data.data.pageNo;
  102. this.state.pagination.total = data.data.totalCount;
  103. if (data.data && data.data.list && !data.data.list.length) {
  104. this.state.pagination.current = 0;
  105. this.state.pagination.total = 0;
  106. }
  107. this.setState({
  108. dataSource: theArr,
  109. pagination: this.state.pagination,
  110. });
  111. }.bind(this),
  112. }).always(
  113. function () {
  114. this.setState({
  115. loading: false,
  116. });
  117. }.bind(this)
  118. );
  119. },
  120. moneyOk() {
  121. this.setState({
  122. loading: true,
  123. });
  124. $.ajax({
  125. method: "post",
  126. dataType: "json",
  127. crossDomain: false,
  128. url: globalConfig.context + "/api/admin/personnel/updateLvl",
  129. data: {
  130. id: this.state.id,
  131. jobs: this.state.jobs,
  132. lvl: this.state.lvl,
  133. aliveRewards: this.state.aliveRewards,
  134. rewards: this.state.rewards,
  135. twoRewards: this.state.twoRewards,
  136. threeRewards: this.state.threeRewards,
  137. },
  138. success: function (data) {
  139. if (!data.data) {
  140. if (data.error && data.error.length) {
  141. message.warning(data.error[0].message);
  142. }
  143. } else {
  144. this.loadData()
  145. this.setState({
  146. visible: false
  147. })
  148. }
  149. }.bind(this),
  150. }).always(
  151. function () {
  152. this.setState({
  153. loading: false,
  154. });
  155. }.bind(this)
  156. );
  157. },
  158. editMoney(record) {
  159. this.setState({
  160. visible: true,
  161. id: record.id,
  162. jobs: record.jobs,
  163. lvl: record.lvl,
  164. aliveRewards: record.aliveRewards,
  165. rewards: record.rewards,
  166. twoRewards: record.twoRewards,
  167. threeRewards: record.threeRewards,
  168. });
  169. },
  170. changeList(arr) {
  171. const newArr = [];
  172. this.state.columns.forEach(item => {
  173. arr.forEach(val => {
  174. if (val === item.title) {
  175. newArr.push(item);
  176. }
  177. });
  178. });
  179. this.setState({
  180. changeList: newArr
  181. });
  182. },
  183. render() {
  184. return (
  185. <div className="user-content">
  186. <Tabs
  187. defaultActiveKey="1"
  188. onChange={this.callback}
  189. className="test">
  190. <TabPane tab="更改表格显示数据" key="1">
  191. <div style={{ marginLeft: 10 }}>
  192. <ChooseList
  193. columns={this.state.columns}
  194. changeFn={this.changeList}
  195. changeList={this.state.changeList}
  196. top={55}
  197. margin={11}
  198. />
  199. </div>
  200. </TabPane>
  201. </Tabs>
  202. <Table
  203. bordered
  204. columns={
  205. this.state.changeList
  206. ? this.state.changeList
  207. : this.state.columns
  208. }
  209. onRowClick={this.tableRowClick}
  210. dataSource={this.state.dataSource}
  211. scroll={{ x: "max-content", y: 0 }}
  212. pagination={false}
  213. size="small"
  214. />
  215. <Modal
  216. maskClosable={false}
  217. visible={this.state.visible}
  218. footer={null}
  219. width={600}
  220. onCancel={() => {
  221. this.loadData();
  222. this.setState({
  223. visible: false,
  224. });
  225. }}
  226. >
  227. <Spin spinning={this.state.loading}>
  228. <div>
  229. <h3 style={{ textAlign: "center", marginBottom: 10 }}>奖励修改</h3>
  230. <div className="clearfix" style={{ marginBottom: 10 }}>
  231. <FormItem
  232. className="half-item"
  233. labelCol={{ span: 6 }}
  234. wrapperCol={{ span: 30 }}
  235. label="在职奖励"
  236. >
  237. <Input
  238. placeholder="请输入金额"
  239. value={this.state.aliveRewards}
  240. style={{ width: 200 }}
  241. onChange={(e) => {
  242. this.setState({ aliveRewards: e.target.value });
  243. }}
  244. />
  245. </FormItem>
  246. <FormItem
  247. className="half-item"
  248. labelCol={{ span: 6 }}
  249. wrapperCol={{ span: 30 }}
  250. label="奖励"
  251. >
  252. <Input
  253. placeholder="请输入金额"
  254. value={this.state.rewards}
  255. style={{ width: 200 }}
  256. onChange={(e) => {
  257. this.setState({ rewards: e.target.value });
  258. }}
  259. />
  260. </FormItem>
  261. </div>
  262. <div className="clearfix" style={{ marginBottom: 10 }}>
  263. <FormItem
  264. className="half-item"
  265. labelCol={{ span: 6 }}
  266. wrapperCol={{ span: 30 }}
  267. label="二级奖励"
  268. >
  269. <Input
  270. placeholder="请输入金额"
  271. value={this.state.twoRewards}
  272. style={{ width: 200 }}
  273. onChange={(e) => {
  274. this.setState({ twoRewards: e.target.value });
  275. }}
  276. />
  277. </FormItem>
  278. <FormItem
  279. className="half-item"
  280. labelCol={{ span: 6 }}
  281. wrapperCol={{ span: 30 }}
  282. label="三级奖励"
  283. >
  284. <Input
  285. placeholder="请输入金额"
  286. value={this.state.threeRewards}
  287. style={{ width: 200 }}
  288. onChange={(e) => {
  289. this.setState({ threeRewards: e.target.value });
  290. }}
  291. />
  292. </FormItem>
  293. </div>
  294. </div>
  295. <Button
  296. type="primary"
  297. shape="round"
  298. size="large"
  299. style={{
  300. position: "relative",
  301. left: "50%",
  302. transform: "translateX(-50%)",
  303. }}
  304. onClick={this.moneyOk}
  305. >
  306. 保存
  307. </Button>
  308. </Spin>
  309. </Modal>
  310. </div>
  311. );
  312. },
  313. });
  314. export default BonusList;