100011797 3 rokov pred
rodič
commit
2b9da0c8dd

+ 8 - 0
src/pages/device/Product/Detail/Access/index.tsx

@@ -412,6 +412,14 @@ const Access = () => {
           labelAlign: 'left',
           layout: 'vertical',
         },
+        'x-validator': [
+          {
+            required: !!item?.type?.expands?.required,
+            message: `${item.type.type === 'enum' ? '请选择' : '请输入'}${item.name}`,
+          },
+        ],
+        required: !!item?.type?.expands?.required,
+        default: item?.type?.expands?.defaultValue,
         enum:
           item?.type?.type === 'enum' && item?.type?.elements
             ? (item?.type?.elements || []).map((t: { value: string; text: string }) => {

+ 1 - 0
src/pages/device/Product/typings.d.ts

@@ -40,6 +40,7 @@ export type ConfigProperty = {
     id: string;
     type: string;
     elements?: any[];
+    expands?: any;
   };
   scopes: any[];
 };

+ 8 - 9
src/pages/link/AccessConfig/Detail/Media/SipSelectComponent/index.tsx

@@ -21,15 +21,14 @@ const SipSelectComponent = (props: SipSelectComponentProps) => {
   }, [value]);
 
   useEffect(() => {
-    if (!props.type) {
-      setData(value || { host: '0.0.0.0' });
-      if (!value) {
-        const dt: any = props.data.find((i) => i.host === '0.0.0.0');
-        setList(dt?.portList || []);
-      } else {
-        const dt: any = props.data.find((i) => i.host === value.host);
-        setList(dt?.portList || []);
-      }
+    if (!props.type && !value) {
+      setData({ host: '0.0.0.0' });
+      const dt: any = props.data.find((i) => i.host === '0.0.0.0');
+      setList(dt?.portList || []);
+    }
+    if (value) {
+      const dt: any = props.data.find((i) => i.host === value.host);
+      setList(dt?.portList || []);
     }
   }, [props.type]);