inforChange.jsx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. import React, { Component } from "react";
  2. import {
  3. AutoComplete,
  4. Button,
  5. Cascader,
  6. Input,
  7. message,
  8. Modal,
  9. Popconfirm,
  10. Select,
  11. Spin,
  12. Table,
  13. Tag,
  14. Tooltip
  15. } from "antd";
  16. import { areaSelect, getProvince } from '@/NewDicProvinceList';
  17. import { industry } from '@/dataDic.js'
  18. import { getIndustry } from '@/tools.js'
  19. import $ from "jquery/src/ajax";
  20. import TextArea from "antd/es/input/TextArea";
  21. const Option = Select.Option;
  22. class InforChange extends Component {
  23. constructor(props) {
  24. super(props);
  25. this.state = {
  26. visible: false,
  27. changeType: 0,
  28. colunmn: [
  29. {
  30. title: "操作人名称",
  31. dataIndex: "adminName",
  32. key: "adminName",
  33. },
  34. {
  35. title: "客户名称",
  36. dataIndex: "name",
  37. key: "name",
  38. render: (text) => {
  39. return (
  40. <Tooltip title={text}>
  41. <div
  42. // style={{
  43. // maxWidth: '150px',
  44. // overflow: 'hidden',
  45. // textOverflow: "ellipsis",
  46. // whiteSpace: 'nowrap',
  47. // }}
  48. >{text}</div>
  49. </Tooltip>
  50. )
  51. }
  52. },
  53. {
  54. title: "操作时间",
  55. dataIndex: "createTimes",
  56. key: "createTimes",
  57. },
  58. ],
  59. dataSource: [],
  60. inputVisible: false,
  61. inputValue: '',
  62. dataArrar: [],
  63. cooperationProjects: [],
  64. orgCode: props.data.orgCode,
  65. locationProvince: props.data.locationProvince,
  66. businessScope: props.data.businessScope,
  67. intendedProject: props.data.intendedProject,
  68. industryName: props.data.industry,
  69. }
  70. this.onChange = this.onChange.bind(this);
  71. this.onCancel = this.onCancel.bind(this);
  72. this.loadData = this.loadData.bind(this);
  73. this.onOk = this.onOk.bind(this);
  74. this.showInput = this.showInput.bind(this);
  75. this.handleInputConfirm = this.handleInputConfirm.bind(this);
  76. this.handleClose = this.handleClose.bind(this);
  77. this.handleCloseCooperation = this.handleCloseCooperation.bind(this);
  78. this.supervisor = this.supervisor.bind(this);
  79. this.onSelect = this.onSelect.bind(this);
  80. }
  81. onChange(type) {
  82. if (!this.props.data.level && this.props.data.level != 0) {
  83. Modal.warning({
  84. title: '系统提示',
  85. content: (
  86. <div>
  87. <p>请先设置客户类型。操作位置:</p>
  88. <p>1.勾选客户名称</p>
  89. <p>2.点击切换至“操作”项</p>
  90. <p>3.选择相应的客户类型即可。</p>
  91. </div>
  92. ),
  93. });
  94. return
  95. }
  96. this.setState({
  97. visible: true,
  98. changeType: type,
  99. })
  100. }
  101. onCancel() {
  102. this.setState({
  103. visible: false,
  104. loading: false,
  105. changeType: 0,
  106. dataArrar: []
  107. })
  108. }
  109. loadData() {
  110. this.setState({
  111. loading: true
  112. });
  113. $.ajax({
  114. method: "get",
  115. dataType: "json",
  116. crossDomain: false,
  117. url: globalConfig.context + "/api/admin/customer/listUserName",
  118. data: {
  119. uid: this.props.enterpriseId,
  120. },
  121. success: function (data) {
  122. if (data.error.length || data.data.list == "") {
  123. if (data.error && data.error.length) {
  124. message.warning(data.error[0].message);
  125. }
  126. } else {
  127. this.setState({
  128. initialName: data.data[0] ? data.data[0].name : ''
  129. })
  130. data.data.splice(0, 1);
  131. this.setState({
  132. dataSource: data.data,
  133. });
  134. }
  135. }.bind(this),
  136. }).always(
  137. function () {
  138. this.setState({
  139. loading: false,
  140. });
  141. }.bind(this)
  142. );
  143. }
  144. onOk() {
  145. const { dataArrar } = this.state;
  146. if (this.state.changeType === 3 && !/^[A-Z0-9]{15}$|^[A-Z0-9]{17}$|^[A-Z0-9]{18}$|^[A-Z0-9]{20}$/.test(dataArrar)) {
  147. message.warning('请输入正确的统一社会信用代码')
  148. return
  149. }
  150. if (this.state.changeType === 0 && dataArrar.length === 0) {
  151. message.warning('请输入省-市-区');
  152. return;
  153. }
  154. if (this.state.changeType === 1 && dataArrar.length === 0) {
  155. message.warning('请输入企业主管产品/服务');
  156. return;
  157. }
  158. if (this.state.changeType === 2 && dataArrar.length === 0) {
  159. message.warning('请输入意向合作项目');
  160. return;
  161. }
  162. if (this.state.changeType === 4 && dataArrar.length === 0) {
  163. message.warning('请选择企业行业');
  164. return
  165. }
  166. this.setState({
  167. loading: true
  168. });
  169. let data = {
  170. uid: this.props.enterpriseId,
  171. }
  172. if (this.state.changeType === 0) {
  173. data.province = dataArrar[0] || undefined;
  174. data.city = dataArrar[1] || undefined;
  175. data.area = dataArrar[2] || undefined;
  176. }
  177. if (this.state.changeType === 1) {
  178. data.businessScope = dataArrar.join(',')
  179. }
  180. if (this.state.changeType === 2) {
  181. let arr = [];
  182. for (let i of dataArrar) {
  183. arr.push(i.label)
  184. }
  185. data.intendedProject = arr.join(',')
  186. }
  187. if (this.state.changeType === 3) {
  188. data.orgCode = dataArrar
  189. // this.props.onCancel();
  190. }
  191. if (this.state.changeType === 4) {
  192. data.industry = dataArrar
  193. }
  194. $.ajax({
  195. url: globalConfig.context + "/api/admin/customer/updateUserDate",
  196. method: "post",
  197. data: data
  198. }).done(
  199. function (data) {
  200. this.setState({
  201. loading: false
  202. });
  203. if (data.error.length === 0) {
  204. message.success("恭喜您,更改成功!");
  205. if (this.state.changeType === 0) {
  206. this.setState({
  207. locationProvince: getProvince(dataArrar[0], dataArrar[1], dataArrar[2])
  208. })
  209. }
  210. if (this.state.changeType === 1) {
  211. this.setState({
  212. businessScope: dataArrar.join(',')
  213. })
  214. }
  215. if (this.state.changeType === 2) {
  216. let arr = [];
  217. for (let i of dataArrar) {
  218. arr.push(i.label)
  219. }
  220. this.setState({
  221. intendedProject: arr.join(',')
  222. })
  223. }
  224. if (this.state.changeType === 3) {
  225. this.setState({
  226. orgCode: dataArrar
  227. })
  228. this.props.onCancel();
  229. }
  230. if (this.state.changeType === 4) {
  231. this.setState({
  232. industryName: getIndustry(dataArrar)
  233. })
  234. }
  235. this.onCancel();
  236. } else {
  237. message.warning(data.error[0].message);
  238. }
  239. }.bind(this)
  240. )
  241. }
  242. showInput() {
  243. let str = this.state.dataArrar.join('/')
  244. this.setState({
  245. inputVisible: true,
  246. inputValue: str
  247. });
  248. }
  249. handleInputConfirm() {
  250. let inputValue = this.state.inputValue;
  251. let arr = inputValue.split('/');
  252. let lv = true;
  253. for (let i of arr) {
  254. if (i.length > 16) {
  255. message.warning('单个标签字数不能超过16个字符')
  256. lv = false;
  257. return;
  258. }
  259. }
  260. if (lv) {
  261. arr = Array.from(new Set(arr));
  262. arr = arr.filter(v => v);
  263. this.setState({
  264. dataArrar: arr,
  265. inputVisible: false,
  266. inputValue: '',
  267. });
  268. }
  269. }
  270. handleClose(removedTag) {
  271. let dataArrar = this.state.dataArrar.filter(tag => { return tag !== removedTag });
  272. this.setState({ dataArrar });
  273. }
  274. handleCloseCooperation(removedTag) {
  275. let dataArrar = this.state.dataArrar.filter(tag => { return tag.value !== removedTag.value });
  276. this.setState({ dataArrar });
  277. }
  278. supervisor(value) {
  279. $.ajax({
  280. method: "get",
  281. dataType: "json",
  282. crossDomain: false,
  283. url: globalConfig.context + '/api/admin/order/getBusinessProjectByName',
  284. data: {
  285. businessName: value
  286. },
  287. success: function (data) {
  288. let thedata = data.data;
  289. if (data.error.length === 0) {
  290. this.setState({
  291. cooperationProjects: thedata,
  292. });
  293. } else {
  294. message.warning(data.error[0].message);
  295. }
  296. }.bind(this),
  297. }).always(
  298. function () {
  299. }.bind(this)
  300. );
  301. }
  302. onSelect(value) {
  303. let arr = this.state.cooperationProjects.filter(v => v.id === value);
  304. let arr1 = this.state.dataArrar.filter(v => v.value === value);
  305. if (arr.length > 0) {
  306. if (arr1.length > 0) {
  307. message.warning('选项已存在');
  308. } else {
  309. this.state.dataArrar.push({
  310. label: arr[0].bname,
  311. value: arr[0].id,
  312. })
  313. this.setState({
  314. dataArrar: this.state.dataArrar
  315. })
  316. }
  317. }
  318. }
  319. render() {
  320. return (
  321. <div style={{
  322. fontSize: 14,
  323. fontWeight: "bold",
  324. marginTop: 20,
  325. }}>
  326. <div style={{
  327. display: 'flex',
  328. alignItems: 'center',
  329. paddingBottom: '5px'
  330. }}>
  331. <div style={{ width: '123px', color: "#58A3FF" }}>统一社会信用代码:</div>
  332. <div style={{ color: "#58A3FF" }}>
  333. {
  334. !this.state.orgCode ? "待补充" : this.state.orgCode
  335. }
  336. </div>
  337. {this.props.type === 'modify' && <Button style={{ marginLeft: '5px' }} type="primary" onClick={(e) => { e.stopPropagation(); this.onChange(3) }}>修改</Button>}
  338. {this.props.type === 'modify' && <span style={{ color: "red", marginLeft: 20 }}>如,科德集团则填写91430105670766451M</span>}
  339. </div>
  340. <div style={{
  341. display: 'flex',
  342. alignItems: 'center',
  343. paddingBottom: '5px'
  344. }}>
  345. <div style={{ width: '123px' }}>省-市-区:</div>
  346. <div>
  347. {
  348. this.state.locationProvince
  349. }
  350. </div>
  351. {this.props.type === 'modify' && <Button style={{ marginLeft: '5px' }} type="primary" onClick={(e) => { e.stopPropagation(); this.onChange(0) }}>修改</Button>}
  352. </div>
  353. <div style={{
  354. display: 'flex',
  355. alignItems: 'center',
  356. paddingBottom: '5px'
  357. }}>
  358. <div style={{ width: '123px' }}>企业主营产品/服务:</div>
  359. <div>
  360. {
  361. this.state.businessScope
  362. }
  363. </div>
  364. {this.props.type === 'modify' && <Button style={{ marginLeft: '5px' }} type="primary" onClick={(e) => { e.stopPropagation(); this.onChange(1) }}>修改</Button>}
  365. </div>
  366. <div style={{
  367. display: 'flex',
  368. alignItems: 'center',
  369. paddingBottom: '5px'
  370. }}>
  371. <div style={{ width: '123px' }}>意向合作项目:</div>
  372. <div>
  373. {
  374. this.state.intendedProject
  375. }
  376. </div>
  377. {this.props.type === 'modify' && <Button style={{ marginLeft: '5px' }} type="primary" onClick={(e) => { e.stopPropagation(); this.onChange(2) }}>修改</Button>}
  378. </div>
  379. <div style={{
  380. display: 'flex',
  381. alignItems: 'center',
  382. paddingBottom: '5px'
  383. }}>
  384. <div style={{ width: '123px' }}>企业行业:</div>
  385. <div>
  386. {
  387. this.state.industryName
  388. }
  389. </div>
  390. {this.props.type === 'modify' && <Button style={{ marginLeft: '5px' }} type="primary" onClick={(e) => { e.stopPropagation(); this.onChange(4) }}>修改</Button>}
  391. </div>
  392. <Modal
  393. footer={null}
  394. maskClosable={false}
  395. width={this.props.type === 'journal' ? '1200px' : this.props.type === 'modify' ? '400px' : '800px'}
  396. title={this.props.type === 'journal' ? '操作日志' : this.props.type === 'modify' ? '信息修改' : ''}
  397. visible={this.state.visible}
  398. onCancel={this.onCancel}>
  399. <div>
  400. {this.props.type === 'modify' ?
  401. <div className='enterpriseNameContent'>
  402. <div className='enterpriseNameItem'>
  403. <div className='enterpriseNameTitle'>
  404. {
  405. this.state.changeType === 0 ? '省-市-区' :
  406. this.state.changeType === 1 ? '企业主管产品/服务' :
  407. this.state.changeType === 2 ? '意向合作项目' :
  408. this.state.changeType === 3 ? '统一社会信用代码' :
  409. this.state.changeType === 4 ? '企业行业' : ''
  410. }
  411. :
  412. </div>
  413. <div className='enterpriseNameValue'>
  414. {
  415. this.state.changeType === 0 ? this.state.locationProvince :
  416. this.state.changeType === 1 ? this.state.businessScope :
  417. this.state.changeType === 2 ? this.state.intendedProject :
  418. this.state.changeType === 3 ? this.state.orgCode :
  419. this.state.changeType === 4 ? this.state.industryName : ''
  420. }
  421. </div>
  422. </div>
  423. <div className='enterpriseNameItem'>
  424. <div className='enterpriseNameTitle'>更改:</div>
  425. <div className='enterpriseNameValue'>
  426. {
  427. this.state.changeType === 0 ? <Cascader
  428. options={areaSelect()}
  429. placeholder="选择城市"
  430. onChange={(e, pre) => {
  431. this.setState({
  432. dataArrar: e
  433. })
  434. }}
  435. /> :
  436. this.state.changeType === 1 ?
  437. <div>
  438. <div>
  439. {this.state.dataArrar.map((tag) => {
  440. const isLongTag = tag.length > 20;
  441. const tagElem = (
  442. <Tag closable key={tag} afterClose={() => this.handleClose(tag)}>
  443. {isLongTag ? `${tag.slice(0, 20)}...` : tag}
  444. </Tag>
  445. );
  446. return isLongTag ? <Tooltip title={tag} key={tag}>{tagElem}</Tooltip> : tagElem;
  447. })}
  448. {
  449. !this.state.inputVisible &&
  450. <Button
  451. size="small"
  452. type="primary"
  453. onClick={this.showInput}>
  454. + 新增主营产品
  455. </Button>
  456. }
  457. </div>
  458. {this.state.inputVisible && (<div>
  459. <TextArea
  460. style={{ width: '300px', height: '100px' }}
  461. value={this.state.inputValue}
  462. onChange={(e) => {
  463. this.setState({
  464. inputValue: e.target.value
  465. })
  466. }} />
  467. <div style={{ color: '#f00' }}>提示:请用 / 符号隔开关键字</div>
  468. <div>
  469. <Button
  470. size="small"
  471. type="primary"
  472. onClick={this.handleInputConfirm}>
  473. 确定
  474. </Button>
  475. <Button
  476. size="small"
  477. style={{ marginLeft: '5px' }}
  478. onClick={() => {
  479. this.setState({
  480. inputVisible: false,
  481. inputValue: ''
  482. })
  483. }}>
  484. 取消
  485. </Button>
  486. </div>
  487. </div>)}
  488. </div>
  489. :
  490. this.state.changeType === 2 ?
  491. <div>
  492. <div style={{ paddingBottom: this.state.dataArrar.length === 0 ? 0 : '10px' }}>
  493. {this.state.dataArrar.map((tag, index) => {
  494. const isLongTag = tag.label.length > 20;
  495. const tagElem = (
  496. <Tag closable key={tag.label} afterClose={() => this.handleCloseCooperation(tag)}>
  497. {isLongTag ? `${tag.label.slice(0, 20)}...` : tag.label}
  498. </Tag>
  499. );
  500. return isLongTag ? <Tooltip title={tag.label} key={tag.label}>{tagElem}</Tooltip> : tagElem;
  501. })}
  502. </div>
  503. <div>
  504. <AutoComplete
  505. style={{ width: 200 }}
  506. onSearch={this.supervisor}
  507. onSelect={this.onSelect}
  508. placeholder="请输入关键字"
  509. >
  510. {
  511. this.state.cooperationProjects.map(function (item) {
  512. return <Select.Option key={item.id} value={item.id}>{item.bname}</Select.Option>
  513. })
  514. }
  515. </AutoComplete>
  516. </div>
  517. </div>
  518. :
  519. this.state.changeType === 3 ?
  520. <div>
  521. <div>
  522. <Input
  523. style={{ width: 200 }}
  524. placeholder="请输入统一社会信用代码"
  525. onChange={(e) => {
  526. this.setState({
  527. dataArrar: e.target.value
  528. })
  529. }}
  530. />
  531. </div>
  532. <div style={{ color: "red", position: "absolute" }}>如,科德集团则填写91430105670766451M</div>
  533. </div>
  534. : this.state.changeType === 4 ?
  535. <div>
  536. <Select
  537. style={{ width: 200 }}
  538. placeholder="请选择行业"
  539. onChange={e => {
  540. this.setState({
  541. dataArrar: e
  542. })
  543. }}
  544. >
  545. {
  546. industry.map(function (item) {
  547. return <Option key={item.value} value={item.value}>{item.key}</Option>
  548. })
  549. }
  550. </Select>
  551. </div>
  552. : ''
  553. }
  554. </div>
  555. </div>
  556. </div> : this.props.type === 'journal' ?
  557. <div>
  558. <Spin spinning={this.state.loading} >
  559. <Table
  560. columns={this.state.colunmn}
  561. dataSource={this.state.dataSource}
  562. pagination={false}
  563. scroll={{ x: "max-content", y: 0 }}
  564. bordered
  565. size="small"
  566. />
  567. </Spin>
  568. </div> : null
  569. }
  570. {
  571. this.props.type === 'modify' ?
  572. <Popconfirm placement="top" title="确定要修改吗?" onConfirm={(e) => {
  573. e.stopPropagation();
  574. this.onOk();
  575. }} okText="确定" cancelText="取消">
  576. <Button type='primary'>
  577. 确定修改
  578. </Button>
  579. </Popconfirm> : null
  580. }
  581. </div>
  582. </Modal >
  583. </div >
  584. )
  585. }
  586. }
  587. export default InforChange;