business.jsx 8.6 KB

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