projectManage.jsx 20 KB

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