import React from 'react'; 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, formatMoney, bindSearch } from '@src/services/Tools'; import { asyncSMessage, asyncForm } from '@src/services/AsyncTools'; import { ServiceParamMap, ServiceKey, ServiceSource } from '../../../../Constant'; import { User } from '../../../stores/user'; const ServiceKeyMap = getMap(ServiceKey, 'value', 'label'); const ServiceSourceMap = getMap(ServiceSource, 'value', 'label'); const ServiceParamList = getMap(Object.keys(ServiceParamMap).map(key => { return { list: ServiceParamMap[key], key }; }), 'key', 'list'); const ServiceParamRelation = getMap(Object.keys(ServiceParamMap).map(key => { return { map: getMap(ServiceParamMap[key], 'value', 'label'), key }; }), 'key', 'map'); export default class extends Page { init() { this.timeout = null; this.mobile = null; this.actionList = [{ key: 'add', type: 'primary', name: '创建', }]; this.formF = null; this.itemList = [{ key: 'id', type: 'hidden', }, { key: 'mobile', type: 'input', name: '手机号', placeholder: '请输入', option: { normalize: (value) => { if (this.mobile === value) return value; if (this.timeout) { clearTimeout(this.timeout); this.timeout = null; } this.timeout = setTimeout(() => { User.validMobile({ mobile: value }).then(result => { this.mobile = value; this.itemList[1].suffix = result ? '已注册' : '未注册'; this.formF.setFieldsValue({ load: true }); }); }, 1500); return value; }, }, }, { key: 'service', type: 'select', name: '开通服务', select: ServiceKey, placeholder: '请选择', onChange: (value) => { this.itemList[3].select = ServiceParamList[value] || []; this.formF.setFieldsValue({ param: '' }); }, }, { key: 'param', type: 'select', name: '服务参数', select: [], }, { key: 'source', type: 'select', name: '开通方式', select: ServiceSource, placeholder: '请选择', }]; this.filterForm = [{ key: 'userId', type: 'select', allowClear: true, name: '用户', select: [], number: true, placeholder: '请输入', }, { key: 'service', type: 'select', allowClear: true, name: '服务', select: ServiceKey, onChange: (value) => { this.filterForm[2].select = ServiceParamList[value] || []; }, }, { key: 'param', type: 'select', name: '参数', select: [], allowClear: true, notFound: null, }]; this.columns = [{ title: '用户ID', dataIndex: 'userId', }, { title: '用户手机', dataIndex: 'user.mobile', }, { title: '用户姓名', dataIndex: 'user.nickname', }, { title: '开通服务', dataIndex: 'service', render: (text, record) => { return `${ServiceKeyMap[text]}${(ServiceParamRelation[record.service] || {})[text] || ''}`; }, }, { title: '开通时间', dataIndex: 'time', render: (text, record) => { return `${record.startTime ? formatDate(record.startTime) : ''} - ${record.endTime ? formatDate(record.endTime) : ''}`; }, }, { title: '开通方式', dataIndex: 'source', render: (text) => { return ServiceSourceMap[text] || ''; }, }, { title: '累计消费金额', dataIndex: 'user.totalMoney', render: (text) => { return formatMoney(text); }, }, { title: '操作', dataIndex: 'handler', render: (text, record) => { return