duplicateData.jsx 9.3 KB

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