business.jsx 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. import React from 'react';
  2. import {
  3. Form,
  4. Button,
  5. Spin,
  6. message,
  7. Table,
  8. Popconfirm,
  9. Modal,
  10. AutoComplete,
  11. Input,
  12. Select
  13. } from "antd";
  14. import ajax from 'jquery/src/ajax/xhr.js';
  15. import $ from 'jquery/src/ajax';
  16. import {getfllowSituation,getcustomerStatue} from '@/tools.js';
  17. import BusinessDetail from './businessDetail.jsx';
  18. const Business = React.createClass({
  19. getInitialState() {
  20. return {
  21. selectedRowKeys: [],
  22. bVisible: false,
  23. loading: false,
  24. dataBusiness: [],
  25. followData: {},
  26. paginationt: {
  27. defaultCurrent: 1,
  28. defaultPageSize: 10,
  29. showQuickJumper: true,
  30. pageSize: 10,
  31. onChange: function (page) {
  32. this.BusinessList(page, false);
  33. }.bind(this),
  34. showTotal: function (total) {
  35. return "共" + total + "条数据";
  36. },
  37. },
  38. businessIntentionList: [
  39. {
  40. title: "意向时间",
  41. dataIndex: "createTime",
  42. key: "createTime",
  43. },
  44. {
  45. title: "客户名称",
  46. dataIndex: "identifyName",
  47. key: "identifyName",
  48. },
  49. {
  50. title: "业务名",
  51. dataIndex: "businessName",
  52. key: "businessName",
  53. },
  54. {
  55. title: "营销员",
  56. dataIndex: "adminName",
  57. key: "adminName",
  58. },
  59. {
  60. title: "业务意向进度",
  61. dataIndex: "followSituation",
  62. key: "followSituation",
  63. render: (text) => {
  64. return getfllowSituation(text);
  65. },
  66. },
  67. {
  68. title: "客户状态",
  69. dataIndex: "customerStatus",
  70. key: "customerStatus",
  71. render: (text) => {
  72. return getcustomerStatue(text);
  73. },
  74. },
  75. {
  76. title: "操作",
  77. dataIndex: "ooo",
  78. key: "ooo",
  79. render: (text, record) => {
  80. const dataSources = this.state.customerArr || [];
  81. const options = dataSources.map((group) => (
  82. <Select.Option key={group.id} value={group.name}>
  83. {group.name}
  84. </Select.Option>
  85. ));
  86. return (
  87. <div className="control">
  88. <Button
  89. onClick={(e) => {
  90. e.stopPropagation();
  91. this.businessIntentionDetails(record);
  92. }}
  93. >
  94. 查看
  95. </Button>
  96. <AutoComplete
  97. className="certain-category-search"
  98. dropdownClassName="certain-category-search-dropdown"
  99. dropdownMatchSelectWidth={false}
  100. dropdownStyle={{ width: 120 }}
  101. style={{
  102. width: "120px",
  103. marginLeft: 10,
  104. transition: "all .5s",
  105. display:
  106. record.followSituation == 5 ? "inline-block" : "none",
  107. }}
  108. dataSource={options}
  109. placeholder="输入转交人姓名"
  110. onChange={this.httpChange}
  111. filterOption={true}
  112. onBlur={this.blurChange}
  113. onSelect={this.selectAuto}
  114. >
  115. <Input />
  116. </AutoComplete>
  117. <Button
  118. style={{ marginLeft: 10 }}
  119. onClick={(e) => {
  120. // this.changeBusiness(record);
  121. e.stopPropagation();
  122. this.showConfirm(this.changeBusiness, record);
  123. }}
  124. type={"primary"}
  125. style={{
  126. marginLeft: 10,
  127. transition: "all .5s",
  128. display:
  129. record.followSituation == 5 ? "inline-block" : "none",
  130. }}
  131. >
  132. 转交业务
  133. </Button>
  134. </div>
  135. );
  136. },
  137. },
  138. ],
  139. };
  140. },
  141. showConfirm(fn, record) {
  142. Modal.confirm({
  143. title: "提示",
  144. content: <span style={{ color: "red" }}>确定转交此项目?</span>,
  145. onOk() {
  146. fn(record);
  147. },
  148. onCancel() {},
  149. });
  150. },
  151. //指定转交人自动补全
  152. supervisor(e) {
  153. $.ajax({
  154. method: "get",
  155. dataType: "json",
  156. crossDomain: false,
  157. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  158. data: {
  159. adminName: e,
  160. },
  161. success: function (data) {
  162. let thedata = data.data;
  163. if (!thedata) {
  164. if (data.error && data.error.length) {
  165. message.warning(data.error[0].message);
  166. }
  167. thedata = {};
  168. }
  169. this.setState({
  170. customerArr: thedata,
  171. });
  172. }.bind(this),
  173. }).always(
  174. function () {
  175. this.setState({
  176. loading: false,
  177. });
  178. }.bind(this)
  179. );
  180. },
  181. //输入转交人输入框失去焦点是判断客户是否存在
  182. selectAuto(value, options) {
  183. this.setState({
  184. auto: value,
  185. });
  186. },
  187. blurChange(e) {
  188. let theType = "";
  189. let contactLists = this.state.customerArr || [];
  190. if (e) {
  191. contactLists.map(function (item) {
  192. if (item.name == e.toString()) {
  193. theType = item.id;
  194. }
  195. });
  196. }
  197. this.setState({
  198. theTypes: theType,
  199. });
  200. },
  201. //值改变时请求客户名称
  202. httpChange(e) {
  203. if (e.length >= 1) {
  204. this.supervisor(e);
  205. }
  206. this.setState({
  207. auto: e,
  208. });
  209. },
  210. businessIntentionDetails(record) {
  211. this.setState({
  212. followData: record,
  213. businessModul: true,
  214. });
  215. },
  216. businessIntentionCancel() {
  217. this.setState({
  218. businessModul: false,
  219. });
  220. },
  221. //业务意向
  222. BusinessList(pageNo) {
  223. this.setState({
  224. loading: true,
  225. });
  226. $.ajax({
  227. method: "post",
  228. dataType: "json",
  229. crossDomain: false,
  230. url: globalConfig.context + "/api/admin/customer/listBusiness",
  231. data: {
  232. pageNo: pageNo || 1,
  233. pageSize: this.state.paginationt.pageSize,
  234. uid: this.props.data.id,
  235. },
  236. success: function (data) {
  237. let theArr = [];
  238. if (data.error.length || data.data.list == "") {
  239. if (data.error && data.error.length) {
  240. message.warning(data.error[0].message);
  241. }
  242. } else {
  243. for (let i = 0; i < data.data.list.length; i++) {
  244. let thisdata = data.data.list[i];
  245. theArr.push({
  246. key: i,
  247. businessId: thisdata.businessId,
  248. businessProjectId: thisdata.businessProjectId,
  249. businessName: thisdata.businessName,
  250. identifyName: thisdata.identifyName,
  251. followSituation: thisdata.followSituation,
  252. customerStatus: thisdata.customerStatus,
  253. adminName: thisdata.adminName,
  254. createTime: thisdata.createTime,
  255. });
  256. }
  257. this.state.paginationt.current = data.data.pageNo;
  258. this.state.paginationt.total = data.data.totalCount;
  259. }
  260. if (data.data && data.data.list && !data.data.list.length) {
  261. this.state.paginationt.current = 0;
  262. this.state.paginationt.total = 0;
  263. }
  264. this.setState({
  265. dataBusiness: theArr,
  266. paginationt: this.state.paginationt || [],
  267. });
  268. console.log(this.state.dataBusiness);
  269. }.bind(this),
  270. }).always(
  271. function () {
  272. this.setState({
  273. loading: false,
  274. });
  275. window.setTimeout(() => {
  276. let dom = document.querySelectorAll(".control");
  277. for (let i = 0; i < dom.length; i++) {
  278. document.querySelectorAll(".control")[i].parentNode.style.width =
  279. "300px";
  280. }
  281. }, 100);
  282. }.bind(this)
  283. );
  284. },
  285. componentWillMount() {
  286. this.BusinessList();
  287. console.log(this.state.dataBusiness);
  288. },
  289. detailsModal() {
  290. this.props.closeDetail(false, false);
  291. },
  292. componentWillReceiveProps(nextProps) {
  293. if (nextProps.data.id && nextProps.businessState) {
  294. this.BusinessList();
  295. }
  296. this.setState({
  297. businessModul: false,
  298. });
  299. },
  300. changeBusiness(e) {
  301. this.setState({
  302. loading: true,
  303. });
  304. $.ajax({
  305. method: "post",
  306. dataType: "json",
  307. crossDomain: false,
  308. url: globalConfig.context + "/api/admin/customer/privateBusinessTransfer",
  309. data: {
  310. inputId: this.state.theTypes,
  311. pid: e.businessProjectId,
  312. uid: this.props.data.id,
  313. },
  314. success: function (data) {
  315. if (data.error.length || data.data.list == "") {
  316. if (data.error && data.error.length) {
  317. message.warning(data.error[0].message);
  318. }
  319. } else {
  320. message.success("转交成功!");
  321. this.props.closeDesc(false, true);
  322. this.props.closeDetail();
  323. this.BusinessList();
  324. this.setState({
  325. selectedRowKeys: [],
  326. });
  327. }
  328. }.bind(this),
  329. }).always(
  330. function () {
  331. this.setState({
  332. loading: false,
  333. });
  334. }.bind(this)
  335. );
  336. },
  337. onSelectChange(selectedRowKeys) {
  338. this.setState({
  339. selectedRowKeys,
  340. businessModul: false,
  341. });
  342. },
  343. render() {
  344. return (
  345. <div className="clearfix">
  346. <Spin spinning={this.state.loading}>
  347. <Table
  348. pagination={this.state.paginationt}
  349. columns={this.state.businessIntentionList}
  350. dataSource={this.state.dataBusiness}
  351. />
  352. </Spin>
  353. <BusinessDetail
  354. ids={this.props.data.id}
  355. data={this.state.followData}
  356. businessModul={this.state.businessModul}
  357. businessIntentionCancel={this.businessIntentionCancel}
  358. />
  359. </div>
  360. );
  361. },
  362. });
  363. export default Business;