import React, { Component } from 'react' import { observer } from 'mobx-react' import { AJAX_STATUS } from '@/shared/common/constants' import { message, Button, Table, Form, Input, Modal } from 'antd' import FormItemDecorator from '@/components/FormItemDecorator' import TextArea from 'antd/lib/input/TextArea' import { RouteComponentProps, withRouter } from 'react-router-dom' import { FormComponentProps } from 'antd/lib/form' import { Character, CreateCharacterRequest } from '@xmly/cbp-spec/lib/portal/service/oss/ChannelStrategyService' import API from '@/api' import './index.scss' type P = RouteComponentProps & FormComponentProps & {} type S = { dataSource: Array searchParams: any loading: boolean isEdit: boolean visible: boolean curRole: { id: number; name: string } } @observer class MerchantRole extends Component { state = { dataSource: [], searchParams: null, loading: true, isEdit: false, visible: false, curRole: null, } componentDidMount() { this.initialRequest() } initialRequest = () => { this.getMerchantRoles() } getMerchantRoles = async () => { this.setState({ loading: true, dataSource: [], }) try { const res = await API.channel.getAllCharacters() if (res.code === AJAX_STATUS.SUCCESS) { const dataSource = res.data this.setState({ loading: false, dataSource, }) } else { message.error(res.message) } } catch (err) { throw new Error(err) } } getTableProps = () => { const { dataSource } = this.state const columns = [ { title: '序号', dataIndex: 'id', key: 'id', render: (id: number, rows, index) => { return index + 1 }, }, { title: '角色名称', dataIndex: 'name', key: 'name', }, { title: '备注', dataIndex: 'description', key: 'description', render: curVal => { return curVal ? curVal : '无' }, }, { title: '操作', dataIndex: 'actions', key: 'actions', render: (val, row) => { return ( <> this.setPricePlate(row)}> 设置价盘 {/* 开通权益充值 */} {/* this.handleDelete(row)}>删除 */} ) }, }, ] return { dataSource, columns, rowKey: 'id' } } // 设置价盘 setPricePlate = (rows: Character) => { this.props.history.push({ pathname: `/business/role/channelPrice/${rows.id}`, }) } handleAddRole = () => { this.setState({ visible: true, isEdit: false, }) } handleEdit = () => { this.setState({ visible: true, isEdit: true, }) } handleConfirm = () => { this.props.form.validateFields((err, params) => { if (!err) { const createParams = { name: params.name || '', description: params.description || '', } this.createCharacter(createParams) this.setState({ visible: false, }) } }) } createCharacter = async (params: CreateCharacterRequest) => { const res = await API.channel.createCharacter(params) if (res.code === AJAX_STATUS.SUCCESS) { message.success('角色创建成功') this.getMerchantRoles() } else { message.error(res.message) } } handleCancel = () => { this.setState({ visible: false, }) } render() { const { loading } = this.state const { form } = this.props return (
{/* */}

商户角色

{/*
{dataSource.length} 条数据
*/} {/* 添加or编辑 */} ) } } export default withRouter(Form.create

()(MerchantRole))