assign.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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(this.props.data.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. console.log(record);
  218. let orderNo = this.props.data.join(",")
  219. console.log(orderNo,record.id,this.props.selApi);
  220. this.setState({
  221. loading: true
  222. });
  223. console.log(this.state.contact);
  224. $.ajax({
  225. method: this.props.requestMethod,
  226. dataType: "json",
  227. crossDomain: false,
  228. url: globalConfig.context + this.props.selApi,
  229. // data:{
  230. // taskId:this.props.data.id,//任务ID
  231. // taskReceiverId:this.state.contact?record.id:record.contactId,//分配人物ID
  232. // specially:this.props.specially,//是否是咨询师管理员
  233. // orderNo:this.state.orderNo,
  234. // financeId: this.state.contact?record.id:record.contactId, //分配人物id
  235. // approval:this.props.data.approval, //是否特批
  236. // newFinance:this.state.contact?record.id:record.contactId
  237. //
  238. // }
  239. data: {
  240. orderNo,
  241. financeId: record.id,
  242. }
  243. }).done(
  244. function(data) {
  245. if (!data.error.length) {
  246. message.success("派单成功");
  247. this.onShow();
  248. } else {
  249. message.warning(data.error[0].message);
  250. }
  251. this.setState({
  252. loading: false
  253. });
  254. }.bind(this)
  255. );
  256. },
  257. /* 区分分派和两种转交 */
  258. judge(props,record){
  259. if (props.fenpaiData===8) {
  260. if(props.flag === true) {
  261. return {
  262. taskId: props.data.id, //任务ID
  263. taskReceiverId: this.state.contact
  264. ? record.id
  265. : record.contactId, //分配人物ID
  266. specially: 2 //退给咨询师经理
  267. };
  268. }
  269. return {
  270. taskId:props.data.id,//任务ID
  271. taskReceiverId:this.state.contact?record.id:record.contactId,//分配人物ID
  272. specially:props.specially//是否是咨询师管理员
  273. };
  274. } else if(props.fenpaiData===4){
  275. return {
  276. orderNo:this.state.orderNo,
  277. financeId: this.state.contact?record.id:record.contactId, //分配人物id
  278. approval:props.data.approval //是否特批
  279. };
  280. } else {
  281. return {
  282. orderNo:this.state.orderNo,
  283. newFinance:this.state.contact?record.id:record.contactId
  284. };
  285. }
  286. },
  287. searchOrder(){
  288. this.contactList({},this.state.contact);
  289. },
  290. resetOrder(){
  291. this.state.departmenttList=undefined;
  292. this.state.financeNameSearch='';
  293. this.state.contact=0;
  294. this.setState({
  295. distributionList:[]
  296. });
  297. },
  298. //初始加载组件,和主页面一起加载
  299. componentDidMount() {
  300. },
  301. //组件调用初始加载函数,可用条件控制,在调用组件时可以拿到参数
  302. componentWillReceiveProps(nextProps) {
  303. this.state.visible=nextProps.showDesc;
  304. if(nextProps.showDesc){
  305. this.contactList(nextProps,0);
  306. this.departmentList()
  307. this.setState({
  308. orderNo:nextProps.data.orderNo
  309. })
  310. }
  311. this.setState({
  312. contact:0
  313. })
  314. // console.log("kan", this.props.specially);
  315. // console.log("kan22", this.state);
  316. },
  317. render() {
  318. let departmentArr = this.state.departmentArr || [];
  319. return (
  320. <div className="user-content" >
  321. <Modal maskClosable={false} visible={this.state.visible}
  322. onOk={this.onShow} onCancel={this.onCancel}
  323. width='800px'
  324. title='选择'
  325. footer=''
  326. className="admin-desc-content">
  327. <Form layout="horizontal" onSubmit={this.handleSubmit} id="demand-form" style={{paddingBottom:'40px'}} >
  328. <Spin spinning={this.state.loading}>
  329. <div>
  330. <span style={{marginRight:5}}>常用联系人:</span>
  331. <Radio.Group onChange={(e)=>{this.setState({contact:e.target.value})}} value={this.state.contact}>
  332. <Radio value={0}>是</Radio>
  333. <Radio value={1}>否</Radio>
  334. </Radio.Group>
  335. <Select placeholder="部门"
  336. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  337. value={this.state.departmenttList}
  338. onChange={(e) => { this.setState({ departmenttList: e }) }}>
  339. {
  340. departmentArr.map(function (item) {
  341. return <Select.Option key={item.id} >{item.name}</Select.Option>
  342. })
  343. }
  344. </Select>
  345. <Input placeholder="姓名" style={{width:'150px',marginLeft:'10px'}}
  346. value={this.state.financeNameSearch}
  347. onChange={(e) => { this.setState({ financeNameSearch: e.target.value }); }} />
  348. <Button type="primary" onClick={this.searchOrder} style={{marginLeft:'10px',marginRight:'10px'}}>搜索</Button>
  349. <Button onClick={this.resetOrder}>重置</Button>
  350. </div>
  351. <div className="patent-table" style={{marginTop:'10px'}}>
  352. <Spin spinning={this.state.loading}>
  353. <Table columns={this.state.userList}
  354. dataSource={this.state.distributionList}
  355. pagination={false}
  356. scroll={{y:400}}
  357. />
  358. </Spin>
  359. </div>
  360. </Spin>
  361. </Form>
  362. </Modal>
  363. </div>
  364. );
  365. }
  366. });
  367. export default Assign;