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