assign.jsx 19 KB

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