assign.jsx 9.6 KB

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