123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549 |
- 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, groupActivityId: '', groupStatus: ''},
- }
- }
-
-
- componentDidMount () {
- const { groupActivityId } = this.state.visibleData
- this.getList({ groupActivityId: groupActivityId, groupStatus:status, pageNumber: 1, pageSize: 5 })
- }
-
- componentDidUpdate (preProps, preState) {
- const { groupActivityId } = this.props.visibleData
- console.log("groupActivityId",this.props.visibleData);
- if (this.props.visibleData.visible !== preState.visibleData.visible) {
- this.getList({ ...this.props.visibleData, pageNumber: 1, pageSize: 5 })
- this.setState({ visibleData: this.props.visibleData });
- }
- }
-
-
-
- handleOk () {
- this.setState({ visibleData: { visible: false, groupActivityId: '', realtyConsultant: '' } })
- }
-
-
- handleCancel () {
- this.setState({ visibleData: { visible: false, groupActivityId: '', realtyConsultant: '' } })
- }
-
- getList (params) {
- console.log("params",params);
- request({ ...apis.groupActivity.shareChildList, 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 })
- }
-
- exportChildRecord(params) {
- request({ ...apis.groupActivity.exportShareChildRecord, responseType: 'blob', params: { ...params} })
- .then(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()
- }).catch(() => {
-
- })
- }
-
- render () {
- const columns = [
- {
- title: '用户姓名',
- dataIndex: 'nickname',
- key: 'nickname',
- align: 'center',
- },
- {
- title: '手机号',
- dataIndex: 'phone',
- key: 'phone',
- align: 'center',
- render: text => <a>{text}</a>,
- },
- {
- title: '开团时间',
- dataIndex: 'createTime',
- key: 'createTime',
- align: 'center',
- },
- ]
- return (
- <>
- <Modal
- title="参团者"
- destroyOnClose="true"
- width={900}
- footer={null}
- visible={this.state.visibleData.visible}
-
- onCancel={(e) => this.handleCancel(e)}
- >
- <Button type="primary" onClick={() => this.exportChildRecord({ ...this.props.visibleData, pageNumber: 1, pageSize: 5 })} style={{ float: 'right', margin: '20px 0', zIndex: 1 }}>
- 导出
- </Button>
-
- <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 = {
- groupActivityId: { id: '' },
- visibleData: { visible: false, groupActivityId: '' },
- }
- }
-
-
- componentDidMount () {
- const { groupActivityId } = this.state.visibleData
- }
-
- componentDidUpdate (preProps, preState) {
- const { groupActivityId } = this.state.visibleData
- console.log('this.state.visibleData', this.state.visibleData)
- if (this.props.visibleData.visible !== preState.visibleData.visible) {
- this.setState({ visibleData: this.props.visibleData });
- }
- }
-
-
-
- handleOk () {
-
- }
-
-
- handleCancel () {
-
-
- this.props.onSuccess({groupActivityId: this.props.visibleData.groupActivityId, groupStatus: 0});
- }
-
- getVerCodeList (params) {
- request({ ...apis.groupActivity.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, groupActivityId: this.props.visibleData.groupActivityId, verificationCode: e.target.value } })
- }
-
-
- verification(e) {
- this.getVerCodeList({ groupActivityId: this.state.visibleData.groupActivityId, verifyCode: this.state.visibleData.verificationCode })
- this.props.onSuccess({groupActivityId: this.props.visibleData.groupActivityId, groupStatus: 0});
- }
-
- 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, groupActivityId : '', recordId:'', groupStatus: ''})
-
- const [gVerifierData, setVerifierData] = useState({ visible: false, groupActivityId: '', verificateCode: '' })
-
- const { getFieldDecorator, getFieldsValue } = props.form
-
-
- const [dataSource, setDataSource] = useState({ records: [] })
-
-
-
-
-
- const [groupStatus, setgroupStatus] = useState('0')
-
-
-
- const [gVisibleData, setGVisibleData] = useState({ visible: false})
-
-
-
-
-
- const { groupActivityId } = props.location.query
- useEffect(() => {
- getList({ pageNumber: 1, pageSize: 10, groupStatus: groupStatus, groupActivityId: groupActivityId })
- }, [])
-
-
- function getFailList(params) {
-
- request({ ...apis.groupActivity.shareFailList, params: { ...params } }).then(res => {
- console.log(res);
- setDataSource(res)
- }).catch(err => {
-
- <Alert
- style={{
- marginBottom: 24,
- }}
- message={err}
- type="error"
- showIcon
- />
- })
- }
-
- function getList(params) {
- console.log(params);
-
- request({ ...apis.groupActivity.shareSuccList, 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, groupStatus, ...values })
- }
- });
- }
-
-
- function handleSelectChange(e) {
-
- console.log(e)
- }
-
-
- function onChange(pageNum) {
-
- getList({ pageNumber: pageNum, pageSize: 10, groupStatus })
- }
-
-
- function radioButtonHandleSizeChange(e) {
- setGInviteData({ visible: false})
- displayNone()
-
- const { value } = e.target
- setgroupStatus(value)
- if (value == 0) {
- getList({ pageNumber: 1, pageSize: 10, groupStatus: value, groupActivityId: groupActivityId }) }
- if (value == 1 || value == 2) {
- getFailList({ pageNumber: 1, pageSize: 10, groupStatus: value, groupActivityId: groupActivityId })
- }
- }
-
- function handleReset() {
- props.form.resetFields();
- getList({ pageNumber: 1, pageSize: 10, groupStatus })
- }
-
- function toCustomerDateil(record) {
- router.push({
- pathname: '/customer/customerlist/customerDetail',
- query: {
- id: record.customerId,
- },
- });
- }
-
- 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 exportRecord () {
- request({ ...apis.groupActivity.exportShareRecord, responseType: 'blob', params: {groupActivityId: groupActivityId, groupStatus: groupStatus } })
- .then(response => {
- download(response)
- }).catch(error => {
-
- })
- }
-
-
- function helpRecord(row) {
-
-
- setVerifierData({ visible: false, groupActivityId: row.groupActivityId, groupStatus: 0})
-
- setGInviteData({ visible: true, groupActivityId: row.groupActivityId, groupStatus: row.status, recordId: row.recordId})
- }
-
- function shareRecordVerify(row) {
-
-
- setVerifierData({ visible: true, groupActivityId: row.groupActivityId, groupStatus: 0})
-
- setGInviteData({ visible: false, groupActivityId: row.groupActivityId})
- }
-
- function onSuccess(e) {
- setVerifierData({ visible: false, groupActivityId: '', groupStatus: 0})
- getList({ pageNumber: 1, pageSize: 10, ...e});
- }
-
- const publicColumns = [
- {
- title: '拼团者',
- dataIndex: 'nickname',
- key: 'nickname',
- align: 'center',
- width: '15%',
- },
- {
- title: '拼团者手机号',
- dataIndex: 'phone',
- key: 'phone',
- align: 'center',
- width: '10%',
- },
- {
- title: '拼团时间',
- dataIndex: 'createTime',
- key: 'createTime',
- align: 'center',
- width: '15%',
- },
- {
- title: '参团者',
- dataIndex: 'helpCount',
- key: 'helpCount',
- align: 'center',
- width: '15%',
- render: (text, record) => <a style={ { color: '#66B3FF' } } onClick={() => helpRecord(record)}>{record.joinPeople}/{record.groupBuyPeople}</a>,
- },
- ]
-
- const privateColumns = [
- {
- title: '拼团者',
- dataIndex: 'nickname',
- key: 'nickname',
- align: 'center',
- width: '15%',
-
- },
- {
- title: '手机号',
- dataIndex: 'phone',
- key: 'phone',
- align: 'center',
- width: '10%',
-
-
- },
- {
- title: '发起时间',
- dataIndex: 'createTime',
- key: 'createTime',
- align: 'center',
- width: '10%',
-
- },
- {
- title: '成团时间',
- dataIndex: 'endTime',
- key: 'endTime',
- align: 'center',
- width: '10%',
-
- },
- {
- title: '核销状态',
- dataIndex: 'verificationStatus',
- key: 'verificationStatus',
- 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={(e) => shareRecordVerify(row)}>核销</span>
- </AuthButton>
- }
- </>
- ),
- },
- ]
-
-
- const changePageNum = pageNumber => {
- getList({ pageNum: pageNumber, pageSize: 10 })
- }
-
- return (
- <>
- <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
- <Form.Item>
- {getFieldDecorator('phone')(
- <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={() => exportRecord()} 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={groupStatus} onChange={radioButtonHandleSizeChange} buttonStyle="solid">
- <Radio.Button value="0">拼团成功</Radio.Button>
- <Radio.Button value="1">进行中</Radio.Button>
- <Radio.Button value="2">拼团失败</Radio.Button>
- </Radio.Group>
- </AuthButton>
- </div>
-
- {groupStatus === '0' ?
- <Table dataSource={dataSource.records} columns={privateColumns} pagination={{ total: dataSource.total, onChange }} rowKey="customerList" /> :
- <Table dataSource={dataSource.records} columns={publicColumns} pagination={{ total: dataSource.total, onChange }} rowKey="customerList" />
- }
- <InviteTable visibleData={gInviteData} />
- {}
- <Verifier visibleData={gVerifierData} onSuccess={(e) => onSuccess(e)} />
- </>
- );
- }
-
- const WrappedBody = Form.create({ name: 'body' })(body);
-
- export default WrappedBody
|