fix: bug#13639、13188

This commit is contained in:
xieyonghong 2023-05-18 10:29:06 +08:00
parent 7b05778587
commit 1dc0722b65
11 changed files with 96 additions and 12 deletions

View File

@ -25,7 +25,7 @@
"event-source-polyfill": "^1.0.31", "event-source-polyfill": "^1.0.31",
"global": "^4.4.0", "global": "^4.4.0",
"jetlinks-store": "^0.0.3", "jetlinks-store": "^0.0.3",
"jetlinks-ui-components": "^1.0.15", "jetlinks-ui-components": "^1.0.16",
"js-cookie": "^3.0.1", "js-cookie": "^3.0.1",
"less": "^4.1.3", "less": "^4.1.3",
"less-loader": "^11.1.0", "less-loader": "^11.1.0",

View File

@ -16,11 +16,13 @@
<template v-if="showType === 'network'"> <template v-if="showType === 'network'">
<Network <Network
v-if="provider.id !== 'plugin_gateway'" v-if="provider.id !== 'plugin_gateway'"
:bindProduct='bindProduct'
:provider="provider" :provider="provider"
:data="data" :data="data"
/> />
<Plugin <Plugin
v-else v-else
:bindProduct='bindProduct'
:provider="provider" :provider="provider"
:data="data" :data="data"
/> />
@ -28,21 +30,25 @@
<Media <Media
v-if="showType === 'media'" v-if="showType === 'media'"
:bindProduct='bindProduct'
:provider="provider" :provider="provider"
:data="data" :data="data"
/> />
<Channel <Channel
v-if="showType === 'channel'" v-if="showType === 'channel'"
:bindProduct='bindProduct'
:provider="provider" :provider="provider"
:data="data" :data="data"
/> />
<Edge <Edge
v-if="showType === 'edge'" v-if="showType === 'edge'"
:bindProduct='bindProduct'
:provider="provider" :provider="provider"
:data="data" :data="data"
/> />
<Cloud <Cloud
v-if="showType === 'cloud'" v-if="showType === 'cloud'"
:bindProduct='bindProduct'
:provider="provider" :provider="provider"
:data="data" :data="data"
/> />
@ -63,6 +69,7 @@ import Cloud from '../components/Cloud/index.vue';
import Plugin from '../components/Plugin/index.vue' import Plugin from '../components/Plugin/index.vue'
import { getProviders, detail } from '@/api/link/accessConfig'; import { getProviders, detail } from '@/api/link/accessConfig';
import { accessConfigTypeFilter } from '@/utils/setting'; import { accessConfigTypeFilter } from '@/utils/setting';
import { queryProductList } from '@/api/device/product';
const route = useRoute(); const route = useRoute();
const id = route.params.id as string; const id = route.params.id as string;
@ -73,6 +80,7 @@ const loading = ref(true);
const provider = ref({}); const provider = ref({});
const data = ref({}); const data = ref({});
const showType: any = ref(''); const showType: any = ref('');
const bindProduct = ref(false)
const goProviders = (param: any) => { const goProviders = (param: any) => {
showType.value = param.type; showType.value = param.type;
@ -188,8 +196,27 @@ const queryProviders = async () => {
} }
}; };
/**
* 检查是否被产品使用
*/
const checkBindProduct = async (_id: string) => {
const resp = await queryProductList({
paging: false,
terms: [{
column: 'accessId',
termType: 'eq',
value: _id
}]
})
console.log(resp.success && resp.result?.total)
if (resp.success && resp.result?.total) {
bindProduct.value = true
}
}
const getProvidersData = async () => { const getProvidersData = async () => {
if (id !== ':id') { if (id !== ':id') {
checkBindProduct(id)
getProviders().then((response: any) => { getProviders().then((response: any) => {
if (response.status === 200) { if (response.status === 200) {
const _data = response.result || []; const _data = response.result || [];

View File

@ -22,13 +22,12 @@
}}</j-tooltip> }}</j-tooltip>
</div> </div>
<div class="checked-icon"> <div class="checked-icon">
<div><CheckOutlined /></div> <div><a-icon type='CheckOutlined' /></div>
</div> </div>
</j-card> </j-card>
</template> </template>
<script lang="ts" setup name="AccessCard"> <script lang="ts" setup name="AccessCard">
import { CheckOutlined } from '@ant-design/icons-vue';
const emit = defineEmits(['checkedChange']); const emit = defineEmits(['checkedChange']);
@ -48,7 +47,9 @@ const props = defineProps({
}); });
const checkedChange = (id: string) => { const checkedChange = (id: string) => {
if (!props.disabled) {
emit('checkedChange', id); emit('checkedChange', id);
}
}; };
</script> </script>

View File

@ -177,6 +177,7 @@
@search="procotolSearch" @search="procotolSearch"
/> />
<PermissionButton <PermissionButton
v-if='showAddBtn'
type="primary" type="primary"
@click="addProcotol" @click="addProcotol"
hasPermission="link/Protocol:add" hasPermission="link/Protocol:add"
@ -199,6 +200,7 @@
<AccessCard <AccessCard
@checkedChange="procotolChange" @checkedChange="procotolChange"
:checked="procotolCurrent" :checked="procotolCurrent"
:disabled='!showAddBtn'
:data="{ ...item, type: 'protocol' }" :data="{ ...item, type: 'protocol' }"
> >
</AccessCard> </AccessCard>
@ -352,6 +354,10 @@ const props = defineProps({
type: Object, type: Object,
default: () => {}, default: () => {},
}, },
bindProduct: {
type: Boolean,
default: false
}
}); });
const formRef1 = ref<FormInstance>(); const formRef1 = ref<FormInstance>();
@ -368,6 +374,10 @@ const formData = ref<Form>({
description: '', description: '',
}); });
const showAddBtn = computed(() => {
return route.query.view === 'false' && !props.bindProduct
})
const current = ref(0); const current = ref(0);
const stepCurrent = ref(0); const stepCurrent = ref(0);
const steps = ref(['接入配置', '消息协议', '完成']); const steps = ref(['接入配置', '消息协议', '完成']);

