mirror of
https://github.com/silenty4ng/k5web
synced 2025-04-19 08:39:56 +00:00
update
This commit is contained in:
parent
e2a31dc4ef
commit
8c969dcaaf
5 changed files with 288 additions and 1 deletions
src
|
@ -150,6 +150,9 @@ export default {
|
|||
'image.negative': 'Negative',
|
||||
'workplace.clickNotice': ' (Official firmware can only detect 8KB/64Kbit)',
|
||||
'menu.cps.radio': 'Radio',
|
||||
'menu.cps.mdc': 'MDC Contact',
|
||||
'cps.contact': 'Name',
|
||||
'cps.mdcid': 'MDC ID',
|
||||
...localeSettings,
|
||||
...localeMessageBox,
|
||||
...localeLogin,
|
||||
|
|
|
@ -150,6 +150,9 @@ export default {
|
|||
'image.negative': '反色',
|
||||
'workplace.clickNotice': '(官方固件只能检测 8KB/64Kbit)',
|
||||
'menu.cps.radio': '收音机',
|
||||
'menu.cps.mdc': 'MDC 联系人',
|
||||
'cps.contact': '联系人',
|
||||
'cps.mdcid': 'MDC ID',
|
||||
...localeSettings,
|
||||
...localeMessageBox,
|
||||
...localeLogin,
|
||||
|
|
|
@ -42,6 +42,16 @@ const DASHBOARD: AppRouteRecordRaw = {
|
|||
roles: ['*'],
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'mdc',
|
||||
name: 'Mdc',
|
||||
component: () => import('@/views/list/mdc/index.vue'),
|
||||
meta: {
|
||||
locale: 'menu.cps.mdc',
|
||||
requiresAuth: true,
|
||||
roles: ['*'],
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'settings',
|
||||
name: 'Settings',
|
||||
|
|
271
src/views/list/mdc/index.vue
Normal file
271
src/views/list/mdc/index.vue
Normal file
|
@ -0,0 +1,271 @@
|
|||
<template>
|
||||
<div class="container">
|
||||
<Breadcrumb :items="[$t('menu.dashboard'), $t('menu.cps.mdc')]" />
|
||||
<a-card class="general-card">
|
||||
<template #title>
|
||||
<span @click="()=>{istate.showHide += 1}">{{ $t('menu.cps.mdc') + $t('global.onStart') }}</span>
|
||||
</template>
|
||||
<a-row style="margin-bottom: 16px">
|
||||
<a-col :span="12">
|
||||
<a-space>
|
||||
<a-button type="primary" @click="readChannel">
|
||||
<template #icon>
|
||||
<icon-plus />
|
||||
</template>
|
||||
{{ $t('cps.onDeviceRead') }}
|
||||
</a-button>
|
||||
<a-button @click="writeChannel">
|
||||
<template #icon>
|
||||
<icon-plus />
|
||||
</template>
|
||||
{{ $t('cps.onDeviceWrite') }}
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<t-table
|
||||
class="ttable"
|
||||
:loading="loading"
|
||||
size="medium"
|
||||
:columns="columns"
|
||||
:data="cstate.renderData"
|
||||
:pagination="{
|
||||
defaultPageSize: cstate.pageSize,
|
||||
total: cstate.renderData.length,
|
||||
defaultCurrent: 1,
|
||||
pageSizeOptions: [15, 30, 50, 100, 200]
|
||||
}"
|
||||
@change="(e: any)=>{cstate.pageSize = e.pagination.pageSize, cstate.nowPage = e.pagination.current}"
|
||||
bordered
|
||||
lazy-load
|
||||
:headerAffixedTop="{ offsetTop: 60 }"
|
||||
:hover="true"
|
||||
drag-sort="row-handler"
|
||||
@drag-sort="onDragSort"
|
||||
>
|
||||
<template #drag="{ row, rowIndex }">
|
||||
<span>
|
||||
<MoveIcon />
|
||||
</span>
|
||||
</template>
|
||||
<template #index="{ row, rowIndex }">
|
||||
{{ (cstate.nowPage - 1) * cstate.pageSize + rowIndex + 1 }}
|
||||
</template>
|
||||
<template #operate="{ row, rowIndex }">
|
||||
<t-button theme="default" variant="dashed" @click="clearRow((cstate.nowPage - 1) * cstate.pageSize + rowIndex)">{{ $t('cps.clear') }}</t-button>
|
||||
</template>
|
||||
</t-table>
|
||||
</a-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, reactive, watch } from 'vue';
|
||||
import { Input } from 'tdesign-vue-next';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import { eeprom_read, uint8ArrayToHexReverseString, hexReverseStringToUint8Array, stringToUint8Array, uint8ArrayToString, eeprom_write, eeprom_reboot, eeprom_init } from '@/utils/serial.js';
|
||||
import { useAppStore } from '@/store';
|
||||
import { MoveIcon } from 'tdesign-icons-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
const { t } = useI18n();
|
||||
|
||||
const appStore = useAppStore();
|
||||
|
||||
const { loading, setLoading } = useLoading(false);
|
||||
|
||||
const cstate : {
|
||||
renderData: any[],
|
||||
pageSize: number,
|
||||
nowPage: number
|
||||
} = reactive({
|
||||
renderData: Array.from({length: 16}).map(e=>{return {}}),
|
||||
pageSize: 16,
|
||||
nowPage: 1,
|
||||
})
|
||||
|
||||
const istate = reactive({
|
||||
showHide: 0
|
||||
})
|
||||
|
||||
const onDragSort = (params: any) => {
|
||||
cstate.renderData = params.newData
|
||||
}
|
||||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
colKey: 'drag', // 列拖拽排序必要参数
|
||||
title: t('cps.sort'),
|
||||
width: 46,
|
||||
},
|
||||
{
|
||||
title: '#',
|
||||
colKey: 'index',
|
||||
align: 'left',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: t('cps.contact'),
|
||||
colKey: 'name',
|
||||
width: 250,
|
||||
align: 'left',
|
||||
cell: (h, { row }) => row.name ? row.name.replace(/[^a-z0-9_]/g, '') : undefined,
|
||||
edit: {
|
||||
component: Input,
|
||||
props: {
|
||||
clearable: true
|
||||
},
|
||||
onEdited: (context: any) => {
|
||||
const newData = [...cstate.renderData];
|
||||
newData.splice((cstate.nowPage - 1) * cstate.pageSize + context.rowIndex, 1, context.newRowData);
|
||||
cstate.renderData = newData;
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('cps.mdcid'),
|
||||
colKey: 'mdcid',
|
||||
align: 'left',
|
||||
width: 200,
|
||||
cell: (h, { row }) => parseInt(row.mdcid, 16) <= 65535 ? parseInt(row.mdcid, 16).toString(16) : undefined,
|
||||
edit: {
|
||||
component: Input,
|
||||
props: {
|
||||
clearable: true
|
||||
},
|
||||
onEdited: (context: any) => {
|
||||
context.newRowData.mdcid = context.newRowData.mdcid ? context.newRowData.mdcid : undefined
|
||||
const newData = [...cstate.renderData];
|
||||
newData.splice((cstate.nowPage - 1) * cstate.pageSize + context.rowIndex, 1, context.newRowData);
|
||||
cstate.renderData = newData;
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('cps.operate'),
|
||||
colKey: 'operate',
|
||||
align: 'left',
|
||||
width: 150
|
||||
}
|
||||
]);
|
||||
|
||||
const readChannel = async() => {
|
||||
if(appStore.connectState != true){alert(sessionStorage.getItem('noticeConnectK5')); return;};
|
||||
await eeprom_init(appStore.connectPort);
|
||||
setLoading(true)
|
||||
let rawEEPROM = new Uint8Array(0x100);
|
||||
for (let i = 0x1D00; i < 0x1E00; i += 0x10) {
|
||||
const _data = await eeprom_read(appStore.connectPort, i, 0x10, appStore.configuration?.uart)
|
||||
rawEEPROM.set(_data, i - 0x1D00)
|
||||
}
|
||||
const _renderData : any = [];
|
||||
for (let i = 0; i < 0x100; i += 0x10) {
|
||||
if(uint8ArrayToHexReverseString(rawEEPROM.subarray(i, i + 0x02)) != 'ffff'){
|
||||
_renderData.push({
|
||||
name: uint8ArrayToString(rawEEPROM.subarray(i + 0x02, i + 0x10), appStore.configuration?.charset),
|
||||
mdcid: uint8ArrayToHexReverseString(rawEEPROM.subarray(i, i + 0x02))
|
||||
})
|
||||
}else{
|
||||
_renderData.push({})
|
||||
}
|
||||
}
|
||||
cstate.renderData = _renderData;
|
||||
setLoading(false)
|
||||
}
|
||||
const writeChannel = async() =>{
|
||||
if(appStore.connectState != true){alert(sessionStorage.getItem('noticeConnectK5')); return;};
|
||||
await eeprom_init(appStore.connectPort);
|
||||
setLoading(true)
|
||||
for (let i = 0; i < 0x100; i += 0x10) {
|
||||
if(cstate.renderData[i / 0x10].mdcid){
|
||||
const _data = new Uint8Array(0x10).fill(0x20)
|
||||
_data.set(hexReverseStringToUint8Array(cstate.renderData[i / 0x10].mdcid.padStart(4, '0')))
|
||||
_data.set(stringToUint8Array(cstate.renderData[i / 0x10].name), 0x02)
|
||||
await eeprom_write(
|
||||
appStore.connectPort,
|
||||
i + 0x1D00,
|
||||
_data,
|
||||
0x10,
|
||||
appStore.configuration?.uart
|
||||
);
|
||||
}else{
|
||||
await eeprom_write(
|
||||
appStore.connectPort,
|
||||
i + 0x1D00,
|
||||
hexReverseStringToUint8Array('ffffffffffffffffffffffffffffffff'),
|
||||
0x10,
|
||||
appStore.configuration?.uart
|
||||
);
|
||||
}
|
||||
}
|
||||
const _tmp = await eeprom_read(appStore.connectPort, 0x1FF0, 0x10, appStore.configuration?.uart)
|
||||
_tmp.set([0x10], 0x10 - 1)
|
||||
await eeprom_write(
|
||||
appStore.connectPort,
|
||||
0x1FF0,
|
||||
_tmp,
|
||||
0x10,
|
||||
appStore.configuration?.uart
|
||||
);
|
||||
await eeprom_reboot(appStore.connectPort);
|
||||
setLoading(false)
|
||||
}
|
||||
const clearRow = async (row: any) =>{
|
||||
const newData = [...cstate.renderData];
|
||||
newData.splice(row, 1, {scanlist: []});
|
||||
cstate.renderData = newData;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'Radio',
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
:deep(::-webkit-scrollbar-thumb){
|
||||
border-radius: 0 !important;
|
||||
}
|
||||
:deep(.scrollbar::-webkit-scrollbar) {
|
||||
height: 10px;
|
||||
}
|
||||
:deep(.t-table__content::-webkit-scrollbar) {
|
||||
height: 15px;
|
||||
}
|
||||
.container {
|
||||
padding: 0 20px 20px 20px;
|
||||
}
|
||||
:deep(.arco-table-th) {
|
||||
&:last-child {
|
||||
.arco-table-th-item-title {
|
||||
margin-left: 16px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.action-icon {
|
||||
margin-left: 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.active {
|
||||
color: #0960bd;
|
||||
background-color: #e3f4fc;
|
||||
}
|
||||
.setting {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 200px;
|
||||
.title {
|
||||
margin-left: 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
.ttable {
|
||||
:deep(.t-table__affixed-header-elm-wrap){
|
||||
height: 60px !important;
|
||||
}
|
||||
:deep(.t-table__content){
|
||||
scrollbar-width: auto !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -91,7 +91,7 @@
|
|||
pageSize: number,
|
||||
nowPage: number
|
||||
} = reactive({
|
||||
renderData: Array.from({length: 20}).map(e=>{return {scanlist: []}}),
|
||||
renderData: Array.from({length: 20}).map(e=>{return {}}),
|
||||
pageSize: 50,
|
||||
nowPage: 1,
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue