duplicateData.jsx 11 KB

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