Commit 9a81636f authored by 崔佳豪's avatar 崔佳豪

fix: 修改指标选择器服务

parent 44d5d6c8
import { request } from '@wisdom-utils/utils';
const REQUEST_METHOD_GET = 'get';
const REQUEST_METHOD_POST = 'post';
// eslint-disable-next-line no-undef
const baseUrl = typeof DUMI_TYPE !== 'undefined' && DUMI_TYPE === 'dumi' ? '/api' : '';
const MonitorUrl = `/PandaMonitor/Monitor`;
// 查询设备指标
export function getQuataList(params) {
return request({
url: `${MonitorUrl}/Device/GetQutaList`,
method: REQUEST_METHOD_GET,
params,
});
}
// 设备监控展示
export function getMonitorConf(params) {
return request({
url: `${MonitorUrl}/MonitorConfig/GetMonitorConf`,
method: REQUEST_METHOD_GET,
params,
});
}
// 设备监控展示
export function updateMonitorConf(data) {
return request({
url: `${MonitorUrl}/MonitorConfig/AddOrUpdateMonitorConf`,
method: REQUEST_METHOD_POST,
data,
});
}
......@@ -4,6 +4,7 @@ import request from 'umi-request';
import { UnorderedListOutlined, SearchOutlined } from '@ant-design/icons';
import PandaQuotaSelect from '../index';
import { service } from '@wisdom-utils/utils';
import { getMonitorConf } from '../apis';
const REQUEST_HTTP = 'http';
const REQUEST_METHOD_GET = 'get';
......@@ -42,7 +43,7 @@ const quotaSelectService = {
const qsService = service(quotaSelectService);
const getQuotaList = qsService.getQuotaList;
const getDeviceConf = qsService.getDeviceConf;
const getDeviceConf = getMonitorConf;
const updateDeviceConfService = qsService.updateDeviceConfService;
const pointType = 'cardPoints';
......@@ -107,7 +108,6 @@ const Demo = () => {
buttonProps={{}}
// defaultSelect={'all'}
deviceList={deviceList}
quotaListService={getQuotaList}
pointType={pointType}
onSelect={onSelect}
// onModalCancel={onModalCancel}
......@@ -120,8 +120,6 @@ const Demo = () => {
<PandaQuotaSelect
buttonProps={{}}
deviceList={deviceList}
quotaListService={getQuotaList}
updateDeviceConfService={updateDeviceConfService}
confList={confList}
pointType={pointType}
onSelect={onSelect}
......@@ -129,7 +127,7 @@ const Demo = () => {
onModalOk={onModalOk}
onModalClose={onModalClose}
maximum={5}
user={'user'}
user={'admin'}
/>
</>
);
......
......@@ -21,14 +21,13 @@ import {
CloseOutlined,
} from '@ant-design/icons';
import './index.less';
import { getQuataList, updateMonitorConf } from './apis';
const { TreeNode } = Tree;
const QuotaSelect = ({
buttonProps,
deviceList,
quotaListService,
updateDeviceConfService,
confList,
onSelect,
pointType,
......@@ -60,7 +59,7 @@ const QuotaSelect = ({
const fetchData = (item = {}) => {
// 请求指标列表
quotaListService({
getQuataList({
accountName: item.deviceType,
addrSchemeID: item.pointAddressID,
}).then((res) => {
......@@ -69,9 +68,9 @@ const QuotaSelect = ({
res.data.length > 0
? res.data.map((child) => ({
...child,
checked: item.confList.includes(child.name),
title: child.name,
key: child.name,
checked: item.confList.includes(child.sensorName),
title: child.sensorName,
key: child.sensorName,
}))
: [];
setAllQuotaList(data);
......@@ -92,7 +91,8 @@ const QuotaSelect = ({
const curSelectList = JSON.parse(JSON.stringify(selectData));
const curSelectKey = curSelectList.map((child) => child.key);
params[pointType] = curSelectKey.join(',');
updateDeviceConfService(params).then((response) => {
console.log(params);
updateMonitorConf(params).then((response) => {
if (response.code === 0) {
message.success('保存成功');
} else {
......@@ -218,8 +218,8 @@ const QuotaSelect = ({
if (e.target.value !== '') {
let newQuotaList = [];
quotaList.forEach((item) => {
if (!item.name) return;
if (item.name.indexOf(e.target.value) > -1) newQuotaList.push(item);
if (!item.sensorName) return;
if (item.sensorName.indexOf(e.target.value) > -1) newQuotaList.push(item);
});
setQuotaList(newQuotaList);
} else {
......@@ -463,8 +463,6 @@ QuotaSelect.defaultProps = {
deviceList: [],
confList: [],
treeProps: {},
quotaListService: () => {},
updateDeviceConfService: () => {},
onSelect: () => {},
onModalCancel: () => {},
onModalOk: () => {},
......@@ -486,8 +484,6 @@ QuotaSelect.propTypes = {
deviceList: PropTypes.array,
confList: PropTypes.array,
treeProps: PropTypes.object,
quotaListService: PropTypes.func,
updateDeviceConfService: PropTypes.func,
onSelect: PropTypes.func,
onModalCancel: PropTypes.func,
onModalOk: PropTypes.func,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment