Browse Source

fix(bug): fix bugs

lind 3 years ago
parent
commit
92d06150d5

+ 10 - 6
src/components/ProTableCard/CardItems/networkCard.tsx

@@ -19,23 +19,27 @@ export default (props: NoticeCardProps) => {
   const createDetail = () => {
   const createDetail = () => {
     const record = props;
     const record = props;
     if (record.shareCluster) {
     if (record.shareCluster) {
-      const publicHost = record.configuration.publicHost;
-      const publicPort = record.configuration.publicPort;
-      return publicHost ? (
+      const host = record.configuration.publicHost || record.configuration.remoteHost;
+      const port = record.configuration.publicPort || record.configuration.remotePort;
+      return host ? (
         <>
         <>
           {networkMap[record.type]}
           {networkMap[record.type]}
-          {publicHost}:{publicPort}
+          {host}:{port}
         </>
         </>
       ) : null;
       ) : null;
     } else {
     } else {
       const log = record.cluster?.map(
       const log = record.cluster?.map(
-        (item) => `${item.configuration.publicHost}:${item.configuration.publicPort}`,
+        (item) =>
+          `${item.configuration.publicHost || record.configuration.remoteHost}:${
+            item.configuration.publicPort || record.configuration.remotePort
+          }`,
       );
       );
       return (
       return (
         <>
         <>
           {log.map((item) => (
           {log.map((item) => (
             <div key={item}>
             <div key={item}>
-              `${networkMap[record.type]}${item}`
+              {networkMap[record.type]}
+              {item}
             </div>
             </div>
           ))}
           ))}
         </>
         </>

+ 43 - 3
src/pages/Northbound/DuerOS/Detail/index.tsx

@@ -5,11 +5,13 @@ import { Card, Col, message, Row } from 'antd';
 import {
 import {
   ArrayCollapse,
   ArrayCollapse,
   ArrayTable,
   ArrayTable,
+  DatePicker,
   Form,
   Form,
   FormButtonGroup,
   FormButtonGroup,
   FormGrid,
   FormGrid,
   FormItem,
   FormItem,
   Input,
   Input,
+  NumberPicker,
   PreviewText,
   PreviewText,
   Select,
   Select,
 } from '@formily/antd';
 } from '@formily/antd';
@@ -29,6 +31,7 @@ import { Store } from 'jetlinks-store';
 import { useParams } from 'umi';
 import { useParams } from 'umi';
 import Doc from '@/pages/Northbound/DuerOS/Detail/Doc';
 import Doc from '@/pages/Northbound/DuerOS/Detail/Doc';
 import _ from 'lodash';
 import _ from 'lodash';
+import FUpload from '@/components/Upload';
 
 
 const Save = () => {
 const Save = () => {
   const SchemaField = createSchemaField({
   const SchemaField = createSchemaField({
@@ -99,7 +102,7 @@ const Save = () => {
             );
             );
             const value = (field as Field).value;
             const value = (field as Field).value;
 
 
-            const title = actions.find((item: any) => item.id === value)?.name;
+            const title = actions?.find((item: any) => item.id === value)?.name;
             f.setFieldState(actionPath, (state) => {
             f.setFieldState(actionPath, (state) => {
               state.componentProps = {
               state.componentProps = {
                 header: title || '动作映射',
                 header: title || '动作映射',
@@ -122,7 +125,7 @@ const Save = () => {
               const product = field.query('id').value();
               const product = field.query('id').value();
               const _functionList = findProductMetadata(product)?.functions;
               const _functionList = findProductMetadata(product)?.functions;
               const _function =
               const _function =
-                _functionList && _functionList.find((item: any) => item.id === functionId);
+                _functionList && _functionList?.find((item: any) => item.id === functionId);
               form1.setFieldState(field.query('.inputs'), (state) => {
               form1.setFieldState(field.query('.inputs'), (state) => {
                 state.value = _function?.inputs.map((item: any) => ({
                 state.value = _function?.inputs.map((item: any) => ({
                   ...item,
                   ...item,
@@ -141,7 +144,7 @@ const Save = () => {
               (index) => `propertyMappings.${index}`,
               (index) => `propertyMappings.${index}`,
             );
             );
             const value = (field as Field).value;
             const value = (field as Field).value;
-            const title = propertiesList.find((item: any) => item.id === value)?.name;
+            const title = propertiesList?.find((item: any) => item.id === value)?.name;
             f.setFieldState(propertyMappingPath, (state) => {
             f.setFieldState(propertyMappingPath, (state) => {
               state.componentProps = {
               state.componentProps = {
                 header: title || '属性映射',
                 header: title || '属性映射',
@@ -152,6 +155,39 @@ const Save = () => {
             const product = field.query('id').value();
             const product = field.query('id').value();
             (field as Field).setDataSource(findProductMetadata(product)?.properties);
             (field as Field).setDataSource(findProductMetadata(product)?.properties);
           });
           });
+          onFieldReact('actionMappings.*.layout.command.message.inputs.*.valueType', (field) => {
+            const value = (field as Field).value;
+            const format = field.query('.value').take() as any;
+            if (!format) return;
+            switch (value) {
+              case 'date':
+                format.setComponent(DatePicker);
+                break;
+              case 'string':
+                format.setComponent(Input);
+                break;
+              case 'number':
+              case 'int':
+                format.setComponent(NumberPicker);
+                break;
+              case 'boolean':
+                format.setComponent(Select);
+                format.setDataSource([
+                  { label: '是', value: true },
+                  { label: '否', value: false },
+                ]);
+                break;
+              case 'file':
+                format.setComponent(FUpload, {
+                  type: 'file',
+                });
+                break;
+
+              case 'other':
+                format.setComponent(Input);
+                break;
+            }
+          });
         },
         },
       }),
       }),
     [],
     [],
@@ -246,6 +282,10 @@ const Save = () => {
                 label: 'name',
                 label: 'name',
                 value: 'id',
                 value: 'id',
               },
               },
+              showSearch: true,
+              showArrow: true,
+              filterOption: (input: string, option: any) =>
+                option.name.toLowerCase().indexOf(input.toLowerCase()) >= 0,
             },
             },
             'x-reactions': '{{useAsyncDataSource(getTypes)}}',
             'x-reactions': '{{useAsyncDataSource(getTypes)}}',
             required: true,
             required: true,

+ 1 - 1
src/pages/link/Type/Detail/index.tsx

@@ -282,7 +282,7 @@ const Save = observer(() => {
         'x-decorator': 'FormItem',
         'x-decorator': 'FormItem',
         'x-component': 'Select',
         'x-component': 'Select',
         'x-component-props': {
         'x-component-props': {
-          placeholder: '请输入本地端口',
+          placeholder: '请选择本地端口',
         },
         },
         'x-reactions': {
         'x-reactions': {
           dependencies: ['type'],
           dependencies: ['type'],

+ 11 - 6
src/pages/link/Type/index.tsx

@@ -91,25 +91,30 @@ const Network = () => {
       dataIndex: 'configuration',
       dataIndex: 'configuration',
       title: '详情',
       title: '详情',
       ellipsis: true,
       ellipsis: true,
+      hideInSearch: true,
       renderText: (text, record) => {
       renderText: (text, record) => {
         if (record.shareCluster) {
         if (record.shareCluster) {
-          const publicHost = record.configuration.publicHost;
-          const publicPort = record.configuration.publicPort;
-          return publicHost ? (
+          const host = record.configuration.publicHost || record.configuration.remoteHost;
+          const port = record.configuration.publicPort || record.configuration.remotePort;
+          return host ? (
             <>
             <>
               {networkMap[record.type]}
               {networkMap[record.type]}
-              {publicHost}:{publicPort}
+              {host}:{port}
             </>
             </>
           ) : null;
           ) : null;
         } else {
         } else {
           const log = record.cluster?.map(
           const log = record.cluster?.map(
-            (item) => `${item.configuration.publicHost}:${item.configuration.publicPort}`,
+            (item) =>
+              `${item.configuration.publicHost || record.configuration.remoteHost}:${
+                item.configuration.publicPort || record.configuration.remotePort
+              }`,
           );
           );
           return (
           return (
             <>
             <>
               {log.map((item) => (
               {log.map((item) => (
                 <div key={item}>
                 <div key={item}>
-                  `${networkMap[record.type]}${item}`
+                  {networkMap[record.type]}
+                  {item}
                 </div>
                 </div>
               ))}
               ))}
             </>
             </>

+ 49 - 0
src/pages/notice/Config/index.tsx

@@ -42,6 +42,53 @@ export const state = model<{
   log: false,
   log: false,
   syncUser: false,
   syncUser: false,
 });
 });
+const list = {
+  weixin: {
+    corpMessage: {
+      text: '企业消息',
+      status: 'corpMessage',
+    },
+    // officialMessage: {
+    //   text: '服务号消息',
+    //   status: 'officialMessage',
+    // },
+  },
+  dingTalk: {
+    dingTalkMessage: {
+      text: '钉钉消息',
+      status: 'dingTalkMessage',
+    },
+    dingTalkRobotWebHook: {
+      text: '群机器人消息',
+      status: 'dingTalkRobotWebHook',
+    },
+  },
+  voice: {
+    aliyun: {
+      text: '阿里云语音',
+      status: 'aliyun',
+    },
+  },
+  sms: {
+    aliyunSms: {
+      text: '阿里云短信',
+      status: 'aliyunSms',
+    },
+  },
+  email: {
+    embedded: {
+      text: '默认',
+      status: 'embedded',
+    },
+  },
+  webhook: {
+    http: {
+      text: 'Webhook',
+      status: 'http',
+    },
+  },
+};
+
 const Config = observer(() => {
 const Config = observer(() => {
   const intl = useIntl();
   const intl = useIntl();
   const actionRef = useRef<ActionType>();
   const actionRef = useRef<ActionType>();
@@ -62,6 +109,8 @@ const Config = observer(() => {
       dataIndex: 'provider',
       dataIndex: 'provider',
       title: '通知方式',
       title: '通知方式',
       renderText: (text, record) => typeList[record.type][record.provider],
       renderText: (text, record) => typeList[record.type][record.provider],
+      valueType: 'select',
+      valueEnum: list[id],
     },
     },
     {
     {
       dataIndex: 'description',
       dataIndex: 'description',

+ 4 - 4
src/pages/notice/Template/index.tsx

@@ -45,10 +45,10 @@ const list = {
       text: '企业消息',
       text: '企业消息',
       status: 'corpMessage',
       status: 'corpMessage',
     },
     },
-    officialMessage: {
-      text: '服务号消息',
-      status: 'officialMessage',
-    },
+    // officialMessage: {
+    //   text: '服务号消息',
+    //   status: 'officialMessage',
+    // },
   },
   },
   dingTalk: {
   dingTalk: {
     dingTalkMessage: {
     dingTalkMessage: {

+ 3 - 9
src/pages/rule-engine/Alarm/Configuration/Save/index.tsx

@@ -140,6 +140,8 @@ const Save = (props: Props) => {
     }
     }
   };
   };
 
 
+  const { permission } = PermissionButton.usePermission('rule-engine/Scene');
+
   const schema: ISchema = {
   const schema: ISchema = {
     type: 'object',
     type: 'object',
     properties: {
     properties: {
@@ -234,20 +236,12 @@ const Save = (props: Props) => {
             <PermissionButton
             <PermissionButton
               type="link"
               type="link"
               style={{ padding: 0 }}
               style={{ padding: 0 }}
-              isPermission={true}
+              isPermission={permission.add}
               onClick={() => {
               onClick={() => {
                 const tab: any = window.open(`${origin}/#/iot/rule-engine/scene/Save`);
                 const tab: any = window.open(`${origin}/#/iot/rule-engine/scene/Save`);
                 tab!.onTabSaveSuccess = (value: any) => {
                 tab!.onTabSaveSuccess = (value: any) => {
                   form.setFieldState('sceneId', async (state) => {
                   form.setFieldState('sceneId', async (state) => {
                     state.dataSource = await getScene();
                     state.dataSource = await getScene();
-                    // .then((resp) =>
-                    //   resp.result?.map((item: Record<string, unknown>) => ({
-                    //     ...item,
-                    //     label: item.name,
-                    //     value: item.id,
-                    //   })),
-                    // );
-                    console.log(value, 'value');
                     state.value = value?.result?.id;
                     state.value = value?.result?.id;
                   });
                   });
                 };
                 };