assign.jsx 19 KB

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