Procházet zdrojové kódy

fix: 场景联动及组织管理相关bug

wzyyy před 2 roky
rodič
revize
9d0f0ee168

+ 2 - 0
src/pages/rule-engine/Scene/Save/action/ListItem/FilterGroup.tsx

@@ -91,6 +91,7 @@ export default observer((props: TermsProps) => {
                   rules={[
                     {
                       validator(_, v) {
+                        // console.log('-----v',v)
                         if (v !== undefined) {
                           if (!Object.keys(v).length) {
                             return Promise.reject(new Error('该数据已发生变更,请重新配置'));
@@ -162,6 +163,7 @@ export default observer((props: TermsProps) => {
                       });
                     }}
                     onValueChange={(data) => {
+                      // console.log('----data',data)
                       const newList = [...listRef.current];
                       newList[index] = {
                         ...item,

+ 5 - 0
src/pages/rule-engine/Scene/Save/terms/paramsItem.tsx

@@ -392,6 +392,11 @@ const ParamsItem = observer((props: ParamsItemProps) => {
                 _value.metric = item.id;
               }
               setValue(_value);
+              if (v.source === 'metric' && v.value) {
+                setIsRange(true);
+              } else {
+                setIsRange(false);
+              }
               ValueRef.current.value = v;
               if (!!metricsOptions.length) {
                 if (DoubleFilter.includes(termType)) {

+ 3 - 3
src/pages/system/Department/Assets/deivce/bind.tsx

@@ -390,9 +390,9 @@ const Bind = observer((props: Props) => {
               code: resp.message,
               result: {
                 data: newData as DeviceItem[],
-                pageIndex: 0,
-                pageSize: 0,
-                total: 0,
+                pageIndex: resp.result.pageIndex,
+                pageSize: resp.result.pageIndex,
+                total: resp.result.total,
               },
               status: resp.status,
             };

+ 7 - 1
src/pages/system/Department/Assets/deivce/index.tsx

@@ -300,7 +300,13 @@ export default observer((props: { parentId: string }) => {
         <PermissionButton
           icon={<DisconnectOutlined />}
           key="unBind"
-          onClick={handleUnBind}
+          popConfirm={{
+            title: intl.formatMessage({
+              id: 'pages.system.role.option.unBindUser',
+              defaultMessage: '是否批量解除绑定',
+            }),
+            onConfirm: handleUnBind,
+          }}
           isPermission={permission.bind}
         >
           {intl.formatMessage({

+ 22 - 8
src/pages/system/Department/Assets/product/bind.tsx

@@ -36,6 +36,8 @@ const Bind = observer((props: Props) => {
   const [checkAssets, setCheckAssets] = useState<string[]>(['read']);
   const [isAll, setIsAll] = useState<boolean>(true);
   const bindChecks = useRef(new Map());
+  const recordRef = useRef<any>([]);
+  const recordMap = new Map();
 
   const columns: ProColumns<any>[] = [
     {
@@ -139,7 +141,7 @@ const Bind = observer((props: Props) => {
 
   const handleBind = () => {
     if (Models.bindKeys.length) {
-      setLoading(true);
+      // setLoading(true);
       const _data: any[] = [];
       bindChecks.current.forEach((value, key) => {
         _data.push({
@@ -150,6 +152,7 @@ const Bind = observer((props: Props) => {
           permission: value,
         });
       });
+      // console.log(_data)
       service.bind('product', _data).subscribe({
         next: () => onlyMessage('操作成功'),
         error: () => onlyMessage('操作失败', 'error'),
@@ -217,13 +220,21 @@ const Bind = observer((props: Props) => {
               options={props.assetsType}
               value={checkAssets}
               onChange={(e: any) => {
+                recordRef.current?.forEach((it: any) => {
+                  recordMap.set(it.id, it.permissionInfoList);
+                });
+                // console.log(recordMap)
                 Store.set('assets-product', {
                   isAll: isAll,
                   assets: e,
                   bindKeys: Models.bindKeys,
                 });
                 bindChecks.current.forEach((_, key) => {
-                  bindChecks.current.set(key, e);
+                  const arr = recordMap
+                    .get(key)
+                    .filter?.((item: any) => e.includes(item.id))
+                    .map((it: any) => it.id);
+                  bindChecks.current.set(key, arr);
                 });
                 setCheckAssets(e);
               }}
@@ -311,7 +322,9 @@ const Bind = observer((props: Props) => {
               // },
               onSelect: (record: any, selected, selectedRows) => {
                 if (selected) {
-                  // console.log('---------',record.permissionInfoList)
+                  const arr = record.permissionInfoList
+                    .map((it: any) => it.id)
+                    .filter?.((item: any) => checkAssets.includes(item));
                   const isShare = record.permissionInfoList.find(
                     (item: any) => item.id === 'share',
                   );
@@ -319,7 +332,8 @@ const Bind = observer((props: Props) => {
                     Models.bindKeys = [
                       ...new Set([...Models.bindKeys, ...getSelectedRowsKey(selectedRows)]),
                     ];
-                    bindChecks.current.set(record.id, checkAssets);
+                    bindChecks.current.set(record.id, arr);
+                    console.log('checkAssets----', arr);
                   } else {
                     onlyMessage('该资产不支持共享', 'warning');
                   }
@@ -385,14 +399,14 @@ const Bind = observer((props: Props) => {
                   console.log('--------', newData);
                 }
               }
-
+              recordRef.current = newData;
               return {
                 code: resp.message,
                 result: {
                   data: newData as ProductItem[],
-                  pageIndex: 0,
-                  pageSize: 0,
-                  total: 0,
+                  pageIndex: resp.result.pageIndex,
+                  pageSize: resp.result.pageIndex,
+                  total: resp.result.total,
                 },
                 status: resp.status,
               };

+ 12 - 1
src/pages/system/Department/Assets/product/index.tsx

@@ -37,6 +37,7 @@ export default observer((props: { parentId: string }) => {
   const [updateId, setUpdateId] = useState<string | string[]>('');
   const [permissions, setPermissions] = useState<string[]>(['read']);
   const [assetsType, setAssetsType] = useState([]);
+  const recordRef = useRef<any>([]);
 
   // 资产类型的权限定义
   const getAssetsType = () => {
@@ -304,6 +305,14 @@ export default observer((props: { parentId: string }) => {
           key="update"
           isPermission={permission.assert}
           onClick={() => {
+            const arr = recordRef.current.map((item: any) => item.grantedPermissions);
+            console.log(arr);
+            //求权限交集
+            const list = arr.reduce((total: any, next: any) => {
+              return [...total].filter((item) => new Set(next).has(item));
+            });
+            setPermissions(list);
+            // console.log(list)
             if (Models.unBindKeys.length) {
               setUpdateId([...Models.unBindKeys]);
               setUpdateVisible(true);
@@ -440,9 +449,11 @@ export default observer((props: { parentId: string }) => {
         rowSelection={{
           selectedRowKeys: Models.unBindKeys,
           // onChange: (selectedRowKeys, selectedRows) => {
-          //   Models.unBindKeys = selectedRows.map((item) => item.id);
+          //   console.log(selectedRows)
           // },
           onSelect: (record, selected, selectedRows) => {
+            recordRef.current = selectedRows;
+            // console.log('selectedRows',selectedRows)
             if (selected) {
               Models.unBindKeys = [
                 ...new Set([...Models.unBindKeys, ...getSelectedRowsKey(selectedRows)]),

+ 2 - 2
src/pages/system/Department/Assets/updateModal.tsx

@@ -60,8 +60,8 @@ export default (props: UpdateModalProps) => {
         permissions: props.permissions,
       });
     }
-    // console.log('1------------', props.assetsType)
-    // console.log('2------------', props.permissions)
+    console.log('1------------', props.assetsType);
+    console.log('2------------', props.permissions);
     const item = props.assetsType.filter((it: any) => props.permissions.indexOf(it.value) > -1);
     setOptions(item);
   }, [props.permissions, form]);