projectManage.jsx 22 KB

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