projectManage.jsx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  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. //启动
  405. startUp(record){
  406. this.removeList(true,record)
  407. },
  408. //完成
  409. endUp(record){
  410. this.removeList(false,record)
  411. },
  412. removeList(state,record){
  413. this.setState({
  414. loading: true
  415. });
  416. let api=state?'/api/admin/techproject/startTask':'/api/admin/techproject/completeTask';
  417. $.ajax({
  418. method: "get",
  419. dataType: "json",
  420. crossDomain: false,
  421. url: globalConfig.context + api,
  422. data: {
  423. taskId:record.taskId
  424. }
  425. }).done(function(data) {
  426. this.setState({
  427. loading: false
  428. });
  429. if(!data.error.length) {
  430. message.success('操作成功!');
  431. this.loadData(this.state.pageNo)
  432. } else {
  433. message.warning(data.error[0].message);
  434. }
  435. }.bind(this));
  436. },
  437. searchSwitch() {
  438. this.setState({
  439. searchMore: !this.state.searchMore
  440. });
  441. },
  442. search() {
  443. this.loadData();
  444. },
  445. tableRowClick(record, index) {
  446. this.state.datauser = record;
  447. this.setState({
  448. showDesc: true
  449. });
  450. },
  451. searchOrder(){
  452. this.contactList();
  453. },
  454. resetOrder(){
  455. this.state.departmenttList=undefined;
  456. this.state.financeNameSearch='';
  457. this.setState({
  458. distributionList:[]
  459. })
  460. },
  461. reset() {
  462. this.state.buyerNameSearch='';
  463. this.state.releaseDate[0] = undefined;
  464. this.state.releaseDate[1] = undefined;
  465. this.state.departmentt=undefined;
  466. this.state.orderStatusSearch = undefined;
  467. this.state.salesmanNameSearch = '';
  468. this.state.orderNoSearch='';
  469. this.state.deleteSignSearch=undefined;
  470. this.state.categoryIdSearch=undefined;
  471. this.loadData();
  472. },
  473. render() {
  474. const FormItem = Form.Item;
  475. const formItemLayout = {
  476. labelCol: { span: 8 },
  477. wrapperCol: { span: 14 },
  478. };
  479. const { RangePicker } = DatePicker;
  480. const rowSelection = {
  481. selectedRowKeys: this.state.selectedRowKeys,
  482. onChange: (selectedRowKeys, selectedRows) => {
  483. this.setState({
  484. selectedRows: selectedRows.slice(-1),
  485. selectedRowKeys: selectedRowKeys.slice(-1)
  486. });
  487. },
  488. onSelectAll: (selected, selectedRows, changeRows) => {
  489. this.setState({
  490. selectedRowKeys:[]
  491. })
  492. },
  493. };
  494. const hasSelected = this.state.selectedRowKeys.length > 0;
  495. let departmentArr = this.state.departmentArr || [];
  496. let businessArr = this.state.businessArr || []
  497. return (
  498. <div className="user-content" >
  499. <div className="content-title">
  500. <span style={{fontSize:'16px'}}>我的项目任务</span>
  501. <div className="user-search">
  502. <Input placeholder="客户名称" style={{width:'150px'}}
  503. value={this.state.buyerNameSearch}
  504. onChange={(e) => { this.setState({ buyerNameSearch: e.target.value }); }} />
  505. <RangePicker
  506. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  507. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  508. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  509. <Button type="primary" onClick={this.search} style={{marginLeft:'10px'}}>搜索</Button>
  510. <Button onClick={this.reset}>重置</Button>
  511. <span style={{marginLeft:'10px',marginRight:'20px'}}>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  512. </div>
  513. <div className='clearfix' style={{marginTop:'5px'}}>
  514. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  515. <Select placeholder="任务状态"
  516. style={{ width: 150 ,marginRight:'10px'}}
  517. value={this.state.orderStatusSearch}
  518. onChange={(e) => { this.setState({ orderStatusSearch: e }) }}>
  519. {
  520. taskStatus.map(function (item) {
  521. return <Select.Option key={item.value} >{item.key}</Select.Option>
  522. })
  523. }
  524. </Select>
  525. <Select placeholder="业务类别"
  526. style={{ width: 150 ,marginRight:'10px',marginBottom:'10px'}}
  527. value={this.state.categoryIdSearch}
  528. onChange={(e) => { this.setState({ categoryIdSearch: e }) }}>
  529. {
  530. businessArr.map(function (item) {
  531. return <Select.Option key={item.id} >{item.name}</Select.Option>
  532. })
  533. }
  534. </Select>
  535. <Input placeholder="项目编号" style={{width:'150px'}}
  536. value={this.state.orderNoSearch}
  537. onChange={(e) => { this.setState({ orderNoSearch: e.target.value }); }} />
  538. </div>
  539. </div>
  540. <div className="patent-table">
  541. <Spin spinning={this.state.loading}>
  542. <Table columns={this.state.columns}
  543. dataSource={this.state.dataSource}
  544. rowSelection={rowSelection}
  545. pagination={this.state.pagination}
  546. onRowClick={this.tableRowClick}
  547. />
  548. </Spin>
  549. </div>
  550. <MySettlementDetaile
  551. datauser={this.state.datauser}
  552. showDesc={this.state.showDesc}
  553. />
  554. </div >
  555. <Modal maskClosable={false} visible={this.state.distributionVisible}
  556. onOk={this.distributionCancel} onCancel={this.distributionCancel}
  557. width='800px'
  558. title='转交'
  559. footer=''
  560. className="admin-desc-content">
  561. <Form layout="horizontal" onSubmit={this.handleSubmit} id="demand-form" style={{paddingBottom:'40px'}} >
  562. <Spin spinning={this.state.loading}>
  563. <div>
  564. <Select placeholder="订单部门"
  565. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  566. value={this.state.departmenttList}
  567. onChange={(e) => { this.setState({ departmenttList: e }) }}>
  568. {
  569. departmentArr.map(function (item) {
  570. return <Select.Option key={item.id} >{item.name}</Select.Option>
  571. })
  572. }
  573. </Select>
  574. <Input placeholder="任务负责人" style={{width:'150px',marginLeft:'10px'}}
  575. value={this.state.financeNameSearch}
  576. onChange={(e) => { this.setState({ financeNameSearch: e.target.value }); }} />
  577. <Button type="primary" onClick={this.searchOrder} style={{marginLeft:'10px',marginRight:'10px'}}>搜索</Button>
  578. <Button onClick={this.resetOrder}>重置</Button>
  579. </div>
  580. <div className="patent-table" style={{marginTop:'10px'}}>
  581. <Spin spinning={this.state.loading}>
  582. <Table columns={this.state.userList}
  583. dataSource={this.state.distributionList}
  584. pagination={false}
  585. />
  586. </Spin>
  587. </div>
  588. </Spin>
  589. </Form>
  590. </Modal>
  591. </div>
  592. );
  593. }
  594. }));
  595. export default MyTask;