diff --git a/src/main/webapp/app/entities/dict/dict-edit.component.ts b/src/main/webapp/app/entities/dict/dict-edit.component.ts index faed377..6361691 100644 --- a/src/main/webapp/app/entities/dict/dict-edit.component.ts +++ b/src/main/webapp/app/entities/dict/dict-edit.component.ts @@ -3,6 +3,7 @@ import { useI18n } from 'vue-i18n'; import { useAlertService } from '@/shared/alert/alert.service'; import { useRoute, useRouter } from 'vue-router'; import axios from 'axios'; +import type { VxeFormInstance } from 'vxe-table'; export default defineComponent({ name: 'DictUpdate', @@ -29,9 +30,11 @@ export default defineComponent({ sortNo: 0, version: 0, }); - const rules = { - number: [{ required: true, message: $t('validation.required') }], - name: [{ required: true, message: $t('validation.required') }], + const dictForm = ref(); + const formRules = { + number: [{ required: true, message: $t('entity.validation.required') }], + name: [{ required: true, message: $t('entity.validation.required') }], + status: [{ required: true, message: $t('entity.validation.required') }], }; const loadData = async () => { @@ -118,6 +121,12 @@ export default defineComponent({ }; const save = async () => { + const valid = await dictForm.value?.validate(); + if (valid) { + alertService.showError($t('entity.validation.failed')); + return; + } + isSaving.value = true; try { if (dictValues.value.length > 0) { @@ -127,12 +136,6 @@ export default defineComponent({ } } - // 验证必填字段 - if (!dict.value.number || !dict.value.name) { - alertService.showError($t('validation.required')); - return; - } - if (dict.value.id) { await axios.put(`api/dicts/${dict.value.id}`, dict.value); alertService.showInfo($t('jewpmsApp.dict.updated', { param: dict.value.name })); @@ -164,7 +167,8 @@ export default defineComponent({ save, addNewValue, removeValue, - rules, + dictForm, + formRules, }; }, }); diff --git a/src/main/webapp/app/entities/dict/dict-edit.vue b/src/main/webapp/app/entities/dict/dict-edit.vue index 3caf01c..568ef59 100644 --- a/src/main/webapp/app/entities/dict/dict-edit.vue +++ b/src/main/webapp/app/entities/dict/dict-edit.vue @@ -20,92 +20,49 @@
-
-
- {{ $t('jewpmsApp.dict.number') }} - -
- -
- {{ $t('jewpmsApp.dict.name') }} - -
- -
- {{ $t('jewpmsApp.dict.parentNumber') }} - - - - -
- -
- {{ $t('jewpmsApp.dict.property') }} - -
- -
- {{ $t('jewpmsApp.dict.remark') }} - -
- -
- {{ $t('jewpmsApp.dict.status') }} - - - - -
- -
- {{ $t('jewpmsApp.dict.sortNo') }} - -
-
+ + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/webapp/app/entities/dict/dict.vue b/src/main/webapp/app/entities/dict/dict.vue index 80dd91b..169709d 100644 --- a/src/main/webapp/app/entities/dict/dict.vue +++ b/src/main/webapp/app/entities/dict/dict.vue @@ -24,21 +24,13 @@ -
-
-
- {{ $t('jewpmsApp.dict.number') }} -
+ + + + + + + + + + + + + +