jsBonus11.jsx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. import React from 'react';
  2. import ajax from 'jquery/src/ajax/xhr.js';
  3. import $ from 'jquery/src/ajax';
  4. import moment from 'moment';
  5. import '../distribute/public.less';
  6. import { Button, Input, Spin, Table,Select, Switch, message, DatePicker,Modal ,Form } from 'antd';
  7. import {getTaskStatus,getBonusState,getLiquidationStatus,getJsyPaymentType} from '@/tools';
  8. import JsBonuseDetail from './jsBonusDetail';
  9. import { ChooseList } from "../../order/orderNew/chooseList";
  10. import {getProjectName} from "../../../tools";
  11. const FormItem= Form.Item;
  12. const JsBonus = React.createClass({
  13. departmentList() {
  14. this.setState({
  15. loading: true
  16. });
  17. $.ajax({
  18. method: "get",
  19. dataType: "json",
  20. crossDomain: false,
  21. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  22. data: {},
  23. success: function(data) {
  24. let thedata = data.data;
  25. let theArr = [];
  26. if (!thedata) {
  27. if (data.error && data.error.length) {
  28. message.warning(data.error[0].message);
  29. }
  30. } else {
  31. thedata.map(function(item, index) {
  32. theArr.push({
  33. key: index,
  34. name: item.name,
  35. id: item.id
  36. });
  37. });
  38. }
  39. this.setState({
  40. departmentArr: theArr
  41. });
  42. }.bind(this)
  43. }).always(
  44. function() {
  45. this.setState({
  46. loading: false
  47. });
  48. }.bind(this)
  49. );
  50. },
  51. loadData(pageNo) {
  52. this.state.data = [];
  53. this.setState({
  54. selectedRowKeys: [],
  55. selectedRowKey: [],
  56. page: pageNo,
  57. loading: true
  58. });
  59. $.ajax({
  60. method: "get",
  61. dataType: "json",
  62. crossDomain: false,
  63. url: globalConfig.context + "/api/admin/bonus/technicianBonusStatistics",
  64. data: {
  65. pageNo: pageNo || 1,
  66. pageSize: this.state.pagination.pageSize,
  67. salesName: this.state.orderRefundSearch, //订单负责人
  68. targetName: this.state.projectMenSearch, //项目负责人
  69. departmentId: this.state.departmenttList,
  70. orderNo: this.state.orderNoSearch,
  71. startTime: this.state.releaseDate[0],
  72. endTime: this.state.releaseDate[1],
  73. grantStatus: this.state.grantStatus,
  74. startTime1: this.state.createDate[0],
  75. endTime1: this.state.createDate[1]
  76. },
  77. success: function(data) {
  78. let theArr = [];
  79. if (!data.data || !data.data.list) {
  80. if (data.error && data.error.length) {
  81. message.warning(data.error[0].message);
  82. }
  83. } else {
  84. for (let i = 0; i < data.data.list.length; i++) {
  85. let thisdata = data.data.list[i];
  86. theArr.push({
  87. key: i,
  88. id: thisdata.id,
  89. tid: thisdata.tid,
  90. targetName: thisdata.targetName,
  91. orderNo: thisdata.orderNo,
  92. taskReceiver: thisdata.taskReceiver,
  93. taskStatus: thisdata.taskStatus,
  94. commodityQuantity: thisdata.commodityQuantity,
  95. projectStatus: thisdata.projectStatus,
  96. byName: thisdata.byName,
  97. commodityName: thisdata.commodityName,
  98. bonusSubject: thisdata.bonusSubject,
  99. grantStatus: thisdata.grantStatus,
  100. grantTime: thisdata.grantTime,
  101. targetName: thisdata.targetName,
  102. liquidationStatus: thisdata.liquidationStatus,
  103. licenceTime: thisdata.licenceTime,
  104. acceptTime: thisdata.acceptTime,
  105. reviewTime: thisdata.reviewTime
  106. });
  107. }
  108. }
  109. this.state.pagination.current = data.data.pageNo;
  110. this.state.pagination.total = data.data.totalCount;
  111. if (data.data && data.data.list && !data.data.list.length) {
  112. this.state.pagination.current = 0;
  113. this.state.pagination.total = 0;
  114. }
  115. this.setState({
  116. dataSource: theArr,
  117. pagination: this.state.pagination
  118. });
  119. }.bind(this)
  120. }).always(
  121. function() {
  122. this.setState({
  123. loading: false
  124. });
  125. }.bind(this)
  126. );
  127. },
  128. getInitialState() {
  129. return {
  130. searchMore: true,
  131. releaseDate: [],
  132. createDate: [],
  133. RowData: {},
  134. execState: false,
  135. selectedRowKeys: [],
  136. selectedRows: [],
  137. changeList: undefined,
  138. proofData: {},
  139. loading: false,
  140. pagination: {
  141. defaultCurrent: 1,
  142. defaultPageSize: 10,
  143. showQuickJumper: true,
  144. pageSize: 10,
  145. onChange: function(page) {
  146. this.loadData(page);
  147. }.bind(this),
  148. showTotal: function(total) {
  149. return "共" + total + "条数据";
  150. }
  151. },
  152. columns: [
  153. {
  154. title: "任务编号",
  155. dataIndex: "tid",
  156. key: "tid",
  157. // fixed: "left"
  158. },
  159. {
  160. title: "订单编号",
  161. dataIndex: "orderNo",
  162. key: "orderNo"
  163. },
  164. {
  165. title: "任务名称",
  166. dataIndex: "commodityName",
  167. key: "commodityName"
  168. },
  169. {
  170. title: "任务负责人",
  171. dataIndex: "targetName",
  172. key: "targetName"
  173. },
  174. {
  175. title: "任务状态",
  176. dataIndex: "taskStatus",
  177. key: "taskStatus",
  178. render: text => {
  179. return getTaskStatus(text);
  180. }
  181. },
  182. {
  183. title: "任务数量",
  184. dataIndex: "commodityQuantity",
  185. key: "commodityQuantity"
  186. },
  187. {
  188. title: "项目状态",
  189. dataIndex: "projectStatus",
  190. key: "projectStatus",
  191. render: text => {
  192. return getProjectName(text);
  193. }
  194. },
  195. {
  196. title: "受理日期",
  197. dataIndex: "acceptTime",
  198. key: "acceptTime"
  199. },
  200. {
  201. title: "评审日期",
  202. dataIndex: "reviewTime",
  203. key: "reviewTime"
  204. },
  205. {
  206. title: "下证日期",
  207. dataIndex: "licenceTime",
  208. key: "licenceTime"
  209. },
  210. {
  211. title: "订单结算状态",
  212. dataIndex: "liquidationStatus",
  213. key: "liquidationStatus",
  214. render: text => {
  215. return getLiquidationStatus(text);
  216. }
  217. },
  218. {
  219. title: "发放类型",
  220. dataIndex: "bonusSubject",
  221. key: "bonusSubject",
  222. render: text => {
  223. return getJsyPaymentType(text);
  224. }
  225. },
  226. {
  227. title: "发放状态",
  228. dataIndex: "grantStatus",
  229. key: "grantStatus",
  230. render: text => {
  231. return getBonusState(text);
  232. }
  233. },
  234. {
  235. title: "操作",
  236. dataIndex: "state11",
  237. key: "state11",
  238. render: (text, recard) => {
  239. return (
  240. <div>
  241. {!recard.grantStatus && (
  242. <Button
  243. type="primary"
  244. style={{ margin: "0 10px" }}
  245. onClick={e => {
  246. e.stopPropagation(), this.proofread(recard);
  247. }}
  248. >
  249. 发放
  250. </Button>
  251. )}
  252. </div>
  253. );
  254. }
  255. }
  256. ],
  257. dataSource: [],
  258. searchTime: [,]
  259. };
  260. },
  261. proofread(recard) {
  262. this.setState({
  263. boHuiVisible: true,
  264. proofData: recard
  265. });
  266. },
  267. tableRowClick(record, index) {
  268. this.state.RowData = record;
  269. this.setState({
  270. showDesc: true
  271. });
  272. },
  273. closeDesc(e, s) {
  274. this.state.RowData = {};
  275. this.state.showDesc = e;
  276. if (s) {
  277. this.loadData(this.state.page);
  278. }
  279. },
  280. componentWillMount() {
  281. this.loadData();
  282. this.departmentList();
  283. },
  284. search() {
  285. this.loadData();
  286. },
  287. boHuiOk() {
  288. this.setState({
  289. boHuiVisible: false
  290. });
  291. this.loadData(this.state.page);
  292. },
  293. boHuiCancel(e) {
  294. this.setState({
  295. boHuiVisible: false
  296. });
  297. },
  298. //导出
  299. exportExec() {
  300. let departmentName = "",
  301. depart = this.state.departmentArr || [];
  302. depart.map(item => {
  303. if (this.state.departmentId == item.id) {
  304. departmentName = item.name;
  305. return;
  306. }
  307. });
  308. let data = {
  309. departmentId: this.state.departmentId,
  310. departmentName: departmentName,
  311. salesName: this.state.orderRefundSearch, //订单负责人
  312. targetName: this.state.projectMenSearch, //项目负责人
  313. startTime: this.state.releaseDate[0],
  314. endTime: this.state.releaseDate[1],
  315. grantStatus: this.state.grantStatus,
  316. startTime1: this.state.createDate[0],
  317. endTime1: this.state.createDate[1]
  318. };
  319. window.location.href =
  320. globalConfig.context +
  321. "/api/admin/bonus/exportTechnicianBonusData?" +
  322. $.param(data);
  323. },
  324. //保存发放状态
  325. boHuiSubmit(e) {
  326. e.preventDefault();
  327. this.setState({
  328. loading: true
  329. });
  330. $.ajax({
  331. method: "POST",
  332. dataType: "json",
  333. crossDomain: false,
  334. url: globalConfig.context + "/api/admin/bonus/changeBonus",
  335. data: {
  336. id: this.state.proofData.id
  337. }
  338. }).done(
  339. function(data) {
  340. if (!data.error.length) {
  341. message.success("发放成功!");
  342. this.boHuiOk();
  343. } else {
  344. message.warning(data.error[0].message);
  345. }
  346. this.setState({
  347. loading: false
  348. });
  349. }.bind(this)
  350. );
  351. },
  352. reset() {
  353. this.state.orderRefundSearch = "";
  354. this.state.projectMenSearch = "";
  355. this.state.releaseDate = [];
  356. this.state.createDate = [];
  357. this.state.orderNoSearch = "";
  358. this.state.grantStatus = undefined;
  359. this.state.departmenttList = undefined;
  360. this.loadData();
  361. },
  362. searchSwitch() {
  363. this.setState({
  364. searchMore: !this.state.searchMore
  365. });
  366. },
  367. changeList(arr) {
  368. const newArr = [];
  369. this.state.columns.forEach(item => {
  370. arr.forEach(val => {
  371. if (val === item.title) {
  372. newArr.push(item);
  373. }
  374. });
  375. });
  376. this.setState({
  377. changeList: newArr
  378. });
  379. },
  380. render() {
  381. const rowSelection = {
  382. selectedRowKeys: this.state.selectedRowKeys,
  383. onChange: (selectedRowKeys, selectedRows) => {
  384. this.setState({
  385. selectedRows: selectedRows.slice(-1),
  386. selectedRowKeys: selectedRowKeys.slice(-1)
  387. });
  388. }
  389. };
  390. const hasSelected = this.state.selectedRowKeys.length > 0;
  391. const { RangePicker } = DatePicker;
  392. let departmentArr = this.state.departmentArr || [];
  393. return (
  394. <div className="user-content">
  395. <div className="content-title">
  396. <span>技术员奖金</span>
  397. </div>
  398. <div className="user-search">
  399. <Select
  400. placeholder="订单部门"
  401. style={{ width: 150, marginRight: 10 }}
  402. value={this.state.departmenttList}
  403. onChange={e => {
  404. this.setState({ departmenttList: e });
  405. }}
  406. >
  407. {departmentArr.map(function(item) {
  408. return <Select.Option key={item.id}>{item.name}</Select.Option>;
  409. })}
  410. </Select>
  411. <Input
  412. placeholder="订单编号"
  413. value={this.state.orderNoSearch}
  414. onChange={e => {
  415. this.setState({ orderNoSearch: e.target.value });
  416. }}
  417. />
  418. <Input
  419. placeholder="任务负责人"
  420. value={this.state.projectMenSearch}
  421. onChange={e => {
  422. this.setState({ projectMenSearch: e.target.value });
  423. }}
  424. />
  425. <Select
  426. placeholder="发放状态"
  427. style={{ width: 150, marginRight: 10 }}
  428. value={this.state.grantStatus}
  429. onChange={e => {
  430. this.setState({ grantStatus: e });
  431. }}
  432. >
  433. <Option value="0">未发放</Option>
  434. <Option value="1">已发放</Option>
  435. </Select>
  436. <Button type="primary" onClick={this.search}>
  437. 搜索
  438. </Button>
  439. <Button onClick={this.reset}>重置</Button>
  440. <Button onClick={this.exportExec} type="primary">
  441. 导出excel
  442. </Button>
  443. <span>
  444. 更多搜索
  445. <Switch
  446. defaultChecked={false}
  447. onChange={this.searchSwitch.bind(this)}
  448. />
  449. </span>
  450. <div
  451. className="search-more"
  452. style={this.state.searchMore ? { display: "none" } : {}}
  453. >
  454. <span>签单时间 :</span>
  455. <RangePicker
  456. format="YYYY-MM"
  457. value={[
  458. this.state.releaseDate[0]
  459. ? moment(this.state.releaseDate[0])
  460. : null,
  461. this.state.releaseDate[1]
  462. ? moment(this.state.releaseDate[1])
  463. : null
  464. ]}
  465. onChange={(data, dataString) => {
  466. this.setState({ releaseDate: dataString });
  467. }}
  468. />
  469. <span>创建时间 :</span>
  470. <RangePicker
  471. format="YYYY-MM-DD"
  472. value={[
  473. this.state.createDate[0]
  474. ? moment(this.state.createDate[0])
  475. : null,
  476. this.state.createDate[1]
  477. ? moment(this.state.createDate[1])
  478. : null
  479. ]}
  480. onChange={(data, dataString) => {
  481. this.setState({ createDate: dataString });
  482. }}
  483. />
  484. <ChooseList
  485. columns={this.state.columns}
  486. changeFn={this.changeList}
  487. changeList={this.state.changeList}
  488. top={55}
  489. display={"inline-block"}
  490. />
  491. </div>
  492. </div>
  493. <div className="patent-table" id="table">
  494. <Spin spinning={this.state.loading}>
  495. <Table
  496. bordered
  497. columns={
  498. this.state.changeList == undefined
  499. ? this.state.columns
  500. : this.state.changeList
  501. }
  502. dataSource={this.state.dataSource}
  503. scroll={{ x: 1500, y: 0 }}
  504. rowSelection={false}
  505. pagination={this.state.pagination}
  506. onRowClick={this.tableRowClick}
  507. bordered
  508. size="small"
  509. />
  510. </Spin>
  511. </div>
  512. <JsBonuseDetail
  513. data={this.state.RowData}
  514. showDesc={this.state.showDesc}
  515. closeDesc={this.closeDesc.bind(this)}
  516. />
  517. <Modal
  518. maskClosable={false}
  519. visible={this.state.boHuiVisible}
  520. width="400px"
  521. title="发放"
  522. footer=""
  523. onOk={this.boHuiOk}
  524. onCancel={this.boHuiCancel}
  525. >
  526. <Form layout="horizontal" onSubmit={this.boHuiSubmit}>
  527. <Spin spinning={this.state.loading}>
  528. <FormItem
  529. labelCol={{ span: 8 }}
  530. wrapperCol={{ span: 10 }}
  531. label="应收人"
  532. >
  533. <span>{this.state.proofData.targetName}</span>
  534. </FormItem>
  535. <FormItem
  536. labelCol={{ span: 8 }}
  537. wrapperCol={{ span: 10 }}
  538. label="发放人"
  539. >
  540. <span>{this.state.proofData.byName}</span>
  541. </FormItem>
  542. <FormItem wrapperCol={{ span: 12, offset: 8 }}>
  543. <Button
  544. type="primary"
  545. htmlType="submit"
  546. style={{ marginRight: 20 }}
  547. >
  548. 发放
  549. </Button>
  550. <Button
  551. type="default"
  552. onClick={() => {
  553. this.boHuiCancel();
  554. }}
  555. >
  556. 取消
  557. </Button>
  558. </FormItem>
  559. </Spin>
  560. </Form>
  561. </Modal>
  562. </div>
  563. );
  564. }
  565. });
  566. export default JsBonus;