jsBonus.jsx 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  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, Tabs } from 'antd';
  7. import { getProjectName, getTaskStatus, getBonusState, getLiquidationStatus, getJsyPaymentType } from '@/tools';
  8. import JsBonuseDetail from './jsBonusDetail';
  9. import { ChooseList } from "../../order/orderNew/chooseList";
  10. const FormItem = Form.Item;
  11. const { TabPane } = Tabs
  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", display: this.props.isLook ? "none" : "inline-block" }}
  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" style={{ marginBottom: 10 }}>
  396. <span style={{ fontWeight: 900, fontSize: 16 }}>技术员奖金</span>
  397. </div>
  398. <div className="user-search">
  399. <Tabs
  400. defaultActiveKey="1"
  401. onChange={this.callback}
  402. className="test">
  403. <TabPane tab="搜索" key="1">
  404. <Select
  405. placeholder="订单部门"
  406. style={{ width: 150, marginRight: 10, marginLeft: 10, marginBottom: 10 }}
  407. value={this.state.departmenttList}
  408. onChange={e => {
  409. this.setState({ departmenttList: e });
  410. }}
  411. >
  412. {departmentArr.map(function (item) {
  413. return <Select.Option key={item.id}>{item.name}</Select.Option>;
  414. })}
  415. </Select>
  416. <Input
  417. placeholder="订单编号"
  418. value={this.state.orderNoSearch}
  419. style={{ width: 150, marginRight: 10 }}
  420. onChange={e => {
  421. this.setState({ orderNoSearch: e.target.value });
  422. }}
  423. />
  424. <Input
  425. placeholder="任务负责人"
  426. value={this.state.projectMenSearch}
  427. style={{ width: 150, marginRight: 10 }}
  428. onChange={e => {
  429. this.setState({ projectMenSearch: e.target.value });
  430. }}
  431. />
  432. <Select
  433. placeholder="发放状态"
  434. style={{ width: 150, marginRight: 10 }}
  435. value={this.state.grantStatus}
  436. onChange={e => {
  437. this.setState({ grantStatus: e });
  438. }}
  439. >
  440. <Option value="0">未发放</Option>
  441. <Option value="1">已发放</Option>
  442. </Select>
  443. <Button type="primary" onClick={this.search} style={{ marginRight: 10 }}>
  444. 搜索
  445. </Button>
  446. <Button onClick={this.reset} style={{ marginRight: 10 }}>重置</Button>
  447. <span>
  448. 更多搜索
  449. <Switch
  450. defaultChecked={false}
  451. onChange={this.searchSwitch.bind(this)}
  452. />
  453. </span>
  454. <div
  455. className="search-more"
  456. style={this.state.searchMore ? { display: "none" } : {}}
  457. >
  458. <span style={{ marginLeft: 10 }}>签单时间 :</span>
  459. <RangePicker
  460. format="YYYY-MM"
  461. value={[
  462. this.state.releaseDate[0]
  463. ? moment(this.state.releaseDate[0])
  464. : null,
  465. this.state.releaseDate[1]
  466. ? moment(this.state.releaseDate[1])
  467. : null
  468. ]}
  469. onChange={(data, dataString) => {
  470. this.setState({ releaseDate: dataString });
  471. }}
  472. />
  473. <span>创建时间 :</span>
  474. <RangePicker
  475. format="YYYY-MM-DD"
  476. value={[
  477. this.state.createDate[0]
  478. ? moment(this.state.createDate[0])
  479. : null,
  480. this.state.createDate[1]
  481. ? moment(this.state.createDate[1])
  482. : null
  483. ]}
  484. onChange={(data, dataString) => {
  485. this.setState({ createDate: dataString });
  486. }}
  487. />
  488. </div>
  489. </TabPane>
  490. <TabPane tab="导出" key="2">
  491. <Button onClick={this.exportExec} type="primary" style={{ margin: 10 }}>
  492. 导出excel
  493. </Button>
  494. </TabPane>
  495. <TabPane tab="更改表格数据" key="3">
  496. <div style={{ margin: 10, marginBottom: 0 }}>
  497. <ChooseList
  498. columns={this.state.columns}
  499. changeFn={this.changeList}
  500. changeList={this.state.changeList}
  501. top={55}
  502. display={"inline-block"}
  503. />
  504. </div>
  505. </TabPane>
  506. </Tabs>
  507. </div>
  508. <div className="patent-table" id="table">
  509. <Spin spinning={this.state.loading}>
  510. <Table
  511. bordered
  512. columns={
  513. this.state.changeList == undefined
  514. ? this.state.columns
  515. : this.state.changeList
  516. }
  517. dataSource={this.state.dataSource}
  518. scroll={{ x: 1500, y: 0 }}
  519. rowSelection={false}
  520. pagination={this.state.pagination}
  521. onRowClick={this.tableRowClick}
  522. bordered
  523. size="small"
  524. />
  525. </Spin>
  526. </div>
  527. <JsBonuseDetail
  528. data={this.state.RowData}
  529. showDesc={this.state.showDesc}
  530. closeDesc={this.closeDesc.bind(this)}
  531. />
  532. <Modal
  533. visible={this.state.boHuiVisible}
  534. width="400px"
  535. title="发放"
  536. footer=""
  537. onOk={this.boHuiOk}
  538. onCancel={this.boHuiCancel}
  539. >
  540. <Form layout="horizontal" onSubmit={this.boHuiSubmit}>
  541. <Spin spinning={this.state.loading}>
  542. <FormItem
  543. labelCol={{ span: 8 }}
  544. wrapperCol={{ span: 10 }}
  545. label="应收人"
  546. >
  547. <span>{this.state.proofData.targetName}</span>
  548. </FormItem>
  549. <FormItem
  550. labelCol={{ span: 8 }}
  551. wrapperCol={{ span: 10 }}
  552. label="发放人"
  553. >
  554. <span>{this.state.proofData.byName}</span>
  555. </FormItem>
  556. <FormItem wrapperCol={{ span: 12, offset: 8 }}>
  557. <Button
  558. type="primary"
  559. htmlType="submit"
  560. style={{ marginRight: 20 }}
  561. >
  562. 发放
  563. </Button>
  564. <Button
  565. type="default"
  566. onClick={() => {
  567. this.boHuiCancel();
  568. }}
  569. >
  570. 取消
  571. </Button>
  572. </FormItem>
  573. </Spin>
  574. </Form>
  575. </Modal>
  576. </div>
  577. );
  578. }
  579. });
  580. export default JsBonus;