瀏覽代碼

fix: bug

Next wzy
hear 3 年之前
父節點
當前提交
ef3b8a5659

+ 1 - 1
src/components/ProTableCard/CardItems/Scene/index.tsx

@@ -92,7 +92,7 @@ const deviceRender = (data: ActionsType | undefined) => {
         data?.options?.type + tags + data?.options?.productName + data?.options?.properties
       }`;
     case 'relation':
-      return `${data?.options?.type}与${data?.options?.name}具有相同${data?.options?.relationName}的${data?.options?.productName}设备的${data?.options?.properties}`;
+      return `${data?.options?.type}与${data?.options?.triggerName}具有相同${data?.options?.relationName}的${data?.options?.productName}设备的${data?.options?.properties}`;
     default:
       return null;
   }

+ 12 - 3
src/pages/account/Center/index.tsx

@@ -11,7 +11,7 @@ import {
   Row,
   Upload,
 } from 'antd';
-import { useEffect, useState } from 'react';
+import { useEffect, useRef, useState } from 'react';
 import styles from './index.less';
 import { UploadProps } from 'antd/lib/upload';
 import Token from '@/utils/token';
@@ -38,6 +38,8 @@ const Center = () => {
   const [password, setPassword] = useState<boolean>(false);
   const [bindList, setBindList] = useState<any>([]);
   const [apiUser, setApiUser] = useState<any>();
+  const orgRef = useRef<any>('');
+  const roleRef = useRef<any>('');
 
   const iconMap = new Map();
   iconMap.set('dingtalk-ent-app', require('/public/images/notice/dingtalk.png'));
@@ -56,6 +58,9 @@ const Center = () => {
   const getDetail = () => {
     service.getUserDetail().subscribe((res) => {
       setData(res.result);
+      console.log('-------', res.result);
+      orgRef.current = res.result.orgList.map((item: any) => item.name).join(',');
+      roleRef.current = res.result.roleList.map((item: any) => item.name).join(',');
       setImageUrl(res.result.avatar);
     });
   };
@@ -201,8 +206,12 @@ const Center = () => {
               </Descriptions.Item>
               <Descriptions.Item label="电话">{data?.telephone || '-'}</Descriptions.Item>
               <Descriptions.Item label="姓名">{data?.name}</Descriptions.Item>
-              <Descriptions.Item label="角色">{data?.roleList[0]?.name || '-'}</Descriptions.Item>
-              <Descriptions.Item label="组织">{data?.orgList[0]?.name || '-'}</Descriptions.Item>
+              <Descriptions.Item label="角色">
+                <Ellipsis title={roleRef.current || '-'} tooltip={{ placement: 'topLeft' }} />
+              </Descriptions.Item>
+              <Descriptions.Item label="组织">
+                <Ellipsis title={orgRef.current || '-'} tooltip={{ placement: 'topLeft' }} />
+              </Descriptions.Item>
               <Descriptions.Item label="邮箱">{data?.email || '-'}</Descriptions.Item>
             </Descriptions>
           </div>

+ 2 - 2
src/pages/media/Cascade/Channel/index.tsx

@@ -73,7 +73,7 @@ const Channel = () => {
           onClick={async () => {
             if (!!data) {
               if (data.length <= 64) {
-                if (pass) {
+                if (pass && !isnull) {
                   const resp: any = await service.editBindInfo(record.id, {
                     gbChannelId: data,
                   });
@@ -83,7 +83,7 @@ const Channel = () => {
                     setPopvisible('');
                   }
                 } else {
-                  message.error('该国标ID在同一设备下已存在');
+                  message.error('请填写正确的国标ID');
                 }
               } else {
                 message.error('最多可输入64个字符');

+ 1 - 1
src/pages/rule-engine/Scene/Save/action/DeviceOutput/actions/index.tsx

@@ -164,7 +164,7 @@ export default observer((props: Props) => {
             <ReadProperty
               properties={properties}
               onChange={(_, text) => {
-                console.log(text);
+                // console.log(text);
                 DeviceModel.propertiesName = text;
               }}
             />

+ 11 - 5
src/pages/rule-engine/Scene/Save/action/DeviceOutput/device/index.tsx

@@ -449,7 +449,6 @@ export default observer((props: Props) => {
       form.setFieldsValue({ selector: DeviceModel.selector });
     }
     sourceChangeEvent();
-    // console.log('-----deviceid-----', DeviceModel.deviceId);
     if (DeviceModel.deviceId) {
       service.detail(DeviceModel.deviceId).then((res) => {
         if (res.status === 200) {
@@ -459,16 +458,23 @@ export default observer((props: Props) => {
     }
   }, []);
 
-  // useEffect(()=>{
-  //   console.log('----------------',props.branchGroup,props.thenName,props.name)
-  // },[props.branchGroup,props.thenName])
-
   useEffect(() => {
     if (DeviceModel.productDetail) {
       const metadata = JSON.parse(DeviceModel.productDetail?.metadata || '{}');
       setTagList(metadata.tags);
       filterType();
     }
+    //处理变量
+    if (builtInList && builtInList.length !== 0) {
+      const param = DeviceModel.selectorValues?.[0]?.value;
+      const isVariable = builtInList.find((item: any) => {
+        return item.children.find((i: any) => i.id === param);
+      });
+      if (isVariable) {
+        form.setFieldsValue({ selector: 'variable' });
+      }
+      console.log(isVariable);
+    }
   }, [DeviceModel.productDetail, builtInList]);
 
   useEffect(() => {

+ 10 - 3
src/pages/rule-engine/Scene/Save/action/DeviceOutput/index.tsx

@@ -98,6 +98,10 @@ export default observer((props: Props) => {
       productId: DeviceModel.productId,
       message: value.message,
     };
+    //处理按变量
+    if (DeviceModel.selector === 'variable') {
+      item.selector = 'fixed';
+    }
     // console.log(item, value);
 
     const _options: any = {
@@ -108,6 +112,7 @@ export default observer((props: Props) => {
       selector: DeviceModel.selector, //选择器标识
       productName: DeviceModel.productDetail.name,
       relationName: DeviceModel.relationName,
+      triggerName: FormModel.current.options?.trigger?.name || '触发设备',
       taglist: [],
       columns: [],
       otherColumns: [],
@@ -139,9 +144,11 @@ export default observer((props: Props) => {
         type: it.type ? (it.type === 'and' ? '并且' : '或者') : '',
         value: it.value,
       }));
-      // console.log(_options.taglist, 'taglist')
     }
-    // console.log(DeviceModel.propertiesValue, _options);
+    if (_options.selector === 'variable') {
+      _options.name = DeviceModel.selectorValues?.[0]?.name;
+    }
+    // console.log("----------",item,_options)
     props.save(item, _options);
     init();
   };
@@ -166,8 +173,8 @@ export default observer((props: Props) => {
 
   useEffect(() => {
     const item = FormModel.current?.branches?.[0].then?.[0]?.actions?.[0].device?.productId;
-    console.log(item);
     formProductIdRef.current = item;
+    // console.log('---------', FormModel.current.options?.trigger?.name)
   }, []);
 
   return (

+ 1 - 1
src/pages/rule-engine/Scene/Save/action/ListItem/Item.tsx

@@ -261,7 +261,7 @@ export default (props: ItemProps) => {
         return (
           <div>
             <AIcon type={typeIconMap[data!.device!.message!.messageType]} />
-            {data?.options?.type}与<span>{data?.options?.name}</span>具有相同
+            {data?.options?.type}与<span>{data?.options?.triggerName}</span>具有相同
             {data?.options?.relationName}的{data?.options?.productName}设备的
             {data?.options?.properties}
           </div>

+ 10 - 19
src/pages/rule-engine/Scene/index.tsx

@@ -19,7 +19,7 @@ import { onlyMessage } from '@/utils/util';
 import useHistory from '@/hooks/route/useHistory';
 import Save from './Save/save';
 import { getMenuPathByCode } from '@/utils/menu';
-import { Spin } from 'antd';
+// import { Spin } from 'antd';
 
 export const service = new Service('scene');
 
@@ -32,7 +32,7 @@ const Scene = () => {
   const [current, setCurrent] = useState<Partial<SceneItem>>({});
   const history = useHistory();
   const [loading, setLoading] = useState<boolean>(true);
-  const [title, setTitle] = useState<string>('确定删除?');
+  const [title, setTitle] = useState<string>('');
 
   const deleteById = async (id: string) => {
     // const alarmResp = await service.sceneByAlarm(id);
@@ -159,27 +159,18 @@ const Scene = () => {
         disabled={record.state.value === 'started'}
         onClick={async () => {
           const res = await service.sceneByAlarm(record.id);
-          if (res.status === 200) {
-            // setTimeout(()=>{})
-            setLoading(false);
-            if (res.result !== 0) {
-              setTitle('该场景已绑定告警,确定删除?');
-            } else {
-              setTitle('确定删除?');
-            }
+          if (res.status === 200 && res.result.data.length !== 0) {
+            setTitle('该场景已绑定告警,确定删除?');
           } else {
-            setLoading(false);
+            setTitle('确定删除?');
           }
         }}
         popConfirm={{
-          title: <>{loading ? <Spin /> : title}</>,
-          okButtonProps: {
-            loading: loading,
-          },
-          onCancel: () => {
-            setTitle('');
-            setLoading(false);
-          },
+          // title: loading ? <Spin /> : title,
+          // okButtonProps: {
+          //   loading: loading,
+          // },
+          title: '确定删除?',
           disabled: record.state.value === 'started',
           onConfirm: () => {
             deleteById(record.id);

+ 2 - 2
src/pages/rule-engine/Scene/service.ts

@@ -19,9 +19,9 @@ class Service extends BaseService<SceneItem> {
     }).then((resp) => resp.result);
 
   sceneByAlarm = (id: string) =>
-    request(`${SystemConst.API_BASE}/alarm/config/_count`, {
+    request(`${SystemConst.API_BASE}/alarm/config/_query`, {
       method: 'POST',
-      data: { terms: [{ column: 'sceneId', value: id }] },
+      data: { terms: [{ column: 'id', value: id, termType: 'rule-bind-alarm' }] },
     });
   _execute = (id: string) =>
     request(`/${SystemConst.API_BASE}/scene/${id}/_execute`, {