assign.jsx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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: 0,
  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: 150,
  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. }, {
  85. title: '联系手机',
  86. dataIndex: 'contactMobile',
  87. key: 'contactMobile',
  88. width: 100
  89. }, {
  90. title: '操作',
  91. dataIndex: 'abc',
  92. key: 'abc',
  93. width: 100,
  94. render: (text, record, index) => {
  95. if (this.props.data.length) {
  96. return (
  97. // <Popconfirm title={'您确认将所选订单分配给【'+record.departmentName+'-'+record.name+'】?'} onConfirm={(e)=>{this.confirmSelect1(record)}} okText="确认" cancelText="取消">
  98. // <Button style={{marginRight:'5px'}} type="primary">选定</Button>
  99. // </Popconfirm>
  100. <Popconfirm title={'您确认将所选订单分配给【' + record.departmentName + '-' + record.name + '】?'} onConfirm={(e) => { this.setState({ remarksVisible: true, remarks: "", fn: this.confirmSelect1, record }) }} okText="确认" cancelText="取消">
  101. <Button style={{ marginRight: '5px' }} type="primary">选定</Button>
  102. </Popconfirm>
  103. )
  104. } else {
  105. return (
  106. // <Popconfirm title={'您确认将' + this.props.title + ' 【' + this.props.data.orderNo + '】 分配给【' + record.departmentName + '-' + record.name + '】?'} onConfirm={(e) => { this.confirmSelect(record) }} okText="确认" cancelText="取消">
  107. // <Button style={{ marginRight: '5px' }} type="primary">选定</Button>
  108. // </Popconfirm>
  109. <Popconfirm title={'您确认将' + this.props.title + ' 【' + this.props.data.orderNo + '】 分配给【' + record.departmentName + '-' + record.name + '】?'} onConfirm={(e) => { this.setState({ remarksVisible: true, remarks: "", fn: this.confirmSelect, record }) }} okText="确认" cancelText="取消">
  110. <Button style={{ marginRight: '5px' }} type="primary">选定</Button>
  111. </Popconfirm>
  112. )
  113. }
  114. }
  115. }
  116. ],
  117. dataSource: [],
  118. };
  119. },
  120. //操作分配
  121. confirmDelet(index) {
  122. this.setState({
  123. orderNos: index.orderNo,
  124. });
  125. },
  126. onCancel() {
  127. this.setState({
  128. visible: false
  129. })
  130. this.props.closeDesc(false, false);
  131. },
  132. onShow() {
  133. this.setState({
  134. visible: false,
  135. });
  136. this.props.closeDesc(false, true);
  137. },
  138. //分配对象列表
  139. contactList(item = {}, nub) {
  140. this.setState({
  141. loading: true
  142. });
  143. let api = !nub ? '/api/admin/frequentContactsList' : '/api/admin/superviser/adminList';
  144. $.ajax({
  145. method: "get",
  146. dataType: "json",
  147. crossDomain: false,
  148. url: globalConfig.context + api,
  149. data: {
  150. pageNo: 1,
  151. pageSize: 99,
  152. departmentId: this.state.departmenttList,
  153. name: this.state.financeNameSearch,
  154. roleName: this.props.roleName
  155. },
  156. success: function (data) {
  157. let theArr = [];
  158. if (!data.data) {
  159. if (data.error && data.error.length) {
  160. message.warning(data.error[0].message);
  161. };
  162. } else {
  163. for (let i = 0; i < data.data.list.length; i++) {
  164. let thisdata = data.data.list[i];
  165. theArr.push({
  166. key: i,
  167. id: thisdata.id,
  168. contactId: thisdata.contactId,
  169. userNo: thisdata.userNo,
  170. name: thisdata.name,
  171. departmentName: thisdata.departmentName,
  172. departmentId: thisdata.departmentId,
  173. position: thisdata.roles[0],
  174. contactMobile: thisdata.contactMobile,
  175. });
  176. };
  177. };
  178. this.setState({
  179. distributionList: theArr,
  180. });
  181. }.bind(this),
  182. }).always(function () {
  183. this.setState({
  184. loading: false
  185. });
  186. }.bind(this));
  187. },
  188. //选定对象
  189. confirmSelect(record) {
  190. if (this.state.remarks == "") {
  191. message.warning("请填写备注信息")
  192. return
  193. }
  194. this.setState({
  195. loading: true
  196. });
  197. console.log(this.state.contact);
  198. $.ajax({
  199. method: this.props.requestMethod,
  200. dataType: "json",
  201. crossDomain: false,
  202. url: globalConfig.context + this.props.selApi,
  203. // data:{
  204. // taskId:this.props.data.id,//任务ID
  205. // taskReceiverId:this.state.contact?record.id:record.contactId,//分配人物ID
  206. // specially:this.props.specially,//是否是咨询师管理员
  207. // orderNo:this.state.orderNo,
  208. // financeId: this.state.contact?record.id:record.contactId, //分配人物id
  209. // approval:this.props.data.approval, //是否特批
  210. // newFinance:this.state.contact?record.id:record.contactId
  211. //
  212. // }
  213. data: this.judge(this.props, record)
  214. }).done(function (data) {
  215. if (!data.error.length) {
  216. message.success('派单成功');
  217. this.setState({
  218. remarksVisible: false
  219. })
  220. this.onShow();
  221. if (this.props.reset) {
  222. this.props.reset()
  223. }
  224. } else {
  225. message.warning(data.error[0].message);
  226. };
  227. this.setState({
  228. loading: false,
  229. });
  230. }.bind(this));
  231. },
  232. confirmSelect1(record) {
  233. if (this.state.remarks == "") {
  234. message.warning("请填写备注信息")
  235. return
  236. }
  237. console.log(record);
  238. let orderNo = this.props.data.join(",")
  239. console.log(orderNo, record.id, this.props.selApi);
  240. this.setState({
  241. loading: true
  242. });
  243. console.log(this.state.contact);
  244. $.ajax({
  245. method: this.props.requestMethod,
  246. dataType: "json",
  247. crossDomain: false,
  248. url: globalConfig.context + this.props.selApi,
  249. // data:{
  250. // taskId:this.props.data.id,//任务ID
  251. // taskReceiverId:this.state.contact?record.id:record.contactId,//分配人物ID
  252. // specially:this.props.specially,//是否是咨询师管理员
  253. // orderNo:this.state.orderNo,
  254. // financeId: this.state.contact?record.id:record.contactId, //分配人物id
  255. // approval:this.props.data.approval, //是否特批
  256. // newFinance:this.state.contact?record.id:record.contactId
  257. //
  258. // }
  259. data: {
  260. orderNo,
  261. financeId: record.id,
  262. remarks: this.state.remarks
  263. }
  264. }).done(
  265. function (data) {
  266. if (!data.error.length) {
  267. message.success("派单成功");
  268. this.onShow();
  269. this.setState({
  270. remarksVisible: false
  271. })
  272. if (this.props.reset) {
  273. this.props.reset();
  274. }
  275. } else {
  276. message.warning(data.error[0].message);
  277. }
  278. this.setState({
  279. loading: false
  280. });
  281. }.bind(this)
  282. );
  283. },
  284. /* 区分分派和两种转交 */
  285. judge(props, record) {
  286. if (props.fenpaiData === 8) {
  287. if (props.flag === true) {
  288. return {
  289. taskId: props.data.id, //任务ID
  290. taskReceiverId: this.state.contact
  291. ? record.id
  292. : record.contactId, //分配人物ID
  293. specially: 2, //退给咨询师经理
  294. remarks: this.state.remarks
  295. };
  296. }
  297. return {
  298. taskId: props.data.id,//任务ID
  299. taskReceiverId: this.state.contact ? record.id : record.contactId,//分配人物ID
  300. specially: props.specially,//是否是咨询师管理员
  301. remarks: this.state.remarks
  302. };
  303. } else if (props.fenpaiData === 4) {
  304. return {
  305. orderNo: this.state.orderNo,
  306. financeId: this.state.contact ? record.id : record.contactId, //分配人物id
  307. approval: props.data.approval, //是否特批
  308. remarks: this.state.remarks
  309. };
  310. } else {
  311. return {
  312. orderNo: this.state.orderNo,
  313. newFinance: this.state.contact ? record.id : record.contactId,
  314. remarks: this.state.remarks
  315. };
  316. }
  317. },
  318. searchOrder() {
  319. this.contactList({}, this.state.contact);
  320. },
  321. resetOrder() {
  322. this.state.departmenttList = undefined;
  323. this.state.financeNameSearch = '';
  324. this.state.contact = 0;
  325. this.setState({
  326. distributionList: []
  327. });
  328. },
  329. //初始加载组件,和主页面一起加载
  330. componentDidMount() {
  331. console.log(this.props);
  332. },
  333. //组件调用初始加载函数,可用条件控制,在调用组件时可以拿到参数
  334. componentWillReceiveProps(nextProps) {
  335. this.state.visible = nextProps.showDesc;
  336. if (nextProps.showDesc) {
  337. this.contactList(nextProps, 0);
  338. this.departmentList()
  339. this.setState({
  340. orderNo: nextProps.data.orderNo
  341. })
  342. }
  343. this.setState({
  344. contact: 0
  345. })
  346. // console.log("kan", this.props.specially);
  347. // console.log("kan22", this.state);
  348. },
  349. render() {
  350. const FormItem = Form.Item;
  351. let departmentArr = this.state.departmentArr || [];
  352. return (
  353. <div className="user-content" >
  354. <Modal maskClosable={false} visible={this.state.visible}
  355. onOk={this.onShow} onCancel={this.onCancel}
  356. width='800px'
  357. title='选择'
  358. footer=''
  359. className="admin-desc-content">
  360. <Form layout="horizontal" onSubmit={this.handleSubmit} id="demand-form" style={{ paddingBottom: '40px' }} >
  361. <Spin spinning={this.state.loading}>
  362. <div>
  363. <span style={{ marginRight: 5 }}>常用联系人:</span>
  364. <Radio.Group onChange={(e) => { this.setState({ contact: e.target.value }) }} value={this.state.contact}>
  365. <Radio value={0}>是</Radio>
  366. <Radio value={1}>否</Radio>
  367. </Radio.Group>
  368. <Select placeholder="部门"
  369. style={{ width: 150, marginRight: '10px', marginLeft: '10px' }}
  370. value={this.state.departmenttList}
  371. onChange={(e) => { this.setState({ departmenttList: e }) }}>
  372. {
  373. departmentArr.map(function (item) {
  374. return <Select.Option key={item.id} >{item.name}</Select.Option>
  375. })
  376. }
  377. </Select>
  378. <Input placeholder="姓名" style={{ width: '150px', marginLeft: '10px' }}
  379. value={this.state.financeNameSearch}
  380. onChange={(e) => { this.setState({ financeNameSearch: e.target.value }); }} />
  381. <Button type="primary" onClick={this.searchOrder} style={{ marginLeft: '10px', marginRight: '10px' }}>搜索</Button>
  382. <Button onClick={this.resetOrder}>重置</Button>
  383. </div>
  384. <div className="patent-table" style={{ marginTop: '10px' }}>
  385. <Spin spinning={this.state.loading}>
  386. <Table columns={this.state.userList}
  387. dataSource={this.state.distributionList}
  388. pagination={false}
  389. scroll={{ y: 400 }}
  390. />
  391. </Spin>
  392. </div>
  393. </Spin>
  394. </Form>
  395. </Modal>
  396. <Modal
  397. maskClosable={false}
  398. visible={this.state.remarksVisible}
  399. onOk={e => {
  400. this.setState({
  401. remarksVisible: false
  402. })
  403. }}
  404. onCancel={e => {
  405. this.setState({
  406. remarksVisible: false
  407. })
  408. }}
  409. width="400px"
  410. title={"备注"}
  411. footer=""
  412. className="admin-desc-content"
  413. >
  414. <Form layout="horizontal" id="demand-form">
  415. <Spin spinning={this.state.loading}>
  416. <div className="clearfix">
  417. <FormItem
  418. labelCol={{ span: 4 }}
  419. wrapperCol={{ span: 16 }}
  420. label="备注"
  421. >
  422. <Input
  423. type="textarea"
  424. placeholder="请输入备注"
  425. rows={4}
  426. value={this.state.remarks}
  427. onChange={e => {
  428. this.setState({ remarks: e.target.value });
  429. }}
  430. />
  431. </FormItem>
  432. </div>
  433. <div className="clearfix">
  434. <Button
  435. className="cancel"
  436. type="primary"
  437. onClick={e => {
  438. // console.log(this.state.fn, this.state.record)
  439. this.state.fn(this.state.record)
  440. }}
  441. style={{ marginLeft: "50px" }}
  442. htmlType="submit"
  443. >
  444. 确定
  445. </Button>
  446. <Button
  447. className="cancel"
  448. type="ghost"
  449. onClick={e => {
  450. this.setState({
  451. remarksVisible: false
  452. })
  453. }}
  454. style={{ marginLeft: "50px" }}
  455. >
  456. 取消
  457. </Button>
  458. </div>
  459. </Spin>
  460. </Form>
  461. </Modal>
  462. </div>
  463. );
  464. }
  465. });
  466. export default Assign;