index.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. import React,{Component} from 'react';
  2. import {
  3. Button,
  4. Input,
  5. message,
  6. Select,
  7. Spin,
  8. Table,
  9. } from "antd";
  10. import './index.less';
  11. import $ from "jquery/src/ajax";
  12. import CustomerDetails from './customerDetails';
  13. class DepartmentStatistics extends Component{
  14. constructor(props) {
  15. super(props);
  16. this.state={
  17. superId:'',
  18. nameSearch: '',
  19. columns: [
  20. {
  21. title: "部门",
  22. dataIndex: "name",
  23. key: "name",
  24. width: '25%',
  25. },
  26. {
  27. title: "客户总数",
  28. dataIndex: "userCount",
  29. key: "userCount",
  30. className: 'tableRowStyle',
  31. render: (text, record) => {
  32. return (
  33. <div
  34. className={record.aid ? 'receiveCount' : ''}
  35. onClick={(e)=>{
  36. if(record.aid){
  37. e.stopPropagation();
  38. this.setState({
  39. customerVisible: true,
  40. aid: record.aid,
  41. type: 0,
  42. })
  43. }
  44. }}>
  45. {text}
  46. </div>
  47. );
  48. },
  49. },
  50. {
  51. title: "成交客户总数",
  52. dataIndex: "completeCount",
  53. key: "completeCount",
  54. className: 'tableRowStyle',
  55. render: (text, record) => {
  56. return (
  57. <div
  58. className={record.aid ? 'receiveCount' : ''}
  59. onClick={(e)=>{
  60. if(record.aid){
  61. e.stopPropagation();
  62. this.setState({
  63. customerVisible: true,
  64. aid: record.aid,
  65. type: 3,
  66. })
  67. }
  68. }}>
  69. {text}
  70. </div>
  71. );
  72. },
  73. },
  74. {
  75. title: "新增客户数",
  76. dataIndex: "inputCount",
  77. key: "inputCount",
  78. className: 'tableRowStyle',
  79. render: (text, record) => {
  80. return (
  81. <div
  82. className={record.aid ? 'receiveCount' : ''}
  83. onClick={(e)=>{
  84. if(record.aid){
  85. e.stopPropagation();
  86. this.setState({
  87. customerVisible: true,
  88. aid: record.aid,
  89. type: 1,
  90. })
  91. }
  92. }}>
  93. {text}
  94. </div>
  95. );
  96. },
  97. },
  98. {
  99. title: "新增面谈数",
  100. dataIndex: "interviewCount",
  101. key: "interviewCount",
  102. className: 'tableRowStyle',
  103. render: (text, record) => {
  104. return (
  105. <div
  106. className={record.aid ? 'receiveCount' : ''}
  107. onClick={(e)=>{
  108. if(record.aid){
  109. e.stopPropagation();
  110. this.setState({
  111. customerVisible: true,
  112. aid: record.aid,
  113. type: 4,
  114. })
  115. }
  116. }}>
  117. {text}
  118. </div>
  119. );
  120. },
  121. },
  122. {
  123. title: "新增领取客户数",
  124. dataIndex: "receiveCount",
  125. key: "receiveCount",
  126. className: 'tableRowStyle',
  127. render: (text, record) => {
  128. return (
  129. <div
  130. className={record.aid ? 'receiveCount' : ''}
  131. onClick={(e)=>{
  132. if(record.aid){
  133. e.stopPropagation();
  134. this.setState({
  135. customerVisible: true,
  136. aid: record.aid,
  137. type: 2,
  138. })
  139. }
  140. }}>
  141. {text}
  142. </div>
  143. );
  144. },
  145. },
  146. ],
  147. contactsOption:null,
  148. loading: false,
  149. ispage: 1,
  150. aid:'',
  151. type:'',
  152. visible:false,
  153. };
  154. this.loadData = this.loadData.bind(this);
  155. this.reset = this.reset.bind(this);
  156. this.selectSuperId = this.selectSuperId.bind(this);
  157. }
  158. componentDidMount() {
  159. this.loadData();
  160. this.selectSuperId();
  161. }
  162. loadData() {
  163. this.setState({
  164. loading: true,
  165. });
  166. let api = '/api/admin/customer/selectAllUser';
  167. let data = {};
  168. if(this.state.superId){
  169. data.depId = this.state.superId;
  170. }
  171. if(this.state.nameSearch){
  172. data.aName = this.state.nameSearch;
  173. }
  174. $.ajax({
  175. method: "get",
  176. dataType: "json",
  177. crossDomain: false,
  178. url: globalConfig.context + api,
  179. data: data,
  180. success: function (data) {
  181. let theArr = [];
  182. if (data.error.length !== 0) {
  183. if (data.error && data.error.length) {
  184. message.warning(data.error[0].message);
  185. }
  186. } else {
  187. data.data.children = data.data.list;
  188. data.data.children = data.data.children.concat(data.data.aList);
  189. theArr.push(data.data);
  190. theArr = this.handleTabsInfor(theArr);
  191. console.log(theArr,'表格数据')
  192. this.setState({
  193. ispage: data.data.pageNo,
  194. dataSource: theArr,
  195. });
  196. }
  197. }.bind(this),
  198. }).always(
  199. function () {
  200. this.setState({
  201. loading: false,
  202. });
  203. }.bind(this)
  204. );
  205. };
  206. //表格数据处理
  207. handleTabsInfor(infor){
  208. for(let i=0;i<infor.length;i++){
  209. if(!infor[i].key){
  210. infor[i].key = infor[i].id ? infor[i].id : (infor[i].aid ? infor[i].aid : i)
  211. }
  212. if(infor[i].children){
  213. for(let c=0;c<infor[i].children.length;c++){
  214. infor[i].children[c].key = infor[i].children[c].id;
  215. infor[i].children[c].children = infor[i].children[c].list;
  216. if(infor[i].children[c].aName){infor[i].children[c].name = infor[i].children[c].aName}
  217. if(infor[i].children[c].aList && Array.isArray(infor[i].children[c].aList) && infor[i].children[c].aList.length){
  218. if(infor[i].children[c].children && Array.isArray(infor[i].children[c].children)){
  219. for(let t of infor[i].children[c].aList){
  220. t.key = t.aid;
  221. t.name = t.aName;
  222. }
  223. infor[i].children[c].children = infor[i].children[c].children.concat(infor[i].children[c].aList);
  224. }
  225. }
  226. this.handleTabsInfor(infor[i].children);
  227. }
  228. }
  229. }
  230. return infor;
  231. }
  232. reset(){
  233. this.setState({
  234. superId:'',
  235. nameSearch: '',
  236. },()=>{
  237. this.loadData();
  238. });
  239. };
  240. //获取上级组织
  241. selectSuperId() {
  242. this.state.data = []
  243. $.ajax({
  244. method: "get",
  245. dataType: "json",
  246. crossDomain: false,
  247. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  248. data:{},
  249. success: function (data) {
  250. let theArr = [];
  251. let theId=[];//用于保存上级组织的ID和名称
  252. let thedata=data.data;
  253. if (!thedata) {
  254. if (data.error && data.error.length) {
  255. message.warning(data.error[0].message);
  256. };
  257. thedata = {};
  258. };
  259. for(var i=0;i<data.data.length;i++){
  260. let theData = data.data[i];
  261. theArr.push(
  262. <Select.Option value={theData.id} key={theData.id}>{theData.name}</Select.Option>
  263. );
  264. theId.push(
  265. [theData.id,theData.name]
  266. );
  267. };
  268. this.setState({
  269. SuperArr:thedata,
  270. contactsOption: theArr,
  271. theId: theId,
  272. orderStatusOptions:data.data,
  273. });
  274. }.bind(this),
  275. }).always(function () {
  276. this.setState({
  277. loading: false
  278. });
  279. }.bind(this));
  280. }
  281. render() {
  282. return(
  283. <div className="user-content">
  284. <div className="content-title">
  285. <span>指导意见</span>
  286. </div>
  287. <div className="user-search" style={{display:'flex',alignItems:'center'}}>
  288. <div>
  289. <Select placeholder="请选择部门"
  290. style={{ width:200,marginLeft:10}}
  291. value={this.state.superId}
  292. onChange={(e) => { this.setState({ superId: e }) }} notFoundContent="未获取到上级组织列表">
  293. {this.state.contactsOption}
  294. </Select>
  295. </div>
  296. <Input
  297. placeholder="客户名称"
  298. value={this.state.nameSearch}
  299. style={{ width: 150, marginRight: 10, marginLeft: 10 }}
  300. onChange={(e) => {
  301. this.setState({ nameSearch: e.target.value });
  302. }}
  303. />
  304. <Button
  305. type="primary"
  306. style={{ marginLeft: "10px", marginRight: 10 }}
  307. onClick={()=>{
  308. this.loadData();
  309. }}
  310. >
  311. 搜索
  312. </Button>
  313. <Button onClick={this.reset}>重置</Button>
  314. </div>
  315. <div className="patent-table">
  316. <Spin spinning={this.state.loading}>
  317. <Table
  318. columns={this.state.columns}
  319. dataSource={this.state.dataSource}
  320. pagination={false}
  321. />
  322. </Spin>
  323. </div>
  324. {this.state.customerVisible ? <CustomerDetails
  325. aid={this.state.aid}
  326. type={this.state.type}
  327. visible={this.state.customerVisible}
  328. onCancel={()=>{
  329. this.setState({
  330. customerVisible: false,
  331. aid: '',
  332. type: '',
  333. })
  334. }}
  335. /> : <div/>}
  336. </div>
  337. )
  338. }
  339. }
  340. export default DepartmentStatistics;