bonusList.jsx 7.8 KB

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