Pārlūkot izejas kodu

feature 1001694

关联企业为必填项
Kevin Jiang 2 gadi atpakaļ
vecāks
revīzija
10aa416e4d

+ 15 - 2
src/views/report/ReportEditorView.vue

@@ -35,8 +35,10 @@ const reportExport = useReportExport()
 const authStore = useAuthStore()
 
 const report: Ref<ReportSaveRequest | null> = ref(null);
+const relationCompanyEl = ref<HTMLInputElement | null>(null);
 const reportCategoryEl = ref<HTMLInputElement | null>(null);
 const reportNameEl = ref<HTMLInputElement | null>(null);
+const keywordsEl = ref<HTMLInputElement | null>(null);
 
 // 报告元数据
 const metadata: Ref<ReportMetadataItem[]> = ref([]);
@@ -126,6 +128,11 @@ const saveLoading = ref(false);
 
 function onSave() {
   if (report.value) {
+    if (!report.value.companyId) {
+      message.warning("请填写关联企业!")
+      relationCompanyEl.value?.focus();
+      return;
+    }
     const reportName = (report.value.name || '').trim();
     if (reportName == '') {
       message.warning("请填写报告类型!");
@@ -137,6 +144,12 @@ function onSave() {
       reportNameEl.value?.focus();
       return;
     }
+    const keywords = (report.value.keywords || '').trim();
+    if (keywords == '') {
+      message.warning("请填写关键词!");
+      keywordsEl.value?.focus();
+      return;
+    }
     saveLoading.value = true;
     reportService.save(report.value).then(() => {
       saveLoading.value = false;
@@ -243,10 +256,10 @@ onUnmounted(() => {
   <a-row :gutter="24" v-if="report">
     <a-col :span="12">
       <div class="metadata-wrap">
-        <RelationCompanyInput v-model:id="report.companyId" @change="onCompanyChange" />
+        <RelationCompanyInput v-model:id="report.companyId" @change="onCompanyChange" ref="relationCompanyEl" />
         <ReportCategory v-model="report.name" ref="reportCategoryEl" />
         <ReportName v-model="report.reportName" ref="reportNameEl"/>
-        <ReportKeywords v-model="report.keywords" />
+        <ReportKeywords v-model="report.keywords" ref="keywordsEl" />
         <DynamicMeta v-model:data="report.metadata" @change="onMetaChange" />
       </div>
     </a-col>

+ 11 - 0
src/views/report/components/report-create/RelationCompanyInput.vue

@@ -20,6 +20,8 @@ const props = defineProps({
 
 const options = ref<SelectProps['options']>([]);
 
+const selectEl = ref<HTMLInputElement | null>(null);
+
 const newName = ref('');
 
 const visible = ref(false);
@@ -53,6 +55,10 @@ function onModalOk() {
   }).catch(logError);
 }
 
+function focus() {
+  selectEl.value?.focus();
+}
+
 onMounted(() => {
   const id = props.id;
   if (id > 0) {
@@ -62,6 +68,10 @@ onMounted(() => {
     }).catch(logError);
   }
 });
+
+defineExpose({
+  focus
+});
 </script>
 
 <template>
@@ -84,6 +94,7 @@ onMounted(() => {
         @focus="onFocus"
         @search="fetchCompany"
         @change="onChange"
+        ref="selectEl"
       >
       </a-select>
     </a-col>