business.jsx 8.3 KB

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