settlementManagement.jsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. "use strict";
  2. import React from 'react';
  3. import ReactDom from 'react-dom';
  4. import ajax from 'jquery/src/ajax/xhr.js';
  5. import $ from 'jquery/src/ajax';
  6. import { Form, Radio, Icon, Button, Input, Select, Spin, Table, Switch, message, DatePicker, Modal, Upload, Popconfirm } from 'antd';
  7. import ManagementDetaile from "./managementDetaile.jsx";
  8. import moment from 'moment';
  9. import '../../userMangagement.less';
  10. import { orderState, orderChannel, orderType } from '../../../../dataDic.js';
  11. import { getProjectState, getOrderChannel, getOrderType, getOrderState, getPaymentState, getApprovedState } from '../../../../tools.js';
  12. const SettlementManage = Form.create()(React.createClass({
  13. loadData(pageNo) {
  14. this.state.data = [];
  15. this.setState({
  16. loading: true
  17. });
  18. $.ajax({
  19. method: "post",
  20. dataType: "json",
  21. crossDomain: false,
  22. url: globalConfig.context + '/api/admin/order/listAllSettlement',
  23. data: {
  24. pageNo: pageNo || 1,
  25. pageSize: this.state.pagination.pageSize,
  26. buyerName: this.state.buyerNameSearch,
  27. depId: this.state.departmenttSearch, //部门
  28. salesmanName: this.state.salesmanNameSearch, //负责人
  29. startDate: this.state.releaseDate[0],
  30. endDate: this.state.releaseDate[1],
  31. liquidationStatus: this.state.liquidationStatusSearch, //结算
  32. orderStatus: this.state.orderStatusSearch,
  33. orderChannel: this.state.orderChannelSearch,
  34. financeName: this.state.financeNameSearchs,
  35. orderType: this.state.orderTypeSearch,
  36. orderNo: this.state.orderNoSearch,
  37. isDistributionFinance: this.state.isDistributionFinance
  38. },
  39. success: function(data) {
  40. let theArr = [];
  41. if(!data.data) {
  42. if(data.error && data.error.length) {
  43. message.warning(data.error[0].message);
  44. };
  45. } else {
  46. for(let i = 0; i < data.data.list.length; i++) {
  47. let thisdata = data.data.list[i];
  48. theArr.push({
  49. key: i,
  50. id: thisdata.id,
  51. orderNo: thisdata.orderNo, //订单编号
  52. orderType: thisdata.orderType, //订单类型
  53. orderStatus: thisdata.orderStatus,
  54. liquidationStatus: thisdata.liquidationStatus,
  55. createTime: thisdata.createTime,
  56. buyerName: thisdata.buyerName,
  57. signTotalAmount: thisdata.signTotalAmount,
  58. projectStage: thisdata.projectStage,
  59. approval: thisdata.approval,
  60. orderChannel: thisdata.orderChannel,
  61. salesmanName: thisdata.salesmanName,
  62. active: thisdata.active,
  63. departmentName: thisdata.departmentName,
  64. salesmanName: thisdata.salesmanName,
  65. financeName: thisdata.financeName,
  66. technicianName: thisdata.technicianName,
  67. });
  68. };
  69. this.state.pagination.current = data.data.pageNo;
  70. this.state.pagination.total = data.data.totalCount;
  71. };
  72. if(!data.data.list.length) {
  73. this.state.pagination.current = 0
  74. this.state.pagination.total = 0
  75. }
  76. this.setState({
  77. pageNo: pageNo,
  78. dataSource: theArr,
  79. pagination: this.state.pagination,
  80. selectedRowKeys: [],
  81. signBillVisible: false
  82. });
  83. }.bind(this),
  84. }).always(function() {
  85. this.setState({
  86. loading: false
  87. });
  88. }.bind(this));
  89. },
  90. //部门
  91. departmentList() {
  92. this.setState({
  93. loading: true
  94. });
  95. $.ajax({
  96. method: "get",
  97. dataType: "json",
  98. crossDomain: false,
  99. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  100. data: {
  101. },
  102. success: function(data) {
  103. let thedata = data.data;
  104. let theArr = [];
  105. if(!thedata) {
  106. if(data.error && data.error.length) {
  107. message.warning(data.error[0].message);
  108. };
  109. thedata = {};
  110. } else {
  111. thedata.map(function(item, index) {
  112. theArr.push({
  113. key: index,
  114. name: item.name,
  115. id: item.id,
  116. })
  117. })
  118. }
  119. this.setState({
  120. departmentArr: theArr,
  121. })
  122. }.bind(this),
  123. }).always(function() {
  124. this.setState({
  125. loading: false
  126. });
  127. }.bind(this));
  128. },
  129. getInitialState() {
  130. return {
  131. datauser: {},
  132. selectedRowKeys: [],
  133. releaseDate: [],
  134. selectedRows: [],
  135. departmentArr: [],
  136. searchMore: true,
  137. loading: false,
  138. distributionVisible: false,
  139. visible: false,
  140. showDesc: false,
  141. pagination: {
  142. defaultCurrent: 1,
  143. defaultPageSize: 10,
  144. showQuickJumper: true,
  145. pageSize: 10,
  146. onChange: function(page) {
  147. this.loadData(page);
  148. }.bind(this),
  149. showTotal: function(total) {
  150. return '共' + total + '条数据';
  151. }
  152. },
  153. columns: [{
  154. title: '订单编号',
  155. dataIndex: 'orderNo',
  156. key: 'orderNo'
  157. }, {
  158. title: '订单类型',
  159. dataIndex: 'orderType',
  160. key: 'orderType',
  161. render: text => {
  162. return getOrderType(text)
  163. }
  164. }, {
  165. title: '下单时间',
  166. dataIndex: 'createTime',
  167. key: 'createTime'
  168. }, {
  169. title: '订单客户',
  170. dataIndex: 'buyerName',
  171. key: 'buyerName',
  172. render: (text) => {
  173. return(text && text.length > 9 ? text.substr(0, 9) + '...' : text)
  174. }
  175. }, {
  176. title: '实际下单金额(万元)',
  177. dataIndex: 'signTotalAmount',
  178. key: 'signTotalAmount'
  179. }, {
  180. title: '订单状态',
  181. dataIndex: 'orderStatus',
  182. key: 'orderStatus',
  183. render: (text) => {
  184. return getOrderState(text)
  185. }
  186. }, {
  187. title: '结算状态',
  188. dataIndex: 'liquidationStatus',
  189. key: 'liquidationStatus',
  190. render: text => {
  191. return getPaymentState(text)
  192. }
  193. }, {
  194. title: '项目状态',
  195. dataIndex: 'projectStage',
  196. key: 'projectStage',
  197. render: text => {
  198. return getProjectState(text)
  199. }
  200. }, {
  201. title: '是否特批',
  202. dataIndex: 'approval',
  203. key: 'approval',
  204. render: text => {
  205. return getApprovedState(text)
  206. }
  207. }, {
  208. title: '订单部门',
  209. dataIndex: 'departmentName',
  210. key: 'departmentName',
  211. }, {
  212. title: '订单负责人',
  213. dataIndex: 'salesmanName',
  214. key: 'salesmanName',
  215. }, {
  216. title: '财务负责人',
  217. dataIndex: 'financeName',
  218. key: 'financeName',
  219. }, {
  220. title: '项目负责人',
  221. dataIndex: 'technicianName',
  222. key: 'technicianName',
  223. }, {
  224. title: '操作',
  225. dataIndex: 'operation',
  226. key: 'operation',
  227. render: (text, record, index) => {
  228. return <div>
  229. {!record.financeName&&<Button style={{marginRight:'5px'}} onClick={(e) =>{ e.stopPropagation(),this.confirmDelet(record)}} type="primary">派单</Button>}
  230. </div>
  231. }
  232. }],
  233. userList: [{
  234. title: '用户编号',
  235. dataIndex: 'userNo',
  236. key: 'userNo'
  237. }, {
  238. title: '用户姓名',
  239. dataIndex: 'name',
  240. key: 'name'
  241. }, {
  242. title: '部门机构',
  243. dataIndex: 'departmentName',
  244. key: 'departmentName'
  245. }, {
  246. title: '职务',
  247. dataIndex: 'position',
  248. key: 'position'
  249. }, {
  250. title: '联系手机',
  251. dataIndex: 'mobile',
  252. key: 'mobile'
  253. }, {
  254. title: '操作',
  255. dataIndex: 'abc',
  256. key: 'abc',
  257. render: (text, record, index) => {
  258. return(
  259. <Popconfirm title={'您确认将订单 【'+ this.state.orderNot+'】 分配给【'+record.departmentName+'-'+record.name+'】进行业务跟进?'} onConfirm={(e)=>{this.confirmSelect(record)}} okText="确认" cancelText="取消">
  260. <Button style={{marginRight:'5px'}} type="primary">选定</Button>
  261. </Popconfirm>
  262. )
  263. }
  264. }],
  265. dataSource: [],
  266. };
  267. },
  268. //操作分配
  269. confirmDelet(index) {
  270. this.setState({
  271. orderNot: index.orderNo,
  272. userDetaile: false,
  273. distributionVisible: true
  274. });
  275. },
  276. distributionCancel() {
  277. this.setState({
  278. distributionVisible: false
  279. })
  280. },
  281. distributionOk() {
  282. this.setState({
  283. distributionVisible: false
  284. })
  285. },
  286. //分配对象列表
  287. contactList() {
  288. $.ajax({
  289. method: "get",
  290. dataType: "json",
  291. crossDomain: false,
  292. url: globalConfig.context + '/api/admin/superviser/adminList',
  293. data: {
  294. pageNo: 1,
  295. pageSize: 99,
  296. departmentId: this.state.departmenttList,
  297. name: this.state.financeNameSearch,
  298. },
  299. success: function(data) {
  300. let theArr = [];
  301. if(!data.data) {
  302. if(data.error && data.error.length) {
  303. message.warning(data.error[0].message);
  304. };
  305. } else {
  306. for(let i = 0; i < data.data.list.length; i++) {
  307. let thisdata = data.data.list[i];
  308. theArr.push({
  309. key: i,
  310. id: thisdata.id,
  311. userNo: thisdata.userNo,
  312. name: thisdata.name,
  313. departmentName: thisdata.departmentName,
  314. departmentId: thisdata.departmentId,
  315. position: thisdata.position,
  316. mobile: thisdata.mobile,
  317. });
  318. };
  319. };
  320. this.setState({
  321. distributionList: theArr,
  322. });
  323. }.bind(this),
  324. }).always(function() {
  325. this.setState({
  326. loading: false
  327. });
  328. }.bind(this));
  329. },
  330. //选定对象
  331. confirmSelect(record) {
  332. this.setState({
  333. loading: true
  334. });
  335. $.ajax({
  336. method: "POST",
  337. dataType: "json",
  338. crossDomain: false,
  339. url: globalConfig.context + "/api/admin/order/distributionOrder",
  340. data: {
  341. orderNo: this.state.orderNot,
  342. financeId: record.id
  343. }
  344. }).done(function(data) {
  345. if(!data.error.length) {
  346. message.success('分派成功!');
  347. this.setState({
  348. loading: false,
  349. });
  350. this.distributionOk();
  351. } else {
  352. message.warning(data.error[0].message);
  353. };
  354. this.loadData(this.state.pageNo);
  355. }.bind(this));
  356. },
  357. componentWillMount() {
  358. this.departmentList();
  359. this.loadData();
  360. },
  361. tableRowClick(record, index) {
  362. this.state.userDetaile = true;
  363. this.state.datauser = record;
  364. this.setState({
  365. showDesc: true
  366. });
  367. },
  368. closeDesc(e, s) {
  369. this.state.userDetaile = false;
  370. this.state.showDesc = e;
  371. if(s) {
  372. this.loadData(this.state.pageNo);
  373. };
  374. },
  375. searchSwitch() {
  376. this.setState({
  377. searchMore: !this.state.searchMore
  378. });
  379. },
  380. search() {
  381. this.loadData();
  382. },
  383. //分配时搜索
  384. searchOrder() {
  385. this.contactList();
  386. },
  387. //分配时重置
  388. resetOrder() {
  389. this.setState({
  390. departmenttList: undefined,
  391. financeNameSearch: ''
  392. })
  393. },
  394. reset() {
  395. this.state.buyerNameSearch = '';
  396. this.state.financeNameSearchs = '';
  397. this.state.orderNoSearch = '';
  398. this.state.releaseDate[0] = undefined;
  399. this.state.releaseDate[1] = undefined;
  400. this.state.orderChannelSearch = undefined;
  401. this.state.liquidationStatusSearch = undefined;
  402. this.state.orderStatusSearch = undefined;
  403. this.state.salesmanNameSearch = undefined;
  404. this.state.departmenttSearch = undefined;
  405. this.state.approved = undefined;
  406. this.state.orderChannelSearch = undefined;
  407. this.state.orderTypeSearch = undefined;
  408. this.state.isDistributionFinance = undefined;
  409. this.loadData();
  410. },
  411. render() {
  412. const rowSelection = {
  413. selectedRowKeys: this.state.selectedRowKeys,
  414. onChange: (selectedRowKeys, selectedRows) => {
  415. this.setState({
  416. selectedRows: selectedRows.slice(-1),
  417. selectedRowKeys: selectedRowKeys.slice(-1)
  418. });
  419. },
  420. onSelectAll: (selected, selectedRows, changeRows) => {
  421. this.setState({
  422. selectedRowKeys: []
  423. })
  424. },
  425. };
  426. let departmentArr = this.state.departmentArr || [];
  427. const hasSelected = this.state.selectedRowKeys.length > 0;
  428. const {
  429. RangePicker
  430. } = DatePicker;
  431. return(
  432. <div className="user-content" >
  433. <div className="content-title">
  434. <span style={{fontSize:'16px'}}>结算订单管理</span>
  435. <div className="user-search">
  436. <Input placeholder="客户名称" style={{width:'150px'}}
  437. value={this.state.buyerNameSearch}
  438. onChange={(e) => { this.setState({ buyerNameSearch: e.target.value }); }} />
  439. <RangePicker
  440. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  441. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  442. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  443. <Select placeholder="订单部门"
  444. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  445. value={this.state.departmenttSearch}
  446. onChange={(e) => { this.setState({ departmenttSearch: e }) }}>
  447. {
  448. departmentArr.map(function (item) {
  449. return <Select.Option key={item.id} >{item.name}</Select.Option>
  450. })
  451. }
  452. </Select>
  453. <Input placeholder="订单负责人" style={{width:'150px'}}
  454. value={this.state.salesmanNameSearch}
  455. onChange={(e) => { this.setState({ salesmanNameSearch: e.target.value }); }} />
  456. <Input placeholder="财务负责人" style={{width:'150px'}}
  457. value={this.state.financeNameSearchs}
  458. onChange={(e) => { this.setState({ financeNameSearchs: e.target.value }); }} />
  459. <Button type="primary" onClick={this.search} style={{marginLeft:'10px'}}>搜索</Button>
  460. <Button onClick={this.reset}>重置</Button>
  461. <span style={{marginLeft:'10px',marginRight:'20px'}}>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  462. </div>
  463. <div className='clearfix' style={{marginTop:'5px'}}>
  464. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  465. <Input placeholder="订单编号" style={{width:'150px'}}
  466. value={this.state.orderNoSearch}
  467. onChange={(e) => { this.setState({ orderNoSearch: e.target.value }); }} />
  468. {/*<Select placeholder="订单类型"
  469. style={{ width: 150 }}
  470. value={this.state.orderTypeSearch}
  471. onChange={(e) => { this.setState({ orderTypeSearch: e }) }}>
  472. {
  473. orderType.map(function (item) {
  474. return <Select.Option key={item.value} >{item.key}</Select.Option>
  475. })
  476. }
  477. </Select>
  478. */}
  479. <Select placeholder="订单状态"
  480. style={{ width: 150 ,margin:'10px'}}
  481. value={this.state.orderStatusSearch}
  482. onChange={(e) => { this.setState({ orderStatusSearch: e }) }}>
  483. {
  484. orderState.map(function (item) {
  485. return <Select.Option key={item.value} >{item.key}</Select.Option>
  486. })
  487. }
  488. </Select>
  489. <Select placeholder="是否分配财务"
  490. style={{ width: 150 }}
  491. value={this.state.isDistributionFinance }
  492. onChange={(e) => { this.setState({ isDistributionFinance: e }) }}>
  493. <Select.Option value="1">已分配 </Select.Option>
  494. <Select.Option value="0">未分配 </Select.Option>
  495. </Select>
  496. </div>
  497. </div>
  498. <div className="patent-table">
  499. <Spin spinning={this.state.loading}>
  500. <Table size="middle" columns={this.state.columns}
  501. dataSource={this.state.dataSource}
  502. rowSelection={rowSelection}
  503. pagination={this.state.pagination}
  504. onRowClick={this.tableRowClick} />
  505. </Spin>
  506. </div>
  507. <ManagementDetaile
  508. confirmDelet={this.confirmDelet}
  509. userDetaile={this.state.userDetaile}
  510. datauser={this.state.datauser}
  511. showDesc={this.state.showDesc}
  512. closeDesc={this.closeDesc} />
  513. </div >
  514. <Modal maskClosable={false} visible={this.state.distributionVisible}
  515. onOk={this.distributionOk} onCancel={this.distributionCancel}
  516. width='800px'
  517. title='分派财务订单'
  518. footer=''
  519. className="admin-desc-content">
  520. <Form layout="horizontal" onSubmit={this.handleSubmit} id="demand-form" style={{paddingBottom:'40px'}} >
  521. <Spin spinning={this.state.loading}>
  522. <div>
  523. <Select placeholder="部门"
  524. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  525. value={this.state.departmenttList}
  526. onChange={(e) => { this.setState({ departmenttList: e }) }}>
  527. {
  528. departmentArr.map(function (item) {
  529. return <Select.Option key={item.id} >{item.name}</Select.Option>
  530. })
  531. }
  532. </Select>
  533. <Input placeholder="财务负责人" style={{width:'150px',marginLeft:'10px'}}
  534. value={this.state.financeNameSearch}
  535. onChange={(e) => { this.setState({ financeNameSearch: e.target.value }); }} />
  536. <Button type="primary" onClick={this.searchOrder} style={{marginLeft:'10px',marginRight:'10px'}}>搜索</Button>
  537. <Button onClick={this.resetOrder}>重置</Button>
  538. </div>
  539. <div className="patent-table" style={{marginTop:'10px'}}>
  540. <Spin spinning={this.state.loading}>
  541. <Table size="middle" columns={this.state.userList}
  542. dataSource={this.state.distributionList}
  543. pagination={false}
  544. />
  545. </Spin>
  546. </div>
  547. </Spin>
  548. </Form>
  549. </Modal>
  550. </div>
  551. );
  552. }
  553. }));
  554. export default SettlementManage;