duplicateData.jsx 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. this.state.pagination.current = data.data.pageNo;
  155. this.state.pagination.total = data.data.totalCount;
  156. this.setState({
  157. pageNo: data.data.pageNo,
  158. dataSource: theArr,
  159. pagination: this.state.pagination,
  160. })
  161. }
  162. }.bind(this),
  163. }).always(
  164. function () {
  165. this.setState({
  166. listLoading: false,
  167. });
  168. }.bind(this)
  169. );
  170. }else{
  171. let arr = this.props.duplicateData.slice((pageNo-1)*10,pageNo*10);
  172. this.state.pagination.current = pageNo;
  173. this.state.pagination.total = this.props.duplicateData.length;
  174. for (let i = 0; i < arr.length; i++) {
  175. let diqu =
  176. (arr[i].province == null ? "" : arr[i].province) +
  177. (arr[i].city == null ? "" : "-" + arr[i].city) +
  178. (arr[i].area == null ? "" : "-" + arr[i].area);
  179. arr[i].locationProvince = diqu
  180. }
  181. this.setState({
  182. pageNo: pageNo,
  183. dataSource: arr,
  184. pagination: this.state.pagination,
  185. })
  186. }
  187. }
  188. download() {
  189. window.location.href =
  190. globalConfig.context +
  191. "/api/user/channel/export"
  192. }
  193. render() {
  194. const rowSelection = {
  195. hideDefaultSelections: true,
  196. selectedRowKeys: this.state.selectedRowKeys,
  197. onChange: (selectedRowKeys, selectedRows) => {
  198. this.setState({
  199. selectedRows: selectedRows,
  200. selectedRowKeys: selectedRowKeys,
  201. });
  202. },
  203. };
  204. return (
  205. <Modal
  206. width={1000}
  207. title="错误渠道数据"
  208. visible={this.props.visible}
  209. footer={false}
  210. onCancel={()=>{
  211. this.props.onCancel();
  212. }}
  213. >
  214. <Tabs
  215. defaultActiveKey="1"
  216. className="test"
  217. >
  218. <TabPane tab="操作" key="1">
  219. <Button
  220. disabled={!this.state.dataSource.length}
  221. onClick={(e) => {
  222. e.stopPropagation();
  223. this.download();
  224. }}
  225. type="primary"
  226. style={{
  227. marginRight: "10px",
  228. margin: '10px',
  229. }}
  230. >
  231. 导出错误渠道客户
  232. </Button>
  233. <Popconfirm
  234. title="是否删除?"
  235. onConfirm={() => {
  236. this.confirmDeletNew()
  237. }}
  238. okText="删除"
  239. cancelText="不删除"
  240. >
  241. <Button
  242. disabled={this.state.selectedRows.length === 0}
  243. onClick={(e) => {
  244. e.stopPropagation();
  245. }}
  246. type="danger"
  247. >
  248. 删除
  249. </Button>
  250. </Popconfirm>
  251. </TabPane>
  252. </Tabs>
  253. <Spin spinning={this.state.listLoading}>
  254. <Table
  255. size="middle"
  256. className={'intentionCustomerTable'}
  257. columns={this.state.columns}
  258. dataSource={this.state.dataSource}
  259. rowSelection={rowSelection}
  260. pagination={this.state.pagination}
  261. />
  262. </Spin>
  263. </Modal>
  264. )
  265. }
  266. }
  267. export default DuplicateData;