View File

@ -260,6 +260,7 @@
@search="procotolSearch" @search="procotolSearch"
/> />
<PermissionButton <PermissionButton
v-if='showAddBtn'
type="primary" type="primary"
@click="addProcotol" @click="addProcotol"
hasPermission="link/Protocol:add" hasPermission="link/Protocol:add"
@ -282,6 +283,7 @@
<AccessCard <AccessCard
@checkedChange="procotolChange" @checkedChange="procotolChange"
:checked="procotolCurrent" :checked="procotolCurrent"
:disabled='!showAddBtn'
:data="{ ...item, type: 'protocol' }" :data="{ ...item, type: 'protocol' }"
> >
</AccessCard> </AccessCard>
@ -434,6 +436,10 @@ const props = defineProps({
type: Object, type: Object,
default: () => {}, default: () => {},
}, },
bindProduct: {
type: Boolean,
default: false
}
}); });
const route = useRoute(); const route = useRoute();
@ -462,6 +468,10 @@ const procotolList: any = ref([]);
const allProcotolList = ref([]); const allProcotolList = ref([]);
const procotolCurrent: any = ref(''); const procotolCurrent: any = ref('');
const showAddBtn = computed(() => {
return route.query.view === 'false' && !props.bindProduct
})
const procotolChange = (id: string) => { const procotolChange = (id: string) => {
procotolCurrent.value = id; procotolCurrent.value = id;
}; };

View File

@ -3,11 +3,13 @@
<Ctwing <Ctwing
v-if="channel === 'Ctwing'" v-if="channel === 'Ctwing'"
:provider="props.provider" :provider="props.provider"
:bindProduct='bindProduct'
:data="props.data" :data="props.data"
/> />
<OneNet <OneNet
v-if="channel === 'OneNet'" v-if="channel === 'OneNet'"
:provider="props.provider" :provider="props.provider"
:bindProduct='bindProduct'
:data="props.data" :data="props.data"
/> />
</div> </div>
@ -26,6 +28,10 @@ const props = defineProps({
type: Object, type: Object,
default: () => {}, default: () => {},
}, },
bindProduct: {
type: Boolean,
default: false
}
}); });
const channel = props.provider.channel; const channel = props.provider.channel;

View File

@ -530,7 +530,7 @@ const props = defineProps({
data: { data: {
type: Object, type: Object,
default: () => {}, default: () => {},
}, }
}); });
const route = useRoute(); const route = useRoute();

View File

