projectManage.jsx 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  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, Modal, Upload ,Popconfirm,DatePicker} from 'antd';
  6. import MySettlementDetaile from "./projectManageDetaile.jsx";
  7. import moment from 'moment';
  8. import '../userMangagement.less';
  9. import {projectState,orderState,distributeState} from '../../../../dataDic.js';
  10. import {getProjectState,getOrderState,getOrderType,getPaymentState,getApprovedState,getDistributeState} from '../../../../tools.js';
  11. const ProjectOrder=Form.create()(React.createClass({
  12. loadData(pageNo) {
  13. this.setState({
  14. loading: true
  15. });
  16. $.ajax({
  17. method: "post",
  18. dataType: "json",
  19. crossDomain: false,
  20. url: globalConfig.context + '/api/admin/techproject/listProject',
  21. data: {
  22. pageNo: pageNo || 1,
  23. pageSize: this.state.pagination.pageSize,
  24. setUpStartDate: this.state.releaseDate[0],
  25. setUpEndDate: this.state.releaseDate[1],
  26. depId:this.state.departmentt,
  27. orderStartDate: this.state.releaseDateOrder[0],
  28. orderEndDate: this.state.releaseDateOrder[1],
  29. buyerName:this.state.buyerNameSearch,//客户名称
  30. orderStatus:this.state.orderStatusSearch, //订单状态
  31. salesmanName:this.state.salesmanNameSearch,//订单负责人
  32. financeLeaderSearch:this.state.financeLeaderSearch,//财务负责人
  33. orderNo:this.state.orderNoSearch,//订单编号
  34. deletedSign:this.state.deleteSignSearch,//锁定激活
  35. serialNumber:this.state.serialNumberSearch,//项目编号
  36. principalName:this.state.principalNameSearch,
  37. taskDistribution:this.state.distributeSearch
  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. serialNumber: thisdata.serialNumber,
  52. signDate:thisdata.signDate,
  53. buyerName:thisdata.buyerName,
  54. projectType:thisdata.projectType,
  55. projectStatus:thisdata.projectStatus,
  56. deleteSign:thisdata.deletedSign,
  57. orderNo:thisdata.orderNo,
  58. orderTime:thisdata.orderTime,
  59. orderStatus:thisdata.orderStatus,
  60. liquidationStatus:thisdata.liquidationStatus,
  61. approval:thisdata.approval,
  62. buyerType:thisdata.buyerType,
  63. salesmanName:thisdata.salesmanName,
  64. departmentName:thisdata.departmentName,
  65. principalName:thisdata.principalName,
  66. taskDistribution:thisdata.taskDistribution
  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. newProject:false,
  79. dataSource: theArr,
  80. pagination: this.state.pagination,
  81. selectedRowKeys:[]
  82. });
  83. }.bind(this),
  84. }).always(function () {
  85. this.setState({
  86. loading: false
  87. });
  88. }.bind(this));
  89. },
  90. getInitialState() {
  91. return {
  92. datauser:{},
  93. selectedRowKeys: [],
  94. selectedRows: [],
  95. searchMore: true,
  96. releaseDate: [],
  97. releaseDateOrder:[],
  98. categoryArr:[],
  99. projectState:false,
  100. newProject:false,
  101. loading: false,
  102. KnotState:true,
  103. distributionVisible:false,
  104. visible:false,
  105. showDesc:false,
  106. pagination: {
  107. defaultCurrent: 1,
  108. defaultPageSize: 10,
  109. showQuickJumper: true,
  110. pageSize: 10,
  111. onChange: function (page) {
  112. this.loadData(page);
  113. }.bind(this),
  114. showTotal: function (total) {
  115. return '共' + total + '条数据';
  116. }
  117. },
  118. columns: [
  119. {
  120. title: '项目编号',
  121. dataIndex: 'serialNumber',
  122. key: 'serialNumber'
  123. },{
  124. title: '立项时间',
  125. dataIndex: 'signDate',
  126. key: 'signDate'
  127. },{
  128. title: '客户名称',
  129. dataIndex: 'buyerName',
  130. key: 'buyerName',
  131. // render:(text)=>{
  132. // return text&&text.length>=6?text.substr(0,5)+'...':text
  133. // }
  134. },{
  135. title: '项目状态',
  136. dataIndex: 'projectStatus',
  137. key: 'projectStatus',
  138. render:(text)=>{return getProjectState(text) }
  139. },{
  140. title: '订单编号',
  141. dataIndex: 'orderNo',
  142. key: 'orderNo',
  143. },{
  144. title: '下单时间',
  145. dataIndex: 'orderTime',
  146. key: 'orderTime',
  147. },{
  148. title: '订单状态',
  149. dataIndex: 'orderStatus',
  150. key: 'orderStatus',
  151. render:(text)=>{return getOrderState(text) }
  152. },{
  153. title: '订单负责人',
  154. dataIndex: 'salesmanName',
  155. key: 'salesmanName',
  156. },{
  157. title: '项目负责人',
  158. dataIndex: 'principalName',
  159. key: 'principalName',
  160. },{
  161. title: '订单部门',
  162. dataIndex: 'departmentName',
  163. key: 'departmentName',
  164. },{
  165. title: '结算状态',
  166. dataIndex: 'liquidationStatus',
  167. key: 'liquidationStatus',
  168. render:(text)=>{return getPaymentState(text) }
  169. },{
  170. title: '是否特批',
  171. dataIndex: 'approval',
  172. key: 'approval',
  173. render:(text)=>{return getApprovedState(text) }
  174. },{
  175. title: '分派情况',
  176. dataIndex: 'taskDistribution',
  177. key: 'taskDistribution',
  178. render:(text)=>{return getDistributeState(text) }
  179. },
  180. {
  181. title: '操作',
  182. dataIndex: 'rr',
  183. key: 'rr',
  184. render:(text,record,index)=>{
  185. return (
  186. <div>
  187. {record.projectStatus==2||record.projectStatus==5?<Button style={{marginRight:'5px'}} type="primary" onClick={(e) =>{ e.stopPropagation(),this.Knot(record)}}>派单</Button>:''}
  188. {record.projectStatus==2&&<Button style={{marginRight:'5px'}} type="primary" onClick={(e) =>{ e.stopPropagation(),this.Knots(record)}}>结项</Button>}
  189. {record.projectStatus==1||record.projectStatus==5?<Popconfirm title={'您将作废项目【'+record.roleName+'】,系统将自动同步作废项目任务及项目资料单,请确认'} onConfirm={(e)=>{this.scrapOrder(record)}} okText="确认" cancelText="取消">
  190. <Button style={{marginRight:'5px'}} onClick={(e) =>{ e.stopPropagation()}} type="danger">作废</Button>
  191. </Popconfirm>:''}
  192. </div>
  193. )
  194. }
  195. }
  196. ],
  197. queryColumns: [
  198. {
  199. title: '项目编号',
  200. dataIndex: 'serialNumber',
  201. key: 'serialNumber'
  202. },{
  203. title: '立项时间',
  204. dataIndex: 'signDate',
  205. key: 'signDate'
  206. },{
  207. title: '客户名称',
  208. dataIndex: 'buyerName',
  209. key: 'buyerName',
  210. // render:(text)=>{
  211. // return text&&text.length>=6?text.substr(0,5)+'...':text
  212. // }
  213. },{
  214. title: '客户类型',
  215. dataIndex: 'buyerType',
  216. key: 'buyerType',
  217. render:(text)=>{return text?'单位客户':'个人客户'}
  218. },{
  219. title: '业务品类',
  220. dataIndex: 'projectType',
  221. key: 'projectType',
  222. },{
  223. title: '项目状态',
  224. dataIndex: 'projectStatus',
  225. key: 'projectStatus',
  226. render:(text)=>{return getProjectState(text) }
  227. },{
  228. title: '订单编号',
  229. dataIndex: 'orderNo',
  230. key: 'orderNo',
  231. },{
  232. title: '下单时间',
  233. dataIndex: 'orderTime',
  234. key: 'orderTime',
  235. },{
  236. title: '订单状态',
  237. dataIndex: 'orderStatus',
  238. key: 'orderStatus',
  239. render:(text)=>{return getOrderState(text) }
  240. },{
  241. title: '订单负责人',
  242. dataIndex: 'salesmanName',
  243. key: 'salesmanName',
  244. },{
  245. title: '项目负责人',
  246. dataIndex: 'principalName',
  247. key: 'principalName',
  248. },{
  249. title: '订单部门',
  250. dataIndex: 'departmentName',
  251. key: 'departmentName',
  252. },{
  253. title: '结算状态',
  254. dataIndex: 'liquidationStatus',
  255. key: 'liquidationStatus',
  256. render:(text)=>{return getPaymentState(text) }
  257. },{
  258. title: '是否特批',
  259. dataIndex: 'approval',
  260. key: 'approval',
  261. render:(text)=>{return getApprovedState(text) }
  262. },{
  263. title: '分派情况',
  264. dataIndex: 'taskDistribution',
  265. key: 'taskDistribution',
  266. render:(text)=>{return getDistributeState(text) }
  267. }
  268. ],
  269. dataSource: [],
  270. };
  271. },
  272. //结项
  273. Knots(record){
  274. this.setState({
  275. signComment:'',
  276. contractId:record.id,
  277. serial:record.serialNumber,
  278. buyerName:record.buyerName,
  279. KnotState:false,
  280. signBillVisible:true
  281. })
  282. },
  283. //部门
  284. departmentList() {
  285. this.setState({
  286. loading: true
  287. });
  288. $.ajax({
  289. method: "get",
  290. dataType: "json",
  291. crossDomain: false,
  292. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  293. data: {
  294. },
  295. success: function(data) {
  296. let thedata = data.data;
  297. let theArr=[];
  298. if(!thedata) {
  299. if(data.error && data.error.length) {
  300. message.warning(data.error[0].message);
  301. };
  302. thedata = {};
  303. }else{
  304. thedata.map(function(item,index){
  305. theArr.push({
  306. key:index,
  307. name:item.name,
  308. id:item.id,
  309. depNo:item.depNo
  310. })
  311. })
  312. }
  313. this.setState({
  314. departmentArr:theArr,
  315. })
  316. }.bind(this),
  317. }).always(function() {
  318. this.setState({
  319. loading: false
  320. });
  321. }.bind(this));
  322. },
  323. //作废项目
  324. scrapOrder(record){
  325. this.setState({
  326. loading: true
  327. });
  328. $.ajax({
  329. method: "POST",
  330. dataType: "json",
  331. crossDomain: false,
  332. url: globalConfig.context +'/api/zuofei',
  333. data: {
  334. id:record.id,
  335. }
  336. }).done(function(data) {
  337. this.setState({
  338. loading: false
  339. });
  340. if(!data.error.length) {
  341. message.success('操作成功!');
  342. this.loadData(this.state.pageNo);
  343. } else {
  344. message.warning(data.error[0].message);
  345. }
  346. }.bind(this));
  347. },
  348. //创建项目
  349. addClick() {
  350. this.setState({
  351. newProject:true,
  352. signBillVisible:false,
  353. showDesc: false
  354. });
  355. },
  356. //品类数据获取
  357. category(){
  358. this.setState({
  359. loading: true
  360. });
  361. $.ajax({
  362. method: "get",
  363. dataType: "json",
  364. crossDomain: false,
  365. url: globalConfig.context + "/api/admin/Varieties/getSuperList",
  366. data: {
  367. },
  368. success: function(data) {
  369. let thedata = data.data;
  370. let theArr=[];
  371. if(!thedata) {
  372. if(data.error && data.error.length) {
  373. message.warning(data.error[0].message);
  374. };
  375. thedata = {};
  376. }else{
  377. thedata.map(function(item,index){
  378. theArr.push({
  379. key:index,
  380. name:item.cname,
  381. id:item.id,
  382. })
  383. })
  384. }
  385. this.setState({
  386. categoryArr:theArr,
  387. })
  388. }.bind(this),
  389. }).always(function() {
  390. this.setState({
  391. loading: false
  392. });
  393. }.bind(this));
  394. },
  395. componentWillMount() {
  396. let data=localStorage.getItem('newData');
  397. if(data!='{}'&&data){
  398. var newData = JSON.parse(data);
  399. this.tableRowClick(newData);
  400. };
  401. },
  402. componentDidMount(){
  403. this.loadData();
  404. this.departmentList();
  405. this.category();
  406. },
  407. //项目管理
  408. Knot(record){
  409. this.state.userDetaile=true;
  410. this.state.datauser = record;
  411. this.setState({
  412. projectState:true,
  413. newProject:false,
  414. showDesc: true
  415. });
  416. },
  417. noProject(){
  418. this.setState({
  419. signBillVisible:false
  420. })
  421. },
  422. closeDesc(e, s) {
  423. this.state.userDetaile=false;
  424. this.state.showDesc = e;
  425. if (s) {
  426. this.loadData(this.state.pageNo);
  427. };
  428. },
  429. noProject(){
  430. this.setState({
  431. signBillVisible:false
  432. })
  433. },
  434. //结项
  435. projectSubmit(e){
  436. e.preventDefault();
  437. this.setState({
  438. loading: true
  439. });
  440. $.ajax({
  441. method: "get",
  442. dataType: "json",
  443. crossDomain: false,
  444. url: globalConfig.context +'/api/admin/techproject/revokeOrComplete' ,
  445. data: {
  446. contractId:this.state.contractId,
  447. operatorType:1,
  448. completeComment:this.state.signComment,
  449. }
  450. }).done(function(data) {
  451. this.setState({
  452. loading: false
  453. });
  454. if(!data.error.length) {
  455. message.success('结项成功!');
  456. this.noProject();
  457. this.loadData(this.state.pageNo);
  458. } else {
  459. message.warning(data.error[0].message);
  460. }
  461. }.bind(this));
  462. },
  463. searchSwitch() {
  464. this.setState({
  465. newProject:false,
  466. searchMore: !this.state.searchMore
  467. });
  468. },
  469. search() {
  470. this.loadData();
  471. },
  472. tableRowClick(record, index) {
  473. this.state.userDetaile=true;
  474. this.state.datauser = record;
  475. this.setState({
  476. projectState:false,
  477. newProject:false,
  478. showDesc: true
  479. });
  480. localStorage.setItem('newData','{}');
  481. },
  482. reset() {
  483. this.state.buyerNameSearch='';
  484. this.state.serialNumberSearch='';
  485. this.state.principalNameSearch='';
  486. this.state.releaseDate[0] = undefined;
  487. this.state.releaseDate[1] = undefined;
  488. this.state.releaseDateOrder[0] = undefined;
  489. this.state.releaseDateOrder[1] = undefined;
  490. this.state.departmentt=undefined;
  491. this.state.orderStatusSearch = undefined;
  492. this.state.salesmanNameSearch = '';
  493. this.state.orderNoSearch='';
  494. this.state.distributeSearch=undefined;
  495. this.state.deleteSignSearch=undefined;
  496. this.loadData();
  497. },
  498. render() {
  499. const FormItem = Form.Item;
  500. const formItemLayout = {
  501. labelCol: { span: 8 },
  502. wrapperCol: { span: 14 },
  503. };
  504. const { RangePicker } = DatePicker;
  505. const rowSelection = {
  506. selectedRowKeys: this.state.selectedRowKeys,
  507. onChange: (selectedRowKeys, selectedRows) => {
  508. this.setState({
  509. selectedRows: selectedRows.slice(-1),
  510. selectedRowKeys: selectedRowKeys.slice(-1)
  511. });
  512. },
  513. onSelectAll: (selected, selectedRows, changeRows) => {
  514. this.setState({
  515. selectedRowKeys:[]
  516. })
  517. },
  518. };
  519. const hasSelected = this.state.selectedRowKeys.length > 0;
  520. let departmentArr = this.state.departmentArr || [];
  521. return (
  522. <div className="user-content" >
  523. <div className="content-title">
  524. <span style={{fontSize:'16px'}}>{this.props.queryProject?'项目查询':'项目管理'}</span>
  525. <div className="user-search">
  526. <Input placeholder="客户名称" style={{width:'150px'}}
  527. value={this.state.buyerNameSearch}
  528. onChange={(e) => { this.setState({ buyerNameSearch: e.target.value }); }} />
  529. <Select placeholder="分派情况" style={{width:'150px'}}
  530. value={this.state.distributeSearch}
  531. onChange={(e) => { this.setState({ distributeSearch: e }) }}>
  532. {
  533. distributeState.map(function (item) {
  534. return <Select.Option key={item.value} >{item.key}</Select.Option>
  535. })
  536. }
  537. </Select>
  538. <Input placeholder="订单编号" style={{width:'150px',marginRight:'10px'}}
  539. value={this.state.orderNoSearch}
  540. onChange={(e) => { this.setState({ orderNoSearch: e.target.value }); }} />
  541. <Input placeholder="项目编号" style={{width:'150px',marginRight:'10px'}}
  542. value={this.state.serialNumberSearch}
  543. onChange={(e) => { this.setState({ serialNumberSearch: e.target.value }); }} />
  544. <Select placeholder="选择部门" style={{width:'150px'}}
  545. value={this.state.departmentt}
  546. onChange={(e) => { this.setState({ departmentt: e }) }}>
  547. {
  548. departmentArr.map(function (item) {
  549. return <Select.Option key={item.id} >{item.name}</Select.Option>
  550. })
  551. }
  552. </Select>
  553. <Button type="primary" onClick={this.search} style={{marginLeft:'10px'}}>搜索</Button>
  554. <Button onClick={this.reset}>重置</Button>
  555. <span style={{marginLeft:'10px',marginRight:'20px'}}>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  556. {this.props.queryProject?'':<Button type="primary" className="addButton" onClick={this.addClick} >创建项目<Icon type="plus" /></Button>}
  557. </div>
  558. <div className='clearfix' style={{marginTop:'5px'}}>
  559. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  560. <Input placeholder="项目负责人" style={{width:'150px'}}
  561. value={this.state.principalNameSearch}
  562. onChange={(e) => { this.setState({ principalNameSearch: e.target.value }); }} />
  563. <Input placeholder="订单负责人" style={{width:'150px',margin:'10px'}}
  564. value={this.state.salesmanNameSearch}
  565. onChange={(e) => { this.setState({ salesmanNameSearch: e.target.value }); }} />
  566. <span style={{fontSize:'14px',marginRight:'5px'}}>立项时间:</span>
  567. <RangePicker
  568. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  569. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  570. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  571. <span style={{fontSize:'14px',marginRight:'5px'}}>订单时间:</span>
  572. <RangePicker
  573. value={[this.state.releaseDateOrder[0] ? moment(this.state.releaseDateOrder[0]) : null,
  574. this.state.releaseDateOrder[1] ? moment(this.state.releaseDateOrder[1]) : null]}
  575. onChange={(data, dataString) => { this.setState({ releaseDateOrder: dataString }); }} />
  576. </div>
  577. </div>
  578. <div className="patent-table">
  579. <Spin spinning={this.state.loading}>
  580. <Table size="middle" columns={this.props.queryProject?this.state.queryColumns:this.state.columns}
  581. dataSource={this.state.dataSource}
  582. rowSelection={rowSelection}
  583. pagination={this.state.pagination}
  584. onRowClick={this.tableRowClick}
  585. />
  586. </Spin>
  587. </div>
  588. <MySettlementDetaile
  589. categoryArr={this.state.categoryArr}
  590. queryProject={this.props.queryProject}
  591. departmentArr={this.state.departmentArr}
  592. projectState={this.state.projectState}
  593. newProject={this.state.newProject}
  594. userDetaile={this.state.userDetaile}
  595. datauser={this.state.datauser}
  596. showDesc={this.state.showDesc}
  597. closeDesc={this.closeDesc} />
  598. </div >
  599. <Modal maskClosable={false} visible={this.state.signBillVisible}
  600. onOk={this.noProject} onCancel={this.noProject}
  601. width='800px'
  602. title='项目结项'
  603. footer=''
  604. className="admin-desc-content">
  605. <Form layout="horizontal" onSubmit={this.projectSubmit} id="demand-form">
  606. <Spin spinning={this.state.loading}>
  607. <div className="clearfix">
  608. <FormItem className="half-item"
  609. {...formItemLayout}
  610. label="项目编号" >
  611. <span>{this.state.serial}</span>
  612. </FormItem>
  613. <FormItem className="half-item"
  614. {...formItemLayout}
  615. label="客户名称" >
  616. <span>{this.state.buyerName}</span>
  617. </FormItem>
  618. <div className='clearfix'>
  619. <FormItem
  620. labelCol={{ span: 4 }}
  621. wrapperCol={{ span: 16 }}
  622. label="结项说明" >
  623. <Input type="textarea" placeholder="请输入备注" rows={4} value={this.state.signComment}
  624. onChange={(e)=>{this.setState({signComment:e.target.value})}}/>
  625. </FormItem>
  626. </div>
  627. </div>
  628. <FormItem wrapperCol={{ span: 12, offset: 4 }} className="half-middle">
  629. <Button className="submitSave" type="primary" htmlType="submit">确定结项</Button>
  630. <Button className="submitSave" type="ghost" onClick={this.noProject}>返回</Button>
  631. </FormItem>
  632. </Spin>
  633. </Form >
  634. </Modal>
  635. </div>
  636. );
  637. }
  638. }));
  639. export default ProjectOrder;