lockBusiness.jsx 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. import React,{Component} from 'react';
  2. import {AutoComplete, Button, Input, message, Modal, Select, Spin, Table} from "antd";
  3. import $ from "jquery/src/ajax";
  4. class LockBusiness extends Component{
  5. constructor(props) {
  6. super(props);
  7. this.state={
  8. loading: false,
  9. dataSource: [],
  10. customerArr: [],
  11. columns: [
  12. {
  13. title: '业务名称',
  14. dataIndex: 'businessProjectName',
  15. key: 'businessProjectName',
  16. },
  17. {
  18. title: '签单时间',
  19. dataIndex: 'lockTime',
  20. key: 'lockTime',
  21. },
  22. {
  23. title: '客户所属人',
  24. dataIndex: 'salesmanName',
  25. key: 'salesmanName',
  26. },
  27. {
  28. title: "操作",
  29. dataIndex: "ooo",
  30. key: "ooo",
  31. render: (text, record) => {
  32. const dataSources = this.state.customerArr || [];
  33. const options = dataSources.map((group) => (
  34. <Select.Option key={group.id} value={group.name}>
  35. {group.name}
  36. </Select.Option>
  37. ));
  38. return (
  39. <div>{record.mySign === 1 ?<div className="control">
  40. <AutoComplete
  41. className="certain-category-search"
  42. dropdownClassName="certain-category-search-dropdown"
  43. dropdownMatchSelectWidth={false}
  44. style={{
  45. width: "120px",
  46. marginLeft: 10,
  47. transition: "all .5s",
  48. }}
  49. value={record.transferName}
  50. dataSource={options}
  51. placeholder="输入转交人姓名"
  52. onChange={(e)=>{
  53. record.transferName = e;
  54. this.httpChange(e,record.key);
  55. }}
  56. filterOption={true}
  57. onBlur={(e)=>{
  58. let theType = "";
  59. let contactLists = this.state.customerArr || [];
  60. if (e) {
  61. contactLists.map(function (item) {
  62. if (item.name == e.toString()) {
  63. theType = item.id;
  64. }
  65. });
  66. }
  67. record.theTypes = theType;
  68. }}
  69. >
  70. <Input />
  71. </AutoComplete>
  72. <Button
  73. onClick={(e) => {
  74. e.stopPropagation();
  75. this.showConfirm(record);
  76. }}
  77. type={"primary"}
  78. style={{
  79. marginLeft: 10,
  80. transition: "all .5s",
  81. }}
  82. >
  83. 转交业务
  84. </Button>
  85. </div> : <div/>}</div>
  86. );
  87. },
  88. },
  89. ],
  90. }
  91. this.loadData = this.loadData.bind(this);
  92. }
  93. //值改变时请求客户名称
  94. httpChange(e,index) {
  95. if (e.length >= 1) {
  96. this.supervisor(e);
  97. }
  98. // this.state.dataSource[index].transferName = e;
  99. // this.setState({
  100. // dataSource: this.state.dataSource
  101. // })
  102. }
  103. blurChange(e) {
  104. let theType = "";
  105. let contactLists = this.state.customerArr || [];
  106. if (e) {
  107. contactLists.map(function (item) {
  108. if (item.name == e.toString()) {
  109. theType = item.id;
  110. }
  111. });
  112. }
  113. this.setState({
  114. theTypes: theType,
  115. });
  116. }
  117. //指定转交人自动补全
  118. supervisor(e) {
  119. $.ajax({
  120. method: "get",
  121. dataType: "json",
  122. crossDomain: false,
  123. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  124. data: {
  125. adminName: e,
  126. },
  127. success: function (data) {
  128. let thedata = data.data;
  129. if (!thedata) {
  130. if (data.error && data.error.length) {
  131. message.warning(data.error[0].message);
  132. }
  133. thedata = {};
  134. }
  135. this.setState({
  136. customerArr: thedata,
  137. });
  138. }.bind(this),
  139. }).always(
  140. function () {
  141. this.setState({
  142. loading: false,
  143. });
  144. }.bind(this)
  145. );
  146. }
  147. showConfirm(record) {
  148. let _this = this;
  149. Modal.confirm({
  150. title: "提示",
  151. content: <span style={{ color: "red" }}>确定转交此项目?</span>,
  152. onOk() {
  153. _this.changeBusiness(record);
  154. },
  155. onCancel() {},
  156. });
  157. }
  158. changeBusiness(e) {
  159. let _this = this;
  160. if(!e.theTypes){
  161. message.warn('请选择转交人');
  162. return;
  163. }
  164. _this.setState({
  165. loading: true,
  166. });
  167. $.ajax({
  168. method: "post",
  169. dataType: "json",
  170. crossDomain: false,
  171. url: globalConfig.context + "/api/admin/customer/privateBusinessTransfer",
  172. data: {
  173. inputId: e.theTypes,
  174. pid: e.businessProjectId,
  175. uid: _this.props.id,
  176. },
  177. success: function (data) {
  178. if (data.error.length || data.data.list == "") {
  179. if (data.error && data.error.length) {
  180. message.warning(data.error[0].message);
  181. }
  182. } else {
  183. message.success("转交成功!");
  184. _this.loadData();
  185. _this.setState({
  186. selectedRowKeys: [],
  187. theTypes: null,
  188. });
  189. }
  190. }.bind(this),
  191. }).always(
  192. function () {
  193. _this.setState({
  194. loading: false,
  195. });
  196. }.bind(this)
  197. );
  198. }
  199. loadData() {
  200. this.setState({
  201. loading: true,
  202. });
  203. $.ajax({
  204. method: "get",
  205. dataType: "json",
  206. crossDomain: false,
  207. url: globalConfig.context + '/api/admin/customer/getLockedProject',
  208. data: {
  209. uid: this.props.uid,
  210. },
  211. success: function(data) {
  212. let listArr = [];
  213. let thedata = data.data;
  214. if(!thedata) {
  215. if(data.error && data.error.length) {
  216. message.warning(data.error[0].message);
  217. };
  218. return;
  219. };
  220. for(let i = 0; i < data.data.length; i++) {
  221. let thisdata = data.data[i];
  222. thisdata.lockTime = thisdata.lockTime && thisdata.lockTime.split(' ')[0]
  223. thisdata.key = i;
  224. listArr.push(thisdata);
  225. };
  226. this.setState({
  227. dataSource: listArr,
  228. });
  229. }.bind(this),
  230. }).always(function() {
  231. this.setState({
  232. loading: false
  233. });
  234. }.bind(this));
  235. }
  236. componentDidMount() {
  237. this.loadData();
  238. }
  239. render() {
  240. return(
  241. <div>
  242. <Spin spinning={this.state.loading}>
  243. <Table
  244. size="middle"
  245. columns={this.state.columns}
  246. dataSource={this.state.dataSource}
  247. pagination={false}
  248. />
  249. </Spin>
  250. </div>
  251. )
  252. }
  253. }
  254. export default LockBusiness;