@ -17,6 +17,7 @@
@search="networkSearch" @search="networkSearch"
/> />
<PermissionButton <PermissionButton
type="primary" type="primary"
@click="addNetwork" @click="addNetwork"
hasPermission="link/Type:add" hasPermission="link/Type:add"
@ -112,6 +113,7 @@
@search="procotolSearch" @search="procotolSearch"
/> />
<PermissionButton <PermissionButton
v-if='showAddBtn'
type="primary" type="primary"
@click="addProcotol" @click="addProcotol"
hasPermission="link/Protocol:add" hasPermission="link/Protocol:add"
@ -134,7 +136,7 @@
<AccessCard <AccessCard
@checkedChange="procotolChange" @checkedChange="procotolChange"
:checked="procotolCurrent" :checked="procotolCurrent"
:disabled='id !== ":id"' :disabled='!showAddBtn'
:data="{ ...item, type: 'protocol' }" :data="{ ...item, type: 'protocol' }"
> >
</AccessCard> </AccessCard>
@ -352,6 +354,10 @@ const props = defineProps({
type: Object, type: Object,
default: () => {}, default: () => {},
}, },
bindProduct: {
type: Boolean,
default: false
}
}); });
const clientHeight = document.body.clientHeight; const clientHeight = document.body.clientHeight;
@ -396,6 +402,10 @@ const { resetFields, validate, validateInfos } = useForm(
}), }),
); );
const showAddBtn = computed(() => {
return route.query.view === 'false' && !props.bindProduct
})
const queryNetworkList = async (id: string, include: string, data = {}) => { const queryNetworkList = async (id: string, include: string, data = {}) => {
const resp = await getNetworkList( const resp = await getNetworkList(
NetworkTypeMapping.get(id), NetworkTypeMapping.get(id),

View File

@ -14,6 +14,7 @@
@search="pluginSearch" @search="pluginSearch"
/> />
<PermissionButton <PermissionButton
v-if='showAddBtn'
type="primary" type="primary"
@click="addPlugin" @click="addPlugin"
hasPermission="link/plugin:add" hasPermission="link/plugin:add"
@ -36,7 +37,7 @@
<AccessCard <AccessCard
@checkedChange="AccessChange" @checkedChange="AccessChange"
:checked="AccessCurrent" :checked="AccessCurrent"
:disabled='paramsId !== ":id"' :disabled='!showAddBtn'
:data="{ ...item, type: 'plugin' }" :data="{ ...item, type: 'plugin' }"
> >
<template #other> <template #other>
@ -185,6 +186,10 @@ const props = defineProps({
type: Object, type: Object,
default: () => {}, default: () => {},
}, },
bindProduct: {
type: Boolean,
default: false
}
}); });
const route = useRoute(); const route = useRoute();
@ -220,6 +225,10 @@ const queryPlugin = (params = {}) => {
}) })
} }
const showAddBtn = computed(() => {
return route.query.view === 'false' && !props.bindProduct
})
const getRules = (item: any) => { const getRules = (item: any) => {
let typeName = '输入' let typeName = '输入'
let rules: any[] = [] let rules: any[] = []

View File

@ -48,7 +48,18 @@
<j-form-item name="base-path"> <j-form-item name="base-path">
<template #label> <template #label>
<span>base-path</span> <span>base-path</span>
<j-tooltip title="系统后台访问的url"> <j-tooltip >
<template #title>
<div style='word-break: break-all;'>
<div>
系统后台访问的url
</div>
<div>
格式{http/https}: //{IP}:{}/api
</div>
</div>
</template>
<img <img
class="img-style" class="img-style"
:src=" :src="
@ -59,7 +70,7 @@
</template> </template>
<j-input <j-input
v-model:value="formValue['base-path']" v-model:value="formValue['base-path']"
placeholder="输入base-path" placeholder="{http/https}: //{前端所在服务器IP地址}:{前端暴露的服务端口}/api"
/> />
</j-form-item> </j-form-item>
<j-row :gutter="24" :span="24"> <j-row :gutter="24" :span="24">

View File

@ -3823,10 +3823,10 @@ jetlinks-store@^0.0.3:
resolved "https://registry.npmjs.org/jetlinks-store/-/jetlinks-store-0.0.3.tgz" resolved "https://registry.npmjs.org/jetlinks-store/-/jetlinks-store-0.0.3.tgz"
integrity sha512-AZf/soh1hmmwjBZ00fr1emuMEydeReaI6IBTGByQYhTmK1Zd5pQAxC7WLek2snRAn/HHDgJfVz2hjditKThl6Q== integrity sha512-AZf/soh1hmmwjBZ00fr1emuMEydeReaI6IBTGByQYhTmK1Zd5pQAxC7WLek2snRAn/HHDgJfVz2hjditKThl6Q==
jetlinks-ui-components@^1.0.15: jetlinks-ui-components@^1.0.16:
version "1.0.15" version "1.0.16"
resolved "https://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.15.tgz#fa007e685ead81ed0eb81250c5ecd3909f8b223d" resolved "https://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.16.tgz#bdb65385a30a121065322e5156c13080c8328080"
integrity sha512-ydgWz4Ee80V57yWnudRuGJASnuQULpbLAczY0NRybsVgLNf88N4FGqAug3XKBtsLn8xkPwNDlSLBCEs9baLv5Q== integrity sha512-R3oE8tpXW4oaNSCeGXRK++paNJiHYDO89Id3YqzIVX6/bWMItOWrEU6JT4iPA9uYkPTfsYHxnG5qZRloLnpiZw==
dependencies: dependencies:
"@vueuse/core" "^9.12.0" "@vueuse/core" "^9.12.0"
"@vueuse/router" "^9.13.0" "@vueuse/router" "^9.13.0"