问题分类取字典
This commit is contained in:
@ -6,6 +6,8 @@ import WangEditor from 'wangeditor';
|
|||||||
import { QUESTION_TYPES } from '@/dicts/help';
|
import { QUESTION_TYPES } from '@/dicts/help';
|
||||||
import { addHelpCenterQuestion } from '@/servers/api/help';
|
import { addHelpCenterQuestion } from '@/servers/api/help';
|
||||||
import styles from './helpQuestion.less';
|
import styles from './helpQuestion.less';
|
||||||
|
import { getDictList } from '@/servers/api/dict';
|
||||||
|
import type { DictItem } from '@/servers/api/dict';
|
||||||
|
|
||||||
const { Title } = Typography;
|
const { Title } = Typography;
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
@ -28,9 +30,15 @@ const HelpQuestionPage: React.FC = () => {
|
|||||||
const [editor, setEditor] = useState<WangEditor | null>(null);
|
const [editor, setEditor] = useState<WangEditor | null>(null);
|
||||||
const [content, setContent] = useState<string>('');
|
const [content, setContent] = useState<string>('');
|
||||||
const [submitting, setSubmitting] = useState<boolean>(false);
|
const [submitting, setSubmitting] = useState<boolean>(false);
|
||||||
|
const [typeList, setTypeList] = useState<DictItem[]>([]);
|
||||||
|
|
||||||
// 初始化编辑器
|
// 初始化编辑器
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
getDictList('help_center').then((res) => {
|
||||||
|
if (res.code === 200 && res.success) {
|
||||||
|
setTypeList(res.data);
|
||||||
|
}
|
||||||
|
});
|
||||||
const editorInstance = new WangEditor('#editor');
|
const editorInstance = new WangEditor('#editor');
|
||||||
|
|
||||||
// 配置编辑器
|
// 配置编辑器
|
||||||
@ -138,9 +146,7 @@ const HelpQuestionPage: React.FC = () => {
|
|||||||
<div className={styles.contentWrapper}>
|
<div className={styles.contentWrapper}>
|
||||||
<div className={styles.titleContainer}>
|
<div className={styles.titleContainer}>
|
||||||
<Title level={2}>{intl.formatMessage({ id: 'help.question.title' })}</Title>
|
<Title level={2}>{intl.formatMessage({ id: 'help.question.title' })}</Title>
|
||||||
<p className={styles.subtitle}>
|
<p className={styles.subtitle}>{intl.formatMessage({ id: 'help.question.subtitle' })}</p>
|
||||||
{intl.formatMessage({ id: 'help.question.subtitle' })}
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Divider className={styles.divider} />
|
<Divider className={styles.divider} />
|
||||||
@ -157,12 +163,17 @@ const HelpQuestionPage: React.FC = () => {
|
|||||||
<Form.Item
|
<Form.Item
|
||||||
name="type"
|
name="type"
|
||||||
label={intl.formatMessage({ id: 'help.form.type' })}
|
label={intl.formatMessage({ id: 'help.form.type' })}
|
||||||
rules={[{ required: true, message: intl.formatMessage({ id: 'help.form.type.required' }) }]}
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: intl.formatMessage({ id: 'help.form.type.required' }),
|
||||||
|
},
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<Select placeholder={intl.formatMessage({ id: 'help.form.type.placeholder' })}>
|
<Select placeholder={intl.formatMessage({ id: 'help.form.type.placeholder' })}>
|
||||||
{QUESTION_TYPES.map(type => (
|
{typeList.map((type) => (
|
||||||
<Option key={type.value} value={type.value}>
|
<Option key={type.code} value={type.code}>
|
||||||
{type.label}
|
{type.dicName}
|
||||||
</Option>
|
</Option>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
@ -172,7 +183,12 @@ const HelpQuestionPage: React.FC = () => {
|
|||||||
<Form.Item
|
<Form.Item
|
||||||
name="title"
|
name="title"
|
||||||
label={intl.formatMessage({ id: 'help.form.title' })}
|
label={intl.formatMessage({ id: 'help.form.title' })}
|
||||||
rules={[{ required: true, message: intl.formatMessage({ id: 'help.form.title.required' }) }]}
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: intl.formatMessage({ id: 'help.form.title.required' }),
|
||||||
|
},
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<Input placeholder={intl.formatMessage({ id: 'help.form.title.placeholder' })} />
|
<Input placeholder={intl.formatMessage({ id: 'help.form.title.placeholder' })} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
@ -182,7 +198,9 @@ const HelpQuestionPage: React.FC = () => {
|
|||||||
<Form.Item
|
<Form.Item
|
||||||
name="content"
|
name="content"
|
||||||
label={intl.formatMessage({ id: 'help.form.content' })}
|
label={intl.formatMessage({ id: 'help.form.content' })}
|
||||||
rules={[{ required: true, message: intl.formatMessage({ id: 'help.form.content.required' }) }]}
|
rules={[
|
||||||
|
{ required: true, message: intl.formatMessage({ id: 'help.form.content.required' }) },
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<div id="editor" className={styles.editor}></div>
|
<div id="editor" className={styles.editor}></div>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
@ -192,7 +210,12 @@ const HelpQuestionPage: React.FC = () => {
|
|||||||
<Form.Item
|
<Form.Item
|
||||||
name="name"
|
name="name"
|
||||||
label={intl.formatMessage({ id: 'help.form.name' })}
|
label={intl.formatMessage({ id: 'help.form.name' })}
|
||||||
rules={[{ required: true, message: intl.formatMessage({ id: 'help.form.name.required' }) }]}
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: intl.formatMessage({ id: 'help.form.name.required' }),
|
||||||
|
},
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<Input placeholder={intl.formatMessage({ id: 'help.form.name.placeholder' })} />
|
<Input placeholder={intl.formatMessage({ id: 'help.form.name.placeholder' })} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
@ -201,7 +224,12 @@ const HelpQuestionPage: React.FC = () => {
|
|||||||
<Form.Item
|
<Form.Item
|
||||||
name="company"
|
name="company"
|
||||||
label={intl.formatMessage({ id: 'help.form.company' })}
|
label={intl.formatMessage({ id: 'help.form.company' })}
|
||||||
rules={[{ required: true, message: intl.formatMessage({ id: 'help.form.company.required' }) }]}
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: intl.formatMessage({ id: 'help.form.company.required' }),
|
||||||
|
},
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<Input placeholder={intl.formatMessage({ id: 'help.form.company.placeholder' })} />
|
<Input placeholder={intl.formatMessage({ id: 'help.form.company.placeholder' })} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
@ -213,7 +241,12 @@ const HelpQuestionPage: React.FC = () => {
|
|||||||
<Form.Item
|
<Form.Item
|
||||||
name="account"
|
name="account"
|
||||||
label={intl.formatMessage({ id: 'help.form.account' })}
|
label={intl.formatMessage({ id: 'help.form.account' })}
|
||||||
rules={[{ required: true, message: intl.formatMessage({ id: 'help.form.account.required' }) }]}
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: intl.formatMessage({ id: 'help.form.account.required' }),
|
||||||
|
},
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<Input placeholder={intl.formatMessage({ id: 'help.form.account.placeholder' })} />
|
<Input placeholder={intl.formatMessage({ id: 'help.form.account.placeholder' })} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
@ -223,8 +256,11 @@ const HelpQuestionPage: React.FC = () => {
|
|||||||
name="email"
|
name="email"
|
||||||
label={intl.formatMessage({ id: 'help.form.email' })}
|
label={intl.formatMessage({ id: 'help.form.email' })}
|
||||||
rules={[
|
rules={[
|
||||||
{ required: true, message: intl.formatMessage({ id: 'help.form.email.required' }) },
|
{
|
||||||
{ validator: emailValidator }
|
required: true,
|
||||||
|
message: intl.formatMessage({ id: 'help.form.email.required' }),
|
||||||
|
},
|
||||||
|
{ validator: emailValidator },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Input placeholder={intl.formatMessage({ id: 'help.form.email.placeholder' })} />
|
<Input placeholder={intl.formatMessage({ id: 'help.form.email.placeholder' })} />
|
||||||
@ -245,7 +281,12 @@ const HelpQuestionPage: React.FC = () => {
|
|||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
<Form.Item className={styles.buttonGroup}>
|
<Form.Item className={styles.buttonGroup}>
|
||||||
<Button type="primary" htmlType="submit" loading={submitting} className={styles.submitButton}>
|
<Button
|
||||||
|
type="primary"
|
||||||
|
htmlType="submit"
|
||||||
|
loading={submitting}
|
||||||
|
className={styles.submitButton}
|
||||||
|
>
|
||||||
{intl.formatMessage({ id: 'help.submit' })}
|
{intl.formatMessage({ id: 'help.submit' })}
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={handleCancel} className={styles.cancelButton}>
|
<Button onClick={handleCancel} className={styles.cancelButton}>
|
||||||
|
Reference in New Issue
Block a user