assign.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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. return (
  96. <Popconfirm title={'您确认将'+this.props.title+' 【'+this.props.data.orderNo+'】 分配给【'+record.departmentName+'-'+record.name+'】?'} onConfirm={(e)=>{this.confirmSelect(record)}} okText="确认" cancelText="取消">
  97. <Button style={{marginRight:'5px'}} type="primary">选定</Button>
  98. </Popconfirm>
  99. )
  100. }
  101. }
  102. ],
  103. dataSource: [],
  104. };
  105. },
  106. //操作分配
  107. confirmDelet(index){
  108. this.setState({
  109. orderNos:index.orderNo,
  110. });
  111. },
  112. onCancel(){
  113. this.setState({
  114. visible:false
  115. })
  116. this.props.closeDesc(false,false);
  117. },
  118. onShow() {
  119. this.setState({
  120. visible: false,
  121. });
  122. this.props.closeDesc(false, true);
  123. },
  124. //分配对象列表
  125. contactList(item={},nub){
  126. this.setState({
  127. loading:true
  128. });
  129. let api = !nub?'/api/admin/frequentContactsList':'/api/admin/superviser/adminList';
  130. $.ajax({
  131. method: "get",
  132. dataType: "json",
  133. crossDomain: false,
  134. url: globalConfig.context + api,
  135. data: {
  136. pageNo: 1,
  137. pageSize: 99,
  138. departmentId:this.state.departmenttList,
  139. name:this.state.financeNameSearch,
  140. roleName:this.props.roleName
  141. },
  142. success: function (data) {
  143. let theArr = [];
  144. if (!data.data) {
  145. if (data.error && data.error.length) {
  146. message.warning(data.error[0].message);
  147. };
  148. } else {
  149. for (let i = 0; i < data.data.list.length; i++) {
  150. let thisdata = data.data.list[i];
  151. theArr.push({
  152. key: i,
  153. id: thisdata.id,
  154. contactId:thisdata.contactId,
  155. userNo: thisdata.userNo,
  156. name:thisdata.name,
  157. departmentName:thisdata.departmentName,
  158. departmentId:thisdata.departmentId,
  159. position:thisdata.roles[0],
  160. contactMobile:thisdata.contactMobile,
  161. });
  162. };
  163. };
  164. this.setState({
  165. distributionList: theArr,
  166. });
  167. }.bind(this),
  168. }).always(function () {
  169. this.setState({
  170. loading: false
  171. });
  172. }.bind(this));
  173. },
  174. //选定对象
  175. confirmSelect(record){
  176. this.setState({
  177. loading: true
  178. });
  179. console.log(this.state.contact);
  180. $.ajax({
  181. method: this.props.requestMethod,
  182. dataType: "json",
  183. crossDomain: false,
  184. url: globalConfig.context +this.props.selApi,
  185. // data:{
  186. // taskId:this.props.data.id,//任务ID
  187. // taskReceiverId:this.state.contact?record.id:record.contactId,//分配人物ID
  188. // specially:this.props.specially,//是否是咨询师管理员
  189. // orderNo:this.state.orderNo,
  190. // financeId: this.state.contact?record.id:record.contactId, //分配人物id
  191. // approval:this.props.data.approval, //是否特批
  192. // newFinance:this.state.contact?record.id:record.contactId
  193. //
  194. // }
  195. data: this.judge(this.props,record)
  196. }).done(function (data) {
  197. if (!data.error.length) {
  198. message.success('派单成功');
  199. this.onShow();
  200. } else {
  201. message.warning(data.error[0].message);
  202. };
  203. this.setState({
  204. loading: false,
  205. });
  206. }.bind(this));
  207. },
  208. /* 区分分派和两种转交 */
  209. judge(props,record){
  210. if (props.fenpaiData===8) {
  211. if(props.flag === true) {
  212. return {
  213. taskId: props.data.id, //任务ID
  214. taskReceiverId: this.state.contact
  215. ? record.id
  216. : record.contactId, //分配人物ID
  217. specially: 2 //退给咨询师经理
  218. };
  219. }
  220. return {
  221. taskId:props.data.id,//任务ID
  222. taskReceiverId:this.state.contact?record.id:record.contactId,//分配人物ID
  223. specially:props.specially//是否是咨询师管理员
  224. };
  225. } else if(props.fenpaiData===4){
  226. return {
  227. orderNo:this.state.orderNo,
  228. financeId: this.state.contact?record.id:record.contactId, //分配人物id
  229. approval:props.data.approval //是否特批
  230. };
  231. } else {
  232. return {
  233. orderNo:this.state.orderNo,
  234. newFinance:this.state.contact?record.id:record.contactId
  235. };
  236. }
  237. },
  238. searchOrder(){
  239. this.contactList({},this.state.contact);
  240. },
  241. resetOrder(){
  242. this.state.departmenttList=undefined;
  243. this.state.financeNameSearch='';
  244. this.state.contact=0;
  245. this.setState({
  246. distributionList:[]
  247. });
  248. },
  249. //初始加载组件,和主页面一起加载
  250. componentDidMount() {
  251. },
  252. //组件调用初始加载函数,可用条件控制,在调用组件时可以拿到参数
  253. componentWillReceiveProps(nextProps) {
  254. this.state.visible=nextProps.showDesc;
  255. if(nextProps.showDesc){
  256. this.contactList(nextProps,0);
  257. this.departmentList()
  258. this.setState({
  259. orderNo:nextProps.data.orderNo
  260. })
  261. }
  262. this.setState({
  263. contact:0
  264. })
  265. // console.log("kan", this.props.specially);
  266. // console.log("kan22", this.state);
  267. },
  268. render() {
  269. let departmentArr = this.state.departmentArr || [];
  270. return (
  271. <div className="user-content" >
  272. <Modal maskClosable={false} visible={this.state.visible}
  273. onOk={this.onShow} onCancel={this.onCancel}
  274. width='800px'
  275. title='选择'
  276. footer=''
  277. className="admin-desc-content">
  278. <Form layout="horizontal" onSubmit={this.handleSubmit} id="demand-form" style={{paddingBottom:'40px'}} >
  279. <Spin spinning={this.state.loading}>
  280. <div>
  281. <span style={{marginRight:5}}>常用联系人:</span>
  282. <Radio.Group onChange={(e)=>{this.setState({contact:e.target.value})}} value={this.state.contact}>
  283. <Radio value={0}>是</Radio>
  284. <Radio value={1}>否</Radio>
  285. </Radio.Group>
  286. <Select placeholder="部门"
  287. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  288. value={this.state.departmenttList}
  289. onChange={(e) => { this.setState({ departmenttList: e }) }}>
  290. {
  291. departmentArr.map(function (item) {
  292. return <Select.Option key={item.id} >{item.name}</Select.Option>
  293. })
  294. }
  295. </Select>
  296. <Input placeholder="姓名" style={{width:'150px',marginLeft:'10px'}}
  297. value={this.state.financeNameSearch}
  298. onChange={(e) => { this.setState({ financeNameSearch: e.target.value }); }} />
  299. <Button type="primary" onClick={this.searchOrder} style={{marginLeft:'10px',marginRight:'10px'}}>搜索</Button>
  300. <Button onClick={this.resetOrder}>重置</Button>
  301. </div>
  302. <div className="patent-table" style={{marginTop:'10px'}}>
  303. <Spin spinning={this.state.loading}>
  304. <Table columns={this.state.userList}
  305. dataSource={this.state.distributionList}
  306. pagination={false}
  307. scroll={{y:400}}
  308. />
  309. </Spin>
  310. </div>
  311. </Spin>
  312. </Form>
  313. </Modal>
  314. </div>
  315. );
  316. }
  317. });
  318. export default Assign;