123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502 |
- import React, { useState, useEffect } from 'react';
- import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar, Radio, Modal, Descriptions, message } from 'antd';
- import moment from 'moment';
- import request from '../../../utils/request';
- import apis from '../../../services/apis';
- import router from 'umi/router';
- import BuildSelect from '../../../components/SelectButton/BuildSelect'
- import AuthButton from '@/components/AuthButton';
-
-
- const { Option } = Select;
-
- const { Meta } = Card;
-
-
- class InviteTable extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- dataSource: { records: [] },
- visibleData: { visible: false, customerId: '', realtyConsultant: '' },
- }
- }
-
-
- componentDidMount () {
- const { customerId } = this.state.visibleData
- this.getList({ helpRecordInitiateId: customerId, pageNumber: 1, pageSize: 5 })
- }
-
- componentDidUpdate (preProps, preState) {
- const { customerId } = this.state.visibleData
- if (this.props.visibleData.customerId !== preState.visibleData.customerId) {
- this.getList({ helpRecordInitiateId: customerId, pageNumber: 1, pageSize: 5 })
- this.setState({ visibleData: this.props.visibleData });
- }
- }
-
-
-
- handleOk () {
- this.setState({ visibleData: { visible: false, customerId: '', realtyConsultant: '' } })
- }
-
-
- handleCancel () {
- this.setState({ visibleData: { visible: false, customerId: '', realtyConsultant: '' } })
- }
-
- getList (params) {
- request({ ...apis.helpActivity.helpPeopleDetails, params: { ...params } }).then(res => {
- this.setState({ dataSource: res })
- }).catch(err => {
-
- <Alert
- style={{
- marginBottom: 24,
- }}
- message={err}
- type="error"
- showIcon
- />
- })
- }
-
-
- onChange (pageNum) {
- this.getList({ pageNumber: pageNum, pageSize: 5 })
- }
-
- render () {
- const columns = [
- {
- title: '用户姓名',
- dataIndex: 'name',
- key: 'name',
- align: 'center',
- },
- {
- title: '手机号',
- dataIndex: 'phone',
- key: 'phone',
- align: 'center',
- render: text => <a>{text}</a>,
- },
- {
- title: '助力时间',
- dataIndex: 'createDate',
- key: 'createDate',
- align: 'center',
- },
- ]
- return (
- <>
- <Modal
- title="助力者"
- destroyOnClose="true"
- width={900}
- footer={null}
- visible={this.state.visibleData.visible}
-
- onCancel={(e) => this.handleCancel(e)}
- >
- <Table rowKey="independent" dataSource={this.state.dataSource.records} columns={columns} pagination={{ total: this.state.dataSource.total, onChange: e => this.onChange(e) }} />
- </Modal>
- </>
- );
- }
- }
-
-
-
-
-
-
-
-
- class Verifier extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- verification: { verificationCode: '' },
- visibleData: { visible: false, customerId: '', realtyConsultant: '', helpRecordInitiateId: '', verificationCode: '' },
- }
- }
-
-
- componentDidMount () {
- const { customerId } = this.state.visibleData
- }
-
- componentDidUpdate (preProps, preState) {
- const { customerId } = this.state.visibleData
- if (this.props.visibleData.customerId !== preState.visibleData.customerId) {
- this.setState({ visibleData: { visible: this.props.visibleData.visible, customerId: this.props.visibleData.customerId, verificationCode: '' } })
- }
- }
-
-
-
- handleOk () {
- this.setState({ visibleData: { visible: false, customerId: '', realtyConsultant: '' } })
- }
-
-
- handleCancel () {
- this.setState({ visibleData: { visible: false, customerId: '', realtyConsultant: '' } })
- }
-
-
- getList (params) {
- request({ ...apis.helpActivity.verification, params: { ...params } }).then(res => {
-
- message.info('核销成功')
- }).catch(err => {
-
- <Alert
- style={{
- marginBottom: 24,
- }}
- message={err}
- type="error"
- showIcon
- />
- })
- }
-
-
- verify(e) {
- this.setState({ visibleData: { visible: true, customerId: this.props.visibleData.customerId, verificationCode: e.target.value } })
- }
-
-
- verification(e) {
- this.getList({ helpRecordInitiateId: this.state.visibleData.customerId, verifyCode: this.state.visibleData.verificationCode })
- }
-
- render () {
- return (
- <>
- <Modal
- title="核销"
- destroyOnClose="true"
- width={300}
- footer={null}
- visible={this.state.visibleData.visible}
-
- onCancel={(e) => this.handleCancel(e)}
- >
- <div><span>核销码:<input onChange={this.verify.bind(this)}/></span>
- <Button onClick={(e) => this.verification(e)}>立即核销</Button>
- </div>
- </Modal>
- </>
- );
- }
- }
-
-
- function body(props) {
- const [gInviteData, setGInviteData] = useState({ visible: false, customerId: '', realtyConsultant: '' })
-
- const [gVerifierData, setVerifierData] = useState({ visible: false, customerId: '', realtyConsultant: '', helpRecordInitiateId: '' })
-
- const { getFieldDecorator, getFieldsValue } = props.form
-
-
- const [dataSource, setDataSource] = useState({ records: [] })
-
-
-
-
-
- const [customerType, setCustomerType] = useState('helpSucceed')
-
-
-
- const [gVisibleData, setGVisibleData] = useState({ visible: false, customerId: '', realtyConsultant: '' })
-
-
-
-
-
- const { helpActivityId } = props.location.query
- useEffect(() => {
- console.log('customerType', customerType)
- getList({ pageNumber: 1, pageSize: 10, status: customerType, helpActivityId })
- }, [])
-
- function getList(params) {
-
- request({ ...apis.helpActivity.record, params: { ...params } }).then(res => {
- setDataSource(res)
- }).catch(err => {
-
- <Alert
- style={{
- marginBottom: 24,
- }}
- message={err}
- type="error"
- showIcon
- />
- })
- }
-
- function displayNone() {
- setGVisibleData({ visible: false, customerId: '', realtyConsultant: '' })
- }
-
-
- function handleSubmit(e) {
- displayNone()
-
-
- e.preventDefault();
- props.form.validateFields((err, values) => {
- if (!err) {
- getList({ pageNum: 1, pageSize: 10, customerType, ...values })
- }
- });
- }
-
-
- function handleSelectChange(e) {
-
- console.log(e)
- }
-
-
- function onChange(pageNum) {
-
- getList({ pageNumber: pageNum, pageSize: 10, customerType })
- }
-
-
- function radioButtonHandleSizeChange(e) {
- setGInviteData({ visible: false, customerId: '', realtyConsultant: '' })
- displayNone()
-
- const { value } = e.target
- setCustomerType(value)
-
- getList({ pageNumber: 1, pageSize: 10, status: value, helpActivityId })
- }
-
- function handleReset() {
- props.form.resetFields();
- getList({ pageNumber: 1, pageSize: 10, customerType })
- }
-
- function toCustomerDateil(record) {
- router.push({
- pathname: '/customer/customerlist/customerDetail',
- query: {
- id: record.customerId,
- },
- });
- }
-
- function exportCustomer () {
- const fieldsValue = getFieldsValue()
-
- request({ ...apis.helpActivity.HelpInitiateRecordSucceed, responseType: 'blob', params: { helpActivityId: 6 } })
-
- .then(response => {
- download(response)
- }).catch(error => {
-
- })
- }
-
- function download (data) {
- if (!data) {
- return
- }
- const url = window.URL.createObjectURL(new Blob([data]))
- const link = document.createElement('a')
- link.style.display = 'none'
- link.href = url
- link.setAttribute('download', '客户列表.xlsx')
- document.body.append(link)
- link.click()
- }
-
-
- function helpRecord(row) {
-
- console.log('gInviteData', gInviteData)
-
-
- setGInviteData({ visible: true, customerId: row.helpRecordInitiateId, realtyConsultant: row.realtyConsultant })
-
- setVerifierData({ visible: false, customerId: row.helpRecordInitiateId, realtyConsultant: row.realtyConsultant })
- }
-
- function helpInitiateRecordVerify(row) {
-
- console.log('gVerifierData', gVerifierData)
-
- setGInviteData({ visible: false, customerId: row.helpRecordInitiateId, realtyConsultant: row.realtyConsultant })
-
- setVerifierData({ visible: true, customerId: row.helpRecordInitiateId, realtyConsultant: row.realtyConsultant })
-
-
- }
-
- const publicColumns = [
- {
- title: '发起者',
- dataIndex: 'name',
- key: 'name',
- align: 'center',
- width: '15%',
- },
- {
- title: '发起者手机号',
- dataIndex: 'phone',
- key: 'phone',
- align: 'center',
- width: '10%',
- },
- {
- title: '发起时间',
- dataIndex: 'createDate',
- key: 'createDate',
- align: 'center',
- width: '15%',
- },
- {
- title: '助力者',
- dataIndex: 'helpCount',
- key: 'helpCount',
- align: 'center',
- width: '15%',
- render: (text, record) => <a style={ { color: '#66B3FF' } } onClick={() => helpRecord(record)}>{record.helpCount}/{record.persionNumCount}</a>,
- },
- ]
-
- const privateColumns = [
- {
- title: '发起者',
- dataIndex: 'name',
- key: 'name',
- align: 'center',
- width: '15%',
-
- },
- {
- title: '手机号',
- dataIndex: 'phone',
- key: 'phone',
- align: 'center',
- width: '10%',
-
-
- },
- {
- title: '发起时间',
- dataIndex: 'createDate',
- key: 'createDate',
- align: 'center',
- width: '10%',
-
- },
- {
- title: '助力者',
- dataIndex: 'helpCount',
- key: 'helpCount',
- align: 'center',
- width: '15%',
- render: (text, record) => <a style={ { color: '#66B3FF' } } onClick={() => helpRecord(record)}>{record.helpCount}人</a>,
- },
- {
- title: '核销状态',
- dataIndex: 'reportRecommendStatus',
- key: 'reportRecommendStatus',
- align: 'center',
- width: '10%',
-
- render: (text, records) => {
- if (records.verificationStatus === 0) { return '未核销' }
- if (records.verificationStatus === 1) { return '已核销' }
- },
- },
- {
- title: '操作',
- dataIndex: 'customerId',
- key: 'customerId',
- align: 'center',
- width: '25%',
- render: (x, row) => (
- <>
- {row.verificationStatus === 0 &&
- <AuthButton name="admin.SignList.get" noRight={null}>
- <span style={{ color: '#1990FF', cursor: 'pointer' }} onClick={() => helpInitiateRecordVerify(row)}>核销</span>
- </AuthButton>
- }
- </>
- ),
- },
- ]
-
- return (
- <>
- {console.log('customerType', customerType)}
- <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
- <Form.Item>
- {getFieldDecorator('tel')(
- <Input
- prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
- placeholder="电话"
- />,
- )}
- </Form.Item>
- <Form.Item>
- <Button type="primary" htmlType="submit" >
- 查询
- </Button>
- <Button style={{ marginLeft: 8 }} onClick={handleReset}>
- 重置
- </Button>
- <Button style={{ marginLeft: 8 }} onClick={handleReset}>
- 返回
- </Button>
- </Form.Item>
- </Form>
- <Button type="primary" onClick={() => exportCustomer()} style={{ float: 'right', margin: '20px 0', zIndex: 1 }}>
- 导出
- </Button>
-
- <div style={{ margin: '20px 0' }}>
- <AuthButton name="admin.customer.recommend.get" noRight={null}>
- <Radio.Group value={customerType} onChange={radioButtonHandleSizeChange} buttonStyle="solid">
- <Radio.Button value="helpSucceed">助力成功</Radio.Button>
- <Radio.Button value="helpUnderway">进行中</Radio.Button>
- <Radio.Button value="helpUnfinished">助力失败</Radio.Button>
- </Radio.Group>
- </AuthButton>
- </div>
- {customerType === 'helpSucceed' ?
- <Table dataSource={dataSource.list} columns={privateColumns} pagination={{ total: dataSource.total, onChange }} rowKey="customerList" /> :
- <Table dataSource={dataSource.list} columns={publicColumns} pagination={{ total: dataSource.total, onChange }} rowKey="customerList" />
- }
- <InviteTable visibleData={gInviteData} />
- <Verifier visibleData={gVerifierData} />
- </>
- );
- }
-
- const WrappedBody = Form.create({ name: 'body' })(body);
-
- export default WrappedBody
|