inforChange.jsx 20 KB

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