assign.jsx 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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:100,
  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. render:text=>{
  85. return getPost(text)
  86. }
  87. },{
  88. title: '联系手机',
  89. dataIndex: 'contactMobile',
  90. key: 'contactMobile',
  91. width:100
  92. }, {
  93. title: '操作',
  94. dataIndex: 'abc',
  95. key: 'abc',
  96. width:100,
  97. render:(text,record,index)=>{
  98. return (
  99. <Popconfirm title={'您确认将'+this.props.title+' 【'+this.props.data.orderNo+'】 分配给【'+record.departmentName+'-'+record.name+'】?'} onConfirm={(e)=>{this.confirmSelect(record)}} okText="确认" cancelText="取消">
  100. <Button style={{marginRight:'5px'}} type="primary">选定</Button>
  101. </Popconfirm>
  102. )
  103. }
  104. }
  105. ],
  106. dataSource: [],
  107. };
  108. },
  109. //操作分配
  110. confirmDelet(index){
  111. this.setState({
  112. orderNos:index.orderNo,
  113. });
  114. },
  115. onCancel(){
  116. this.setState({
  117. visible:false
  118. })
  119. this.props.closeDesc(false,false);
  120. },
  121. onShow() {
  122. this.setState({
  123. visible: false,
  124. });
  125. this.props.closeDesc(false, true);
  126. },
  127. //分配对象列表
  128. contactList(item={}){
  129. this.setState({
  130. loading:true
  131. });
  132. let api = this.state.contact?'/api/admin/frequentContactsList':'/api/admin/superviser/adminList';
  133. $.ajax({
  134. method: "get",
  135. dataType: "json",
  136. crossDomain: false,
  137. url: globalConfig.context + api,
  138. data: {
  139. pageNo: 1,
  140. pageSize: 99,
  141. departmentId:this.state.departmenttList,
  142. name:this.state.financeNameSearch,
  143. roleName:item.roleName?item.roleName:this.props.roleName
  144. },
  145. success: function (data) {
  146. let theArr = [];
  147. if (!data.data) {
  148. if (data.error && data.error.length) {
  149. message.warning(data.error[0].message);
  150. };
  151. } else {
  152. for (let i = 0; i < data.data.list.length; i++) {
  153. let thisdata = data.data.list[i];
  154. theArr.push({
  155. key: i,
  156. id: thisdata.id,
  157. contactId:thisdata.contactId,
  158. userNo: thisdata.userNo,
  159. name:thisdata.name,
  160. departmentName:thisdata.departmentName,
  161. departmentId:thisdata.departmentId,
  162. position:thisdata.position,
  163. contactMobile:thisdata.contactMobile,
  164. });
  165. };
  166. };
  167. this.setState({
  168. distributionList: theArr,
  169. });
  170. }.bind(this),
  171. }).always(function () {
  172. this.setState({
  173. loading: false
  174. });
  175. }.bind(this));
  176. },
  177. //选定对象
  178. confirmSelect(record){
  179. this.setState({
  180. loading: true
  181. });
  182. $.ajax({
  183. method: "post",
  184. dataType: "json",
  185. crossDomain: false,
  186. url: globalConfig.context +this.props.selApi,
  187. data: this.props.fenpaiData==8?{
  188. taskId:this.props.data.id,//任务ID
  189. taskReceiverId:!this.state.contact?record.id:record.contactId,//分配人物ID
  190. specially:this.props.specially//是否是咨询师管理员
  191. }:{
  192. orderNo:this.props.data.orderNo,
  193. financeId: !this.state.contact?record.id:record.contactId, //分配人物id
  194. approval:this.props.data.approval //是否特批
  195. }
  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. searchOrder(){
  209. this.contactList();
  210. },
  211. resetOrder(){
  212. this.state.departmenttList=undefined;
  213. this.state.financeNameSearch='';
  214. this.state.contact=0;
  215. this.setState({
  216. distributionList:[]
  217. });
  218. },
  219. componentWillMount() {
  220. },
  221. componentWillReceiveProps(nextProps) {
  222. this.state.visible=nextProps.showDesc;
  223. if(nextProps.showDesc){
  224. this.contactList(nextProps);
  225. this.departmentList()
  226. }
  227. this.setState({
  228. contact:1
  229. })
  230. },
  231. render() {
  232. let departmentArr = this.state.departmentArr || [];
  233. return (
  234. <div className="user-content" >
  235. <Modal maskClosable={false} visible={this.state.visible}
  236. onOk={this.onShow} onCancel={this.onCancel}
  237. width='800px'
  238. title='选择'
  239. footer=''
  240. className="admin-desc-content">
  241. <Form layout="horizontal" onSubmit={this.handleSubmit} id="demand-form" style={{paddingBottom:'40px'}} >
  242. <Spin spinning={this.state.loading}>
  243. <div>
  244. <span style={{marginRight:5}}>常用联系人:</span>
  245. <Radio.Group onChange={(e)=>{this.setState({contact:e.target.value})}} value={this.state.contact}>
  246. <Radio value={0}>否</Radio>
  247. <Radio value={1}>是</Radio>
  248. </Radio.Group>
  249. <Select placeholder="部门"
  250. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  251. value={this.state.departmenttList}
  252. onChange={(e) => { this.setState({ departmenttList: e }) }}>
  253. {
  254. departmentArr.map(function (item) {
  255. return <Select.Option key={item.id} >{item.name}</Select.Option>
  256. })
  257. }
  258. </Select>
  259. <Input placeholder="姓名" style={{width:'150px',marginLeft:'10px'}}
  260. value={this.state.financeNameSearch}
  261. onChange={(e) => { this.setState({ financeNameSearch: e.target.value }); }} />
  262. <Button type="primary" onClick={this.searchOrder} style={{marginLeft:'10px',marginRight:'10px'}}>搜索</Button>
  263. <Button onClick={this.resetOrder}>重置</Button>
  264. </div>
  265. <div className="patent-table" style={{marginTop:'10px'}}>
  266. <Spin spinning={this.state.loading}>
  267. <Table columns={this.state.userList}
  268. dataSource={this.state.distributionList}
  269. pagination={false}
  270. scroll={{y:400}}
  271. />
  272. </Spin>
  273. </div>
  274. </Spin>
  275. </Form>
  276. </Modal>
  277. </div>
  278. );
  279. }
  280. });
  281. export default Assign;