assign.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. import React from 'react';
  2. import ajax from 'jquery/src/ajax/xhr.js';
  3. import $ from 'jquery/src/ajax';
  4. import { Form,Radio, Button, Input, Select, Spin, Table, message, Modal ,Popconfirm} from 'antd';
  5. import {getPost} from '@/tools';
  6. const Assign=React.createClass({
  7. departmentList() {
  8. this.setState({
  9. loading: true
  10. });
  11. $.ajax({
  12. method: "get",
  13. dataType: "json",
  14. crossDomain: false,
  15. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  16. data: {
  17. },
  18. success: function(data) {
  19. let thedata = data.data;
  20. let theArr=[];
  21. if(!thedata) {
  22. if(data.error && data.error.length) {
  23. message.warning(data.error[0].message);
  24. };
  25. thedata = {};
  26. }else{
  27. thedata.map(function(item,index){
  28. theArr.push({
  29. key:index,
  30. name:item.name,
  31. id:item.id,
  32. })
  33. })
  34. }
  35. this.setState({
  36. departmentArr:theArr,
  37. })
  38. }.bind(this),
  39. }).always(function() {
  40. this.setState({
  41. loading: false
  42. });
  43. }.bind(this));
  44. },
  45. getInitialState() {
  46. return {
  47. contact:0,
  48. selectedRows: [],
  49. searchMore: true,
  50. loading: false,
  51. visible:false,
  52. showDesc:false,
  53. pagination: {
  54. defaultCurrent: 1,
  55. defaultPageSize: 10,
  56. showQuickJumper: true,
  57. pageSize: 10,
  58. onChange: function (page) {
  59. this.loadData(page);
  60. }.bind(this),
  61. showTotal: function (total) {
  62. return '共' + total + '条数据';
  63. }
  64. },
  65. userList:[
  66. {
  67. title: '用户姓名',
  68. dataIndex: 'name',
  69. key: 'name',
  70. width:100
  71. },{
  72. title: '部门机构',
  73. dataIndex: 'departmentName',
  74. key: 'departmentName',
  75. width:150,
  76. render:text=>{
  77. return text&&text.length>12?<span title={text}>{text.substr(0,12)+'...'}</span>:text
  78. }
  79. }, {
  80. title: '职务',
  81. dataIndex: 'position',
  82. key: 'position',
  83. width:100,
  84. },{
  85. title: '联系手机',
  86. dataIndex: 'contactMobile',
  87. key: 'contactMobile',
  88. width:100
  89. }, {
  90. title: '操作',
  91. dataIndex: 'abc',
  92. key: 'abc',
  93. width:100,
  94. render:(text,record,index)=>{
  95. if(record.length){
  96. return (
  97. <Popconfirm title={'您确认将所选订单分配给【'+record.departmentName+'-'+record.name+'】?'} onConfirm={(e)=>{this.confirmSelect1(record)}} okText="确认" cancelText="取消">
  98. <Button style={{marginRight:'5px'}} type="primary">选定</Button>
  99. </Popconfirm>
  100. )
  101. }else {
  102. return (
  103. <Popconfirm title={'您确认将'+this.props.title+' 【'+this.props.data.orderNo+'】 分配给【'+record.departmentName+'-'+record.name+'】?'} onConfirm={(e)=>{this.confirmSelect(record)}} okText="确认" cancelText="取消">
  104. <Button style={{marginRight:'5px'}} type="primary">选定</Button>
  105. </Popconfirm>
  106. )
  107. }
  108. }
  109. }
  110. ],
  111. dataSource: [],
  112. };
  113. },
  114. //操作分配
  115. confirmDelet(index){
  116. this.setState({
  117. orderNos:index.orderNo,
  118. });
  119. },
  120. onCancel(){
  121. this.setState({
  122. visible:false
  123. })
  124. this.props.closeDesc(false,false);
  125. },
  126. onShow() {
  127. this.setState({
  128. visible: false,
  129. });
  130. this.props.closeDesc(false, true);
  131. },
  132. //分配对象列表
  133. contactList(item={},nub){
  134. this.setState({
  135. loading:true
  136. });
  137. let api = !nub?'/api/admin/frequentContactsList':'/api/admin/superviser/adminList';
  138. $.ajax({
  139. method: "get",
  140. dataType: "json",
  141. crossDomain: false,
  142. url: globalConfig.context + api,
  143. data: {
  144. pageNo: 1,
  145. pageSize: 99,
  146. departmentId:this.state.departmenttList,
  147. name:this.state.financeNameSearch,
  148. roleName:this.props.roleName
  149. },
  150. success: function (data) {
  151. let theArr = [];
  152. if (!data.data) {
  153. if (data.error && data.error.length) {
  154. message.warning(data.error[0].message);
  155. };
  156. } else {
  157. for (let i = 0; i < data.data.list.length; i++) {
  158. let thisdata = data.data.list[i];
  159. theArr.push({
  160. key: i,
  161. id: thisdata.id,
  162. contactId:thisdata.contactId,
  163. userNo: thisdata.userNo,
  164. name:thisdata.name,
  165. departmentName:thisdata.departmentName,
  166. departmentId:thisdata.departmentId,
  167. position:thisdata.roles[0],
  168. contactMobile:thisdata.contactMobile,
  169. });
  170. };
  171. };
  172. this.setState({
  173. distributionList: theArr,
  174. });
  175. }.bind(this),
  176. }).always(function () {
  177. this.setState({
  178. loading: false
  179. });
  180. }.bind(this));
  181. },
  182. //选定对象
  183. confirmSelect(record){
  184. this.setState({
  185. loading: true
  186. });
  187. console.log(this.state.contact);
  188. $.ajax({
  189. method: this.props.requestMethod,
  190. dataType: "json",
  191. crossDomain: false,
  192. url: globalConfig.context +this.props.selApi,
  193. // data:{
  194. // taskId:this.props.data.id,//任务ID
  195. // taskReceiverId:this.state.contact?record.id:record.contactId,//分配人物ID
  196. // specially:this.props.specially,//是否是咨询师管理员
  197. // orderNo:this.state.orderNo,
  198. // financeId: this.state.contact?record.id:record.contactId, //分配人物id
  199. // approval:this.props.data.approval, //是否特批
  200. // newFinance:this.state.contact?record.id:record.contactId
  201. //
  202. // }
  203. data: this.judge(this.props,record)
  204. }).done(function (data) {
  205. if (!data.error.length) {
  206. message.success('派单成功');
  207. this.onShow();
  208. } else {
  209. message.warning(data.error[0].message);
  210. };
  211. this.setState({
  212. loading: false,
  213. });
  214. }.bind(this));
  215. },
  216. confirmSelect1(record){
  217. this.setState({
  218. loading: true
  219. });
  220. console.log(this.state.contact);
  221. $.ajax({
  222. method: this.props.requestMethod,
  223. dataType: "json",
  224. crossDomain: false,
  225. url: globalConfig.context + this.props.selApi,
  226. // data:{
  227. // taskId:this.props.data.id,//任务ID
  228. // taskReceiverId:this.state.contact?record.id:record.contactId,//分配人物ID
  229. // specially:this.props.specially,//是否是咨询师管理员
  230. // orderNo:this.state.orderNo,
  231. // financeId: this.state.contact?record.id:record.contactId, //分配人物id
  232. // approval:this.props.data.approval, //是否特批
  233. // newFinance:this.state.contact?record.id:record.contactId
  234. //
  235. // }
  236. data: {
  237. orderNo: this.state.orderNo,
  238. financeId: this.state.contact ? record.id : record.contactId
  239. }
  240. }).done(
  241. function(data) {
  242. if (!data.error.length) {
  243. message.success("派单成功");
  244. this.onShow();
  245. } else {
  246. message.warning(data.error[0].message);
  247. }
  248. this.setState({
  249. loading: false
  250. });
  251. }.bind(this)
  252. );
  253. },
  254. /* 区分分派和两种转交 */
  255. judge(props,record){
  256. if (props.fenpaiData===8) {
  257. if(props.flag === true) {
  258. return {
  259. taskId: props.data.id, //任务ID
  260. taskReceiverId: this.state.contact
  261. ? record.id
  262. : record.contactId, //分配人物ID
  263. specially: 2 //退给咨询师经理
  264. };
  265. }
  266. return {
  267. taskId:props.data.id,//任务ID
  268. taskReceiverId:this.state.contact?record.id:record.contactId,//分配人物ID
  269. specially:props.specially//是否是咨询师管理员
  270. };
  271. } else if(props.fenpaiData===4){
  272. return {
  273. orderNo:this.state.orderNo,
  274. financeId: this.state.contact?record.id:record.contactId, //分配人物id
  275. approval:props.data.approval //是否特批
  276. };
  277. } else {
  278. return {
  279. orderNo:this.state.orderNo,
  280. newFinance:this.state.contact?record.id:record.contactId
  281. };
  282. }
  283. },
  284. searchOrder(){
  285. this.contactList({},this.state.contact);
  286. },
  287. resetOrder(){
  288. this.state.departmenttList=undefined;
  289. this.state.financeNameSearch='';
  290. this.state.contact=0;
  291. this.setState({
  292. distributionList:[]
  293. });
  294. },
  295. //初始加载组件,和主页面一起加载
  296. componentDidMount() {
  297. },
  298. //组件调用初始加载函数,可用条件控制,在调用组件时可以拿到参数
  299. componentWillReceiveProps(nextProps) {
  300. this.state.visible=nextProps.showDesc;
  301. if(nextProps.showDesc){
  302. this.contactList(nextProps,0);
  303. this.departmentList()
  304. this.setState({
  305. orderNo:nextProps.data.orderNo
  306. })
  307. }
  308. this.setState({
  309. contact:0
  310. })
  311. // console.log("kan", this.props.specially);
  312. // console.log("kan22", this.state);
  313. },
  314. render() {
  315. let departmentArr = this.state.departmentArr || [];
  316. return (
  317. <div className="user-content" >
  318. <Modal maskClosable={false} visible={this.state.visible}
  319. onOk={this.onShow} onCancel={this.onCancel}
  320. width='800px'
  321. title='选择'
  322. footer=''
  323. className="admin-desc-content">
  324. <Form layout="horizontal" onSubmit={this.handleSubmit} id="demand-form" style={{paddingBottom:'40px'}} >
  325. <Spin spinning={this.state.loading}>
  326. <div>
  327. <span style={{marginRight:5}}>常用联系人:</span>
  328. <Radio.Group onChange={(e)=>{this.setState({contact:e.target.value})}} value={this.state.contact}>
  329. <Radio value={0}>是</Radio>
  330. <Radio value={1}>否</Radio>
  331. </Radio.Group>
  332. <Select placeholder="部门"
  333. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  334. value={this.state.departmenttList}
  335. onChange={(e) => { this.setState({ departmenttList: e }) }}>
  336. {
  337. departmentArr.map(function (item) {
  338. return <Select.Option key={item.id} >{item.name}</Select.Option>
  339. })
  340. }
  341. </Select>
  342. <Input placeholder="姓名" style={{width:'150px',marginLeft:'10px'}}
  343. value={this.state.financeNameSearch}
  344. onChange={(e) => { this.setState({ financeNameSearch: e.target.value }); }} />
  345. <Button type="primary" onClick={this.searchOrder} style={{marginLeft:'10px',marginRight:'10px'}}>搜索</Button>
  346. <Button onClick={this.resetOrder}>重置</Button>
  347. </div>
  348. <div className="patent-table" style={{marginTop:'10px'}}>
  349. <Spin spinning={this.state.loading}>
  350. <Table columns={this.state.userList}
  351. dataSource={this.state.distributionList}
  352. pagination={false}
  353. scroll={{y:400}}
  354. />
  355. </Spin>
  356. </div>
  357. </Spin>
  358. </Form>
  359. </Modal>
  360. </div>
  361. );
  362. }
  363. });
  364. export default Assign;