lockBusiness.jsx 8.9 KB

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