selContact.jsx 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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. getInitialState() {
  8. return {
  9. contact:0,
  10. selectedRows: [],
  11. distributionList:[],
  12. searchMore: true,
  13. loading: false,
  14. visible:false,
  15. showDesc:false,
  16. pagination: {
  17. defaultCurrent: 1,
  18. defaultPageSize: 10,
  19. showQuickJumper: true,
  20. pageSize: 4,
  21. onChange: function (page) {
  22. this.loadData(page);
  23. }.bind(this),
  24. showTotal: function (total) {
  25. return '共' + total + '条数据';
  26. }
  27. },
  28. userList:[
  29. {
  30. title: '用户姓名',
  31. dataIndex: 'name',
  32. key: 'name',
  33. width:150,
  34. },{
  35. title: '部门机构',
  36. dataIndex: 'departmentName',
  37. key: 'departmentName',
  38. width:150,
  39. render:text=>{
  40. return text&&text.length>12?<span title={text}>{text.substr(0,12)+'...'}</span>:text
  41. }
  42. }, {
  43. title: '职务',
  44. dataIndex: 'position',
  45. key: 'position',
  46. width:150,
  47. render:text=>{
  48. return getPost(text);
  49. }
  50. },{
  51. title: '联系手机',
  52. dataIndex: 'contactMobile',
  53. key: 'contactMobile',
  54. width:150,
  55. }
  56. ],
  57. dataSource: [],
  58. };
  59. },
  60. //操作分配
  61. confirmDelet(index){
  62. this.setState({
  63. orderNos:index.orderNo,
  64. });
  65. },
  66. onCancel(){
  67. this.setState({
  68. visible:false
  69. })
  70. this.props.closeDesc(false,false);
  71. },
  72. onShow() {
  73. this.setState({
  74. visible: false,
  75. });
  76. this.props.closeDesc(false, true);
  77. },
  78. //分配对象列表
  79. contactList(){
  80. this.setState({
  81. loading:true,
  82. selectedRows:[],
  83. selectedRowKeys:[]
  84. })
  85. $.ajax({
  86. method: "get",
  87. dataType: "json",
  88. crossDomain: false,
  89. url: globalConfig.context + '/api/admin/superviser/adminList',
  90. data: {
  91. pageNo: 1,
  92. pageSize:999,
  93. departmentId:this.state.departmenttList,
  94. name:this.state.financeNameSearch,
  95. },
  96. success: function (data) {
  97. let theArr = [];
  98. if (!data.data) {
  99. if (data.error && data.error.length) {
  100. message.warning(data.error[0].message);
  101. };
  102. } else {
  103. for (let i = 0; i < data.data.list.length; i++) {
  104. let thisdata = data.data.list[i];
  105. theArr.push({
  106. key: i,
  107. id: thisdata.id,
  108. userNo: thisdata.userNo,
  109. name:thisdata.name,
  110. departmentName:thisdata.departmentName,
  111. departmentId:thisdata.departmentId,
  112. position:thisdata.position,
  113. contactMobile:thisdata.contactMobile,
  114. });
  115. };
  116. };
  117. this.setState({
  118. distributionList: theArr,
  119. });
  120. }.bind(this),
  121. }).always(function () {
  122. this.setState({
  123. loading: false
  124. });
  125. }.bind(this));
  126. },
  127. //选定对象
  128. handleSubmit(e){
  129. e.preventDefault();
  130. let selectedRows = this.state.selectedRows,idArr = [];
  131. selectedRows.map(item=>{
  132. idArr.push(item.id);
  133. })
  134. this.setState({
  135. loading: true
  136. });
  137. $.ajax({
  138. method: "post",
  139. dataType: "json",
  140. crossDomain: false,
  141. url: globalConfig.context +'/api/admin/addFrequentContacts',
  142. data: {
  143. id:idArr.join(',')
  144. }
  145. }).done(function (data) {
  146. if (!data.error.length) {
  147. message.success('添加成功');
  148. this.onShow();
  149. } else {
  150. message.warning(data.error[0].message);
  151. };
  152. this.setState({
  153. loading: false,
  154. });
  155. }.bind(this));
  156. },
  157. searchOrder(){
  158. this.contactList();
  159. },
  160. resetOrder(){
  161. this.state.departmenttList=undefined;
  162. this.state.financeNameSearch='';
  163. this.setState({
  164. distributionList:[]
  165. });
  166. },
  167. componentWillMount() {
  168. },
  169. componentWillReceiveProps(nextProps) {
  170. this.state.visible=nextProps.showDesc;
  171. this.state.distributionList=[];
  172. this.state.selectedRows=[],
  173. this.state.selectedRowKeys=[];
  174. },
  175. render() {
  176. const rowSelection = {
  177. selectedRowKeys: this.state.selectedRowKeys,
  178. onChange: (selectedRowKeys, selectedRows) => {
  179. this.setState({
  180. selectedRows: selectedRows,
  181. selectedRowKeys: selectedRowKeys
  182. });
  183. }
  184. };
  185. let departmentArr = this.props.departmentArr || [],
  186. nub = this.state.distributionList.length;
  187. return (
  188. <div className="user-content" >
  189. <Modal maskClosable={false} visible={this.state.visible}
  190. onOk={this.onShow} onCancel={this.onCancel}
  191. width='800px'
  192. title='常用联系人选择'
  193. footer=''
  194. className="admin-desc-content">
  195. <Form layout="horizontal" onSubmit={this.handleSubmit} id="demand-form" style={{paddingBottom:'40px'}} >
  196. <Spin spinning={this.state.loading}>
  197. <div>
  198. <Select placeholder="订单部门"
  199. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  200. value={this.state.departmenttList}
  201. onChange={(e) => { this.setState({ departmenttList: e }) }}>
  202. {
  203. departmentArr.map(function (item) {
  204. return <Select.Option key={item.id} >{item.name}</Select.Option>
  205. })
  206. }
  207. </Select>
  208. <Input placeholder="姓名" style={{width:'150px',marginLeft:'10px'}}
  209. value={this.state.financeNameSearch}
  210. onChange={(e) => { this.setState({ financeNameSearch: e.target.value }); }} />
  211. <Button type="primary" onClick={this.searchOrder} style={{marginLeft:'10px',marginRight:'10px'}}>搜索</Button>
  212. <Button onClick={this.resetOrder}>重置</Button>
  213. </div>
  214. <div className="patent-table" style={{marginTop:'10px'}}>
  215. <Spin spinning={this.state.loading}>
  216. <Table columns={this.state.userList}
  217. dataSource={this.state.distributionList}
  218. rowSelection={rowSelection}
  219. pagination={false}
  220. scroll={{ y:400}}
  221. />
  222. </Spin>
  223. </div>
  224. {nub?<div style={{textAlign:'center',marginTop:15}}>
  225. <Button type="primary" onClick={(e)=>{this.handleSubmit(e)}} style={{marginRight:20}}>选定</Button>
  226. <Button type="default" onClick={()=>{this.onCancel()}}>取消</Button>
  227. </div>:''}
  228. </Spin>
  229. </Form>
  230. </Modal>
  231. </div>
  232. );
  233. }
  234. });
  235. export default Assign;