fix: 14203、14491、9658、13663、14207、14226、14493

This commit is contained in:
100011797 2023-05-30 18:21:34 +08:00
parent c669985f54
commit ef8dc58ac4
14 changed files with 259 additions and 61 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.18", "jetlinks-ui-components": "^1.0.21",
"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

@ -114,11 +114,11 @@ const handleAdd = () => {
const validateIndicator = (value: any) => { const validateIndicator = (value: any) => {
if (value?.range) { if (value?.range) {
if (!value?.value || !value?.value[0] || !value?.value[1]) { if (!value?.value || (!value?.value[0] && value?.value[0] !== 0) || (!value?.value[1] && value?.value[1] !== 0)) {
return Promise.reject(new Error('请输入指标值')); return Promise.reject(new Error('请输入指标值'));
} }
} else { } else {
if (!value?.value) { if (!value?.value && value?.value !== 0) {
return Promise.reject(new Error('请输入指标值')); return Promise.reject(new Error('请输入指标值'));
} }
} }

View File

@ -46,7 +46,7 @@
:rules="[{ required: true, message: '请选择告警规则' }]" :rules="[{ required: true, message: '请选择告警规则' }]"
> >
<j-select <j-select
:value="form.topicConfig.alarmConfigId?.split(',')" :value="form.topicConfig?.alarmConfigId?.split(',')"
:options="alarmList" :options="alarmList"
placeholder="请选择告警规则" placeholder="请选择告警规则"
mode="multiple" mode="multiple"
@ -146,8 +146,8 @@ function init() {
function onSelect(keys: string[], items: optionsType) { function onSelect(keys: string[], items: optionsType) {
form.value.topicConfig = { form.value.topicConfig = {
alarmConfigId: keys.join(','), alarmConfigId: keys.length ? keys.join(',') : undefined,
alarmConfigName: items.map((item) => item.label).join(','), alarmConfigName: items.length ? items.map((item) => item.label).join(',') : undefined,
}; };
} }
</script> </script>

View File

@ -53,6 +53,6 @@ const findName = (item: any) => {
const _element = item.dataType.elements?.find((a: any) => a.value === item.value) const _element = item.dataType.elements?.find((a: any) => a.value === item.value)
name = _element?.text name = _element?.text
} }
return name return name || item.value
} }
</script> </script>

View File

@ -47,10 +47,10 @@
</template> </template>
<template v-if="modelType === 'tags'"> <template v-if="modelType === 'tags'">
<value-type-form :name="['valueType']" v-model:value="value.valueType" key="property" title="数据类型"></value-type-form> <value-type-form :name="['valueType']" v-model:value="value.valueType" key="property" title="数据类型"></value-type-form>
<j-form-item label="标签类型" :name="['expands', 'type']" :rules="[ <j-form-item label="读写类型" :name="['expands', 'type']" :rules="[
{ required: true, message: '请选择标签类型' }, { required: true, message: '请选择读写类型' },
]"> ]">
<j-select v-model:value="value.expands.type" :options="ExpandsTypeList" mode="multiple" size="small" placeholder="请选择标签类型"></j-select> <j-select v-model:value="value.expands.type" :options="ExpandsTypeList" mode="multiple" size="small" placeholder="请选择读写类型"></j-select>
</j-form-item> </j-form-item>
</template> </template>
<j-form-item label="说明" name="description" :rules="[ <j-form-item label="说明" name="description" :rules="[

View File

@ -0,0 +1,73 @@
<template>
<j-select
:value="host"
:options="options"
placeholder="请选择本地地址"
allowClear
show-search
:disabled="shareCluster"
@change="changeHost"
>
</j-select>
</template>
<script lang="ts" setup>
import { Store } from "jetlinks-store"
import { resourceClustersById } from "@/api/link/type"
const props = defineProps({
value: {
type: String,
default: undefined
},
shareCluster: {
type: Boolean,
default: true
},
serverId: {
type: String,
default: undefined
}
})
const emit = defineEmits(['update:value', 'change', 'valueChange'])
const host = ref<string>()
const options = ref<any[]>([])
const getResourcesClustersById = async (id: string) => {
const _value = Store.get('resourcesClusters')?.[id]
if(!_value){
const resp = await resourceClustersById(id)
if (resp.status === 200) {
const checked = resp.result?.[0]
const checkedHost = [{ value: checked?.host, label: checked?.host }];
options.value = checked ? checkedHost : []
const resourcesClusters = Store.get('resourcesClusters') || {}
resourcesClusters[id] = resp.result
Store.set('resourcesClusters', resourcesClusters)
emit('valueChange', props.value)
} else {
options.value = []
}
} else {
const checked = Store.get('resourcesClusters')?.[id]?.[0]
const checkedHost = [{ value: checked?.host, label: checked?.host }];
options.value = checked ? checkedHost : []
}
}
watchEffect(() => {
host.value = props.value
if(!props.shareCluster && props.serverId){
getResourcesClustersById(props.serverId)
}
emit('valueChange', props.value)
})
const changeHost = (_value: string) => {
emit('update:value', _value)
emit('change', props.value)
}
</script>

View File

@ -209,7 +209,7 @@
/> />
</j-tooltip> </j-tooltip>
</template> </template>
<j-select <!-- <j-select
v-model:value=" v-model:value="
cluster cluster
.configuration .configuration
@ -237,7 +237,14 @@
) )
" "
> >
</j-select> </j-select> -->
<LocalAddressSelect
v-model:value="cluster.configuration.host"
:serverId="cluster.serverId"
:shareCluster="shareCluster"
@change="(value) => changeHost(cluster.serverId, value, index)"
@valueChange="(value) => changeHost(cluster.serverId, value, index, true)"
/>
</j-form-item> </j-form-item>
</j-col> </j-col>
<j-col <j-col
@ -1112,6 +1119,8 @@ import {
supports, supports,
certificates, certificates,
start, start,
resourceClusters,
resourceClustersById,
} from '@/api/link/type'; } from '@/api/link/type';
import { import {
ParserConfiguration, ParserConfiguration,
@ -1129,6 +1138,7 @@ import {
import { cloneDeep } from 'lodash-es'; import { cloneDeep } from 'lodash-es';
import type { FormData2Type, FormDataType } from '../type'; import type { FormData2Type, FormDataType } from '../type';
import { Store } from 'jetlinks-store'; import { Store } from 'jetlinks-store';
import LocalAddressSelect from './LocalAddressSelect.vue';
const route = useRoute(); const route = useRoute();
const NetworkType = route.query.type as string; const NetworkType = route.query.type as string;
@ -1147,8 +1157,9 @@ const hostOptionsIndex: any = ref([]);
const clustersListIndex: any = ref([]); const clustersListIndex: any = ref([]);
const typeOptions = ref([]); const typeOptions = ref([]);
const portOptionsIndex: any = ref([]); const portOptionsIndex: any = ref([]);
let portOptionsConst: any = []; // let portOptionsConst: any = [];
const certIdOptions = ref([]); const certIdOptions = ref([]);
const configClustersList = ref<any[]>([]);
const dynamicValidateForm = reactive<{ cluster: FormData2Type[] }>({ const dynamicValidateForm = reactive<{ cluster: FormData2Type[] }>({
cluster: [{ ...cloneDeep(FormStates2), id: '1' }], cluster: [{ ...cloneDeep(FormStates2), id: '1' }],
@ -1178,7 +1189,7 @@ const filterPortOption = (input: string, option: any) => {
return JSON.stringify(option.label).indexOf(input) >= 0; return JSON.stringify(option.label).indexOf(input) >= 0;
}; };
const filterConfigByType = (data: any, type: string) => { const filterConfigByType = (data: any[], type: string) => {
let _temp = type; let _temp = type;
if (TCPList.includes(type)) { if (TCPList.includes(type)) {
_temp = 'TCP'; _temp = 'TCP';
@ -1197,7 +1208,7 @@ const filterConfigByType = (data: any, type: string) => {
}); });
}; };
const getPortOptions = (portOptions: object, index = 0) => { const getPortOptions = (portOptions: any, index = 0) => {
if (!portOptions) return; if (!portOptions) return;
const type = formData.value.type; const type = formData.value.type;
const host = dynamicValidateForm.cluster[index].configuration.host; const host = dynamicValidateForm.cluster[index].configuration.host;
@ -1227,40 +1238,57 @@ const changeType = (value: string) => {
const updateClustersListIndex = () => { const updateClustersListIndex = () => {
const { cluster } = dynamicValidateForm; const { cluster } = dynamicValidateForm;
const filters = cluster?.map((item) => item.serverId); const filters = cluster?.map((item) => item.serverId);
const newConfigRef = Store.get('configRef')?.filter( const newConfigRef = shareCluster.value ? Store.get('configRef')?.filter(
(item: any) => !filters.includes(item.clusterNodeId), (item: any) => !filters.includes(item.clusterNodeId),
); ) : configClustersList.value?.filter(
(item: any) => !filters.includes(item.id),
)
cluster.forEach((item, index) => { cluster.forEach((item, index) => {
!item.serverId && clustersListIndex.value[index] = newConfigRef?.map((i: any) => {
(clustersListIndex.value[index] = newConfigRef?.map((i: any) => ({ if(shareCluster.value){
value: i.clusterNodeId, return {
lable: i.clusterNodeId, value: i.clusterNodeId,
}))); label: i.clusterNodeId,
}
} else {
return {
value: i.id,
label: i.name,
}
}
})
if(item.serverId) {
clustersListIndex.value[index].push({
value: item.serverId,
label: item.serverId
})
}
}); });
}; };
const changeServerId = (value: string | undefined, index: number) => { const changeServerId = async (value: string | undefined, index: number) => {
const { configuration } = dynamicValidateForm.cluster[index]; const { configuration } = dynamicValidateForm.cluster[index];
configuration.host = undefined; configuration.host = undefined;
configuration.port = undefined; configuration.port = undefined;
const checked = cloneDeep(portOptionsConst).find( hostOptionsIndex.value[index] = [];
(i: any) => i.clusterNodeId === value, if(value){
); updateClustersListIndex();
const checkedHost = [{ value: checked?.host, lable: checked?.host }]; }
hostOptionsIndex.value[index] = checked ? checkedHost : [];
updateClustersListIndex();
}; };
const changeHost = ( const changeHost = (
serverId: string | undefined, serverId: string | undefined,
value: string | undefined, value: string | undefined,
index: number, index: number,
flag?: boolean
) => { ) => {
const { configuration } = dynamicValidateForm.cluster[index]; const { configuration } = dynamicValidateForm.cluster[index];
configuration.port = undefined; if(!flag){
const checked = cloneDeep(portOptionsConst).find( configuration.port = undefined;
(i: any) => i.clusterNodeId === serverId && i.host === value, }
); const checked = Store.get('resourcesClusters')?.[serverId || '']
checked && getPortOptions([checked], index); if(checked){
getPortOptions(checked, index)
}
}; };
const changeParserType = (value: string | undefined, index: number) => { const changeParserType = (value: string | undefined, index: number) => {
@ -1346,9 +1374,20 @@ const getCertificates = async () => {
const getResourcesCurrent = () => { const getResourcesCurrent = () => {
resourcesCurrent().then((resp) => { resourcesCurrent().then((resp) => {
if (resp.status === 200) { if (resp.status === 200) {
portOptionsConst = resp.result; const clusterNodeId = resp.result?.[0]?.clusterNodeId
const resourcesClusters = Store.get('resourcesClusters') || {}
resourcesClusters[clusterNodeId] = resp.result
Store.set('resourcesClusters', resourcesClusters)
Store.set('configRef', resp.result); Store.set('configRef', resp.result);
getPortOptions(portOptionsConst); getPortOptions(Store.get('resourcesClusters')?.[clusterNodeId]);
}
});
};
const getResourcesClusters = () => {
resourceClusters().then((resp) => {
if (resp.status === 200) {
configClustersList.value = resp.result as any[]
} }
}); });
}; };
@ -1369,22 +1408,24 @@ const getDetail = () => {
...configuration, ...configuration,
}; };
const configRef = Store.get('configRef').filter( // const configRef = Store.get('configRef').filter(
(item: any) => item.host === '0.0.0.0', // (item: any) => item.host === '0.0.0.0',
); // );
getPortOptions(configRef); // // getPortOptions(configRef); //
} else { } else {
dynamicValidateForm.cluster = cluster; dynamicValidateForm.cluster = cluster;
// const arr = cluster.map((item: any) => item.configuration.serverId)
// //
setTimeout(() => { // setTimeout(() => {
cluster.forEach((item: any, index: number) => { // cluster.forEach((item: any, index: number) => {
const { host } = item.configuration; // const { serverId } = item.configuration
let configRef = Store.get('configRef').filter( // if(!resourcesClustersMap.get(serverId)){
(item: any) => item.host === host, // // await getResourcesClustersById(serverId)
); // }
getPortOptions(configRef, index); // const checked = resourcesClustersMap.get(serverId)
}); // getPortOptions(checked, index);
}, 0); // });
// }, 0);
} }
if (dynamicValidateForm.cluster.length === 1) { if (dynamicValidateForm.cluster.length === 1) {
@ -1400,6 +1441,7 @@ onMounted(() => {
getSupports(); getSupports();
getCertificates(); getCertificates();
getResourcesCurrent(); getResourcesCurrent();
getResourcesClusters();
getDetail(); getDetail();
}); });

View File

@ -250,7 +250,7 @@ const getActions = (data: any) => {
message.success('操作成功!'); message.success('操作成功!');
instanceRef.value?.reload(); instanceRef.value?.reload();
} else { } else {
message.error('操作失败!'); message.error(resp?.message || '操作失败!');
} }
}, },
}, },

View File

@ -247,6 +247,8 @@ watch(
const validateChannelId = async (_rule: Rule, value: string) => { const validateChannelId = async (_rule: Rule, value: string) => {
// ID, ID, ID // ID, ID, ID
if (!value) return; if (!value) return;
//
if(!!formData.value?.id) return;
const { result } = await ChannelApi.validateField({ const { result } = await ChannelApi.validateField({
deviceId: route.query.id, deviceId: route.query.id,
channelId: value, channelId: value,

View File

@ -944,6 +944,7 @@ const formRules = {
} }
], ],
calledShowNumbers: [ calledShowNumbers: [
{ required: true, message: '请输入被叫显号' },
{ max: 64, message: '最多可输入64个字符' }, { max: 64, message: '最多可输入64个字符' },
{ {
validator(_rule: Rule, value: string) { validator(_rule: Rule, value: string) {

View File

@ -13,8 +13,12 @@
:gridColumn="2" :gridColumn="2"
:params="queryParams" :params="queryParams"
:rowSelection="{ :rowSelection="{
// selectedRowKeys: table._selectedRowKeys.value,
// onChange:(keys:string[])=>table._selectedRowKeys.value = [...keys],
// onSelectNone: table.cancelSelect
selectedRowKeys: table._selectedRowKeys.value, selectedRowKeys: table._selectedRowKeys.value,
onChange:(keys:string[])=>table._selectedRowKeys.value = [...keys], onSelect: table.onSelect,
onSelectAll: table.onSelectAll,
onSelectNone: table.cancelSelect onSelectNone: table.cancelSelect
}" }"
:columns="columns" :columns="columns"
@ -408,6 +412,43 @@ const table = {
table._selectedRowKeys.value = []; table._selectedRowKeys.value = [];
table.selectedRows = []; table.selectedRows = [];
}, },
onSelect: (record: any, selected: boolean) => {
const arr = [...table._selectedRowKeys.value]
const _index = arr.findIndex(item => item === record?.id)
if (selected) {
if (!(_index > -1)) {
table._selectedRowKeys.value.push(record.id)
table.selectedRows.push(record)
}
} else {
if (_index > -1) { //
table._selectedRowKeys.value.splice(_index, 1)
table.selectedRows.splice(_index, 1)
}
}
},
onSelectAll: (selected: boolean, _: any[], changeRows: any) => {
if (selected) {
changeRows.map((i: any) => {
if (!table._selectedRowKeys.value.includes(i.id)) {
table._selectedRowKeys.value.push(i.id)
table.selectedRows.push(i)
}
})
} else {
const arr = changeRows.map((item: any) => item.id)
const _arr: string[] = [];
const _ids: string[] = [];
[...table.selectedRows].map((i: any) => {
if (!arr.includes(i?.id)) {
_arr.push(i)
_ids.push(i.id)
}
})
table._selectedRowKeys.value = _ids
table.selectedRows = _arr
}
},
// //
getData: (params: object, parentId: string) => getData: (params: object, parentId: string) =>
new Promise((resolve) => { new Promise((resolve) => {
@ -496,6 +537,7 @@ const table = {
}, },
clickEdit: (row?: any) => { clickEdit: (row?: any) => {
const ids = row ? [row.id] : [...table._selectedRowKeys.value]; const ids = row ? [row.id] : [...table._selectedRowKeys.value];
if (ids.length < 1) return message.warning('请勾选需要编辑的数据');
if (row || table.selectedRows.length === 1) { if (row || table.selectedRows.length === 1) {
const permissionList = const permissionList =
row?.permission || table.selectedRows[0].permission; row?.permission || table.selectedRows[0].permission;

View File

@ -14,7 +14,8 @@
:params="queryParams" :params="queryParams"
:rowSelection="{ :rowSelection="{
selectedRowKeys: tableData._selectedRowKeys, selectedRowKeys: tableData._selectedRowKeys,
onChange:(keys:string[])=>tableData._selectedRowKeys = [...keys], onSelect: table.onSelect,
onSelectAll: table.onSelectAll,
onSelectNone: table.cancelSelect onSelectNone: table.cancelSelect
}" }"
:columns="columns" :columns="columns"
@ -384,23 +385,59 @@ const table = {
}, },
// //
onSelectChange: (row: any) => { onSelectChange: (row: any) => {
const selectedRowKeys = tableData._selectedRowKeys; const index = tableData._selectedRowKeys.indexOf(row.id);
const index = selectedRowKeys.indexOf(row.id);
if (index === -1) { if (index === -1) {
selectedRowKeys.push(row.id); tableData._selectedRowKeys.push(row.id);
tableData.selectedRows.push(row); tableData.selectedRows.push(row);
} else { } else {
selectedRowKeys.splice(index, 1); tableData._selectedRowKeys.splice(index, 1);
tableData.selectedRows.splice(index, 1); tableData.selectedRows.splice(index, 1);
} }
}, },
// //
cancelSelect: () => { cancelSelect: () => {
console.log(1111); // console.log(1111);
tableData._selectedRowKeys = []; tableData._selectedRowKeys = [];
tableData.selectedRows = []; tableData.selectedRows = [];
}, },
onSelect: (record: any, selected: boolean) => {
const arr = [...tableData._selectedRowKeys]
const _index = arr.findIndex(item => item === record?.id)
if (selected) {
if (!(_index > -1)) {
tableData._selectedRowKeys.push(record.id)
tableData.selectedRows.push(record)
}
} else {
if (_index > -1) { //
tableData._selectedRowKeys.splice(_index, 1)
tableData.selectedRows.splice(_index, 1)
}
}
},
onSelectAll: (selected: boolean, _: any[], changeRows: any) => {
if (selected) {
changeRows.map((i: any) => {
if (!tableData._selectedRowKeys.includes(i.id)) {
tableData._selectedRowKeys.push(i.id)
tableData.selectedRows.push(i)
}
})
} else {
const arr = changeRows.map((item: any) => item.id)
const _arr: string[] = [];
const _ids: string[] = [];
[...tableData.selectedRows].map((i: any) => {
if (!arr.includes(i?.id)) {
_arr.push(i)
_ids.push(i.id)
}
})
tableData._selectedRowKeys = _ids
tableData.selectedRows = _arr
}
},
// //
getData: (params: object, parentId: string) => getData: (params: object, parentId: string) =>
new Promise((resolve) => { new Promise((resolve) => {

View File

@ -150,6 +150,7 @@ const indeterminate = ref<boolean>(false);
const selectAllChange = () => { const selectAllChange = () => {
flatTableData.forEach((item) => { flatTableData.forEach((item) => {
item.granted = selectedAll.value; item.granted = selectedAll.value;
item.indeterminate = false;
item.buttons?.forEach((button) => { item.buttons?.forEach((button) => {
button.granted = selectedAll.value; button.granted = selectedAll.value;
}); });

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.18: jetlinks-ui-components@^1.0.21:
version "1.0.20" version "1.0.21"
resolved "https://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.20.tgz#ca8df39e35e99cf0e124029609a8fc25f7f97b24" resolved "https://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.21.tgz#e2dc28682db91b4b05332fb8ec76faa2a2f4dcd2"
integrity sha512-McGHwvkwEKrb1Bp9EZzpQN3YQe790fkO0Z03pGsil+bZrZ7xqiEywESZtW3MIIRWo/6u+zwNQr4L4/ohvXRCpA== integrity sha512-nlVGo2ze6e4YFPOyqS1GVCpaH9P4VGPMGYJIucTEjjMb/QqPmkwS7HcwyDX3kvb6Acb+dG5oQZlscMHIGqv0YQ==
dependencies: dependencies:
"@vueuse/core" "^9.12.0" "@vueuse/core" "^9.12.0"
"@vueuse/router" "^9.13.0" "@vueuse/router" "^9.13.0"