duplicateData.jsx 11 KB

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