|
|
@@ -3,8 +3,8 @@
|
|
|
<LoadingPage v-if="loading" />
|
|
|
<DynamicForm
|
|
|
ref="formRef"
|
|
|
+ :model="formModel"
|
|
|
:options="formDefine"
|
|
|
- :formModelInit="formModelInit"
|
|
|
/>
|
|
|
<Button type="primary" @click="submit">提交</Button>
|
|
|
<XBarSpace />
|
|
|
@@ -20,121 +20,114 @@ import Button from '@/components/basic/Button.vue';
|
|
|
import XBarSpace from '@/components/layout/space/XBarSpace.vue';
|
|
|
import DynamicForm from '@/components/dynamic/DynamicForm.vue';
|
|
|
import type { IDynamicFormOptions, IDynamicFormRef } from '@/components/dynamic';
|
|
|
+import type { FormProps } from '@/components/form/Form.vue';
|
|
|
|
|
|
const loading = ref(false);
|
|
|
|
|
|
const formRef = ref<IDynamicFormRef>();
|
|
|
+const formModel = ref(new ContributeItem());
|
|
|
const formDefine : IDynamicFormOptions = {
|
|
|
+ formAdditionaProps: {
|
|
|
+ labelFlex: 3,
|
|
|
+ inputFlex: 7
|
|
|
+ } as FormProps,
|
|
|
formItems: [
|
|
|
{
|
|
|
- name: '',
|
|
|
- children: {
|
|
|
- type: 'group',
|
|
|
- props: {
|
|
|
- class: 'form-block',
|
|
|
- },
|
|
|
- propNestType: 'nest',
|
|
|
- items: [
|
|
|
- {
|
|
|
- label: '栏目',
|
|
|
- name: 'mainBodyColumnId',
|
|
|
- type: 'dynamic-select',
|
|
|
- params: {
|
|
|
- loadData: async () => {
|
|
|
- /* (await ContributeApi.getCanClaimVallageList())
|
|
|
- .map((p) => ({
|
|
|
- value: p.id,
|
|
|
- text: p.villageName,
|
|
|
- })) */
|
|
|
- return []
|
|
|
- },
|
|
|
- } as DynamicSelectProps,
|
|
|
- rules: [{
|
|
|
- required: true,
|
|
|
- errorMessage: '请选择投稿栏目',
|
|
|
- }],
|
|
|
- onChange: (_, value, model) => {
|
|
|
- //model.
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- label: '文章标题',
|
|
|
- name: 'title',
|
|
|
- type: 'text',
|
|
|
- defaultValue: '',
|
|
|
- params: {
|
|
|
- placeholder: '请输入文章标题',
|
|
|
+ name: 'a',
|
|
|
+ type: 'flat-group',
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ label: '栏目',
|
|
|
+ name: 'mainBodyColumnId',
|
|
|
+ type: 'select-id',
|
|
|
+ additionalProps: {
|
|
|
+ loadData: async () => {
|
|
|
+ /* (await ContributeApi.getCanClaimVallageList())
|
|
|
+ .map((p) => ({
|
|
|
+ value: p.id,
|
|
|
+ text: p.villageName,
|
|
|
+ })) */
|
|
|
+ return []
|
|
|
},
|
|
|
- rules: [{
|
|
|
- required: true,
|
|
|
- errorMessage: '请输入文章标题',
|
|
|
- }]
|
|
|
},
|
|
|
- {
|
|
|
- label: '内容类型',
|
|
|
- name: 'type',
|
|
|
- type: 'select',
|
|
|
- params: {
|
|
|
- disabled: true,
|
|
|
- localdata: [
|
|
|
- { value: 1, text: "文章" },
|
|
|
- { value: 2, text: "音频" },
|
|
|
- { value: 3, text: "视频" },
|
|
|
- { value: 4, text: "相册" },
|
|
|
- ],
|
|
|
- clear: false,
|
|
|
+ rules: [{
|
|
|
+ required: true,
|
|
|
+ message: '请选择投稿栏目',
|
|
|
+ }],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '文章标题',
|
|
|
+ name: 'title',
|
|
|
+ type: 'text',
|
|
|
+ defaultValue: '',
|
|
|
+ additionalProps: {
|
|
|
+ placeholder: '请输入文章标题',
|
|
|
+ },
|
|
|
+ rules: [{
|
|
|
+ required: true,
|
|
|
+ message: '请输入文章标题',
|
|
|
+ }]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '内容类型',
|
|
|
+ name: 'type',
|
|
|
+ type: 'select-id',
|
|
|
+ additionalProps: {
|
|
|
+ disabled: true,
|
|
|
+ loadData: async () => {
|
|
|
+ return [
|
|
|
+ { id: 1, text: "文章" },
|
|
|
+ { id: 2, text: "音频" },
|
|
|
+ { id: 3, text: "视频" },
|
|
|
+ { id: 4, text: "相册" },
|
|
|
+ ]
|
|
|
},
|
|
|
- defaultValue: 1,
|
|
|
- rules: [{
|
|
|
- required: true,
|
|
|
- errorMessage: '请选择类型',
|
|
|
- }]
|
|
|
},
|
|
|
- ]
|
|
|
- }
|
|
|
+ defaultValue: 1,
|
|
|
+ rules: [{
|
|
|
+ required: true,
|
|
|
+ message: '请选择类型',
|
|
|
+ }]
|
|
|
+ },
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
- name: '',
|
|
|
- children: {
|
|
|
- type: 'group',
|
|
|
- props: {
|
|
|
- class: 'form-block',
|
|
|
- },
|
|
|
- propNestType: 'nest',
|
|
|
- items: [
|
|
|
- {
|
|
|
- label: '内容',
|
|
|
- name: 'intro',
|
|
|
- type: 'richtext',
|
|
|
- defaultValue: '',
|
|
|
- params: {
|
|
|
- placeholder: '请输入内容',
|
|
|
- saveTempKey: 'contribute',
|
|
|
- },
|
|
|
- rules: [{
|
|
|
- required: true,
|
|
|
- errorMessage: '请输入内容',
|
|
|
- }]
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
+ name: 'b',
|
|
|
+ type: 'flat-group',
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ label: '内容',
|
|
|
+ name: 'intro',
|
|
|
+ type: 'richtext',
|
|
|
+ defaultValue: '',
|
|
|
+ additionalProps: {
|
|
|
+ placeholder: '请输入内容',
|
|
|
+ saveTempKey: 'contribute',
|
|
|
+ },
|
|
|
+ rules: [{
|
|
|
+ required: true,
|
|
|
+ message: '请输入内容',
|
|
|
+ }]
|
|
|
+ }
|
|
|
+ ]
|
|
|
},
|
|
|
]
|
|
|
}
|
|
|
|
|
|
-function formModelInit() {
|
|
|
- return new ContributeItem();
|
|
|
-}
|
|
|
-
|
|
|
async function submit() {
|
|
|
if (!formRef.value)
|
|
|
return;
|
|
|
try {
|
|
|
- const data = await formRef.value.submitForm<ContributeItem>();
|
|
|
- if (!data)
|
|
|
- return;
|
|
|
+ await formRef.value.validate();
|
|
|
+ } catch {
|
|
|
+ uni.showToast({
|
|
|
+ title: '有必填项未填写,请检查',
|
|
|
+ icon: 'none',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ try {
|
|
|
loading.value = true;
|
|
|
- await ContributeApi.contribute(data);
|
|
|
+ await ContributeApi.contribute(formModel.value as ContributeItem);
|
|
|
uni.showModal({
|
|
|
title: '提交成功',
|
|
|
content: '感谢您的投稿,我们将尽快审核并通知您结果。',
|