publist.jsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. // 公共渠道列表
  2. import React, { Component } from "react";
  3. import {
  4. Form,
  5. Button,
  6. message,
  7. Spin,
  8. Input,
  9. DatePicker,
  10. Select,
  11. Tabs,
  12. Table,
  13. Modal,
  14. AutoComplete,
  15. } from "antd";
  16. import { ChooseList } from "../../../manageCenter/order/orderNew/chooseList";
  17. import { provinceList } from "../../../NewDicProvinceList";
  18. import $ from "jquery/src/ajax";
  19. import { ShowModal } from "@/tools";
  20. import moment from "moment";
  21. import AddChannel from "./addchannel"; //新增渠道
  22. import ChannelLog from "./channellog"; //转交日志
  23. import ChangeLog from "./changelog"; //更名日志
  24. import ChannelDetail from "./channeldetail"; //渠道详情
  25. import FollowDetail from "../../../../component/manageCenter/customer/NEW/intentionCustomer/followDetail";
  26. const { TabPane } = Tabs;
  27. const FormItem = Form.Item;
  28. const Option = Select.Option;
  29. const { RangePicker } = DatePicker;
  30. class ChannelUnit extends Component {
  31. constructor(props) {
  32. super(props);
  33. this.state = {
  34. query: { type: 1 },
  35. changeList: undefined,
  36. selectedRowKeys: [],
  37. columns: [
  38. {
  39. title: "渠道名称",
  40. dataIndex: "name",
  41. key: "name",
  42. },
  43. {
  44. title: "地区",
  45. dataIndex: "province",
  46. key: "province",
  47. render: (text, record) => {
  48. return record.province + "-" + record.city + "-" + record.area;
  49. },
  50. },
  51. {
  52. title: "渠道类别",
  53. dataIndex: "type",
  54. key: "type",
  55. width: 200,
  56. render: (text) =>
  57. [
  58. "",
  59. "政府部门",
  60. "民主党派",
  61. "园区",
  62. "民间组织",
  63. "其他战略合作单位",
  64. ][text],
  65. },
  66. {
  67. title: "初始时间",
  68. dataIndex: "createTime",
  69. key: "createTime",
  70. width: 200,
  71. },
  72. {
  73. title: "操作",
  74. dataIndex: "op",
  75. key: "op",
  76. render: (text, record) => (
  77. <Button
  78. type="primary"
  79. onClick={(e) => {
  80. e.stopPropagation(), this.receive(record);
  81. }}
  82. >
  83. 领取
  84. </Button>
  85. ),
  86. },
  87. ],
  88. dataSource: [],
  89. pagination: {
  90. defaultCurrent: 1,
  91. defaultPageSize: 10,
  92. showQuickJumper: true,
  93. pageSize: 10,
  94. onChange: function (page) {
  95. this.loadData(page);
  96. }.bind(this),
  97. showTotal: function (total) {
  98. return "共" + total + "条数据";
  99. },
  100. },
  101. channeOb: [
  102. { name: "政府部门", val: 1 },
  103. { name: "民主党派", val: 2 },
  104. { name: "园区", val: 3 },
  105. { name: "民间组织", val: 4 },
  106. { name: "其他战略合作单位", val: 5 },
  107. ],
  108. fjlist: [], // 查询到的更进人列表
  109. loading: false,
  110. cityList: [],
  111. areaList: [],
  112. searchInfor: {}, // 查询条件
  113. mvisible: "", //控制弹窗变量
  114. };
  115. }
  116. componentWillMount() {
  117. this.loadData();
  118. }
  119. /*单个领取*/
  120. receive(e) {
  121. this.setState({
  122. loading: true,
  123. selectedRowKeys: [],
  124. });
  125. $.ajax({
  126. method: "get",
  127. dataType: "json",
  128. crossDomain: false,
  129. url: globalConfig.context + "/api/admin/customer/receiveCustomer",
  130. data: {
  131. uid: e.id,
  132. },
  133. }).done(
  134. function (data) {
  135. if (!data.error.length) {
  136. message.success("领取成功!");
  137. this.setState({
  138. loading: false,
  139. });
  140. } else {
  141. message.warning(data.error[0].message);
  142. }
  143. this.loadData(this.state.pageNo);
  144. }.bind(this)
  145. );
  146. }
  147. //
  148. getVal(arr, val) {
  149. if (!val || arr.length == 0) {
  150. return undefined;
  151. } else {
  152. for (const items of arr) {
  153. if (items.id == val) {
  154. return items.name;
  155. }
  156. }
  157. }
  158. }
  159. changeList(arr) {
  160. const newArr = [];
  161. this.state.columns.forEach((item) => {
  162. arr.forEach((val) => {
  163. if (val === item.title) {
  164. newArr.push(item);
  165. }
  166. });
  167. });
  168. this.setState({
  169. changeList: newArr,
  170. });
  171. }
  172. // 重置
  173. resetAll() {
  174. this.setState(
  175. {
  176. searchInfor: JSON.parse(JSON.stringify({})),
  177. selectedRowKeys: [],
  178. },
  179. () => {
  180. this.loadData();
  181. }
  182. );
  183. }
  184. // 列表接口
  185. loadData(pageNo) {
  186. const { searchInfor, pagination } = this.state;
  187. this.setState({
  188. loading: true,
  189. });
  190. let datas = Object.assign(searchInfor, {
  191. pageNo: pageNo || 1,
  192. pageSize: pagination.pageSize,
  193. });
  194. // delete datas.aname
  195. $.ajax({
  196. method: "get",
  197. dataType: "json",
  198. crossDomain: false,
  199. url: globalConfig.context + "/api/admin/customer/publicChannelUserList",
  200. data: datas,
  201. success: function (data) {
  202. ShowModal(this);
  203. this.setState({
  204. loading: false,
  205. });
  206. if (data.error && data.error.length === 0) {
  207. if (data.data.list) {
  208. pagination.current = data.data.pageNo;
  209. pagination.total = data.data.totalCount;
  210. if (data.data && data.data.list && !data.data.list.length) {
  211. pagination.current = 0;
  212. pagination.total = 0;
  213. }
  214. this.setState({
  215. dataSource: data.data.list,
  216. pagination: this.state.pagination,
  217. pageNo: data.data.pageNo,
  218. });
  219. } else {
  220. this.setState({
  221. dataSource: data.data,
  222. pagination: false,
  223. });
  224. }
  225. } else {
  226. message.warning(data.error[0].message);
  227. }
  228. }.bind(this),
  229. }).always(
  230. function () {
  231. this.setState({
  232. loading: false,
  233. });
  234. }.bind(this)
  235. );
  236. }
  237. // 选择行
  238. onSelectChange(selectedRowKeys) {
  239. this.setState({ selectedRowKeys });
  240. }
  241. // 关闭弹窗
  242. closeDesc() {
  243. this.setState({
  244. mvisible: "",
  245. });
  246. this.loadData(this.state.pageNo);
  247. }
  248. render() {
  249. const {
  250. columns,
  251. selectedRowKeys,
  252. cityList,
  253. areaList,
  254. changeList,
  255. searchInfor,
  256. channeOb,
  257. dataSource,
  258. } = this.state;
  259. const rowSelection = {
  260. selectedRowKeys,
  261. onChange: this.onSelectChange.bind(this),
  262. hideDefaultSelections: true,
  263. type: "radio",
  264. };
  265. const hasSelected = this.state.selectedRowKeys.length > 0;
  266. return (
  267. <div className="user-content">
  268. <div className="content-title" style={{ marginBottom: 10 }}>
  269. <span style={{ fontWeight: 900, fontSize: 16 }}>公共渠道列表</span>
  270. </div>
  271. <Tabs defaultActiveKey="1" >
  272. <TabPane tab="搜索" key="1">
  273. <div>
  274. <Form layout="inline">
  275. <FormItem>
  276. <Input
  277. placeholder={"请输入渠道名称"}
  278. value={searchInfor.name || undefined}
  279. onChange={(e) => {
  280. this.setState({
  281. searchInfor: Object.assign(searchInfor, {
  282. name: e.target.value,
  283. }),
  284. });
  285. }}
  286. />
  287. </FormItem>
  288. <FormItem>
  289. <Select
  290. placeholder={"选择省份"}
  291. style={{ width: 100 }}
  292. value={this.getVal(provinceList, searchInfor.province)}
  293. onChange={(e) => {
  294. for (const items of provinceList) {
  295. if (items.id == e) {
  296. this.setState({
  297. cityList: items.cityList,
  298. areaList: [],
  299. searchInfor: Object.assign(searchInfor, {
  300. province: items.id,
  301. city: undefined,
  302. area: undefined,
  303. }),
  304. });
  305. }
  306. }
  307. }}
  308. >
  309. {provinceList.map((item, index) => (
  310. <Option key={item.id}>{item.name}</Option>
  311. ))}
  312. </Select>
  313. </FormItem>
  314. <FormItem>
  315. <Select
  316. placeholder={"选择城市"}
  317. style={{ width: 100 }}
  318. value={this.getVal(cityList, searchInfor.city)}
  319. onChange={(e) => {
  320. for (const items of cityList) {
  321. if (items.id == e) {
  322. this.setState({
  323. areaList: items.areaList,
  324. searchInfor: Object.assign(searchInfor, {
  325. city: items.id,
  326. area: undefined,
  327. }),
  328. });
  329. }
  330. }
  331. }}
  332. >
  333. {cityList.map((cit, cin) => (
  334. <Option key={cit.id}>{cit.name}</Option>
  335. ))}
  336. </Select>
  337. </FormItem>
  338. <FormItem>
  339. <Select
  340. placeholder={"选择地区"}
  341. style={{ width: 100 }}
  342. value={this.getVal(areaList, searchInfor.area)}
  343. onChange={(e) => {
  344. for (const items of areaList) {
  345. if (items.id == e) {
  346. this.setState({
  347. searchInfor: Object.assign(searchInfor, {
  348. area: items.id,
  349. }),
  350. });
  351. }
  352. }
  353. }}
  354. >
  355. {areaList.map((cit, cin) => (
  356. <Option key={cit.id}>{cit.name}</Option>
  357. ))}
  358. </Select>
  359. </FormItem>
  360. <FormItem>
  361. <Select
  362. placeholder={"渠道类型"}
  363. style={{ width: 130 }}
  364. value={searchInfor.type || undefined}
  365. onChange={(e) => {
  366. this.setState({
  367. searchInfor: Object.assign(searchInfor, {
  368. type: e,
  369. }),
  370. });
  371. }}
  372. >
  373. {channeOb.map((it, ins) => (
  374. <Option key={it.val}>{it.name}</Option>
  375. ))}
  376. </Select>
  377. </FormItem>
  378. <FormItem>
  379. <RangePicker
  380. value={[
  381. searchInfor.startDate
  382. ? moment(searchInfor.startDate)
  383. : null,
  384. searchInfor.endDate ? moment(searchInfor.endDate) : null,
  385. ]}
  386. onChange={(data, dataString) => {
  387. this.setState({
  388. searchInfor: Object.assign(searchInfor, {
  389. startDate: dataString[0],
  390. endDate: dataString[1],
  391. }),
  392. });
  393. }}
  394. />
  395. </FormItem>
  396. <Button
  397. type="primary"
  398. onClick={() => {
  399. this.loadData();
  400. }}
  401. style={{ marginRight: "10px" }}
  402. >
  403. 搜索
  404. </Button>
  405. <Button
  406. onClick={this.resetAll.bind(this)}
  407. style={{ marginRight: "10px" }}
  408. >
  409. 重置
  410. </Button>
  411. </Form>
  412. </div>
  413. </TabPane>
  414. <TabPane tab="操作" key="2">
  415. <div
  416. style={{
  417. marginLeft: 10,
  418. paddingBottom: 10,
  419. display: "flex",
  420. }}
  421. >
  422. <div style={{ flex: 1 }}>
  423. <Button
  424. type="primary"
  425. onClick={() => {
  426. this.setState({
  427. mvisible: "channellog",
  428. });
  429. }}
  430. style={{ marginLeft: "10px" }}
  431. disabled={!hasSelected}
  432. >
  433. 渠道日志
  434. </Button>
  435. <Button
  436. type="primary"
  437. onClick={() => {
  438. this.setState({
  439. mvisible: "changelog",
  440. });
  441. }}
  442. style={{ marginLeft: "10px" }}
  443. disabled={!hasSelected}
  444. >
  445. 更改日志
  446. </Button>
  447. </div>
  448. </div>
  449. </TabPane>
  450. <TabPane tab="更改表格显示数据" key="3">
  451. <div style={{ marginLeft: 10 }}>
  452. <ChooseList
  453. columns={columns}
  454. changeFn={this.changeList.bind(this)}
  455. changeList={changeList}
  456. top={55}
  457. margin={11}
  458. />
  459. </div>
  460. </TabPane>
  461. </Tabs>
  462. <div className="patent-table">
  463. <Spin spinning={this.state.loading}>
  464. <Table
  465. bordered
  466. size="middle"
  467. columns={changeList ? changeList : columns}
  468. dataSource={this.state.dataSource}
  469. pagination={this.state.pagination}
  470. rowSelection={rowSelection}
  471. />
  472. </Spin>
  473. </div>
  474. {this.state.mvisible == "channellog" && (
  475. <ChannelLog
  476. cancel={this.closeDesc.bind(this)}
  477. visible={this.state.mvisible}
  478. id={dataSource[selectedRowKeys[0]].id}
  479. />
  480. )}
  481. {this.state.mvisible == "changelog" && (
  482. <ChangeLog
  483. cancel={this.closeDesc.bind(this)}
  484. visible={this.state.mvisible}
  485. id={dataSource[selectedRowKeys[0]].id}
  486. />
  487. )}
  488. </div>
  489. );
  490. }
  491. }
  492. export default ChannelUnit;