|
@@ -1,7 +1,6 @@
|
|
|
import { defHttp } from '/@/utils/http/axios';
|
|
import { defHttp } from '/@/utils/http/axios';
|
|
|
-import { isNil } from 'lodash-es';
|
|
|
|
|
-import { getEnfMineTree } from '/@/api/sys/menu';
|
|
|
|
|
-import { message } from 'ant-design-vue';
|
|
|
|
|
|
|
+import { isNil, map } from 'lodash-es';
|
|
|
|
|
+// import { getEnfMineTree } from '/@/api/sys/menu';
|
|
|
|
|
|
|
|
enum Api {
|
|
enum Api {
|
|
|
getMineData = '/province/mineData/getMineData',
|
|
getMineData = '/province/mineData/getMineData',
|
|
@@ -30,9 +29,7 @@ export function updateCoalSeamAlarmRule(params: any) {
|
|
|
return defHttp.post({ url: Api.updateCoalSeamAlarmRule, params });
|
|
return defHttp.post({ url: Api.updateCoalSeamAlarmRule, params });
|
|
|
}
|
|
}
|
|
|
export function addCoalSeamAlarmRule(params: any) {
|
|
export function addCoalSeamAlarmRule(params: any) {
|
|
|
- return defHttp.post({ url: Api.addCoalSeamAlarmRule, params }).then(() => {
|
|
|
|
|
- message.success('新增成功');
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ return defHttp.post({ url: Api.addCoalSeamAlarmRule, params });
|
|
|
}
|
|
}
|
|
|
export function deleteCoalSeamAlarmRule(params: any) {
|
|
export function deleteCoalSeamAlarmRule(params: any) {
|
|
|
return defHttp.post({ url: Api.deleteCoalSeamAlarmRule, params }, { joinParamsToUrl: true });
|
|
return defHttp.post({ url: Api.deleteCoalSeamAlarmRule, params }, { joinParamsToUrl: true });
|
|
@@ -44,9 +41,7 @@ export function getGoafDataLimit(params: any) {
|
|
|
return defHttp.post({ url: Api.getGoafDataLimit, params }, { joinParamsToUrl: true });
|
|
return defHttp.post({ url: Api.getGoafDataLimit, params }, { joinParamsToUrl: true });
|
|
|
}
|
|
}
|
|
|
export function addGoafDataLimit(params: any) {
|
|
export function addGoafDataLimit(params: any) {
|
|
|
- return defHttp.post({ url: Api.addGoafDataLimit, params }).then(() => {
|
|
|
|
|
- message.success('新增成功');
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ return defHttp.post({ url: Api.addGoafDataLimit, params });
|
|
|
}
|
|
}
|
|
|
export function updateGoafDataLimit(params: any) {
|
|
export function updateGoafDataLimit(params: any) {
|
|
|
return defHttp.post({ url: Api.updateGoafDataLimit, params });
|
|
return defHttp.post({ url: Api.updateGoafDataLimit, params });
|
|
@@ -55,50 +50,16 @@ export function deleteGoafDataLimit(params: any) {
|
|
|
return defHttp.post({ url: Api.deleteGoafDataLimit, params }, { joinParamsToUrl: true });
|
|
return defHttp.post({ url: Api.deleteGoafDataLimit, params }, { joinParamsToUrl: true });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export function getMineTree(params: { searchValue: string }) {
|
|
|
|
|
- return getEnfMineTree().then((tree) => {
|
|
|
|
|
- // 头一个真正的叶节点
|
|
|
|
|
- let firstLeafKey;
|
|
|
|
|
- // 它的父节点
|
|
|
|
|
- let firstParentKey;
|
|
|
|
|
-
|
|
|
|
|
- const transformKeys = (arr: any[]) => {
|
|
|
|
|
- return arr.map((r) => {
|
|
|
|
|
- const isLeaf = isNil(r.childDepart);
|
|
|
|
|
-
|
|
|
|
|
- // 因为接口返回只有两层所以简单处理firstParentKey
|
|
|
|
|
- if (isLeaf && !firstLeafKey) {
|
|
|
|
|
- firstLeafKey = r.id;
|
|
|
|
|
- firstParentKey = r.parentId;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return {
|
|
|
|
|
- title: r.departName,
|
|
|
|
|
- key: r.id,
|
|
|
|
|
- isLeaf: isLeaf,
|
|
|
|
|
- children: isLeaf ? undefined : transformKeys(r.childDepart),
|
|
|
|
|
- };
|
|
|
|
|
- });
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- const filterTreeNodes = (nodes: any[], value: string) => {
|
|
|
|
|
- if (!value) return nodes;
|
|
|
|
|
- return nodes.filter((t) => {
|
|
|
|
|
- // 如果此次匹配成功,那么该节点应返回
|
|
|
|
|
- if (t.title.includes(value)) {
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
- // 如果没有则看看它的子节点是否有匹配的
|
|
|
|
|
- if (t.children) {
|
|
|
|
|
- return filterTreeNodes(t.children, value).length > 0;
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- return {
|
|
|
|
|
- tree: filterTreeNodes(transformKeys(tree), params.searchValue),
|
|
|
|
|
- firstLeafKey,
|
|
|
|
|
- firstParentKey,
|
|
|
|
|
- };
|
|
|
|
|
- });
|
|
|
|
|
|
|
+export function patchGoafDataLimit(params: Record<string, any>) {
|
|
|
|
|
+ return Promise.all(
|
|
|
|
|
+ map(params, (item) => {
|
|
|
|
|
+ if (item.id) {
|
|
|
|
|
+ return updateGoafDataLimit(item);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!isNil(item.lowerLimit) || !isNil(item.upperLimit)) {
|
|
|
|
|
+ return addGoafDataLimit(item);
|
|
|
|
|
+ }
|
|
|
|
|
+ return Promise.resolve();
|
|
|
|
|
+ })
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|