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'; ...@@ -4,6 +4,7 @@ import request from 'umi-request';
import { UnorderedListOutlined, SearchOutlined } from '@ant-design/icons'; import { UnorderedListOutlined, SearchOutlined } from '@ant-design/icons';
import PandaQuotaSelect from '../index'; import PandaQuotaSelect from '../index';
import { service } from '@wisdom-utils/utils'; import { service } from '@wisdom-utils/utils';
import { getMonitorConf } from '../apis';
const REQUEST_HTTP = 'http'; const REQUEST_HTTP = 'http';
const REQUEST_METHOD_GET = 'get'; const REQUEST_METHOD_GET = 'get';
...@@ -42,7 +43,7 @@ const quotaSelectService = { ...@@ -42,7 +43,7 @@ const quotaSelectService = {
const qsService = service(quotaSelectService); const qsService = service(quotaSelectService);
const getQuotaList = qsService.getQuotaList; const getQuotaList = qsService.getQuotaList;
const getDeviceConf = qsService.getDeviceConf; const getDeviceConf = getMonitorConf;
const updateDeviceConfService = qsService.updateDeviceConfService; const updateDeviceConfService = qsService.updateDeviceConfService;
const pointType = 'cardPoints'; const pointType = 'cardPoints';
...@@ -107,7 +108,6 @@ const Demo = () => { ...@@ -107,7 +108,6 @@ const Demo = () => {
buttonProps={{}} buttonProps={{}}
// defaultSelect={'all'} // defaultSelect={'all'}
deviceList={deviceList} deviceList={deviceList}
quotaListService={getQuotaList}
pointType={pointType} pointType={pointType}
onSelect={onSelect} onSelect={onSelect}
// onModalCancel={onModalCancel} // onModalCancel={onModalCancel}
...@@ -120,8 +120,6 @@ const Demo = () => { ...@@ -120,8 +120,6 @@ const Demo = () => {
<PandaQuotaSelect <PandaQuotaSelect
buttonProps={{}} buttonProps={{}}
deviceList={deviceList} deviceList={deviceList}
quotaListService={getQuotaList}
updateDeviceConfService={updateDeviceConfService}
confList={confList} confList={confList}
pointType={pointType} pointType={pointType}
onSelect={onSelect} onSelect={onSelect}
...@@ -129,7 +127,7 @@ const Demo = () => { ...@@ -129,7 +127,7 @@ const Demo = () => {
onModalOk={onModalOk} onModalOk={onModalOk}
onModalClose={onModalClose} onModalClose={onModalClose}
maximum={5} maximum={5}
user={'user'} user={'admin'}
/> />
</> </>
); );
......
...@@ -21,14 +21,13 @@ import { ...@@ -21,14 +21,13 @@ import {
CloseOutlined, CloseOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import './index.less'; import './index.less';
import { getQuataList, updateMonitorConf } from './apis';
const { TreeNode } = Tree; const { TreeNode } = Tree;
const QuotaSelect = ({ const QuotaSelect = ({
buttonProps, buttonProps,
deviceList, deviceList,
quotaListService,
updateDeviceConfService,
confList, confList,
onSelect, onSelect,
pointType, pointType,
...@@ -60,7 +59,7 @@ const QuotaSelect = ({ ...@@ -60,7 +59,7 @@ const QuotaSelect = ({
const fetchData = (item = {}) => { const fetchData = (item = {}) => {
// 请求指标列表 // 请求指标列表
quotaListService({ getQuataList({
accountName: item.deviceType, accountName: item.deviceType,
addrSchemeID: item.pointAddressID, addrSchemeID: item.pointAddressID,
}).then((res) => { }).then((res) => {
...@@ -69,9 +68,9 @@ const QuotaSelect = ({ ...@@ -69,9 +68,9 @@ const QuotaSelect = ({
res.data.length > 0 res.data.length > 0
? res.data.map((child) => ({ ? res.data.map((child) => ({
...child, ...child,
checked: item.confList.includes(child.name), checked: item.confList.includes(child.sensorName),
title: child.name, title: child.sensorName,
key: child.name, key: child.sensorName,
})) }))
: []; : [];
setAllQuotaList(data); setAllQuotaList(data);
...@@ -92,7 +91,8 @@ const QuotaSelect = ({ ...@@ -92,7 +91,8 @@ const QuotaSelect = ({
const curSelectList = JSON.parse(JSON.stringify(selectData)); const curSelectList = JSON.parse(JSON.stringify(selectData));
const curSelectKey = curSelectList.map((child) => child.key); const curSelectKey = curSelectList.map((child) => child.key);
params[pointType] = curSelectKey.join(','); params[pointType] = curSelectKey.join(',');
updateDeviceConfService(params).then((response) => { console.log(params);
updateMonitorConf(params).then((response) => {
if (response.code === 0) { if (response.code === 0) {
message.success('保存成功'); message.success('保存成功');
} else { } else {
...@@ -218,8 +218,8 @@ const QuotaSelect = ({ ...@@ -218,8 +218,8 @@ const QuotaSelect = ({
if (e.target.value !== '') { if (e.target.value !== '') {
let newQuotaList = []; let newQuotaList = [];
quotaList.forEach((item) => { quotaList.forEach((item) => {
if (!item.name) return; if (!item.sensorName) return;
if (item.name.indexOf(e.target.value) > -1) newQuotaList.push(item); if (item.sensorName.indexOf(e.target.value) > -1) newQuotaList.push(item);
}); });
setQuotaList(newQuotaList); setQuotaList(newQuotaList);
} else { } else {
...@@ -463,8 +463,6 @@ QuotaSelect.defaultProps = { ...@@ -463,8 +463,6 @@ QuotaSelect.defaultProps = {
deviceList: [], deviceList: [],
confList: [], confList: [],
treeProps: {}, treeProps: {},
quotaListService: () => {},
updateDeviceConfService: () => {},
onSelect: () => {}, onSelect: () => {},
onModalCancel: () => {}, onModalCancel: () => {},
onModalOk: () => {}, onModalOk: () => {},
...@@ -486,8 +484,6 @@ QuotaSelect.propTypes = { ...@@ -486,8 +484,6 @@ QuotaSelect.propTypes = {
deviceList: PropTypes.array, deviceList: PropTypes.array,
confList: PropTypes.array, confList: PropTypes.array,
treeProps: PropTypes.object, treeProps: PropTypes.object,
quotaListService: PropTypes.func,
updateDeviceConfService: PropTypes.func,
onSelect: PropTypes.func, onSelect: PropTypes.func,
onModalCancel: PropTypes.func, onModalCancel: PropTypes.func,
onModalOk: 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