billing.jsx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. import React from 'react';
  2. import ReactDom from 'react-dom';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import { Form,Radio, Icon, Button, Input, Select, Spin, Table, Switch, message, DatePicker, Checkbox ,Modal, Upload ,Popconfirm} from 'antd';
  6. import NewService from "./addService.jsx";
  7. import moment from 'moment';
  8. import '../userMangagement.less';
  9. import {projectProgress,specially} from '../../../dataDic.js';
  10. import {getApprovedState,getProcessStatus,getLiquidationStatus,getNewOrderStatus} from '../../../tools.js';
  11. const MyService=Form.create()(React.createClass({
  12. loadData(pageNo) {
  13. this.state.data = [];
  14. this.setState({
  15. loading: true
  16. });
  17. $.ajax({
  18. method: "get",
  19. dataType: "json",
  20. crossDomain: false,
  21. url: globalConfig.context + '/api/admin/newOrder/orderNewList',
  22. data: {
  23. pageNo: pageNo || 1,
  24. pageSize: this.state.pagination.pageSize,
  25. specially:0,
  26. name:this.state.customerName,
  27. orderNo:this.state.orderNo,
  28. depId: this.state.departmenttSearch,
  29. starTime: this.state.releaseDate[0],
  30. endTime: this.state.releaseDate[1],
  31. },
  32. success: function (data) {
  33. let theArr = [];
  34. if (!data.data) {
  35. if (data.error && data.error.length) {
  36. message.warning(data.error[0].message);
  37. };
  38. } else {
  39. for (let i = 0; i < data.data.list.length; i++) {
  40. let thisdata = data.data.list[i];
  41. theArr.push({
  42. key: i,
  43. id: thisdata.id,
  44. orderNo: thisdata.orderNo,//订单编号
  45. totalAmount:thisdata.totalAmount,//签单金额
  46. processStatus:thisdata.processStatus,//流程状态
  47. liquidationStatus:thisdata.liquidationStatus,//结算状态
  48. approval:thisdata.approval,//特批状态
  49. signDate:thisdata.signDate,//签单时间
  50. userName:thisdata.userName,//客户名称
  51. salesmanName:thisdata.salesmanName,//营销员名称
  52. financeName:thisdata.financeName,//财务名称
  53. createDate:thisdata.createDate,//下单时间
  54. orderStatus:thisdata.orderStatus,//订单状态
  55. depName:thisdata.depName,//部门名称
  56. });
  57. };
  58. this.state.pagination.current = data.data.pageNo;
  59. this.state.pagination.total = data.data.totalCount;
  60. };
  61. if(!data.data.list.length){
  62. this.state.pagination.current=0
  63. this.state.pagination.total=0
  64. }
  65. this.setState({
  66. pageNo:pageNo,
  67. dataSource: theArr,
  68. pagination: this.state.pagination,
  69. selectedRowKeys:[],
  70. });
  71. }.bind(this),
  72. }).always(function () {
  73. this.setState({
  74. loading: false
  75. });
  76. }.bind(this));
  77. },
  78. getInitialState() {
  79. return {
  80. datauser:{},
  81. selectedRowKeys: [],
  82. releaseDate: [],
  83. departmentArr: [],
  84. signBillState:false,
  85. signBillVisible:false,
  86. selectedRows: [],
  87. searchMore: true,
  88. loading: false,
  89. intentOrder:true,
  90. formalOrder:true,
  91. pagination: {
  92. defaultCurrent: 1,
  93. defaultPageSize: 10,
  94. showQuickJumper: true,
  95. pageSize: 10,
  96. onChange: function (page) {
  97. this.loadData(page);
  98. }.bind(this),
  99. showTotal: function (total) {
  100. return '共' + total + '条数据';
  101. }
  102. },
  103. columns: [
  104. {
  105. title: '订单编号',
  106. dataIndex: 'orderNo',
  107. key: 'orderNo'
  108. },{
  109. title: '客户名称',
  110. dataIndex: 'userName',
  111. key: 'userName',
  112. render:(text)=>{
  113. return (text&&text.length>9?text.substr(0,9)+'...':text)
  114. }
  115. }, {
  116. title: '下单时间',
  117. dataIndex: 'createDate',
  118. key: 'createTime'
  119. },{
  120. title: '合同签订时间',
  121. dataIndex: 'signDate',
  122. key: 'signDate'
  123. }, {
  124. title: '流程状态',
  125. dataIndex: 'processStatus',
  126. key: 'processStatus',
  127. render:text=>{return getProcessStatus(text)}
  128. }, {
  129. title: '签单金额(万元)',
  130. dataIndex: 'totalAmount',
  131. key: 'totalAmount'
  132. },{
  133. title: '结算状态',
  134. dataIndex: 'liquidationStatus',
  135. key: 'liquidationStatus',
  136. render:text=>{return getLiquidationStatus(text)}
  137. }, {
  138. title: '是否特批',
  139. dataIndex: 'approval',
  140. key: 'approval',
  141. render:text=>{return getApprovedState(text)}
  142. },{
  143. title: '订单状态',
  144. dataIndex: 'orderStatus',
  145. key: 'orderStatus',
  146. render:text=>{return getNewOrderStatus(text)}
  147. },{
  148. title: '财务负责人',
  149. dataIndex: 'financeName',
  150. key: 'financeName'
  151. }, {
  152. title: '操作',
  153. dataIndex: 'abc',
  154. key: 'abc',
  155. render: (text, record, index) => {
  156. return <div>
  157. {record.liquidationStatus==2?<Popconfirm title="是否结项?" onConfirm={(e)=>{this.delectRow(record)}} okText="是" cancelText="否">
  158. <Button type="primary" style={{marginRight:'10px',color:'#ffffff',border:'none'}} onClick={(e) =>{ e.stopPropagation()}}>结项</Button>
  159. </Popconfirm>:''}
  160. </div>
  161. }
  162. }
  163. ],
  164. dataSource: [],
  165. };
  166. },
  167. //结项
  168. delectRow(record) {
  169. this.setState({
  170. loading: true
  171. });
  172. $.ajax({
  173. method: "get",
  174. dataType: "json",
  175. crossDomain: false,
  176. url: globalConfig.context + "/api/admin/newOrder/OrderOver",
  177. data: {
  178. orderNo:record.orderNo
  179. }
  180. }).done(function (data) {
  181. if (!data.error.length) {
  182. message.success('该项目已成功结项!');
  183. this.loadData();
  184. } else {
  185. message.warning(data.error[0].message);
  186. };
  187. this.setState({
  188. loading: false,
  189. });
  190. }.bind(this));
  191. },
  192. //是否退款
  193. refundCancel(record){
  194. this.refund(record,0)
  195. },
  196. refundOk(record){
  197. this.refund(record,1)
  198. },
  199. refund(record,index){
  200. this.setState({
  201. signBillVisible:false,
  202. selectedRowKeys: [],
  203. loading: true,
  204. userDetaile:false
  205. });
  206. $.ajax({
  207. method: "get",
  208. dataType: "json",
  209. crossDomain: false,
  210. url: globalConfig.context + '/api/admin/order/confirmRefund',
  211. data: {
  212. orderNo:record.orderNo,
  213. confirm:index
  214. }
  215. }).done(function (data) {
  216. if (!data.error.length) {
  217. message.success('操作成功!');
  218. this.setState({
  219. loading: false,
  220. showDesc:false
  221. });
  222. }
  223. this.loadData(this.state.pageNo);
  224. }.bind(this));
  225. },
  226. //受理订单
  227. admissibleOrderOk(e){
  228. this.admissibleOrder(e,true)
  229. },
  230. admissibleOrderCancel(e){
  231. this.admissibleOrder(e,false)
  232. },
  233. admissibleOrder(record,index) {
  234. this.setState({
  235. signBillVisible:false,
  236. selectedRowKeys: [],
  237. loading: true,
  238. userDetaile:false
  239. });
  240. $.ajax({
  241. method: "POST",
  242. dataType: "json",
  243. crossDomain: false,
  244. url: globalConfig.context + '/api/admin/order/confirmIntention',
  245. data: {
  246. orderNo:record.orderNo,
  247. confirm:index
  248. }
  249. }).done(function (data) {
  250. if (!data.error.length) {
  251. message.success('操作成功!');
  252. this.setState({
  253. loading: false,
  254. showDesc:false
  255. });
  256. } else {
  257. message.warning(data.error[0].message);
  258. this.setState({
  259. showDesc:true
  260. })
  261. };
  262. this.loadData(this.state.pageNo);
  263. }.bind(this));
  264. },
  265. //取消订单
  266. cancelOrder(e){
  267. this.operation(e,3)
  268. },
  269. //作废订单
  270. scrapOrder(e){
  271. this.operation(e,2)
  272. },
  273. //锁定订单
  274. lockOrder(e){
  275. this.operation(e,0)
  276. },
  277. //解锁订单
  278. unlockOrder(e){
  279. this.operation(e,1)
  280. },
  281. //签单
  282. signBill(ids){
  283. this.setState({
  284. uid:ids,
  285. signBillVisible:true
  286. })
  287. },
  288. componentWillMount() {
  289. this.departmentList();
  290. this.loadData();
  291. let data=localStorage.getItem('newData');
  292. if(data!='{}'&&data){
  293. var newData = JSON.parse(data);
  294. this.tableRowClick(newData);
  295. };
  296. },
  297. tableRowClick(record, index) {
  298. this.state.userDetaile=true;
  299. this.state.datauser = record;
  300. this.setState({
  301. signBillVisible:false,
  302. signBillState:true,
  303. showDesc: true
  304. });
  305. localStorage.setItem('newData','{}');
  306. },
  307. //列表各种骚操作
  308. operation(record,index) {
  309. this.setState({
  310. selectedRowKeys: [],
  311. loading: true,
  312. showDesc:false
  313. });
  314. $.ajax({
  315. method: "get",
  316. dataType: "json",
  317. crossDomain: false,
  318. url: globalConfig.context + '/api/admin/order/lockOrRevokeOrder',
  319. data: {
  320. orderNo:record.orderNo,
  321. operatorType:index
  322. }
  323. }).done(function (data) {
  324. if (!data.error.length) {
  325. message.success('操作成功!');
  326. this.setState({
  327. loading: false,
  328. });
  329. } else {
  330. message.warning(data.error[0].message);
  331. };
  332. this.loadData(this.state.pageNo);
  333. }.bind(this));
  334. },
  335. addClick() {
  336. this.state.userDetaile=false;
  337. this.setState({
  338. signBillVisible:false,
  339. showDesc: true
  340. });
  341. },
  342. closeDesc(e, s) {
  343. this.state.userDetaile=false;
  344. this.state.signBillVisible=false;
  345. this.state.showDesc = e;
  346. if (s) {
  347. this.loadData(this.state.pageNo);
  348. };
  349. },
  350. searchSwitch() {
  351. this.setState({
  352. signBillVisible:false,
  353. searchMore: !this.state.searchMore
  354. });
  355. },
  356. search() {
  357. this.setState({
  358. signBillVisible:false
  359. })
  360. this.loadData();
  361. },
  362. reset() {
  363. this.setState({
  364. signBillVisible:false
  365. })
  366. this.state.orderNo='';
  367. this.state.customerName='';
  368. this.state.departmenttSearch=undefined;
  369. this.state.releaseDate[0] = undefined;
  370. this.state.releaseDate[1] = undefined;
  371. this.state.projectProgress = undefined;
  372. this.state.approval= undefined;
  373. this.state.formalOrder=true;
  374. this.state.intentOrder=true;
  375. this.loadData();
  376. },
  377. //部门
  378. departmentList() {
  379. this.setState({
  380. loading: true
  381. });
  382. $.ajax({
  383. method: "get",
  384. dataType: "json",
  385. crossDomain: false,
  386. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  387. data: {
  388. },
  389. success: function(data) {
  390. let thedata = data.data;
  391. let theArr = [];
  392. if(!thedata) {
  393. if(data.error && data.error.length) {
  394. message.warning(data.error[0].message);
  395. };
  396. thedata = {};
  397. } else {
  398. thedata.map(function(item, index) {
  399. theArr.push({
  400. key: index,
  401. name: item.name,
  402. id: item.id,
  403. })
  404. })
  405. }
  406. this.setState({
  407. departmentArr: theArr,
  408. })
  409. }.bind(this),
  410. }).always(function() {
  411. this.setState({
  412. loading: false
  413. });
  414. }.bind(this));
  415. },
  416. render() {
  417. const FormItem = Form.Item;
  418. const formItemLayout = {
  419. labelCol: { span: 8 },
  420. wrapperCol: { span: 14 },
  421. };
  422. const rowSelection = {
  423. selectedRowKeys: this.state.selectedRowKeys,
  424. onChange: (selectedRowKeys, selectedRows) => {
  425. this.setState({
  426. selectedRows: selectedRows.slice(-1),
  427. selectedRowKeys: selectedRowKeys.slice(-1)
  428. });
  429. },
  430. onSelectAll: (selected, selectedRows, changeRows) => {
  431. this.setState({
  432. selectedRowKeys:[]
  433. })
  434. },
  435. };
  436. const hasSelected = this.state.selectedRowKeys.length > 0;
  437. const { RangePicker } = DatePicker;
  438. let departmentArr = this.state.departmentArr || [];
  439. return (
  440. <div className="user-content" >
  441. <div className="content-title">
  442. <span style={{fontSize:'16px'}}>开单与签单</span>
  443. <div className="user-search">
  444. <Input placeholder="客户名称" style={{width:'150px'}}
  445. value={this.state.customerName}
  446. onChange={(e) => { this.setState({ customerName: e.target.value }); }} />
  447. <Input placeholder="订单编号" style={{width:'150px'}}
  448. value={this.state.orderNo}
  449. onChange={(e) => { this.setState({ orderNo: e.target.value }); }} />
  450. <span style={{marginRight:"10px"}}>合同签订时间 :</span>
  451. <RangePicker
  452. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  453. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  454. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  455. <Button type="primary" onClick={this.search} style={{marginLeft:'10px'}}>搜索<Icon type="search" /></Button>
  456. <Button onClick={this.reset}>重置 <Icon type="reload" /></Button>
  457. <Button type="primary" className="addButton" onClick={this.addClick} >开单<Icon type="plus" /></Button>
  458. </div>
  459. <div className="patent-table">
  460. <Spin spinning={this.state.loading}>
  461. <Table columns={this.state.columns}
  462. dataSource={this.state.dataSource}
  463. rowSelection={rowSelection}
  464. pagination={this.state.pagination}
  465. onRowClick={this.tableRowClick} />
  466. </Spin>
  467. </div>
  468. <NewService
  469. uid={this.state.uid}
  470. signBillVisible={this.state.signBillVisible}
  471. signBillState={this.state.signBillState}
  472. operation={this.operation}
  473. admissibleOrder={this.admissibleOrder}
  474. userDetaile={this.state.userDetaile}
  475. datauser={this.state.datauser}
  476. showDesc={this.state.showDesc}
  477. closeDesc={this.closeDesc} />
  478. </div >
  479. </div>
  480. );
  481. }
  482. }));
  483. export default MyService;