duplicateData.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. import React,{Component} from "react";
  2. import {Button, message, Modal, Popconfirm, Spin, Table, Tabs, Tooltip} from "antd";
  3. import {getSocialAttribute,ShowModal,getChannelAllocationStatus} from "@/tools.js";
  4. import $ from "jquery/src/ajax";
  5. const {TabPane} = Tabs;
  6. class DuplicateData extends Component{
  7. constructor(props) {
  8. super(props);
  9. this.state={
  10. columns: [
  11. {
  12. title: "客户名称",
  13. dataIndex: "userName",
  14. key: "userName",
  15. render:(text)=>{
  16. return (
  17. <Tooltip title={text}>
  18. <div
  19. // style={{
  20. // maxWidth:'150px',
  21. // overflow:'hidden',
  22. // textOverflow: "ellipsis",
  23. // whiteSpace:'nowrap',
  24. // }}
  25. >{text}</div>
  26. </Tooltip>
  27. )
  28. }
  29. },
  30. {
  31. title: "地区",
  32. dataIndex: "locationProvince",
  33. key: "locationProvince",
  34. },
  35. {
  36. title: "社会性质",
  37. dataIndex: "societyTag",
  38. key: "societyTag",
  39. // render: (text) => {
  40. // return getSocialAttribute(text);
  41. // },
  42. },
  43. {
  44. title: "客户联系人",
  45. dataIndex: "contacts",
  46. key: "contacts",
  47. },
  48. {
  49. title: "联系电话",
  50. dataIndex: "contactMobile",
  51. key: "contactMobile",
  52. },
  53. {
  54. title: "导入时间",
  55. dataIndex: "createTimes",
  56. key: "createTimes",
  57. },
  58. {
  59. title: "备注",
  60. dataIndex: "remarks",
  61. key: "remarks",
  62. render: (text) => {
  63. return (
  64. <Tooltip placement="topLeft" title={text}>
  65. <div style={{
  66. maxWidth:'150px',
  67. overflow:'hidden',
  68. textOverflow: "ellipsis",
  69. whiteSpace:'nowrap',
  70. }}>{text}</div>
  71. </Tooltip>
  72. )
  73. }
  74. },
  75. {
  76. title: "未导入原因",
  77. dataIndex: "status",
  78. key: "status",
  79. render: (text) => (
  80. getChannelAllocationStatus(text,true)
  81. )
  82. },
  83. ],
  84. selectedRows:[],
  85. selectedRowKeys:[],
  86. dataSource:[],
  87. pagination: {
  88. defaultCurrent: 1,
  89. defaultPageSize: 10,
  90. showQuickJumper: true,
  91. pageSize: 10,
  92. onChange: function (page) {
  93. this.loadData(page);
  94. }.bind(this),
  95. showTotal: function (total) {
  96. return "共" + total + "条数据";
  97. },
  98. },
  99. listLoading:false
  100. }
  101. this.loadData = this.loadData.bind(this);
  102. this.confirmDeletNew = this.confirmDeletNew.bind(this);
  103. }
  104. componentDidMount() {
  105. this.loadData();
  106. }
  107. // 删除供应商信息
  108. confirmDeletNew() {
  109. const hide = message.loading('删除中...', 0);
  110. let changeIds = '';
  111. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  112. let rowItem = this.state.selectedRows[idx];
  113. if (rowItem.id) {
  114. changeIds = this.state.selectedRows.length-1 === idx ? changeIds +rowItem.id : changeIds + rowItem.id + ',' ;
  115. }
  116. }
  117. $.ajax({
  118. url: globalConfig.context + '/api/user/channel/delete',
  119. method: 'post',
  120. data: {
  121. ids: changeIds,
  122. },
  123. }).done(
  124. function (data) {
  125. hide();
  126. if (!data.error.length) {
  127. message.success('删除成功!');
  128. this.setState({
  129. selectedRows:[],
  130. selectedRowKeys:[],
  131. })
  132. this.loadData(this.state.pageNo);
  133. } else {
  134. message.warning(data.error[0].message)
  135. }
  136. }.bind(this)
  137. )
  138. }
  139. loadData(pageNo = 1) {
  140. if(this.props.duplicateData.length === 0){
  141. this.setState({
  142. listLoading: true,
  143. });
  144. $.ajax({
  145. method: "get",
  146. dataType: "json",
  147. crossDomain: false,
  148. url: globalConfig.context + '/api/user/channel/erorrList',
  149. data: {
  150. pageNo: pageNo || 1,
  151. pageSize: this.state.pagination.pageSize,
  152. },
  153. success: function (data) {
  154. ShowModal(this);
  155. let theArr = [];
  156. if (data.error.length > 0) {
  157. message.warning(data.error[0].message);
  158. } else {
  159. for (let i = 0; i < data.data.list.length; i++) {
  160. let thisdata = data.data.list[i];
  161. let diqu =
  162. (thisdata.province == null ? "" : thisdata.province) +
  163. (thisdata.city == null ? "" : "-" + thisdata.city) +
  164. (thisdata.area == null ? "" : "-" + thisdata.area);
  165. thisdata.locationProvince = diqu;
  166. theArr.push(thisdata);
  167. }
  168. if(data.data.list.length === 0 && pageNo > 1){
  169. this.loadData(pageNo - 1);
  170. }else{
  171. this.state.pagination.current = data.data.pageNo;
  172. this.state.pagination.total = data.data.totalCount;
  173. this.setState({
  174. pageNo: data.data.pageNo,
  175. dataSource: theArr,
  176. pagination: this.state.pagination,
  177. })
  178. }
  179. }
  180. }.bind(this),
  181. }).always(
  182. function () {
  183. this.setState({
  184. listLoading: false,
  185. });
  186. }.bind(this)
  187. );
  188. }else{
  189. let arr = this.props.duplicateData.slice((pageNo-1)*10,pageNo*10);
  190. this.state.pagination.current = pageNo;
  191. this.state.pagination.total = this.props.duplicateData.length;
  192. for (let i = 0; i < arr.length; i++) {
  193. let diqu =
  194. (arr[i].province == null ? "" : arr[i].province) +
  195. (arr[i].city == null ? "" : "-" + arr[i].city) +
  196. (arr[i].area == null ? "" : "-" + arr[i].area);
  197. arr[i].locationProvince = diqu
  198. }
  199. this.setState({
  200. pageNo: pageNo,
  201. dataSource: arr,
  202. pagination: this.state.pagination,
  203. })
  204. }
  205. }
  206. download() {
  207. window.location.href =
  208. globalConfig.context +
  209. "/api/user/channel/export"
  210. }
  211. render() {
  212. const rowSelection = {
  213. hideDefaultSelections: true,
  214. selectedRowKeys: this.state.selectedRowKeys,
  215. onChange: (selectedRowKeys, selectedRows) => {
  216. this.setState({
  217. selectedRows: selectedRows,
  218. selectedRowKeys: selectedRowKeys,
  219. });
  220. },
  221. };
  222. return (
  223. <Modal
  224. width={1000}
  225. title="错误外联数据"
  226. visible={this.props.visible}
  227. footer={false}
  228. onCancel={()=>{
  229. this.props.onCancel();
  230. }}
  231. >
  232. <Tabs
  233. defaultActiveKey="1"
  234. className="test"
  235. >
  236. <TabPane tab="操作" key="1">
  237. <Button
  238. disabled={!this.state.dataSource.length}
  239. onClick={(e) => {
  240. e.stopPropagation();
  241. this.download();
  242. }}
  243. type="primary"
  244. style={{
  245. marginRight: "10px",
  246. margin: '10px',
  247. }}
  248. >
  249. 导出错误外联客户
  250. </Button>
  251. <Popconfirm
  252. title="是否删除?"
  253. onConfirm={() => {
  254. this.confirmDeletNew()
  255. }}
  256. okText="删除"
  257. cancelText="不删除"
  258. >
  259. <Button
  260. disabled={this.state.selectedRows.length === 0}
  261. onClick={(e) => {
  262. e.stopPropagation();
  263. }}
  264. type="danger"
  265. >
  266. 删除
  267. </Button>
  268. </Popconfirm>
  269. </TabPane>
  270. </Tabs>
  271. <Spin spinning={this.state.listLoading}>
  272. <Table
  273. size="middle"
  274. className={'intentionCustomerTable'}
  275. columns={this.state.columns}
  276. dataSource={this.state.dataSource}
  277. rowSelection={rowSelection}
  278. pagination={this.state.pagination}
  279. />
  280. </Spin>
  281. </Modal>
  282. )
  283. }
  284. }
  285. export default DuplicateData;