Sfoglia il codice sorgente

fix: bug#5203、5202、5206、5187

xieyonghong 3 anni fa
parent
commit
536ad60c73

+ 1 - 1
src/components/PermissionButton/index.tsx

@@ -53,7 +53,7 @@ const PermissionButton = (props: PermissionButtonProps) => {
     if (isPermission) {
       if (popConfirm) {
         popConfirm.children = tooltip ? isTooltip : defaultButton;
-        return <Popconfirm disabled={!isPermission} {...popConfirm} />;
+        return <Popconfirm disabled={!isPermission || props.disabled} {...popConfirm} />;
       } else if (tooltip && !popConfirm) {
         return isTooltip;
       } else {

+ 1 - 1
src/components/ProTableCard/CardItems/product.tsx

@@ -136,7 +136,7 @@ export default (props: ProductCardProps) => {
             </div>
             <div>
               <label>接入方式</label>
-              <div className={'ellipsis'}>{props.transportProtocol || '未接入'}</div>
+              <div className={'ellipsis'}>{props.protocolName || '未接入'}</div>
             </div>
           </div>
         </div>

+ 12 - 1
src/pages/device/Product/index.tsx

@@ -258,8 +258,19 @@ const Product = observer(() => {
     },
     {
       title: '接入方式',
-      dataIndex: 'transportProtocol',
+      dataIndex: 'accessId',
       width: 150,
+      valueType: 'select',
+      render: (_, row) => {
+        return row.protocolName;
+      },
+      request: () =>
+        service.queryGatewayList().then((resp: any) =>
+          resp.result.map((item: any) => ({
+            label: item.name,
+            value: item.id,
+          })),
+        ),
     },
     {
       title: '设备类型',

+ 9 - 0
src/pages/device/Product/service.ts

@@ -150,6 +150,15 @@ class Service extends BaseService<ProductItem> {
     );
 
   public existsID = (id: string) => request(`${this.uri}/${id}/exists`, { method: 'GET' });
+
+  //接入网关
+  public queryGatewayList = () =>
+    request(`/${SystemConst.API_BASE}/gateway/device/_query/no-paging`, {
+      method: 'POST',
+      data: {
+        paging: false,
+      },
+    });
 }
 
 export default Service;

+ 20 - 12
src/pages/media/Device/index.tsx

@@ -218,7 +218,7 @@ const Device = () => {
         </PermissionButton>,
         <PermissionButton
           tooltip={{
-            title: '查看设备',
+            title: '查看通道',
           }}
           style={{ padding: 0 }}
           type={'link'}
@@ -248,15 +248,23 @@ const Device = () => {
           </Button>
         </Tooltip>,
         <PermissionButton
-          tooltip={{
-            title:
-              record.provider === ProviderValue.FIXED
-                ? '接入方式为固定地址时不支持更新通道'
-                : '更新通道',
-          }}
+          tooltip={
+            record.state.value === 'offline' || record.provider === providerType['fixed-media']
+              ? {
+                  title:
+                    record.provider === providerType['fixed-media']
+                      ? '固定地址无法更新通道'
+                      : record.state.value === 'offline'
+                      ? '设备已离线'
+                      : '',
+                }
+              : undefined
+          }
           key={'updateChannel'}
-          isPermission={permission.action}
-          disabled={record.state.value === 'offline' || record.provider === ProviderValue.FIXED}
+          isPermission={permission.update}
+          disabled={
+            record.state.value === 'offline' || record.provider === providerType['fixed-media']
+          }
           style={{ padding: 0 }}
           type={'link'}
           onClick={() => {
@@ -273,13 +281,13 @@ const Device = () => {
           popConfirm={{
             title: intl.formatMessage({
               id:
-                record.state.value === 'offline'
-                  ? 'pages.device.productDetail.deleteTip'
+                record.state.value !== 'offline'
+                  ? 'pages.device.instance.deleteTip'
                   : 'page.table.isDelete',
               defaultMessage: '是否删除?',
             }),
             onConfirm: async () => {
-              if (record.state.value !== 'offline') {
+              if (record.state.value === 'offline') {
                 await deleteItem(record.id);
               } else {
                 onlyMessage('在线设备不能进行删除操作', 'error');