duplicateData.jsx 10.0 KB

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