approveOrder.jsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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, Modal, Upload ,Popconfirm,Checkbox,Tabs} from 'antd';
  6. import ApproveOrderDetaile from "./approveOrderDetaile.jsx";
  7. import moment from 'moment';
  8. import '../../userMangagement.less';
  9. import {orderState,paymentState,orderChannel} from '../../../../dataDic.js';
  10. import {getOrderState,getPaymentState,getOrderChannel,getProjectState,getApprovedState,getOrderType } from '../../../../tools.js';
  11. import {ChooseList} from "../../orderNew/chooseList";
  12. const {TabPane} = Tabs
  13. const ApproveOrder=Form.create()(React.createClass({
  14. loadData(pageNo) {
  15. this.state.data = [];
  16. this.setState({
  17. loading: true
  18. });
  19. $.ajax({
  20. method: "post",
  21. dataType: "json",
  22. crossDomain: false,
  23. url: globalConfig.context + '/api/admin/order/listApprovalServiceOrder',
  24. data: {
  25. pageNo: pageNo || 1,
  26. pageSize: this.state.pagination.pageSize,
  27. buyerName:this.state.customerName,
  28. startDate: this.state.releaseDate[0],
  29. endDate: this.state.releaseDate[1],
  30. depIds:this.state.departmentSearch , //部门
  31. salesmanName:this.state.orderLeader, //负责人
  32. orderStatus:this.state.orderStateSearch , //订单状态
  33. liquidationStatus:this.state.paymentStateSearch , //结算状态
  34. orderChannel:this.state.orderChannelSearch, //订单渠道
  35. approvalHistory:this.state.approvalHistorySearch?1:0 //特批历史
  36. },
  37. success: function (data) {
  38. let theArr = [];
  39. if (!data.data) {
  40. if (data.error && data.error.length) {
  41. message.warning(data.error[0].message);
  42. };
  43. } else {
  44. for (let i = 0; i < data.data.list.length; i++) {
  45. let thisdata = data.data.list[i];
  46. theArr.push({
  47. key: i,
  48. id: thisdata.id,
  49. orderNo: thisdata.orderNo,
  50. orderType:thisdata.orderType,
  51. orderStatus:thisdata.orderStatus,
  52. liquidationStatus:thisdata.liquidationStatus,
  53. createTime:thisdata.createTime,
  54. buyerName:thisdata.buyerName,
  55. signTotalAmount:thisdata.signTotalAmount,
  56. projectStage:thisdata.projectStage,
  57. approval:thisdata.approval,
  58. salesmanName:thisdata.salesmanName,
  59. orderChannel:thisdata.orderChannel,
  60. financeName:thisdata.financeName,
  61. departmentName:thisdata.departmentName
  62. });
  63. };
  64. this.state.pagination.current = data.data.pageNo;
  65. this.state.pagination.total = data.data.totalCount;
  66. };
  67. if(!data.data.list.length){
  68. this.state.pagination.current=0
  69. this.state.pagination.total=0
  70. }
  71. this.setState({
  72. pageNo:pageNo,
  73. dataSource: theArr,
  74. pagination: this.state.pagination,
  75. selectedRowKeys:[]
  76. });
  77. }.bind(this),
  78. }).always(function () {
  79. this.setState({
  80. loading: false
  81. });
  82. }.bind(this));
  83. },
  84. departmentList() {
  85. this.setState({
  86. loading: true
  87. });
  88. $.ajax({
  89. method: "get",
  90. dataType: "json",
  91. crossDomain: false,
  92. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  93. data: {
  94. },
  95. success: function(data) {
  96. let thedata = data.data;
  97. let theArr=[];
  98. if(!thedata) {
  99. if(data.error && data.error.length) {
  100. message.warning(data.error[0].message);
  101. };
  102. thedata = {};
  103. }else{
  104. thedata.map(function(item,index){
  105. theArr.push({
  106. key:index,
  107. name:item.name,
  108. id:item.id,
  109. depNo:item.depNo
  110. })
  111. })
  112. }
  113. this.setState({
  114. departmentArr:theArr,
  115. })
  116. }.bind(this),
  117. }).always(function() {
  118. this.setState({
  119. loading: false
  120. });
  121. }.bind(this));
  122. },
  123. getInitialState() {
  124. return {
  125. datauser:{},
  126. selectedRowKeys: [],
  127. releaseDate: [],
  128. selectedRows: [],
  129. approvalHistorySearch:true,
  130. searchMore: true,
  131. loading: false,
  132. distributionVisible:false,
  133. intentOrder:false,
  134. visible:false,
  135. showDesc:false,
  136. pagination: {
  137. defaultCurrent: 1,
  138. defaultPageSize: 10,
  139. showQuickJumper: true,
  140. pageSize: 10,
  141. onChange: function (page) {
  142. this.loadData(page);
  143. }.bind(this),
  144. showTotal: function (total) {
  145. return '共' + total + '条数据';
  146. }
  147. },
  148. distributionPagination: {
  149. defaultCurrent: 1,
  150. defaultPageSize: 10,
  151. showQuickJumper: true,
  152. pageSize: 10,
  153. onChange: function (page) {
  154. this.contactList(page);
  155. }.bind(this),
  156. showTotal: function (total) {
  157. return '共' + total + '条数据';
  158. }
  159. },
  160. columns: [
  161. {
  162. title: '订单编号',
  163. dataIndex: 'orderNo',
  164. key: 'orderNo'
  165. }, {
  166. title: '订单类型',
  167. dataIndex: 'orderType',
  168. key: 'orderType',
  169. render:(text)=>{return getOrderType(text)}
  170. }, {
  171. title: '下单时间',
  172. dataIndex: 'createTime',
  173. key: 'createTime'
  174. },{
  175. title: '订单客户',
  176. dataIndex: 'buyerName',
  177. key: 'buyerName',
  178. render:(text)=>{return (text&&text.length>8)?(text).substr(0,8)+'…':text}
  179. },
  180. {
  181. title: '实际下单金额(万元)',
  182. dataIndex: 'signTotalAmount',
  183. key: 'signTotalAmount'
  184. }, {
  185. title: '结算状态',
  186. dataIndex: 'liquidationStatus',
  187. key: 'liquidationStatus',
  188. render:(text)=>{return getPaymentState(text) }
  189. }, {
  190. title: '订单状态',
  191. dataIndex: 'orderStatus',
  192. key: 'orderStatus',
  193. render:(text)=>{return getOrderState(text) }
  194. }, {
  195. title: '项目状态',
  196. dataIndex: 'projectStage',
  197. key: 'projectStage',
  198. render:(text)=>{return getProjectState(text) }
  199. },{
  200. title: '是否特批',
  201. dataIndex: 'approval',
  202. key: 'approval',
  203. render:text=>{return getApprovedState(text)}
  204. },{
  205. title: '订单渠道',
  206. dataIndex: 'orderChannel',
  207. key: 'orderChannel',
  208. render:(text)=>{return getOrderChannel(text) }
  209. },{
  210. title: '部门机构',
  211. dataIndex: 'departmentName',
  212. key: 'departmentName',
  213. },{
  214. title: '订单跟进人',
  215. dataIndex: 'salesmanName',
  216. key: 'salesmanName',
  217. },{
  218. title: '财务跟进人',
  219. dataIndex: 'financeName',
  220. key: 'financeName',
  221. },{
  222. title: '操作',
  223. dataIndex: 'operation',
  224. key: 'operation',
  225. render: (text, record, index) => {
  226. return <div>
  227. {record.approval==1&&<div>
  228. <Popconfirm title={'您确认驳回 【'+ record.salesmanName +'】的特批申请?'} onConfirm={(e)=>{this.reject(record)}} okText="确认" cancelText="取消">
  229. <Button style={{marginRight:'5px'}} type="danger" onClick={(e) =>{ e.stopPropagation()}}>驳回</Button>
  230. </Popconfirm>
  231. <Popconfirm title={'您确定同意 【'+ record.salesmanName +'】的特批申请?'} onConfirm={(e)=>{this.confirm(record)}} okText="确认" cancelText="取消">
  232. <Button style={{marginRight:'5px'}} type="primary" onClick={(e) =>{ e.stopPropagation()}}>同意</Button>
  233. </Popconfirm>
  234. </div>}
  235. </div>
  236. }
  237. }
  238. ],
  239. dataSource: [],
  240. };
  241. },
  242. //操作分配
  243. confirmDelet(index){
  244. this.setState({
  245. userDetaile:false,
  246. });
  247. this.contactList(1,index.id)
  248. },
  249. //驳回
  250. reject(record){
  251. this.confirmSelect(0,record)
  252. },
  253. //确认
  254. confirm(record){
  255. this.confirmSelect(1,record)
  256. },
  257. confirmSelect(nub,record){
  258. this.setState({
  259. loading: true
  260. });
  261. $.ajax({
  262. method: "get",
  263. dataType: "json",
  264. crossDomain: false,
  265. url: globalConfig.context + '/api/admin/order/approvalServiceOrder',
  266. data: {
  267. orderNo:record.orderNo,
  268. confirm:nub
  269. }
  270. }).done(function (data) {
  271. if (!data.error.length) {
  272. message.success('操作成功');
  273. this.setState({
  274. loading: false,
  275. });
  276. this.loadData(this.state.pageNo);
  277. } else {
  278. message.warning(data.error[0].message);
  279. };
  280. }.bind(this));
  281. },
  282. componentWillMount() {
  283. this.loadData();
  284. this.departmentList()
  285. },
  286. tableRowClick(record, index) {
  287. this.state.userDetaile=true;
  288. this.state.datauser = record;
  289. this.setState({
  290. showDesc: true
  291. });
  292. },
  293. closeDesc(e, s) {
  294. this.state.userDetaile=false;
  295. this.state.showDesc = e;
  296. if (s) {
  297. this.loadData(this.state.pageNo);
  298. };
  299. },
  300. searchSwitch() {
  301. this.setState({
  302. searchMore: !this.state.searchMore
  303. });
  304. },
  305. search() {
  306. this.loadData();
  307. },
  308. //分配时搜索
  309. searchOrder() {
  310. this.contactList();
  311. },
  312. //分配时重置
  313. resetOrder() {
  314. this.contactList();
  315. },
  316. reset() {
  317. this.state.customerName='';
  318. this.state.releaseDate[0] = undefined;
  319. this.state.releaseDate[1] = undefined;
  320. this.state.orderLeader = '';
  321. this.state.departmentSearch=undefined;
  322. this.state.approvalHistorySearch=true;
  323. this.state.orderStateSearch = undefined;
  324. this.state.paymentStateSearch = undefined;
  325. this.loadData();
  326. },
  327. changeList(arr) {
  328. const newArr = [];
  329. this.state.columns.forEach(item => {
  330. arr.forEach(val => {
  331. if (val === item.title) {
  332. newArr.push(item);
  333. }
  334. });
  335. });
  336. this.setState({
  337. changeList: newArr
  338. });
  339. },
  340. render() {
  341. const rowSelection = {
  342. selectedRowKeys: this.state.selectedRowKeys,
  343. onChange: (selectedRowKeys, selectedRows) => {
  344. this.setState({
  345. selectedRows: selectedRows.slice(-1),
  346. selectedRowKeys: selectedRowKeys.slice(-1)
  347. });
  348. },
  349. onSelectAll: (selected, selectedRows, changeRows) => {
  350. this.setState({
  351. selectedRowKeys:[]
  352. })
  353. },
  354. };
  355. let departmentArr = this.state.departmentArr || [];
  356. const hasSelected = this.state.selectedRowKeys.length > 0;
  357. const { RangePicker } = DatePicker;
  358. return (
  359. <div className="user-content" >
  360. <div className="content-title">
  361. <span style={{fontSize:'16px'}}>特批订单</span>
  362. <Tabs
  363. defaultActiveKey="1"
  364. onChange={this.callback}
  365. className="test">
  366. <TabPane tab="搜索" key="1">
  367. <div className="user-search">
  368. <Input placeholder="客户名称" style={{width:'150px',marginLeft:10}}
  369. value={this.state.customerName}
  370. onChange={(e) => { this.setState({ customerName: e.target.value }); }} />
  371. <RangePicker
  372. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  373. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  374. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  375. <Select placeholder="部门机构"
  376. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  377. value={this.state.departmentSearch}
  378. onChange={(e) => { this.setState({ departmentSearch: e }) }}>
  379. {
  380. departmentArr.map(function (item) {
  381. return <Select.Option key={item.id} >{item.name}</Select.Option>
  382. })
  383. }
  384. </Select>
  385. <Input placeholder="订单负责人" style={{width:'150px'}}
  386. value={this.state.orderLeader}
  387. onChange={(e) => { this.setState({ orderLeader: e.target.value }); }} />
  388. <Button type="primary" onClick={this.search} style={{marginLeft:'10px'}}>搜索</Button>
  389. <Button onClick={this.reset}>重置</Button>
  390. <span style={{marginLeft:'10px',marginRight:'20px'}}>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  391. </div>
  392. <div className='clearfix' style={{marginTop:'5px'}}>
  393. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  394. <Checkbox checked={this.state.approvalHistorySearch} style={{marginLeft:10}} onChange={(e)=>{this.setState({approvalHistorySearch:!this.state.approvalHistorySearch})}}>特批历史订单</Checkbox>
  395. <Select placeholder="订单状态"
  396. style={{ width: 150 ,marginRight:'10px',marginBottom:'10px'}}
  397. value={this.state.orderStateSearch}
  398. onChange={(e) => { this.setState({ orderStateSearch: e }) }}>
  399. {
  400. orderState.map(function (item) {
  401. return <Select.Option key={item.value} >{item.key}</Select.Option>
  402. })
  403. }
  404. </Select>
  405. <Select placeholder="结算状态"
  406. style={{ width: 150 ,marginRight:'10px'}}
  407. value={this.state.paymentStateSearch}
  408. onChange={(e) => { this.setState({ paymentStateSearch: e }) }}>
  409. {
  410. paymentState.map(function (item) {
  411. return <Select.Option key={item.value} >{item.key}</Select.Option>
  412. })
  413. }
  414. </Select>
  415. </div>
  416. </div>
  417. </TabPane>
  418. <TabPane tab="更改表格显示数据" key="2">
  419. <div style={{ marginLeft: 10 }}>
  420. <ChooseList
  421. columns={this.state.columns}
  422. changeFn={this.changeList}
  423. changeList={this.state.changeList}
  424. top={55}
  425. margin={11}
  426. />
  427. </div>
  428. </TabPane>
  429. </Tabs>
  430. <div className="patent-table">
  431. <Spin spinning={this.state.loading}>
  432. <Table columns={
  433. this.state.changeList
  434. ? this.state.changeList
  435. : this.state.columns
  436. }
  437. dataSource={this.state.dataSource}
  438. rowSelection={rowSelection}
  439. pagination={this.state.pagination}
  440. onRowClick={this.tableRowClick}
  441. bordered
  442. size="small" />
  443. </Spin>
  444. </div>
  445. <ApproveOrderDetaile
  446. confirmDelet={this.confirmDelet}
  447. userDetaile={this.state.userDetaile}
  448. datauser={this.state.datauser}
  449. showDesc={this.state.showDesc}
  450. closeDesc={this.closeDesc} />
  451. </div >
  452. </div>
  453. );
  454. }
  455. }));
  456. export default ApproveOrder;