|
|
@@ -18,6 +18,7 @@ import CollectorSave from '../../components/Device/Save/index';
|
|
|
import { onlyMessage } from '@/utils/util';
|
|
|
// import { StatusColorEnum } from '@/components/BadgeStatus';
|
|
|
import { useIntl } from '@@/plugin-locale/localeExports';
|
|
|
+import { DataCollectModel } from '../../DataGathering';
|
|
|
|
|
|
const TreeModel = model<{
|
|
|
selectedKeys: string[];
|
|
|
@@ -55,7 +56,7 @@ export default observer((props: Props) => {
|
|
|
const { permission } = PermissionButton.usePermission('link/DataCollect/DataGathering');
|
|
|
const intl = useIntl();
|
|
|
|
|
|
- const handleSearch = (params: any) => {
|
|
|
+ const handleSearch = (params: any, reload?: boolean) => {
|
|
|
TreeModel.loading = true;
|
|
|
TreeModel.param = params;
|
|
|
service
|
|
|
@@ -64,8 +65,11 @@ export default observer((props: Props) => {
|
|
|
if (resp.status === 200) {
|
|
|
TreeModel.dataSource = resp.result;
|
|
|
if (resp.result.length) {
|
|
|
- TreeModel.selectedKeys = [resp.result[0].id];
|
|
|
- props.change(resp.result[0].id, 'channel', resp.result[0].provider);
|
|
|
+ if (!reload) {
|
|
|
+ TreeModel.selectedKeys = [resp.result[0].id];
|
|
|
+ }
|
|
|
+ const provider = !reload ? resp.result[0].provider : DataCollectModel.provider;
|
|
|
+ props.change(TreeModel.selectedKeys[0], 'channel', provider);
|
|
|
}
|
|
|
}
|
|
|
TreeModel.loading = false;
|
|
|
@@ -73,28 +77,12 @@ export default observer((props: Props) => {
|
|
|
};
|
|
|
|
|
|
useEffect(() => {
|
|
|
- handleSearch(TreeModel.param);
|
|
|
- }, [TreeModel.param, props.reload]);
|
|
|
+ handleSearch(TreeModel.param, false);
|
|
|
+ }, [TreeModel.param]);
|
|
|
|
|
|
- // const getState = (record: Partial<ChannelItem>): { text: string; value: string } => {
|
|
|
- // if (record) {
|
|
|
- // if (record?.state?.value === 'enabled') {
|
|
|
- // return {
|
|
|
- // text: record?.runningState?.text || '',
|
|
|
- // value: record?.runningState?.value || '',
|
|
|
- // };
|
|
|
- // } else {
|
|
|
- // return {
|
|
|
- // text: '禁用',
|
|
|
- // value: 'disabled',
|
|
|
- // };
|
|
|
- // }
|
|
|
- // }
|
|
|
- // return {
|
|
|
- // text: '',
|
|
|
- // value: '',
|
|
|
- // };
|
|
|
- // };
|
|
|
+ useEffect(() => {
|
|
|
+ handleSearch(TreeModel.param, true);
|
|
|
+ }, [props.reload]);
|
|
|
|
|
|
const getState = (record: any) => {
|
|
|
if (record) {
|
|
|
@@ -187,7 +175,44 @@ export default observer((props: Props) => {
|
|
|
/>
|
|
|
</Tooltip>
|
|
|
<Popconfirm
|
|
|
+ title={intl.formatMessage({
|
|
|
+ id: `pages.data.option.${
|
|
|
+ item?.state?.value !== 'disabled' ? 'disabled' : 'enabled'
|
|
|
+ }.tips`,
|
|
|
+ defaultMessage: '确认禁用?',
|
|
|
+ })}
|
|
|
+ onConfirm={async () => {
|
|
|
+ const resp =
|
|
|
+ item?.state?.value !== 'disabled'
|
|
|
+ ? await service.updateChannel(item.id, {
|
|
|
+ state: 'disabled',
|
|
|
+ runningState: 'stopped',
|
|
|
+ })
|
|
|
+ : await service.updateChannel(item.id, {
|
|
|
+ state: 'enabled',
|
|
|
+ runningState: 'running',
|
|
|
+ });
|
|
|
+ if (resp.status === 200) {
|
|
|
+ TreeModel.param = {};
|
|
|
+ handleSearch(TreeModel.param);
|
|
|
+ props.onReload();
|
|
|
+ onlyMessage('操作成功');
|
|
|
+ } else {
|
|
|
+ onlyMessage('操作失败!', 'error');
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <Tooltip title={!permission.action ? '暂无权限,请联系管理员' : ''}>
|
|
|
+ {item?.state?.value !== 'disabled' ? (
|
|
|
+ <StopOutlined />
|
|
|
+ ) : (
|
|
|
+ <PlayCircleOutlined />
|
|
|
+ )}
|
|
|
+ </Tooltip>
|
|
|
+ </Popconfirm>
|
|
|
+ <Popconfirm
|
|
|
title={'该操作将会删除下属采集器与点位,确定删除?'}
|
|
|
+ disabled={item?.state?.value !== 'disabled'}
|
|
|
onConfirm={async () => {
|
|
|
const resp = await service.removeChannel(item.id);
|
|
|
if (resp.status === 200) {
|
|
|
@@ -197,7 +222,15 @@ export default observer((props: Props) => {
|
|
|
}
|
|
|
}}
|
|
|
>
|
|
|
- <Tooltip title={!permission.delete ? '暂无权限,请联系管理员' : ''}>
|
|
|
+ <Tooltip
|
|
|
+ title={
|
|
|
+ !permission.delete
|
|
|
+ ? '暂无权限,请联系管理员'
|
|
|
+ : item?.state?.value !== 'disabled'
|
|
|
+ ? '正常的通道不能删除'
|
|
|
+ : ''
|
|
|
+ }
|
|
|
+ >
|
|
|
<DeleteOutlined />
|
|
|
</Tooltip>
|
|
|
</Popconfirm>
|
|
|
@@ -260,9 +293,11 @@ export default observer((props: Props) => {
|
|
|
i?.state?.value !== 'disabled'
|
|
|
? await service.updateCollector(i.id, {
|
|
|
state: 'disabled',
|
|
|
+ runningState: 'stopped',
|
|
|
})
|
|
|
: await service.updateCollector(i.id, {
|
|
|
state: 'enabled',
|
|
|
+ runningState: 'running',
|
|
|
});
|
|
|
if (resp.status === 200) {
|
|
|
TreeModel.param = {};
|
|
|
@@ -284,6 +319,7 @@ export default observer((props: Props) => {
|
|
|
</Popconfirm>
|
|
|
<Popconfirm
|
|
|
title={'该操作将会删除下属点位,确定删除?'}
|
|
|
+ disabled={i?.state?.value !== 'disabled'}
|
|
|
onConfirm={async () => {
|
|
|
const resp = await service.removeCollector(i.id);
|
|
|
if (resp.status === 200) {
|
|
|
@@ -293,7 +329,15 @@ export default observer((props: Props) => {
|
|
|
}
|
|
|
}}
|
|
|
>
|
|
|
- <Tooltip title={!permission.delete ? '暂无权限,请联系管理员' : ''}>
|
|
|
+ <Tooltip
|
|
|
+ title={
|
|
|
+ !permission.delete
|
|
|
+ ? '暂无权限,请联系管理员'
|
|
|
+ : i?.state?.value !== 'disabled'
|
|
|
+ ? '正常的采集器不能删除'
|
|
|
+ : ''
|
|
|
+ }
|
|
|
+ >
|
|
|
<DeleteOutlined />
|
|
|
</Tooltip>
|
|
|
</Popconfirm>
|