inforChange.jsx 18 KB

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