business.jsx 8.2 KB

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