|
|
@@ -4,9 +4,7 @@ import { useRoute } from "vue-router";
|
|
|
import { PlusOutlined } from "@ant-design/icons-vue";
|
|
|
import PageHeader from '@/components/PageHeader.vue';
|
|
|
import RelationCompanyInput from './components/report-create/RelationCompanyInput.vue';
|
|
|
-import ReportCategory from './components/report-create/ReportCategory.vue';
|
|
|
-import ReportKeywords from './components/report-create/ReportKeywords.vue';
|
|
|
-import ReportName from "./components/report-create/ReportName.vue";
|
|
|
+import ReportField from "./components/report-create/ReportField.vue"
|
|
|
import DynamicMeta from './components/dynamic-meta/DynamicMeta.vue';
|
|
|
import ChapterTypeSelect from "./components/ChapterTypeSelect.vue";
|
|
|
import LogoComponent from "./components/LogoComponent.vue";
|
|
|
@@ -38,6 +36,7 @@ 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 supervisorEl = ref<HTMLInputElement | null>(null);
|
|
|
const keywordsEl = ref<HTMLInputElement | null>(null);
|
|
|
|
|
|
// 报告元数据
|
|
|
@@ -126,6 +125,15 @@ function onCompanyChange(companyId: number) {
|
|
|
|
|
|
const saveLoading = ref(false);
|
|
|
|
|
|
+function validateString(text: string, msg: string, el: Ref<HTMLInputElement | null>) {
|
|
|
+ if ((text || '').trim() == '') {
|
|
|
+ message.warning(msg);
|
|
|
+ el.value?.focus()
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
function onSave() {
|
|
|
if (report.value) {
|
|
|
if (!report.value.companyId) {
|
|
|
@@ -133,22 +141,16 @@ function onSave() {
|
|
|
relationCompanyEl.value?.focus();
|
|
|
return;
|
|
|
}
|
|
|
- const reportName = (report.value.name || '').trim();
|
|
|
- if (reportName == '') {
|
|
|
- message.warning("请填写报告类型!");
|
|
|
- reportCategoryEl.value?.focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- if ((report.value.reportName || '').trim() == '') {
|
|
|
- message.warning("请填写报告名称!");
|
|
|
- reportNameEl.value?.focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- const keywords = (report.value.keywords || '').trim();
|
|
|
- if (keywords == '') {
|
|
|
- message.warning("请填写关键词!");
|
|
|
- keywordsEl.value?.focus();
|
|
|
- return;
|
|
|
+ const validtions: [string, string, Ref<HTMLInputElement | null>][] = [
|
|
|
+ [report.value.name, "请填写报告类型!", reportCategoryEl],
|
|
|
+ [report.value.reportName, "请填写项目名称!", reportNameEl],
|
|
|
+ [report.value.supervisor, '请填写负责人!', supervisorEl],
|
|
|
+ [report.value.keywords, "请填写关键词!", keywordsEl],
|
|
|
+ ];
|
|
|
+ for (const [text, msg, el] of validtions) {
|
|
|
+ if (!validateString(text, msg, el)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
if (report.value.metadata) {
|
|
|
for (const item of report.value.metadata) {
|
|
|
@@ -265,9 +267,10 @@ onUnmounted(() => {
|
|
|
<a-col :span="12">
|
|
|
<div class="metadata-wrap">
|
|
|
<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" ref="keywordsEl" />
|
|
|
+ <ReportField name="报告类型" v-model="report.name" ref="reportCategoryEl" />
|
|
|
+ <ReportField name="项目名称" v-model="report.reportName" ref="reportNameEl"/>
|
|
|
+ <ReportField name="项目负责人" v-model="report.supervisor" ref="supervisorEl" />
|
|
|
+ <ReportField name="关键词" v-model="report.keywords" ref="keywordsEl" />
|
|
|
<DynamicMeta v-model:data="report.metadata" @change="onMetaChange" />
|
|
|
</div>
|
|
|
</a-col>
|