|
|
@@ -24,7 +24,9 @@ const Access = () => {
|
|
|
const intl = useIntl();
|
|
|
const actionRef = useRef<ActionType>();
|
|
|
const location = useLocation<string>();
|
|
|
- const [param, setParam] = useState({});
|
|
|
+ const [param, setParam] = useState<any>({
|
|
|
+ terms: [{ column: 'deviceId', value: '' }],
|
|
|
+ });
|
|
|
const [opcUaId, setOpcUaId] = useState<any>('');
|
|
|
const { permission } = PermissionButton.usePermission('link/Channel/Opcua');
|
|
|
const [deviceVisiable, setDeviceVisiable] = useState<boolean>(false);
|
|
|
@@ -38,6 +40,7 @@ const Access = () => {
|
|
|
const [propertyValue, setPropertyValue] = useState<any>({});
|
|
|
const [bindDeviceId, setBindDeviceId] = useState<any>('');
|
|
|
const wsRef = useRef<any>();
|
|
|
+ const [filterList, setFilterList] = useState([]);
|
|
|
|
|
|
const columns: ProColumns<any>[] = [
|
|
|
{
|
|
|
@@ -169,13 +172,16 @@ const Access = () => {
|
|
|
const getBindList = (params: any) => {
|
|
|
service.getBindList(params).then((res: any) => {
|
|
|
if (res.status === 200) {
|
|
|
- setDeviceId(res.result[0]?.deviceId);
|
|
|
- setProductId(res.result[0]?.productId);
|
|
|
- setBindDeviceId(res.result[0]?.id);
|
|
|
- setParam({
|
|
|
- terms: [{ column: 'deviceId', value: res.result[0]?.deviceId }],
|
|
|
- });
|
|
|
- setBindList(res.result);
|
|
|
+ if (res.result && res.result !== 0) {
|
|
|
+ setProductId(res.result[0]?.productId);
|
|
|
+ setBindDeviceId(res.result[0]?.id);
|
|
|
+ setBindList(res.result);
|
|
|
+ setFilterList(res.result);
|
|
|
+ setDeviceId(res.result[0]?.deviceId);
|
|
|
+ setParam({
|
|
|
+ terms: [{ column: 'deviceId', value: res.result[0]?.deviceId }],
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
@@ -219,29 +225,62 @@ const Access = () => {
|
|
|
return (
|
|
|
<PageContainer>
|
|
|
<Card className={styles.list}>
|
|
|
- <PermissionButton
|
|
|
- onClick={() => {
|
|
|
- setDeviceVisiable(true);
|
|
|
- }}
|
|
|
- isPermission={permission.add}
|
|
|
- key="add"
|
|
|
- icon={<PlusOutlined />}
|
|
|
- type="dashed"
|
|
|
- style={{ width: '200px', margin: '16px 0 18px 20px' }}
|
|
|
- >
|
|
|
- 绑定设备
|
|
|
- </PermissionButton>
|
|
|
- {bindList.length > 0 ? (
|
|
|
- <div style={{ display: 'flex' }}>
|
|
|
- <div>
|
|
|
+ <div style={{ display: 'flex' }}>
|
|
|
+ <div>
|
|
|
+ <div style={{ width: '250px', marginTop: 15 }}>
|
|
|
+ <Input.Search
|
|
|
+ placeholder="请输入绑定设备名称"
|
|
|
+ allowClear
|
|
|
+ onSearch={(value) => {
|
|
|
+ if (value) {
|
|
|
+ const items = bindList.filter((item: any) => item.name.match(value));
|
|
|
+ setFilterList(items);
|
|
|
+ if (items.length === 0) {
|
|
|
+ setParam({
|
|
|
+ terms: [{ column: 'deviceId', value: '' }],
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ setParam({
|
|
|
+ terms: [{ column: 'deviceId', value: items[0]?.deviceId }],
|
|
|
+ });
|
|
|
+ setDeviceId(items[0]?.deviceId);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ setFilterList(bindList);
|
|
|
+ if (deviceId) {
|
|
|
+ setParam({
|
|
|
+ terms: [{ column: 'deviceId', value: deviceId }],
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ setParam({
|
|
|
+ terms: [{ column: 'deviceId', value: '' }],
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <PermissionButton
|
|
|
+ onClick={() => {
|
|
|
+ setDeviceVisiable(true);
|
|
|
+ }}
|
|
|
+ isPermission={permission.add}
|
|
|
+ key="add"
|
|
|
+ icon={<PlusOutlined />}
|
|
|
+ type="dashed"
|
|
|
+ style={{ width: '100%', margin: '16px 0 18px 0' }}
|
|
|
+ >
|
|
|
+ 绑定设备
|
|
|
+ </PermissionButton>
|
|
|
+ </div>
|
|
|
+ {filterList.length > 0 ? (
|
|
|
<Tabs
|
|
|
tabPosition={'left'}
|
|
|
- defaultActiveKey={deviceId}
|
|
|
+ // defaultActiveKey={deviceId}
|
|
|
+ activeKey={deviceId}
|
|
|
style={{ height: 600 }}
|
|
|
onChange={(e) => {
|
|
|
setDeviceId(e);
|
|
|
const items = bindList.find((item: any) => item.deviceId === e);
|
|
|
- console.log(items);
|
|
|
setProductId(items?.productId);
|
|
|
setBindDeviceId(items?.id);
|
|
|
setParam({
|
|
|
@@ -249,7 +288,7 @@ const Access = () => {
|
|
|
});
|
|
|
}}
|
|
|
>
|
|
|
- {bindList.map((item: any) => (
|
|
|
+ {filterList.map((item: any) => (
|
|
|
<Tabs.TabPane
|
|
|
key={item.deviceId}
|
|
|
tab={
|
|
|
@@ -283,77 +322,89 @@ const Access = () => {
|
|
|
></Tabs.TabPane>
|
|
|
))}
|
|
|
</Tabs>
|
|
|
- </div>
|
|
|
- <div style={{ width: '100%' }}>
|
|
|
- <ProTable
|
|
|
- actionRef={actionRef}
|
|
|
- params={param}
|
|
|
- columns={columns}
|
|
|
- rowKey="id"
|
|
|
- search={false}
|
|
|
- headerTitle={
|
|
|
- <>
|
|
|
- <PermissionButton
|
|
|
- onClick={() => {
|
|
|
- setPointVisiable(true);
|
|
|
- setCurrent({});
|
|
|
+ ) : (
|
|
|
+ <Empty description={<>暂无绑定设备</>} />
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ <div style={{ width: '100%' }}>
|
|
|
+ <ProTable
|
|
|
+ actionRef={actionRef}
|
|
|
+ params={param}
|
|
|
+ columns={columns}
|
|
|
+ rowKey="id"
|
|
|
+ search={false}
|
|
|
+ headerTitle={
|
|
|
+ <>
|
|
|
+ <PermissionButton
|
|
|
+ onClick={() => {
|
|
|
+ setPointVisiable(true);
|
|
|
+ setCurrent({});
|
|
|
+ }}
|
|
|
+ isPermission={permission.add}
|
|
|
+ key="add"
|
|
|
+ icon={<PlusOutlined />}
|
|
|
+ type="primary"
|
|
|
+ >
|
|
|
+ {intl.formatMessage({
|
|
|
+ id: 'pages.data.option.add',
|
|
|
+ defaultMessage: '新增',
|
|
|
+ })}
|
|
|
+ </PermissionButton>
|
|
|
+ <div style={{ marginLeft: 10 }}>
|
|
|
+ <Input.Search
|
|
|
+ placeholder="请输入属性"
|
|
|
+ allowClear
|
|
|
+ onSearch={(value) => {
|
|
|
+ console.log(value);
|
|
|
+ if (value) {
|
|
|
+ setParam({
|
|
|
+ terms: [
|
|
|
+ { column: 'deviceId', value: deviceId },
|
|
|
+ { column: 'property', value: `%${value}%`, termType: 'like' },
|
|
|
+ ],
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ setParam({
|
|
|
+ terms: [{ column: 'deviceId', value: deviceId }],
|
|
|
+ });
|
|
|
+ }
|
|
|
}}
|
|
|
- isPermission={permission.add}
|
|
|
- key="add"
|
|
|
- icon={<PlusOutlined />}
|
|
|
- type="primary"
|
|
|
- >
|
|
|
- {intl.formatMessage({
|
|
|
- id: 'pages.data.option.add',
|
|
|
- defaultMessage: '新增',
|
|
|
- })}
|
|
|
- </PermissionButton>
|
|
|
- <div style={{ marginLeft: 10 }}>
|
|
|
- <Input.Search
|
|
|
- placeholder="请输入属性"
|
|
|
- allowClear
|
|
|
- onSearch={(value) => {
|
|
|
- console.log(value);
|
|
|
- if (value) {
|
|
|
- setParam({
|
|
|
- terms: [
|
|
|
- { column: 'deviceId', value: deviceId },
|
|
|
- { column: 'property', value: `%${value}%`, termType: 'like' },
|
|
|
- ],
|
|
|
- });
|
|
|
- } else {
|
|
|
- setParam({
|
|
|
- terms: [{ column: 'deviceId', value: deviceId }],
|
|
|
- });
|
|
|
- }
|
|
|
- }}
|
|
|
- />
|
|
|
- </div>
|
|
|
- </>
|
|
|
- }
|
|
|
- request={async (params) => {
|
|
|
- const res = await service.PointList({
|
|
|
- ...params,
|
|
|
- sorts: [{ name: 'createTime', order: 'desc' }],
|
|
|
- });
|
|
|
- setData(res.result.data);
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </>
|
|
|
+ }
|
|
|
+ request={async (params) => {
|
|
|
+ if (Object.keys(params).length && !params.terms[0].value) {
|
|
|
return {
|
|
|
- code: res.message,
|
|
|
+ code: 200,
|
|
|
result: {
|
|
|
- data: res.result.data,
|
|
|
+ data: [],
|
|
|
pageIndex: 0,
|
|
|
pageSize: 0,
|
|
|
total: 0,
|
|
|
},
|
|
|
- status: res.status,
|
|
|
+ status: 200,
|
|
|
};
|
|
|
- }}
|
|
|
- />
|
|
|
- </div>
|
|
|
+ }
|
|
|
+ const res = await service.PointList({
|
|
|
+ ...params,
|
|
|
+ sorts: [{ name: 'createTime', order: 'desc' }],
|
|
|
+ });
|
|
|
+ setData(res.result.data);
|
|
|
+ return {
|
|
|
+ code: res.message,
|
|
|
+ result: {
|
|
|
+ data: res.result.data,
|
|
|
+ pageIndex: res.result.pageIndex,
|
|
|
+ pageSize: res.result.pageSize,
|
|
|
+ total: res.result.total,
|
|
|
+ },
|
|
|
+ status: res.status,
|
|
|
+ };
|
|
|
+ }}
|
|
|
+ />
|
|
|
</div>
|
|
|
- ) : (
|
|
|
- <Empty />
|
|
|
- )}
|
|
|
+ </div>
|
|
|
</Card>
|
|
|
{deviceVisiable && (
|
|
|
<BindDevice
|