business.jsx 10 KB

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