import React from 'react'; import { Tabs, Form, Row, Col, Input, InputNumber, Button, Upload, Icon } from 'antd'; import './index.less'; import Page from '@src/containers/Page'; import Block from '@src/components/Block'; import { flattenObject } from '@src/services/Tools'; import { asyncSMessage } from '@src/services/AsyncTools'; import { SercieParamMap } from '../../../../Constant'; import { System } from '../../../stores/system'; export default class extends Page { constructor(props) { super(props); this.state.tab = 'qx_cat'; this.vipList = SercieParamMap.vip; } initData() { this.refresh(this.state.tab); } refresh(tab) { if (tab === 'qx_cat') { return this.refreshQxCat(); } if (tab === 'textbook') { return this.refreshTextbook(); } if (tab === 'vip') { return this.refreshVip(); } return Promise.reject(); } refreshQxCat() { return System.getServiceQxCat().then(result => { this.setState({ qx_cat: result || {} }); const { form } = this.props; form.setFieldsValue(flattenObject(result, 'sentence')); }); } refreshTextbook() { return System.getServiceTextbook().then(result => { this.setState({ textbook: result || {} }); }); } refreshVip() { return System.getServiceVip().then(result => { this.setState({ vip: result || {} }); }); } changeMapValue(field, index, key, value) { const data = this.state[field] || {}; data[index] = data[index] || {}; data[index][key] = value; this.setState({ [field]: data }); } changeValue(field, key, value) { const data = this.state[field] || {}; data[key] = value; this.setState({ [field]: data }); } submit(tab) { let handler; if (tab === 'qx_cat') { handler = this.submitQxCat(); } if (tab === 'textbook') { handler = this.submitTextbook(); } if (tab === 'vip') { handler = this.submitVip(); } handler.then(() => { asyncSMessage('保存成功'); }); } submitQxCat() { const { qx_cat } = this.state; return System.setServiceQxCat(qx_cat); } submitTextbook() { const { textbook } = this.state; return System.setServiceTextbook(textbook); } submitVip() { const { vip } = this.state; return System.setServiceVip(vip); } renderQxCat() { const { getFieldDecorator, setFieldsValue, getFieldValue } = this.props.form; const image = getFieldValue('qx_cat.image') || null; return
; } renderTextbook() { const { getFieldDecorator, setFieldsValue, getFieldValue } = this.props.form; const image = getFieldValue('textbook.image') || null; return ; } renderVip() { const { getFieldDecorator, setFieldsValue, getFieldValue } = this.props.form; const image = getFieldValue('vip.image') || null; return