123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- import React from 'react';
- import { Link } from 'react-router-dom';
- import './index.less';
- import Page from '@src/containers/Page';
- import Block from '@src/components/Block';
- import FilterLayout from '@src/layouts/FilterLayout';
- import ActionLayout from '@src/layouts/ActionLayout';
- import TableLayout from '@src/layouts/TableLayout';
- import { getMap, formatDate } from '@src/services/Tools';
- import { asyncSMessage, asyncForm } from '@src/services/AsyncTools';
- import { SwitchSelect, PassSelect, InputSelect, MobileArea } from '../../../../Constant';
- import { User } from '../../../stores/user';
- const SwitchSelectMap = getMap(SwitchSelect, 'value', 'label');
- const PassSelectMap = getMap(PassSelect, 'value', 'label');
- const InputSelectMap = getMap(InputSelect, 'value', 'label');
- export default class extends Page {
- constructor(props) {
- super(props);
- this.filterF = null;
- }
- init() {
- this.actionList = [{
- key: 'add',
- type: 'primary',
- name: '创建',
- }];
- this.itemList = [{
- key: 'id',
- type: 'hidden',
- }, {
- key: 'area',
- type: 'select',
- name: '国际码',
- select: MobileArea,
- required: true,
- }, {
- key: 'mobile',
- type: 'input',
- name: '手机号',
- placeholder: '请输入',
- required: true,
- option: {
- normalize: (value) => {
- if (!value) return value;
- if (this.mobile === value) return value;
- if (this.timeout) {
- clearTimeout(this.timeout);
- this.timeout = null;
- }
- this.timeout = setTimeout(() => {
- User.validMobile({ area: this.formF.getFieldValue('area'), mobile: value }).then(result => {
- this.mobile = value;
- this.itemList[2].suffix = !result ? '已注册' : '未注册';
- this.formF.setFieldsValue({ load: true });
- });
- }, 1500);
- return value;
- },
- },
- }, {
- key: 'nickname',
- type: 'input',
- name: '昵称',
- }, {
- key: 'email',
- type: 'input',
- name: '邮箱',
- }];
- this.filterForm = [{
- key: 'keyword',
- type: 'input',
- name: 'ID/手机号',
- placeholder: '请输入',
- }, {
- key: 'real',
- type: 'select',
- allowClear: true,
- name: '实名认证',
- select: PassSelect,
- placeholder: '请选择',
- number: true,
- }, {
- key: 'wechat',
- type: 'select',
- allowClear: true,
- name: '绑定微信',
- select: SwitchSelect,
- placeholder: '请选择',
- number: true,
- }, {
- key: 'prepare',
- type: 'select',
- allowClear: true,
- name: '备考信息',
- select: InputSelect,
- placeholder: '请选择',
- number: true,
- }, {
- key: 'time',
- type: 'daterange',
- name: '注册时间',
- }];
- this.columns = [{
- title: 'ID',
- dataIndex: 'id',
- }, {
- title: '手机号',
- dataIndex: 'mobile',
- }, {
- title: '昵称',
- dataIndex: 'nickname',
- }, {
- title: '注册时间',
- sorter: true,
- dataIndex: 'createTime',
- render: (text) => {
- return formatDate(text, 'YYYY-MM-DD');
- },
- }, {
- title: '实名认证',
- dataIndex: 'realStatus',
- render: (text) => {
- return PassSelectMap[text ? 1 : 0];
- },
- }, {
- title: '绑定微信',
- dataIndex: 'wechatUnionid',
- render: (text) => {
- return SwitchSelectMap[text ? 1 : 0];
- },
- }, {
- title: '备考信息',
- dataIndex: 'prepareStatus',
- render: (text) => {
- return InputSelectMap[text ? 1 : 0];
- },
- }, {
- title: '操作',
- dataIndex: 'handler',
- render: (text, record) => {
- return <div className="table-button">
- {(
- <Link to={`/user/detail/${record.id}`}>查看</Link>
- )}
- </div>;
- },
- }];
- }
- initData() {
- const { search } = this.state;
- const data = Object.assign({}, search);
- if (data.time) {
- data.startTime = data.time[0] || '';
- data.endTime = data.time[1] || '';
- }
- User.list(data).then(result => {
- this.setTableData(result.list, result.total);
- });
- }
- addAction() {
- asyncForm('新建', this.itemList, {}, data => {
- return User.add(data).then(() => {
- asyncSMessage('添加成功!');
- this.refresh();
- });
- }).then(component => {
- this.formF = component;
- });
- }
- renderView() {
- return <Block flex>
- <FilterLayout
- show
- itemList={this.filterForm}
- data={this.state.search}
- onChange={data => {
- if (data.time.length > 0) {
- data.time = [data.time[0].format('YYYY-MM-DD 00:00:00'), data.time[1].format('YYYY-MM-DD 23:59:59')];
- }
- data.page = 1;
- this.search(data);
- }}
- ref={(ref) => {
- if (ref) this.filterF = ref;
- }} />
- <ActionLayout
- itemList={this.actionList}
- selectedKeys={this.state.selectedKeys}
- onAction={key => this.onAction(key)}
- />
- <TableLayout
- // select
- columns={this.tableSort(this.columns)}
- list={this.state.list}
- pagination={this.state.page}
- loading={this.props.core.loading}
- onChange={(pagination, filters, sorter) => this.tableChange(pagination, filters, sorter)}
- onSelect={(keys, rows) => this.tableSelect(keys, rows)}
- selectedKeys={this.state.selectedKeys}
- />
- </Block>;
- }
- }
|