assign.jsx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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:1,
  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:item.roleName?item.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. console.log(thisdata.roles[0]);
  152. theArr.push({
  153. key: i,
  154. id: thisdata.id,
  155. contactId:thisdata.contactId,
  156. userNo: thisdata.userNo,
  157. name:thisdata.name,
  158. departmentName:thisdata.departmentName,
  159. departmentId:thisdata.departmentId,
  160. position:thisdata.roles[0],
  161. contactMobile:thisdata.contactMobile,
  162. });
  163. };
  164. };
  165. this.setState({
  166. distributionList: theArr,
  167. });
  168. }.bind(this),
  169. }).always(function () {
  170. this.setState({
  171. loading: false
  172. });
  173. }.bind(this));
  174. },
  175. //选定对象
  176. confirmSelect(record){
  177. this.setState({
  178. loading: true
  179. });
  180. console.log(this.state.contact);
  181. $.ajax({
  182. method: "post",
  183. dataType: "json",
  184. crossDomain: false,
  185. url: globalConfig.context +this.props.selApi,
  186. data: this.props.fenpaiData==8?{
  187. taskId:this.props.data.id,//任务ID
  188. taskReceiverId:this.state.contact?record.id:record.contactId,//分配人物ID
  189. specially:this.props.specially//是否是咨询师管理员
  190. }:{
  191. orderNo:this.state.orderNo,
  192. financeId: this.state.contact?record.id:record.contactId, //分配人物id
  193. approval:this.props.data.approval //是否特批
  194. }
  195. }).done(function (data) {
  196. if (!data.error.length) {
  197. message.success('派单成功');
  198. this.onShow();
  199. } else {
  200. message.warning(data.error[0].message);
  201. };
  202. this.setState({
  203. loading: false,
  204. });
  205. }.bind(this));
  206. },
  207. searchOrder(){
  208. this.contactList({},this.state.contact);
  209. },
  210. resetOrder(){
  211. this.state.departmenttList=undefined;
  212. this.state.financeNameSearch='';
  213. this.state.contact=0;
  214. this.setState({
  215. distributionList:[]
  216. });
  217. },
  218. //初始加载组件,和主页面一起加载
  219. componentWillMount() {
  220. },
  221. //组件调用初始加载函数,可用条件控制,在调用组件时可以拿到参数
  222. componentWillReceiveProps(nextProps) {
  223. this.state.visible=nextProps.showDesc;
  224. if(nextProps.showDesc){
  225. this.contactList(nextProps,1);
  226. this.departmentList()
  227. this.setState({
  228. orderNo:nextProps.data.orderNo
  229. })
  230. }
  231. this.setState({
  232. contact:1
  233. })
  234. },
  235. render() {
  236. let departmentArr = this.state.departmentArr || [];
  237. return (
  238. <div className="user-content" >
  239. <Modal maskClosable={false} visible={this.state.visible}
  240. onOk={this.onShow} onCancel={this.onCancel}
  241. width='800px'
  242. title='选择'
  243. footer=''
  244. className="admin-desc-content">
  245. <Form layout="horizontal" onSubmit={this.handleSubmit} id="demand-form" style={{paddingBottom:'40px'}} >
  246. <Spin spinning={this.state.loading}>
  247. <div>
  248. <span style={{marginRight:5}}>常用联系人:</span>
  249. <Radio.Group onChange={(e)=>{this.setState({contact:e.target.value})}} value={this.state.contact}>
  250. <Radio value={1}>否</Radio>
  251. <Radio value={0}>是</Radio>
  252. </Radio.Group>
  253. <Select placeholder="部门"
  254. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  255. value={this.state.departmenttList}
  256. onChange={(e) => { this.setState({ departmenttList: e }) }}>
  257. {
  258. departmentArr.map(function (item) {
  259. return <Select.Option key={item.id} >{item.name}</Select.Option>
  260. })
  261. }
  262. </Select>
  263. <Input placeholder="姓名" style={{width:'150px',marginLeft:'10px'}}
  264. value={this.state.financeNameSearch}
  265. onChange={(e) => { this.setState({ financeNameSearch: e.target.value }); }} />
  266. <Button type="primary" onClick={this.searchOrder} style={{marginLeft:'10px',marginRight:'10px'}}>搜索</Button>
  267. <Button onClick={this.resetOrder}>重置</Button>
  268. </div>
  269. <div className="patent-table" style={{marginTop:'10px'}}>
  270. <Spin spinning={this.state.loading}>
  271. <Table columns={this.state.userList}
  272. dataSource={this.state.distributionList}
  273. pagination={false}
  274. scroll={{y:400}}
  275. />
  276. </Spin>
  277. </div>
  278. </Spin>
  279. </Form>
  280. </Modal>
  281. </div>
  282. );
  283. }
  284. });
  285. export default Assign;