assign.jsx 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. import React from 'react';
  2. import ajax from 'jquery/src/ajax/xhr.js';
  3. import $ from 'jquery/src/ajax';
  4. import { Form,Radio, Icon, Button, Input, Select, Spin, Table, Switch, message, DatePicker, Modal, Upload ,Popconfirm} from 'antd';
  5. import {orderState,orderChannel,orderType} from '@/dataDic.js';
  6. import {getOrderState,getOrderChannel,getPaymentState,getOrderType} from '@/tools.js';
  7. const Assign=React.createClass({
  8. departmentList() {
  9. this.setState({
  10. loading: true
  11. });
  12. $.ajax({
  13. method: "get",
  14. dataType: "json",
  15. crossDomain: false,
  16. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  17. data: {
  18. },
  19. success: function(data) {
  20. let thedata = data.data;
  21. let theArr=[];
  22. if(!thedata) {
  23. if(data.error && data.error.length) {
  24. message.warning(data.error[0].message);
  25. };
  26. thedata = {};
  27. }else{
  28. thedata.map(function(item,index){
  29. theArr.push({
  30. key:index,
  31. name:item.name,
  32. id:item.id,
  33. })
  34. })
  35. }
  36. this.setState({
  37. departmentArr:theArr,
  38. })
  39. }.bind(this),
  40. }).always(function() {
  41. this.setState({
  42. loading: false
  43. });
  44. }.bind(this));
  45. },
  46. getInitialState() {
  47. return {
  48. datauser:{},
  49. selectedRowKeys: [],
  50. releaseDate: [],
  51. selectedRows: [],
  52. searchMore: true,
  53. loading: false,
  54. distributionVisible:false,
  55. visible:false,
  56. showDesc:false,
  57. pagination: {
  58. defaultCurrent: 1,
  59. defaultPageSize: 10,
  60. showQuickJumper: true,
  61. pageSize: 10,
  62. onChange: function (page) {
  63. this.loadData(page);
  64. }.bind(this),
  65. showTotal: function (total) {
  66. return '共' + total + '条数据';
  67. }
  68. },
  69. userList:[
  70. {
  71. title: '用户姓名',
  72. dataIndex: 'name',
  73. key: 'name'
  74. },{
  75. title: '部门机构',
  76. dataIndex: 'departmentName',
  77. key: 'departmentName'
  78. }, {
  79. title: '职务',
  80. dataIndex: 'position',
  81. key: 'position'
  82. },{
  83. title: '联系手机',
  84. dataIndex: 'mobile',
  85. key: 'mobile'
  86. }, {
  87. title: '操作',
  88. dataIndex: 'abc',
  89. key: 'abc',
  90. render:(text,record,index)=>{
  91. return (
  92. <Popconfirm title={'您确认将订单 【'+this.props.data.orderNos+'】 分配给【'+record.departmentName+'-'+record.name+'】?'} onConfirm={(e)=>{this.confirmSelect(record)}} okText="确认" cancelText="取消">
  93. <Button style={{marginRight:'5px'}} type="primary">选定</Button>
  94. </Popconfirm>
  95. )
  96. }
  97. }
  98. ],
  99. dataSource: [],
  100. };
  101. },
  102. //操作分配
  103. confirmDelet(index){
  104. this.setState({
  105. orderNos:index.orderNo,
  106. });
  107. },
  108. onCancel(){
  109. this.setState({
  110. visible:false
  111. })
  112. this.props.closeDesc(false,false);
  113. },
  114. onShow() {
  115. this.setState({
  116. visible: false,
  117. });
  118. this.props.closeDesc(false, true);
  119. },
  120. //分配对象列表
  121. contactList(){
  122. $.ajax({
  123. method: "get",
  124. dataType: "json",
  125. crossDomain: false,
  126. url: globalConfig.context + '/api/admin/superviser/adminList',
  127. data: {
  128. pageNo: 1,
  129. pageSize: 99,
  130. departmentId:this.state.departmenttList,
  131. name:this.state.financeNameSearch,
  132. },
  133. success: function (data) {
  134. let theArr = [];
  135. if (!data.data) {
  136. if (data.error && data.error.length) {
  137. message.warning(data.error[0].message);
  138. };
  139. } else {
  140. for (let i = 0; i < data.data.list.length; i++) {
  141. let thisdata = data.data.list[i];
  142. theArr.push({
  143. key: i,
  144. id: thisdata.id,
  145. userNo: thisdata.userNo,
  146. name:thisdata.name,
  147. departmentName:thisdata.departmentName,
  148. departmentId:thisdata.departmentId,
  149. position:thisdata.position,
  150. mobile:thisdata.mobile,
  151. });
  152. };
  153. };
  154. this.setState({
  155. distributionList: theArr,
  156. });
  157. }.bind(this),
  158. }).always(function () {
  159. this.setState({
  160. loading: false
  161. });
  162. }.bind(this));
  163. },
  164. //选定对象
  165. confirmSelect(record){
  166. this.setState({
  167. loading: true
  168. });
  169. console.log(this.props.data)
  170. $.ajax({
  171. method: "get",
  172. dataType: "json",
  173. crossDomain: false,
  174. url: globalConfig.context +this.props.selApi,
  175. data: {
  176. orderNo:this.props.data.orderNo,
  177. salesmanId:record.id
  178. }
  179. }).done(function (data) {
  180. if (!data.error.length) {
  181. message.success('派单成功');
  182. this.onShow();
  183. this.setState({
  184. loading: false,
  185. });
  186. } else {
  187. message.warning(data.error[0].message);
  188. };
  189. }.bind(this));
  190. },
  191. searchOrder(){
  192. this.contactList();
  193. },
  194. resetOrder(){
  195. this.state.departmenttList=undefined;
  196. this.state.financeNameSearch='';
  197. this.setState({
  198. distributionList:[]
  199. });
  200. },
  201. componentWillMount() {
  202. this.departmentList();
  203. },
  204. componentWillReceiveProps(nextProps) {
  205. this.state.visible=nextProps.showDesc;
  206. },
  207. render() {
  208. const rowSelection = {
  209. selectedRowKeys: this.state.selectedRowKeys,
  210. onChange: (selectedRowKeys, selectedRows) => {
  211. this.setState({
  212. selectedRows: selectedRows.slice(-1),
  213. selectedRowKeys: selectedRowKeys.slice(-1)
  214. });
  215. },
  216. onSelectAll: (selected, selectedRows, changeRows) => {
  217. this.setState({
  218. selectedRowKeys:[]
  219. })
  220. },
  221. };
  222. let departmentArr = this.state.departmentArr || [];
  223. const hasSelected = this.state.selectedRowKeys.length > 0;
  224. return (
  225. <div className="user-content" >
  226. <Modal maskClosable={false} visible={this.state.visible}
  227. onOk={this.onShow} onCancel={this.onCancel}
  228. width='800px'
  229. title='派单'
  230. footer=''
  231. className="admin-desc-content">
  232. <Form layout="horizontal" onSubmit={this.handleSubmit} id="demand-form" style={{paddingBottom:'40px'}} >
  233. <Spin spinning={this.state.loading}>
  234. <div>
  235. <Select placeholder="订单部门"
  236. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  237. value={this.state.departmenttList}
  238. onChange={(e) => { this.setState({ departmenttList: e }) }}>
  239. {
  240. departmentArr.map(function (item) {
  241. return <Select.Option key={item.id} >{item.name}</Select.Option>
  242. })
  243. }
  244. </Select>
  245. <Input placeholder="任务负责人" style={{width:'150px',marginLeft:'10px'}}
  246. value={this.state.financeNameSearch}
  247. onChange={(e) => { this.setState({ financeNameSearch: e.target.value }); }} />
  248. <Button type="primary" onClick={this.searchOrder} style={{marginLeft:'10px',marginRight:'10px'}}>搜索</Button>
  249. <Button onClick={this.resetOrder}>重置</Button>
  250. </div>
  251. <div className="patent-table" style={{marginTop:'10px'}}>
  252. <Spin spinning={this.state.loading}>
  253. <Table columns={this.state.userList}
  254. dataSource={this.state.distributionList}
  255. pagination={false}
  256. />
  257. </Spin>
  258. </div>
  259. </Spin>
  260. </Form>
  261. </Modal>
  262. </div>
  263. );
  264. }
  265. });
  266. export default Assign;