Prechádzať zdrojové kódy

perf(views): 优化“创建协议”步骤校验协议参数个数的逻辑

wangcong 1 mesiac pred
rodič
commit
26b98e8f3b

+ 1 - 1
src/views/setup-protocol/CreateProtocol.vue

@@ -31,7 +31,7 @@ const protocolContentRef = useTemplateRef('protocolContent');
 
 const finish = async () => {
   await protocolContentRef.value?.validateProtocolInfo();
-  protocolContentRef.value?.isAtLeastOneParam();
+  await protocolContentRef.value?.isAtLeastOneParam();
 
   if (props.form.protocolInfo.id) {
     await updateProtocolBaseInfo(props.form.protocolInfo);

+ 8 - 2
src/views/setup-protocol/ProtocolContent.vue

@@ -432,11 +432,17 @@ const submitLocalParams = async () => {
 /**
  * 协议必须至少配置一条参数,此函数用于提供给外部进行判断是否可以提交协议的创建、修改等操作
  */
-const isAtLeastOneParam = () => {
+const isAtLeastOneParam = async () => {
   let isAtLeastOne: boolean;
 
   if (props.info.id) {
-    isAtLeastOne = paramTotal.value > 0;
+    const { total } = await getProtocolParamList({
+      pageIndex: 1,
+      pageSize: 1,
+      baseInfoId: props.info.id,
+    });
+
+    isAtLeastOne = total > 0;
   } else {
     isAtLeastOne = localParamList.value.length > 0;
   }