|
|
@@ -45,107 +45,125 @@ const formRef = ref<IDynamicFormRef>();
|
|
|
const formModel = ref<VolunteerInfo>();
|
|
|
const formDefine : IDynamicFormOptions = {
|
|
|
formItems: [
|
|
|
- {
|
|
|
- label: '用户名', name: 'username', type: 'text',
|
|
|
- additionalProps: {
|
|
|
- placeholder: '请输入用户名',
|
|
|
- },
|
|
|
- rules: [{ required: true, message: '请输入用户名' }],
|
|
|
- show: { callback: () => isNew.value },
|
|
|
- },
|
|
|
- {
|
|
|
- label: '密码',
|
|
|
- name: 'password',
|
|
|
- type: 'text',
|
|
|
- additionalProps: {
|
|
|
- placeholder: '请输入密码',
|
|
|
- type: 'password',
|
|
|
- } as FieldProps,
|
|
|
- rules: [{ required: true, message: '请输入密码' }],
|
|
|
- },
|
|
|
{
|
|
|
- label: '确认密码',
|
|
|
- name: 'passwordRepeat',
|
|
|
- type: 'text',
|
|
|
- additionalProps: {
|
|
|
- placeholder: '请再输入一次密码',
|
|
|
- type: 'password',
|
|
|
- } as FieldProps,
|
|
|
- rules: [
|
|
|
- { required: true, message: '请再输入一次密码' },
|
|
|
- {
|
|
|
- async validator(rule, value) {
|
|
|
- if (value != formRef.value?.getValueByPath('password'))
|
|
|
- throw '两次输入密码不一致,请检查';
|
|
|
+ name: 'groupBase',
|
|
|
+ type: 'flat-simple',
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ label: '用户名', name: 'username', type: 'text',
|
|
|
+ additionalProps: {
|
|
|
+ placeholder: '请输入用户名',
|
|
|
},
|
|
|
- }
|
|
|
- ] as RuleItem[],
|
|
|
- },
|
|
|
- {
|
|
|
- label: '真实名称', name: 'name', type: 'text',
|
|
|
- additionalProps: { placeholder: '请输入真实名称' },
|
|
|
- rules: [{ required: true, message: '请输入真实名称' }],
|
|
|
- },
|
|
|
- {
|
|
|
- label: '手机号', name: 'mobile', type: 'text',
|
|
|
- additionalProps: { placeholder: '请输入手机号' },
|
|
|
- rules: [{ required: true, message: '请输入手机号' }],
|
|
|
- },
|
|
|
- {
|
|
|
- label: '区域', name: 'regionId', type: 'select-id',
|
|
|
- additionalProps: {
|
|
|
- placeholder: '请选择区域',
|
|
|
- disabled: { callback: () => !isNew.value },
|
|
|
- loadData: async () => (await CommonContent.getCategoryList(1)).map(p => ({ text: p.title, value: p.id, raw: p }))
|
|
|
- } as IDynamicFormItemCallbackAdditionalProps<PickerIdFieldProps>,
|
|
|
- rules: [{ required: true, message: '请选择区域' }],
|
|
|
+ rules: [{ required: true, message: '请输入用户名' }],
|
|
|
+ show: { callback: () => isNew.value },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '密码',
|
|
|
+ name: 'password',
|
|
|
+ type: 'text',
|
|
|
+ additionalProps: {
|
|
|
+ placeholder: '请输入密码',
|
|
|
+ type: 'password',
|
|
|
+ } as FieldProps,
|
|
|
+ rules: [{ required: true, message: '请输入密码' }],
|
|
|
+ show: { callback: () => isNew.value || querys.value.onlyPassword },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '确认密码',
|
|
|
+ name: 'passwordRepeat',
|
|
|
+ type: 'text',
|
|
|
+ additionalProps: {
|
|
|
+ placeholder: '请再输入一次密码',
|
|
|
+ type: 'password',
|
|
|
+ } as FieldProps,
|
|
|
+ rules: [
|
|
|
+ { required: true, message: '请再输入一次密码' },
|
|
|
+ {
|
|
|
+ async validator(rule, value) {
|
|
|
+ if (value != formRef.value?.getValueByPath('password'))
|
|
|
+ throw '两次输入密码不一致,请检查';
|
|
|
+ },
|
|
|
+ }
|
|
|
+ ] as RuleItem[],
|
|
|
+ show: { callback: () => isNew.value || querys.value.onlyPassword },
|
|
|
+ },
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
- label: '性别', name: 'sex', type: 'radio-value',
|
|
|
- additionalProps: {
|
|
|
- options: [
|
|
|
- { text: '男', value: 1 },
|
|
|
- { text: '女', value: 2 }
|
|
|
- ]
|
|
|
- } as RadioValueProps,
|
|
|
- },
|
|
|
- {
|
|
|
- label: '头像', name: 'image', type: 'uploader',
|
|
|
- additionalProps: {
|
|
|
- single: true,
|
|
|
-
|
|
|
- maxFileSize: 1024 * 1024 * 10,
|
|
|
- upload: useAliOssUploadCo('xiangyuan/volunteer/images')
|
|
|
- } as UploaderFieldProps,
|
|
|
- },
|
|
|
- { label: '地址', name: 'address', type: 'text', additionalProps: { placeholder: '请输入地址' } },
|
|
|
- {
|
|
|
- label: '介绍',
|
|
|
- name: 'intro',
|
|
|
- type: 'textarea',
|
|
|
- additionalProps: {
|
|
|
- placeholder: '请输入介绍',
|
|
|
- showWordLimit: true,
|
|
|
- maxLength: 200,
|
|
|
- } as FieldProps,
|
|
|
- },
|
|
|
- {
|
|
|
- label: '采集版块', name: 'catalogIds', type: 'check-box-tree',
|
|
|
- additionalProps: {
|
|
|
- placeholder: '请选择采集版块',
|
|
|
- vertical: true,
|
|
|
- multiple: true,
|
|
|
- loadData: async (pid) => (await VillageApi.getCatalogList(querys.value.villageId, pid)).map((p) => ({
|
|
|
- text: p.title,
|
|
|
- value: p.id,
|
|
|
- hasChildren: p.haschild,
|
|
|
- })),
|
|
|
- } as CheckBoxTreeListProps,
|
|
|
- },
|
|
|
- {
|
|
|
- label: '村落认领说明', name: 'claimReason', type: 'text',
|
|
|
- additionalProps: { placeholder: '请输入村落认领说明' } ,
|
|
|
- show: { callback: () => isNew.value },
|
|
|
+ name: 'groupExtra',
|
|
|
+ type: 'flat-simple',
|
|
|
+ show: { callback: () => querys.value.onlyPassword == false },
|
|
|
+ childrenColProps: {
|
|
|
+ span: 24,
|
|
|
+ },
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ label: '真实名称', name: 'name', type: 'text',
|
|
|
+ additionalProps: { placeholder: '请输入真实名称' },
|
|
|
+ rules: [{ required: true, message: '请输入真实名称' }],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '手机号', name: 'mobile', type: 'text',
|
|
|
+ additionalProps: { placeholder: '请输入手机号' },
|
|
|
+ rules: [{ required: true, message: '请输入手机号' }],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '区域', name: 'regionId', type: 'select-id',
|
|
|
+ additionalProps: {
|
|
|
+ placeholder: '请选择区域',
|
|
|
+ disabled: { callback: () => !isNew.value },
|
|
|
+ loadData: async () => (await CommonContent.getCategoryList(1)).map(p => ({ text: p.title, value: p.id, raw: p }))
|
|
|
+ } as IDynamicFormItemCallbackAdditionalProps<PickerIdFieldProps>,
|
|
|
+ rules: [{ required: true, message: '请选择区域' }],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '性别', name: 'sex', type: 'radio-value',
|
|
|
+ additionalProps: {
|
|
|
+ options: [
|
|
|
+ { text: '男', value: 1 },
|
|
|
+ { text: '女', value: 2 }
|
|
|
+ ]
|
|
|
+ } as RadioValueProps,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '头像', name: 'image', type: 'uploader',
|
|
|
+ additionalProps: {
|
|
|
+ single: true,
|
|
|
+
|
|
|
+ maxFileSize: 1024 * 1024 * 10,
|
|
|
+ upload: useAliOssUploadCo('xiangyuan/volunteer/images')
|
|
|
+ } as UploaderFieldProps,
|
|
|
+ },
|
|
|
+ { label: '地址', name: 'address', type: 'text', additionalProps: { placeholder: '请输入地址' } },
|
|
|
+ {
|
|
|
+ label: '介绍',
|
|
|
+ name: 'intro',
|
|
|
+ type: 'textarea',
|
|
|
+ additionalProps: {
|
|
|
+ placeholder: '请输入介绍',
|
|
|
+ showWordLimit: true,
|
|
|
+ maxLength: 200,
|
|
|
+ } as FieldProps,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '采集版块', name: 'catalogIds', type: 'check-box-tree',
|
|
|
+ additionalProps: {
|
|
|
+ placeholder: '请选择采集版块',
|
|
|
+ vertical: true,
|
|
|
+ multiple: true,
|
|
|
+ loadData: async (pid) => (await VillageApi.getCatalogList(querys.value.villageId, pid)).map((p) => ({
|
|
|
+ text: p.title,
|
|
|
+ value: p.id,
|
|
|
+ hasChildren: p.haschild,
|
|
|
+ })),
|
|
|
+ } as CheckBoxTreeListProps,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '村落认领说明', name: 'claimReason', type: 'text',
|
|
|
+ additionalProps: { placeholder: '请输入村落认领说明' } ,
|
|
|
+ show: { callback: () => isNew.value },
|
|
|
+ },
|
|
|
+ ]
|
|
|
},
|
|
|
],
|
|
|
formAdditionaProps: {
|
|
|
@@ -169,6 +187,8 @@ async function submit() {
|
|
|
try {
|
|
|
loading.value = true;
|
|
|
formModel.value!.villageId = querys.value.villageId;
|
|
|
+ console.log('formModel.value', formModel.value);
|
|
|
+
|
|
|
if (querys.value.id >= 0) {
|
|
|
await VillageApi.updateVolunteer(formModel.value!);
|
|
|
} else {
|
|
|
@@ -198,6 +218,7 @@ function backPrev(needRefresh: boolean) {
|
|
|
const { querys } = useLoadQuerys({
|
|
|
villageId: 0,
|
|
|
villageVolunteerId: 0,
|
|
|
+ onlyPassword: false,
|
|
|
id: 0,
|
|
|
}, async (querys) => {
|
|
|
loading.value = true;
|
|
|
@@ -222,8 +243,10 @@ const { querys } = useLoadQuerys({
|
|
|
}
|
|
|
|
|
|
await nextTick();
|
|
|
-
|
|
|
formRef.value.initDefaultValuesToModel();
|
|
|
+
|
|
|
+ console.log('formModel.value', formModel.value);
|
|
|
+
|
|
|
});
|
|
|
const isNew = computed(() => querys.value.id < 0);
|
|
|
|