Jelajahi Sumber

feat: merge

xieyonghong 3 tahun lalu
induk
melakukan
38c3af4d3b

+ 1 - 1
src/pages/device/DashBoard/index.tsx

@@ -283,7 +283,7 @@ const DeviceBoard = () => {
           grid: {
             top: '2%',
             bottom: '5%',
-            left: '2%',
+            left: '4%',
             right: '2%',
           },
           series: [

+ 21 - 36
src/pages/device/Instance/Detail/MetadataMap/EditableTable/index.tsx

@@ -1,10 +1,10 @@
 import React, { useContext, useEffect, useState } from 'react';
-import { Badge, Col, Form, Input, Pagination, Row, Select, Table, Tooltip } from 'antd';
+import { AutoComplete, Badge, Col, Form, Input, Pagination, Row, Table, Tooltip } from 'antd';
 import { service } from '@/pages/device/Instance';
 import './index.less';
 import { QuestionCircleOutlined } from '@ant-design/icons';
 import { onlyMessage } from '@/utils/util';
-// import { throttle } from 'lodash';
+// import { debounce } from 'lodash';
 
 const defaultImage = require('/public/images/metadata-map.png');
 
@@ -46,15 +46,17 @@ const EditableCell = ({
 }: EditableCellProps) => {
   const form: any = useContext(EditableContext);
   const [temp, setTemp] = useState<any>({});
+  const uuid = '使用物模型属性';
 
   const save = async () => {
     try {
       const values = await form.validateFields();
-      handleSave({
+      const dt = {
         ...record,
-        originalId: !!values?.originalId ? values?.originalId : record.metadataId,
-        customMapping: values?.originalId !== '',
-      });
+        originalId: values?.originalId === uuid ? '' : values?.originalId,
+        customMapping: values?.originalId !== uuid,
+      };
+      handleSave(dt);
     } catch (errInfo) {
       console.log('Save failed:', errInfo);
     }
@@ -62,7 +64,7 @@ const EditableCell = ({
 
   useEffect(() => {
     if (record) {
-      form.setFieldsValue({ [dataIndex]: record.customMapping ? record[dataIndex] : '' });
+      form.setFieldsValue({ [dataIndex]: record.customMapping ? record[dataIndex] : uuid });
       setTemp(properties.find((i) => i.id === record.originalId));
     }
   }, [record]);
@@ -72,41 +74,24 @@ const EditableCell = ({
   if (editable) {
     childNode = (
       <Form.Item style={{ margin: 0 }} name={dataIndex}>
-        {/* <AutoComplete onChange={throttle(save, 5000)}>
-          <AutoComplete.Option value={''}>使用物模型属性</AutoComplete.Option>
+        <AutoComplete
+          onBlur={() => {
+            save();
+          }}
+        >
+          <AutoComplete.Option value={uuid}>使用物模型属性</AutoComplete.Option>
           {record.customMapping && temp && (
             <AutoComplete.Option value={record.originalId}>
               {temp?.name}({temp?.id})
             </AutoComplete.Option>
           )}
-          {tempList.length > 0 &&
-            tempList.map((item: any) => (
-              <AutoComplete.Option key={item?.id} value={item?.id}>
-                {item?.name}({item?.id})
-              </AutoComplete.Option>
-            ))}
-        </AutoComplete> */}
-        <Select
-          onChange={save}
-          showSearch
-          optionFilterProp="children"
-          filterOption={(input: string, option: any) =>
-            (option?.children || '').toLowerCase()?.indexOf(input.toLowerCase()) >= 0
-          }
-        >
-          <Select.Option value={''}>使用物模型属性</Select.Option>
-          {record.customMapping && (
-            <Select.Option value={record.originalId}>
-              {temp?.name}({temp?.id})
-            </Select.Option>
-          )}
           {list.length > 0 &&
             list.map((item: any) => (
-              <Select.Option key={item?.id} value={item?.id}>
+              <AutoComplete.Option key={item?.id} value={item?.id}>
                 {item?.name}({item?.id})
-              </Select.Option>
+              </AutoComplete.Option>
             ))}
-        </Select>
+        </AutoComplete>
       </Form.Item>
     );
   }
@@ -119,7 +104,7 @@ interface Props {
 }
 
 const EditableTable = (props: Props) => {
-  const baseColumns = [
+  const baseColumns: any = [
     {
       title: '物模型属性',
       dataIndex: 'name',
@@ -203,7 +188,7 @@ const EditableTable = (props: Props) => {
           const t = data.find((item: any) => item?.originalId === i?.id);
           return !t || (t && !t.customMapping);
         });
-        setPmList(arr);
+        setPmList([...arr]);
       } else {
         setPmList([]);
       }
@@ -295,7 +280,7 @@ const EditableTable = (props: Props) => {
     }
   };
 
-  const columns = baseColumns.map((col) => {
+  const columns = baseColumns.map((col: any) => {
     if (!col.editable) {
       return col;
     }

+ 5 - 5
src/pages/device/Instance/Detail/Parsing/index.tsx

@@ -262,11 +262,11 @@ const Parsing = (props: Props) => {
                   return {
                     suggestions: [
                       {
-                        label: 'test()',
-                        kind: editor.languages.CompletionItemKind['Function'],
-                        insertText: 'test()',
-                        detail: '测试语法',
-                        range: range,
+                        label: 'test()', //提示内容
+                        kind: editor.languages.CompletionItemKind['Function'], //图标
+                        insertText: 'test()', //填充
+                        detail: '这是一个测试语法', //提示的解释
+                        range: range, //范围
                       },
                     ],
                   };

+ 1 - 0
src/pages/device/Instance/Detail/Running/Property/index.tsx

@@ -237,6 +237,7 @@ const Property = (props: Props) => {
 
   useEffect(() => {
     if (dataSource.data.length > 0) {
+      setLoading1(true);
       getDashboard();
     } else {
       setLoading(false);

+ 1 - 1
src/pages/device/Instance/service.ts

@@ -356,7 +356,7 @@ class Service extends BaseService<DeviceInstance> {
       method: 'POST',
       data,
     });
-  public queryMetadatabyId = (data: any) =>
+  public queryModbusabyId = (data: any) =>
     request(`/${SystemConst.API_BASE}/modbus/master/_query/no-paging`, {
       method: 'POST',
       data,

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

@@ -272,7 +272,7 @@ const Save = (props: Props) => {
         </Row>
         <Row>
           <Col span={24}>
-            <Form.Item label={'分类'} name={'classifiedId'}>
+            <Form.Item label={'产品分类'} name={'classifiedId'}>
               <TreeSelect
                 showSearch
                 allowClear

+ 12 - 8
src/pages/link/AccessConfig/Detail/Access/index.tsx

@@ -27,6 +27,7 @@ const Access = (props: Props) => {
   const [current, setCurrent] = useState<number>(0);
   const [networkList, setNetworkList] = useState<any[]>([]);
   const [procotolList, setProcotolList] = useState<any[]>([]);
+  const [allProcotolList, setAllProcotolList] = useState<any[]>([]);
   const [procotolCurrent, setProcotolCurrent] = useState<string>('');
   const [networkCurrent, setNetworkCurrent] = useState<string>('');
   const [config, setConfig] = useState<any>();
@@ -46,6 +47,7 @@ const Access = (props: Props) => {
     service.getProtocolList(ProcotoleMapping.get(id), params).then((resp) => {
       if (resp.status === 200) {
         setProcotolList(resp.result);
+        setAllProcotolList(resp.result);
       }
     });
   };
@@ -409,14 +411,16 @@ const Access = (props: Props) => {
                 allowClear
                 placeholder="请输入名称"
                 onSearch={(value: string) => {
-                  queryProcotolList(
-                    props.provider?.id,
-                    encodeQuery({
-                      terms: {
-                        name$LIKE: `%${value}%`,
-                      },
-                    }),
-                  );
+                  if (value) {
+                    const list = allProcotolList.filter((i) => {
+                      return (
+                        i?.name && i.name.toLocaleLowerCase().includes(value.toLocaleLowerCase())
+                      );
+                    });
+                    setProcotolList(list);
+                  } else {
+                    setProcotolList(allProcotolList);
+                  }
                 }}
                 style={{ width: 500, margin: '20px 0' }}
               />

+ 2 - 2
src/pages/link/Channel/Modbus/Access/bindDevice/index.tsx

@@ -96,8 +96,8 @@ const BindDevice = (props: Props) => {
         save();
       }}
       width={1300}
-      permissionCode={'link/Channel/Modbus'}
-      permission={['add', 'edit', 'view']}
+      permissionCode={'device/Instance'}
+      permission={['edit', 'view']}
     >
       <SearchComponent
         field={columns}

+ 2 - 2
src/pages/link/Channel/Opcua/Access/bindDevice/index.tsx

@@ -106,8 +106,8 @@ const BindDevice = (props: Props) => {
         save();
       }}
       width={1300}
-      permissionCode={'link/Channel/Opcua'}
-      permission={['add', 'edit', 'view']}
+      permissionCode={'device/Instance'}
+      permission={['edit', 'view']}
     >
       <SearchComponent
         field={columns}

+ 3 - 0
src/pages/link/Type/Detail/index.tsx

@@ -128,6 +128,9 @@ const Save = observer(() => {
                 state.value = '0.0.0.0';
                 state.disabled = true;
               });
+              f.setFieldState('grid.configuration.panel1.layout2.secure', (state) => {
+                state.value = false;
+              });
             }
             const _host = filterConfigByType(_.cloneDeep(configRef.current), value);
             f.setFieldState('grid.configuration.panel1.layout2.host', (state) => {

+ 95 - 110
src/pages/media/Stream/index.tsx

@@ -1,10 +1,10 @@
 import { PageContainer } from '@ant-design/pro-layout';
 import SearchComponent from '@/components/SearchComponent';
 import type { ProColumns } from '@jetlinks/pro-table';
-import { Button, Card, Col, Empty, Pagination, Row } from 'antd';
+import { Card, Col, Empty, Pagination, Row } from 'antd';
 import { useEffect, useState } from 'react';
 import Service from '@/pages/media/Stream/service';
-import { getButtonPermission, getMenuPathByParams, MENUS_CODE } from '@/utils/menu';
+import { getMenuPathByParams, MENUS_CODE } from '@/utils/menu';
 import { useHistory } from 'umi';
 import { DeleteOutlined, EditOutlined, PlusOutlined } from '@ant-design/icons';
 import { model } from '@formily/reactive';
@@ -80,121 +80,106 @@ const Stream = () => {
       <Card>
         <div className="stream" style={{ position: 'relative', minHeight }}>
           <div style={{ height: '100%', paddingBottom: 48 }}>
+            <div>
+              <PermissionButton
+                isPermission={permission.add}
+                onClick={() => {
+                  history.push(`${getMenuPathByParams(MENUS_CODE['media/Stream/Detail'])}`);
+                  StreamModel.current = {};
+                }}
+                key="button"
+                icon={<PlusOutlined />}
+                type="primary"
+              >
+                新增
+              </PermissionButton>
+            </div>
             {dataSource.data.length > 0 ? (
               <div>
-                <div>
-                  <PermissionButton
-                    isPermission={permission.add}
-                    onClick={() => {
-                      history.push(`${getMenuPathByParams(MENUS_CODE['media/Stream/Detail'])}`);
-                      StreamModel.current = {};
-                    }}
-                    key="button"
-                    icon={<PlusOutlined />}
-                    type="primary"
-                  >
-                    新增
-                  </PermissionButton>
-                  <Row gutter={[16, 16]} style={{ marginTop: 10 }}>
-                    {(dataSource?.data || []).map((item: any) => (
-                      <Col key={item.id} span={12}>
-                        <StreamCard
-                          {...item}
-                          actions={[
-                            <PermissionButton
-                              isPermission={permission.update}
-                              onClick={() => {
-                                history.push(
-                                  `${getMenuPathByParams(
-                                    MENUS_CODE['media/Stream/Detail'],
-                                    item.id,
-                                  )}`,
-                                );
-                                StreamModel.current = { ...item };
-                              }}
-                              key="button"
-                              type="link"
-                            >
-                              <EditOutlined />
-                              编辑
-                            </PermissionButton>,
-                            <PermissionButton
-                              isPermission={permission.delete}
-                              popConfirm={{
-                                title: '确认删除',
-                                onConfirm: () => {
-                                  service.remove(item.id).then((resp: any) => {
-                                    if (resp.status === 200) {
-                                      onlyMessage('操作成功!');
-                                      handleSearch({ pageSize: 10, terms: [] });
-                                    }
-                                  });
-                                },
-                              }}
-                              key="delete"
-                              type="link"
-                            >
-                              <DeleteOutlined />
-                            </PermissionButton>,
-                          ]}
-                        />
-                      </Col>
-                    ))}
-                  </Row>
-                </div>
+                <Row gutter={[16, 16]} style={{ marginTop: 10 }}>
+                  {(dataSource?.data || []).map((item: any) => (
+                    <Col key={item.id} span={12}>
+                      <StreamCard
+                        {...item}
+                        actions={[
+                          <PermissionButton
+                            isPermission={permission.update}
+                            onClick={() => {
+                              history.push(
+                                `${getMenuPathByParams(
+                                  MENUS_CODE['media/Stream/Detail'],
+                                  item.id,
+                                )}`,
+                              );
+                              StreamModel.current = { ...item };
+                            }}
+                            key="button"
+                            type="link"
+                          >
+                            <EditOutlined />
+                            编辑
+                          </PermissionButton>,
+                          <PermissionButton
+                            isPermission={permission.delete}
+                            popConfirm={{
+                              title: '确认删除',
+                              onConfirm: () => {
+                                service.remove(item.id).then((resp: any) => {
+                                  if (resp.status === 200) {
+                                    onlyMessage('操作成功!');
+                                    handleSearch({ pageSize: 10, terms: [] });
+                                  }
+                                });
+                              },
+                            }}
+                            key="delete"
+                            type="link"
+                          >
+                            <DeleteOutlined />
+                          </PermissionButton>,
+                        ]}
+                      />
+                    </Col>
+                  ))}
+                </Row>
               </div>
             ) : (
-              <Empty
-                style={{ marginTop: '10%' }}
-                description={
-                  <span>
-                    暂无数据,请先
-                    <Button
-                      type="link"
-                      disabled={getButtonPermission('media/Stream', ['add'])}
-                      onClick={() => {
-                        history.push(`${getMenuPathByParams(MENUS_CODE['media/Stream/Detail'])}`);
-                        StreamModel.current = {};
-                      }}
-                    >
-                      新增流媒体服务
-                    </Button>
-                  </span>
-                }
-              />
+              <Empty style={{ marginTop: '10%' }} />
             )}
           </div>
-          <div
-            style={{
-              display: 'flex',
-              justifyContent: 'flex-end',
-              position: 'absolute',
-              bottom: 0,
-              width: '100%',
-            }}
-          >
-            <Pagination
-              showSizeChanger
-              size="small"
-              className={'pro-table-card-pagination'}
-              total={dataSource?.total || 0}
-              current={dataSource?.pageIndex + 1}
-              onChange={(page, size) => {
-                handleSearch({
-                  ...param,
-                  pageIndex: page - 1,
-                  pageSize: size,
-                });
-              }}
-              pageSizeOptions={[10, 20, 50, 100]}
-              pageSize={dataSource?.pageSize}
-              showTotal={(num) => {
-                const minSize = dataSource?.pageIndex * dataSource?.pageSize + 1;
-                const MaxSize = (dataSource?.pageIndex + 1) * dataSource?.pageSize;
-                return `第 ${minSize} - ${MaxSize > num ? num : MaxSize} 条/总共 ${num} 条`;
+          {dataSource.data.length > 0 && (
+            <div
+              style={{
+                display: 'flex',
+                justifyContent: 'flex-end',
+                position: 'absolute',
+                bottom: 0,
+                width: '100%',
               }}
-            />
-          </div>
+            >
+              <Pagination
+                showSizeChanger
+                size="small"
+                className={'pro-table-card-pagination'}
+                total={dataSource?.total || 0}
+                current={dataSource?.pageIndex + 1}
+                onChange={(page, size) => {
+                  handleSearch({
+                    ...param,
+                    pageIndex: page - 1,
+                    pageSize: size,
+                  });
+                }}
+                pageSizeOptions={[10, 20, 50, 100]}
+                pageSize={dataSource?.pageSize}
+                showTotal={(num) => {
+                  const minSize = dataSource?.pageIndex * dataSource?.pageSize + 1;
+                  const MaxSize = (dataSource?.pageIndex + 1) * dataSource?.pageSize;
+                  return `第 ${minSize} - ${MaxSize > num ? num : MaxSize} 条/总共 ${num} 条`;
+                }}
+              />
+            </div>
+          )}
         </div>
       </Card>
     </PageContainer>