assign.jsx 19 KB

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