assign.jsx 13 KB

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