assign.jsx 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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. roleName:this.props.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. console.log(this.props.data);
  183. console.log(record);
  184. $.ajax({
  185. method: "post",
  186. dataType: "json",
  187. crossDomain: false,
  188. url: globalConfig.context +this.props.selApi,
  189. data: this.props.fenpaiData==8?{
  190. taskId:this.props.data.id,//任务ID
  191. taskReceiverId:!this.state.contact?record.id:record.contactId,//分配人物ID
  192. specially:this.props.specially//是否是咨询师管理员
  193. }:{
  194. orderNo:this.props.data.orderNo,
  195. financeId: !this.state.contact?record.id:record.contactId, //分配人物id
  196. approval:this.props.data.approval //是否特批
  197. }
  198. }).done(function (data) {
  199. if (!data.error.length) {
  200. message.success('派单成功');
  201. this.onShow();
  202. } else {
  203. message.warning(data.error[0].message);
  204. };
  205. this.setState({
  206. loading: false,
  207. });
  208. }.bind(this));
  209. },
  210. searchOrder(){
  211. this.contactList();
  212. },
  213. resetOrder(){
  214. this.state.departmenttList=undefined;
  215. this.state.financeNameSearch='';
  216. this.state.contact=0;
  217. this.setState({
  218. distributionList:[]
  219. });
  220. },
  221. componentWillMount() {
  222. },
  223. componentWillReceiveProps(nextProps) {
  224. this.state.visible=nextProps.showDesc;
  225. if(nextProps.showDesc){
  226. this.contactList();
  227. this.departmentList()
  228. }
  229. this.setState({
  230. contact:1
  231. })
  232. },
  233. render() {
  234. let departmentArr = this.state.departmentArr || [];
  235. return (
  236. <div className="user-content" >
  237. <Modal maskClosable={false} visible={this.state.visible}
  238. onOk={this.onShow} onCancel={this.onCancel}
  239. width='800px'
  240. title='选择'
  241. footer=''
  242. className="admin-desc-content">
  243. <Form layout="horizontal" onSubmit={this.handleSubmit} id="demand-form" style={{paddingBottom:'40px'}} >
  244. <Spin spinning={this.state.loading}>
  245. <div>
  246. <span style={{marginRight:5}}>常用联系人:</span>
  247. <Radio.Group onChange={(e)=>{this.setState({contact:e.target.value})}} value={this.state.contact}>
  248. <Radio value={0}>否</Radio>
  249. <Radio value={1}>是</Radio>
  250. </Radio.Group>
  251. <Select placeholder="部门"
  252. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  253. value={this.state.departmenttList}
  254. onChange={(e) => { this.setState({ departmenttList: e }) }}>
  255. {
  256. departmentArr.map(function (item) {
  257. return <Select.Option key={item.id} >{item.name}</Select.Option>
  258. })
  259. }
  260. </Select>
  261. <Input placeholder="姓名" style={{width:'150px',marginLeft:'10px'}}
  262. value={this.state.financeNameSearch}
  263. onChange={(e) => { this.setState({ financeNameSearch: e.target.value }); }} />
  264. <Button type="primary" onClick={this.searchOrder} style={{marginLeft:'10px',marginRight:'10px'}}>搜索</Button>
  265. <Button onClick={this.resetOrder}>重置</Button>
  266. </div>
  267. <div className="patent-table" style={{marginTop:'10px'}}>
  268. <Spin spinning={this.state.loading}>
  269. <Table columns={this.state.userList}
  270. dataSource={this.state.distributionList}
  271. pagination={false}
  272. scroll={{y:400}}
  273. />
  274. </Spin>
  275. </div>
  276. </Spin>
  277. </Form>
  278. </Modal>
  279. </div>
  280. );
  281. }
  282. });
  283. export default Assign;