selContact.jsx 8.4 KB

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