fix: 修改bug

This commit is contained in:
100011797 2023-07-12 11:27:09 +08:00
parent 57b5a08365
commit 47e11c4c26
8 changed files with 102 additions and 32 deletions

View File

@ -50,9 +50,19 @@ export const regDomain = new RegExp(
);
export const checkEndpoint = (_rule: Rule, value: string): Promise<any> =>
new Promise(async (resolve, reject) => {
if(!value) return resolve('');
const res: any = await validateField(value);
return res.result.passed ? resolve('') : reject(res.result.reason);
});
export const checkHost = (_rule: Rule, value: string): Promise<any> =>
new Promise(async (resolve, reject) => {
if(!value) return resolve('');
if(!(regIP.test(value) || regIPv6.test(value) || regDomain.test(value))) {
return reject('请输入正确格式的Modbus主机IP地址')
}
return resolve('')
});
export const FormValidate = {
name: [
{ required: true, message: '请输入名称', trigger: 'blur' },
@ -65,8 +75,9 @@ export const FormValidate = {
message: '请输入Modbus主机IP',
},
{
pattern: regIP || regIPv6 || regDomain,
message: '请输入正确格式的Modbus主机IP地址',
validator: checkHost,
trigger: 'blur',
// message: '请输入正确格式的Modbus主机IP地址',
},
],
port: [

View File

@ -73,7 +73,7 @@
</j-tooltip>
</div>
</j-col>
<j-col :span="12">
<!-- <j-col :span="12">
<div class="card-item-content-text">
地址
</div>
@ -98,6 +98,14 @@
>
</j-tooltip>
</div>
</j-col> -->
<j-col :span="12">
<div class="card-item-content-text">
说明
</div>
<div class="card-item-content-text">
<j-ellipsis>{{slotProps.description}}</j-ellipsis>
</div>
</j-col>
</j-row>
</div>

View File

@ -4,9 +4,9 @@
<div style="display: flex; padding-bottom: 24px; margin-bottom: 24px; border-bottom: 1px solid #E4E7F6">
<j-avatar :size="100" :src="userInfos.avatar"></j-avatar>
<div style="margin-left: 24px;">
<div class="name">{{ userInfos.name }}</div>
<div class="subTitle">用户名: {{ userInfos?.username }}</div>
<div class="subTitle">账号ID: {{ userInfos?.id }}</div>
<div class="name"><j-ellipsis>{{ userInfos.name }}</j-ellipsis></div>
<div class="subTitle"><j-ellipsis>用户名: {{ userInfos?.username }}</j-ellipsis></div>
<!-- <div class="subTitle">账号ID: {{ userInfos?.id }}</div> -->
</div>
</div>
<j-descriptions
@ -69,10 +69,10 @@ const org = computed(() => {
color: #1D2129;
font-weight: 500;
font-size: 26px;
margin: 15px 0 10px 0;
}
.subTitle {
color: rgba(0, 0, 0, 0.6);
margin-top: 5px;
}
</style>

View File

@ -10,7 +10,11 @@
@cancel="_vis = false"
:confirmLoading="loading"
>
<pro-search :columns="columns" target="media-bind" @search="handleSearch" />
<pro-search
:columns="columns"
target="media-bind"
@search="handleSearch"
/>
<JProTable
ref="listRef"
@ -38,7 +42,9 @@
:params="params"
:rowSelection="{
selectedRowKeys: _selectedRowKeys,
onChange: onSelectChange,
onSelectNone: onSelectNone,
onSelect: onSelect,
onSelectAll: onAllSelect,
}"
:pagination="{
showSizeChanger: true,
@ -103,6 +109,7 @@ const columns = [
title: '设备名称',
dataIndex: 'deviceName',
key: 'deviceName',
ellipsis: true,
search: {
type: 'string',
},
@ -111,6 +118,7 @@ const columns = [
title: '通道名称',
dataIndex: 'name',
key: 'name',
ellipsis: true,
search: {
type: 'string',
first: true,
@ -120,6 +128,7 @@ const columns = [
title: '安装地址',
dataIndex: 'address',
key: 'address',
ellipsis: true,
search: {
type: 'string',
},
@ -128,6 +137,7 @@ const columns = [
title: '厂商',
dataIndex: 'manufacturer',
key: 'manufacturer',
ellipsis: true,
search: {
type: 'string',
},
@ -163,8 +173,31 @@ const handleSearch = (e: any) => {
const listRef = ref();
const _selectedRowKeys = ref<string[]>([]);
const onSelectChange = (keys: string[]) => {
_selectedRowKeys.value = [...keys];
const onSelectNone = () => {
_selectedRowKeys.value = [];
};
const onSelect = (record: any, selected: boolean) => {
const _set = new Set([..._selectedRowKeys.value])
if (selected) {
_set.add(record.id)
} else {
_set.delete(record.id)
}
_selectedRowKeys.value = [..._set]
};
const onAllSelect = (selected: boolean, _: any, keys: any[]) => {
const _keys = keys.map(item => item.id) || []
const _set = new Set([..._selectedRowKeys.value])
_keys.map((i: any) => {
if(selected) {
_set.add(i)
} else {
_set.delete(i)
}
});
_selectedRowKeys.value = [..._set]
};
const loading = ref(false);

View File

@ -168,6 +168,7 @@ const columns = [
key: 'deviceName',
// width: 200,
// fixed: 'left',
ellipsis: true,
search: {
type: 'string',
},
@ -175,6 +176,7 @@ const columns = [
{
title: '通道名称',
dataIndex: 'name',
ellipsis: true,
key: 'name',
search: {
type: 'string',
@ -185,6 +187,7 @@ const columns = [
title: '国标ID',
dataIndex: 'channelId',
key: 'channelId',
ellipsis: true,
scopedSlots: true,
headerCell: 'gbChannelIdHeader', //
search: {
@ -195,6 +198,7 @@ const columns = [
title: '安装地址',
dataIndex: 'address',
key: 'address',
ellipsis: true,
search: {
type: 'string',
},
@ -203,6 +207,7 @@ const columns = [
title: '厂商',
dataIndex: 'manufacturer',
key: 'manufacturer',
ellipsis: true,
search: {
type: 'string',
},

View File

@ -56,16 +56,20 @@
{{ slotProps.name }}
</h3>
<p>通道数量{{ slotProps.count || 0 }}</p>
<Ellipsis>
<j-badge
:text="`sip:${slotProps.sipConfigs[0]?.sipId}@${slotProps.sipConfigs[0]?.hostAndPort}`"
:status="
slotProps.status?.value === 'enabled'
? 'success'
: 'error'
"
/>
</Ellipsis>
<j-badge
:status="
slotProps.status?.value === 'enabled'
? 'success'
: 'error'
"
style="display: flex; align-items: center;"
>
<template #text>
<j-ellipsis>
{{ `sip:${slotProps.sipConfigs[0]?.sipId}@${slotProps.sipConfigs[0]?.hostAndPort}` }}
</j-ellipsis>
</template>
</j-badge>
</template>
<template #actions="item">
<PermissionButton
@ -170,6 +174,7 @@ const columns = [
key: 'name',
width: 200,
fixed: 'left',
ellipsis: true,
search: {
type: 'string',
},
@ -179,12 +184,14 @@ const columns = [
dataIndex: 'sipId',
key: 'sipId',
scopedSlots: true,
ellipsis: true,
},
{
title: '上级SIP 地址',
dataIndex: 'publicHost',
key: 'publicHost',
scopedSlots: true,
ellipsis: true,
},
{
title: '通道数量',

View File

@ -158,6 +158,7 @@ const columns = [
title: '通道ID',
dataIndex: 'channelId',
key: 'channelId',
ellipsis: true,
search: {
type: 'string',
},
@ -166,6 +167,7 @@ const columns = [
title: '名称',
dataIndex: 'name',
key: 'name',
ellipsis: true,
search: {
type: 'string',
first: true,
@ -175,6 +177,7 @@ const columns = [
title: '厂商',
dataIndex: 'manufacturer',
key: 'manufacturer',
ellipsis: true,
search: {
type: 'string',
},
@ -182,6 +185,7 @@ const columns = [
{
title: '安装地址',
dataIndex: 'address',
ellipsis: true,
key: 'address',
search: {
type: 'string',
@ -206,6 +210,7 @@ const columns = [
{
title: '操作',
key: 'action',
width: 200,
scopedSlots: true,
},
];

View File

@ -3,12 +3,11 @@
<div class="table">
<j-pro-table
:columns="columns"
:dataSource="props.tableData"
:dataSource="_tableData"
:rowSelection="props.mode !== 'home' ? rowSelection : undefined"
noPagination
model="TABLE"
>
<!-- :rowKey="(record) => record.id + record.method" -->
<template #url="slotProps">
<span
style="color: #1d39c4; cursor: pointer"
@ -39,6 +38,7 @@ import {
import { modeType } from '../typing';
import { useDepartmentStore } from '@/store/department';
import { onlyMessage } from '@/utils/comm';
import { uniqBy } from 'lodash-es';
const department = useDepartmentStore();
const emits = defineEmits([
@ -70,8 +70,8 @@ const columns = [
},
];
watchEffect(() => {
console.log(props.tableData)
const _tableData = computed(() => {
return uniqBy(props.tableData, 'id') || []
})
const rowSelection = {
@ -91,9 +91,10 @@ const rowSelection = {
// });
// }
// },
onChange: (keys: string[]) => {
onChange: (keys: string[], _data: any[]) => {
const _keys = _data.map(i => i.id)
// id
const currenTableKeys = props.tableData.map((m: any) => m.id);
const currenTableKeys = _tableData.value.map((m: any) => m.id);
// , id
const oldSelectedKeys = currenTableKeys.filter((key) =>
props.sourceKeys.includes(key),
@ -104,16 +105,16 @@ const rowSelection = {
);
//
const removeKeys = oldSelectedKeys.filter((key) => !keys.includes(key));
const removeKeys = oldSelectedKeys.filter((key) => !_keys.includes(key));
//
const addKeys = keys.filter((key) => !oldSelectedKeys.includes(key));
const addKeys = _keys.filter((key) => !oldSelectedKeys.includes(key));
//
emits('update:selectedRowKeys', [...otherSelectedKeys, ...keys]);
emits('update:selectedRowKeys', [...otherSelectedKeys, ..._keys]);
// /
const changed = {};
[...addKeys, ...removeKeys].forEach((key: string) => {
changed[key] = props.tableData.find((f: any) => f.id === key);
changed[key] = _tableData.value.find((f: any) => f.id === key);
});
if (props.mode === 'appManger') {
//
@ -178,7 +179,7 @@ watch(
() => props.selectedRowKeys,
(n) => {
// console.log('props.selectedRowKeys: ', n);
rowSelection.selectedRowKeys.value = n;
rowSelection.selectedRowKeys.value = n
},
);
</script>