fix: bug#10833
This commit is contained in:
parent
c0d72a3863
commit
ffdee18c34
|
@ -3,6 +3,8 @@ import { systemVersion } from '@/api/comm'
|
||||||
import { useMenuStore } from './menu'
|
import { useMenuStore } from './menu'
|
||||||
import { getDetails_api } from '@/api/system/basis';
|
import { getDetails_api } from '@/api/system/basis';
|
||||||
import type { ConfigInfoType } from '@/views/system/Basis/typing';
|
import type { ConfigInfoType } from '@/views/system/Basis/typing';
|
||||||
|
import { LocalStore } from '@/utils/comm'
|
||||||
|
import { SystemConst } from '@/utils/consts'
|
||||||
|
|
||||||
type SystemStateType = {
|
type SystemStateType = {
|
||||||
isCommunity: boolean;
|
isCommunity: boolean;
|
||||||
|
@ -22,6 +24,7 @@ export const useSystem = defineStore('system', {
|
||||||
const resp = await systemVersion()
|
const resp = await systemVersion()
|
||||||
if (resp.success && resp.result) {
|
if (resp.success && resp.result) {
|
||||||
const isCommunity = resp.result.edition === 'community'
|
const isCommunity = resp.result.edition === 'community'
|
||||||
|
LocalStore.set(SystemConst.VERSION_CODE, resp.result.edition)
|
||||||
this.isCommunity = isCommunity
|
this.isCommunity = isCommunity
|
||||||
// 获取菜单
|
// 获取菜单
|
||||||
const menu = useMenuStore()
|
const menu = useMenuStore()
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { isNoCommunity } from '@/utils/utils';
|
||||||
|
|
||||||
|
// 过滤网关类型
|
||||||
|
export const accessConfigTypeFilter = (data: any[], filterKey: string = 'id'): any[] => {
|
||||||
|
if (!data) return []
|
||||||
|
const filterKeys = !isNoCommunity ?
|
||||||
|
[
|
||||||
|
'mqtt-server-gateway',
|
||||||
|
'http-server-gateway',
|
||||||
|
'mqtt-client-gateway',
|
||||||
|
'tcp-server-gateway',
|
||||||
|
'plugin_gateway'
|
||||||
|
] : ['plugin_gateway']
|
||||||
|
return data.filter(item => !filterKeys.includes(item[filterKey])).map( item => ({ ...item, label: item.name, value: item.id}))
|
||||||
|
}
|
|
@ -309,6 +309,7 @@ import BadgeStatus from '@/components/BadgeStatus/index.vue';
|
||||||
import BatchDropdown from '@/components/BatchDropdown/index.vue';
|
import BatchDropdown from '@/components/BatchDropdown/index.vue';
|
||||||
import { BatchActionsType } from '@/components/BatchDropdown/types';
|
import { BatchActionsType } from '@/components/BatchDropdown/types';
|
||||||
import {useRouterParams} from "@/utils/hooks/useParams";
|
import {useRouterParams} from "@/utils/hooks/useParams";
|
||||||
|
import { accessConfigTypeFilter } from '@/utils/setting'
|
||||||
|
|
||||||
const instanceRef = ref<Record<string, any>>({});
|
const instanceRef = ref<Record<string, any>>({});
|
||||||
const params = ref<Record<string, any>>({});
|
const params = ref<Record<string, any>>({});
|
||||||
|
@ -417,12 +418,17 @@ const columns = [
|
||||||
options: () =>
|
options: () =>
|
||||||
new Promise((resolve) => {
|
new Promise((resolve) => {
|
||||||
getProviders().then((resp: any) => {
|
getProviders().then((resp: any) => {
|
||||||
resolve(
|
const data = resp.result || []
|
||||||
resp.result.map((item: any) => ({
|
resolve(accessConfigTypeFilter(data).map(item => ({
|
||||||
label: item.name,
|
...item,
|
||||||
value: `accessProvider is ${item.id}`,
|
value: `accessProvider is ${item.id}`
|
||||||
})),
|
})))
|
||||||
);
|
// resolve(
|
||||||
|
// resp.result.map((item: any) => ({
|
||||||
|
// label: item.name,
|
||||||
|
// value: `accessProvider is ${item.id}`,
|
||||||
|
// })),
|
||||||
|
// );
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
|
@ -419,7 +419,7 @@ import { marked } from 'marked';
|
||||||
import type { TableColumnType } from 'ant-design-vue';
|
import type { TableColumnType } from 'ant-design-vue';
|
||||||
import { useMenuStore } from '@/store/menu';
|
import { useMenuStore } from '@/store/menu';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import encodeQuery from '@/utils/encodeQuery';
|
import { accessConfigTypeFilter } from '@/utils/setting'
|
||||||
|
|
||||||
const tableRef = ref();
|
const tableRef = ref();
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
|
@ -434,7 +434,6 @@ marked.setOptions({
|
||||||
});
|
});
|
||||||
const simpleImage = ref(Empty.PRESENTED_IMAGE_SIMPLE);
|
const simpleImage = ref(Empty.PRESENTED_IMAGE_SIMPLE);
|
||||||
const visible = ref<boolean>(false);
|
const visible = ref<boolean>(false);
|
||||||
const listData = ref<string[]>([]);
|
|
||||||
const access = ref({});
|
const access = ref({});
|
||||||
const config = ref<any>({});
|
const config = ref<any>({});
|
||||||
const metadata = ref<ConfigMetadata>({ properties: [] });
|
const metadata = ref<ConfigMetadata>({ properties: [] });
|
||||||
|
@ -501,35 +500,10 @@ const query = reactive({
|
||||||
search: {
|
search: {
|
||||||
type: 'select',
|
type: 'select',
|
||||||
options: async () => {
|
options: async () => {
|
||||||
return new Promise((res) => {
|
return new Promise((resolve) => {
|
||||||
getProviders().then((resp: any) => {
|
getProviders().then((resp: any) => {
|
||||||
listData.value = [];
|
const data = resp.result || []
|
||||||
if (isNoCommunity) {
|
resolve(accessConfigTypeFilter(data))
|
||||||
(resp?.result || []).map((item: any) => {
|
|
||||||
if (item.id != 'plugin_gateway') {
|
|
||||||
listData.value.push({
|
|
||||||
label: item.name,
|
|
||||||
value: item.id,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
listData.value = (resp?.result || [])
|
|
||||||
.filter((i: any) =>
|
|
||||||
[
|
|
||||||
'mqtt-server-gateway',
|
|
||||||
'http-server-gateway',
|
|
||||||
'mqtt-client-gateway',
|
|
||||||
'tcp-server-gateway',
|
|
||||||
].includes(i.id),
|
|
||||||
)
|
|
||||||
.map((item: any) => ({
|
|
||||||
label: item.name,
|
|
||||||
value: item.id,
|
|
||||||
}));
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
res(listData.value);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -961,7 +935,8 @@ const getData = async (accessId?: string) => {
|
||||||
);
|
);
|
||||||
getProviders().then((resp) => {
|
getProviders().then((resp) => {
|
||||||
if (resp.status === 200) {
|
if (resp.status === 200) {
|
||||||
dataSource.value = resp.result;
|
const data = resp.result || []
|
||||||
|
dataSource.value = accessConfigTypeFilter(data as any[]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,6 +182,7 @@ import Save from './Save/index.vue';
|
||||||
import { useMenuStore } from 'store/menu';
|
import { useMenuStore } from 'store/menu';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import {useRouterParams} from "@/utils/hooks/useParams";
|
import {useRouterParams} from "@/utils/hooks/useParams";
|
||||||
|
import { accessConfigTypeFilter } from '@/utils/setting'
|
||||||
/**
|
/**
|
||||||
* 表格数据
|
* 表格数据
|
||||||
*/
|
*/
|
||||||
|
@ -442,37 +443,11 @@ const query = reactive({
|
||||||
dataIndex: 'accessProvider',
|
dataIndex: 'accessProvider',
|
||||||
search: {
|
search: {
|
||||||
type: 'select',
|
type: 'select',
|
||||||
options: async () => {
|
options: () => {
|
||||||
return new Promise((res) => {
|
return new Promise((resolve) => {
|
||||||
getProviders().then((resp: any) => {
|
getProviders().then((resp: any) => {
|
||||||
listData.value = [];
|
const data = resp.result || []
|
||||||
// const list = () => {
|
resolve(accessConfigTypeFilter(data))
|
||||||
if (isNoCommunity) {
|
|
||||||
(resp?.result || []).map((item: any) => {
|
|
||||||
if (item.id != 'plugin_gateway') {
|
|
||||||
listData.value.push({
|
|
||||||
label: item.name,
|
|
||||||
value: item.id,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
listData.value = (resp?.result || [])
|
|
||||||
.filter((i: any) =>
|
|
||||||
[
|
|
||||||
'mqtt-server-gateway',
|
|
||||||
'http-server-gateway',
|
|
||||||
'mqtt-client-gateway',
|
|
||||||
'tcp-server-gateway',
|
|
||||||
].includes(i.id),
|
|
||||||
)
|
|
||||||
.map((item: any) => ({
|
|
||||||
label: item.name,
|
|
||||||
value: item.id,
|
|
||||||
}));
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
res(listData.value);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -51,6 +51,7 @@ import Channel from '../components/Channel/index.vue';
|
||||||
import Edge from '../components/Edge/index.vue';
|
import Edge from '../components/Edge/index.vue';
|
||||||
import Cloud from '../components/Cloud/index.vue';
|
import Cloud from '../components/Cloud/index.vue';
|
||||||
import { getProviders, detail } from '@/api/link/accessConfig';
|
import { getProviders, detail } from '@/api/link/accessConfig';
|
||||||
|
import { accessConfigTypeFilter } from '@/utils/setting'
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const id = route.params.id as string;
|
const id = route.params.id as string;
|
||||||
|
@ -140,7 +141,8 @@ const getTypeList = (result: Record<string, any>) => {
|
||||||
const queryProviders = async () => {
|
const queryProviders = async () => {
|
||||||
const resp: any = await getProviders();
|
const resp: any = await getProviders();
|
||||||
if (resp.status === 200) {
|
if (resp.status === 200) {
|
||||||
dataSource.value = getTypeList(resp.result);
|
const data = resp.result || []
|
||||||
|
dataSource.value = getTypeList(accessConfigTypeFilter(data as any[]));
|
||||||
// dataSource.value = getTypeList(resp.result)[0].list.filter(
|
// dataSource.value = getTypeList(resp.result)[0].list.filter(
|
||||||
// (item) => item.name !== '插件设备接入',
|
// (item) => item.name !== '插件设备接入',
|
||||||
// );
|
// );
|
||||||
|
@ -151,7 +153,8 @@ const getProvidersData = async () => {
|
||||||
if (id !== ':id') {
|
if (id !== ':id') {
|
||||||
getProviders().then((response: any) => {
|
getProviders().then((response: any) => {
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
const list = getTypeList(response.result);
|
const data = response.result || []
|
||||||
|
const list = getTypeList(accessConfigTypeFilter(data as any[]));
|
||||||
dataSource.value = list.filter(
|
dataSource.value = list.filter(
|
||||||
(item: any) =>
|
(item: any) =>
|
||||||
item.channel === 'network' ||
|
item.channel === 'network' ||
|
||||||
|
|
|
@ -188,6 +188,7 @@ import {
|
||||||
} from '@/api/link/accessConfig';
|
} from '@/api/link/accessConfig';
|
||||||
import { onlyMessage } from '@/utils/comm';
|
import { onlyMessage } from '@/utils/comm';
|
||||||
import { useMenuStore } from 'store/menu';
|
import { useMenuStore } from 'store/menu';
|
||||||
|
import { accessConfigTypeFilter } from '@/utils/setting'
|
||||||
|
|
||||||
const menuStory = useMenuStore();
|
const menuStory = useMenuStore();
|
||||||
const tableRef = ref<Record<string, any>>({});
|
const tableRef = ref<Record<string, any>>({});
|
||||||
|
@ -318,12 +319,7 @@ const getActions = (data: Partial<Record<string, any>>): ActionsType[] => {
|
||||||
const getProvidersList = async () => {
|
const getProvidersList = async () => {
|
||||||
const res: any = await getProviders();
|
const res: any = await getProviders();
|
||||||
providersList.value = res.result;
|
providersList.value = res.result;
|
||||||
providersOptions.value = (res?.result || [])
|
providersOptions.value = accessConfigTypeFilter(res.result || [])
|
||||||
?.map((item: any) => ({
|
|
||||||
label: item.name,
|
|
||||||
value: item.id,
|
|
||||||
}))
|
|
||||||
.filter((item: any) => item.value !== 'plugin_gateway'); // todo 暂时不做插件接入
|
|
||||||
};
|
};
|
||||||
getProvidersList();
|
getProvidersList();
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ import { queryTree } from '@/api/device/category'
|
||||||
import { getTreeData_api } from '@/api/system/department'
|
import { getTreeData_api } from '@/api/system/department'
|
||||||
import { isNoCommunity } from '@/utils/utils'
|
import { isNoCommunity } from '@/utils/utils'
|
||||||
import { getImage } from '@/utils/comm'
|
import { getImage } from '@/utils/comm'
|
||||||
|
import { accessConfigTypeFilter } from '@/utils/setting'
|
||||||
|
|
||||||
type Emit = {
|
type Emit = {
|
||||||
(e: 'update:rowKey', data: string): void
|
(e: 'update:rowKey', data: string): void
|
||||||
|
@ -115,23 +116,7 @@ const columns = [
|
||||||
search: {
|
search: {
|
||||||
type: 'select',
|
type: 'select',
|
||||||
options: () => getProviders().then((resp: any) => {
|
options: () => getProviders().then((resp: any) => {
|
||||||
if (isNoCommunity) {
|
return accessConfigTypeFilter(resp.result || [])
|
||||||
return (resp?.result || []).map((item: any) => ({
|
|
||||||
label: item.name,
|
|
||||||
value: item.id
|
|
||||||
}))
|
|
||||||
} else {
|
|
||||||
return (resp?.result || []).filter((item: any) => [
|
|
||||||
'mqtt-server-gateway',
|
|
||||||
'http-server-gateway',
|
|
||||||
'mqtt-client-gateway',
|
|
||||||
'tcp-server-gateway',
|
|
||||||
].includes(item.id))
|
|
||||||
.map((item: any) => ({
|
|
||||||
label: item.name,
|
|
||||||
value: item.id,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -74,6 +74,7 @@ import { queryTree } from '@/api/device/category';
|
||||||
import { getTreeData_api } from '@/api/system/department';
|
import { getTreeData_api } from '@/api/system/department';
|
||||||
import { isNoCommunity } from '@/utils/utils';
|
import { isNoCommunity } from '@/utils/utils';
|
||||||
import { getImage } from '@/utils/comm';
|
import { getImage } from '@/utils/comm';
|
||||||
|
import { accessConfigTypeFilter } from '@/utils/setting'
|
||||||
|
|
||||||
type Emit = {
|
type Emit = {
|
||||||
(e: 'update:rowKey', data: string): void;
|
(e: 'update:rowKey', data: string): void;
|
||||||
|
@ -127,26 +128,8 @@ const columns = [
|
||||||
type: 'select',
|
type: 'select',
|
||||||
options: () =>
|
options: () =>
|
||||||
getProviders().then((resp: any) => {
|
getProviders().then((resp: any) => {
|
||||||
if (isNoCommunity) {
|
const data = resp.result || []
|
||||||
return (resp?.result || []).map((item: any) => ({
|
return accessConfigTypeFilter(data)
|
||||||
label: item.name,
|
|
||||||
value: item.id,
|
|
||||||
}));
|
|
||||||
} else {
|
|
||||||
return (resp?.result || [])
|
|
||||||
.filter((item: any) =>
|
|
||||||
[
|
|
||||||
'mqtt-server-gateway',
|
|
||||||
'http-server-gateway',
|
|
||||||
'mqtt-client-gateway',
|
|
||||||
'tcp-server-gateway',
|
|
||||||
].includes(item.id),
|
|
||||||
)
|
|
||||||
.map((item: any) => ({
|
|
||||||
label: item.name,
|
|
||||||
value: item.id,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -572,44 +572,6 @@ const rules = [{
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
|
||||||
const formTouchOff = () => {
|
|
||||||
console.log('formTouchOff')
|
|
||||||
formItemContext.onFieldChange()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验当前执行动作的设备或者产品是否删除
|
|
||||||
*/
|
|
||||||
const checkDeviceDelete = async () => {
|
|
||||||
const item = _data.value.branches![props.branchesName].then[props.thenName].actions[props.name].device
|
|
||||||
const proResp = await queryProductList({ terms: [{ terms: [{ column: 'id', termType: 'eq', value: item!.productId }]}]})
|
|
||||||
if (proResp.success && (proResp.result as any)?.total === 0) { // 产品已删除
|
|
||||||
_data.value.branches![props.branchesName].then[props.thenName].actions[props.name].device!.productId = undefined
|
|
||||||
formTouchOff()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const deviceList = item!.selectorValues?.map(item => item.value) || []
|
|
||||||
const deviceResp = await deviceQuery({ terms: [{ terms: [{ column: 'id', termType: 'in', value: deviceList.toString() }]}]})
|
|
||||||
if (deviceResp.success && (deviceResp.result as any)?.total < (item!.selectorValues?.length || 0)) { // 某一个设备被删除
|
|
||||||
_data.value.branches![props.branchesName].then[props.thenName].actions[props.name].device!.selectorValues = undefined
|
|
||||||
formTouchOff()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验当前执行动作的通知配置、消息模板是否删除
|
|
||||||
*/
|
|
||||||
const checkNoticeDelete = () => {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
nextTick(() => {
|
|
||||||
if (_data.value.branches![props.branchesName].then[props.thenName].actions[props.name]?.executor === 'device') {
|
|
||||||
checkDeviceDelete()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
|
Loading…
Reference in New Issue