Skip to content

Commit 834ba1f

Browse files
committed
[opt]:opt cani channel choose
1 parent e84c311 commit 834ba1f

File tree

2 files changed

+87
-71
lines changed

2 files changed

+87
-71
lines changed

src/main/docan/toomoss/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ export class TOOMOSS_CAN extends CanBase {
303303
}
304304

305305
callbackError(err: any) {
306-
console.log('callbackError', err)
307306
this.log.error(getTsUs() - this.startTime, 'bus error')
308307
this.close(true)
309308
}

src/renderer/src/views/uds/cani.vue

Lines changed: 87 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
style="width: 65px;margin-right: 5px;margin-bottom: 5px"
198198
@input="dataChange(index - 1, $event)" @change="dataChangeDone"><template #prepend>{{
199199
index - 1
200-
}}</template></el-input>
200+
}}</template></el-input>
201201
</div>
202202
</el-tab-pane>
203203

@@ -276,7 +276,75 @@ const speicalDb = computed(() => {
276276
}
277277
return list
278278
})
279+
const props = defineProps<{
280+
height: number
281+
editIndex: string
282+
283+
}>()
284+
// const start = toRef(props, 'start')
285+
const h = toRef(props, 'height')
286+
const editIndex = toRef(props, 'editIndex')
287+
const dataBase = useDataStore()
288+
const gridOptions = computed(() => {
289+
const v: VxeGridProps<CanInterAction> = {
290+
border: true,
291+
size: "mini",
292+
columnConfig: {
293+
resizable: true,
294+
},
295+
height: props.height,
296+
showOverflow: true,
297+
scrollY: {
298+
enabled: true,
299+
gt: 0
300+
},
301+
rowConfig: {
302+
isCurrent: true,
279303
304+
},
305+
editConfig: {
306+
trigger: 'click',
307+
mode: 'cell',
308+
showIcon: false,
309+
beforeEditMethod({ rowIndex, column, row }) {
310+
if (periodTimer.value[rowIndex] == true) {
311+
return false
312+
}
313+
if (column.field == 'name' && row.database != undefined) {
314+
return false
315+
}
316+
return true
317+
}
318+
},
319+
toolbarConfig: {
320+
slots: {
321+
tools: 'toolbar'
322+
}
323+
},
324+
align: 'center',
325+
columns: [
326+
{
327+
type: "seq",
328+
width: 50,
329+
title: "",
330+
align: "center",
331+
fixed: "left",
332+
resizable: false,
333+
},
334+
{ field: 'send', title: 'Send', width: 100, resizable: false, slots: { default: 'default_send' } },
335+
{ field: 'trigger', title: 'Trigger', width: 200, resizable: false, slots: { default: 'default_trigger' } },
336+
{ field: 'name', title: 'Name', width: 100, editRender: {}, slots: { edit: 'default_name' } },
337+
{ field: 'id', title: 'ID (HEX)', minWidth: 100, editRender: {}, slots: { edit: 'default_id' } },
338+
{ field: 'channel', title: 'Channel', minWidth: 100, editRender: {}, slots: { default: 'default_channel', edit: 'edit_channel' } },
339+
{ field: 'type', title: 'Type', width: 100, editRender: {}, slots: { default: 'default_type1', edit: 'default_type' } },
340+
{ field: 'dlc', title: 'DLC', width: 100, editRender: {}, slots: { edit: 'default_dlc' } },
341+
342+
],
343+
data: dataBase.ia[props.editIndex]?.action || []
344+
345+
}
346+
return v
347+
})
280348
function addFrame() {
281349
const channel = Object.keys(devices.value)[0] || ''
282350
dataBase.ia[editIndex.value].action.push({
@@ -441,19 +509,35 @@ const devices = computed(() => {
441509
const dd: Record<string, CanBaseInfo> = {}
442510
for (const d in dataBase.devices) {
443511
if (dataBase.devices[d] && dataBase.devices[d].type == 'can' && dataBase.devices[d].canDevice) {
444-
dd[d] = dataBase.devices[d].canDevice
512+
if (dataBase.ia[editIndex.value].devices.includes(d)) {
513+
dd[d] = dataBase.devices[d].canDevice
514+
}
515+
445516
446517
447518
}
448519
449520
}
450521
return dd
451522
})
523+
watch(devices, (val) => {
524+
//check channel
525+
const action = dataBase.ia[editIndex.value].action as CanInterAction[]
526+
const list = Object.keys(val)
527+
for (const a of action) {
528+
if (!list.includes(a.channel)) {
529+
530+
a.channel = ''
531+
}
532+
533+
}
534+
})
452535
interface Option {
453536
key: string
454537
label: string
455538
disabled: boolean
456539
}
540+
457541
const allDeviceLabel = computed(() => {
458542
const dd: Option[] = []
459543
for (const d of Object.keys(devices.value)) {
@@ -485,15 +569,9 @@ function openPr(index: number) {
485569
}
486570
487571
}
488-
const props = defineProps<{
489-
height: number
490-
editIndex: string
491572
492-
}>()
493-
// const start = toRef(props, 'start')
494-
const h = toRef(props, 'height')
495573
watch(formData, (v) => {
496-
v=cloneDeep(v)
574+
v = cloneDeep(v)
497575
if (v && popoverIndex.value != -1) {
498576
if (!isEqual(dataBase.ia[editIndex.value].action[popoverIndex.value], v)) {
499577
Object.assign(dataBase.ia[editIndex.value].action[popoverIndex.value], v)
@@ -506,68 +584,7 @@ watch(formData, (v) => {
506584
}, {
507585
deep: true
508586
})
509-
const editIndex = toRef(props, 'editIndex')
510-
const dataBase = useDataStore()
511-
const gridOptions = computed(() => {
512-
const v: VxeGridProps<CanInterAction> = {
513-
border: true,
514-
size: "mini",
515-
columnConfig: {
516-
resizable: true,
517-
},
518-
height: props.height,
519-
showOverflow: true,
520-
scrollY: {
521-
enabled: true,
522-
gt: 0
523-
},
524-
rowConfig: {
525-
isCurrent: true,
526587
527-
},
528-
editConfig: {
529-
trigger: 'click',
530-
mode: 'cell',
531-
showIcon: false,
532-
beforeEditMethod({ rowIndex, column, row }) {
533-
if (periodTimer.value[rowIndex] == true) {
534-
return false
535-
}
536-
if (column.field == 'name' && row.database != undefined) {
537-
return false
538-
}
539-
return true
540-
}
541-
},
542-
toolbarConfig: {
543-
slots: {
544-
tools: 'toolbar'
545-
}
546-
},
547-
align: 'center',
548-
columns: [
549-
{
550-
type: "seq",
551-
width: 50,
552-
title: "",
553-
align: "center",
554-
fixed: "left",
555-
resizable: false,
556-
},
557-
{ field: 'send', title: 'Send', width: 100, resizable: false, slots: { default: 'default_send' } },
558-
{ field: 'trigger', title: 'Trigger', width: 200, resizable: false, slots: { default: 'default_trigger' } },
559-
{ field: 'name', title: 'Name', width: 100, editRender: {}, slots: { edit: 'default_name' } },
560-
{ field: 'id', title: 'ID (HEX)', minWidth: 100, editRender: {}, slots: { edit: 'default_id' } },
561-
{ field: 'channel', title: 'Channel', minWidth: 100, editRender: {}, slots: { default: 'default_channel', edit: 'edit_channel' } },
562-
{ field: 'type', title: 'Type', width: 100, editRender: {}, slots: { default: 'default_type1', edit: 'default_type' } },
563-
{ field: 'dlc', title: 'DLC', width: 100, editRender: {}, slots: { edit: 'default_dlc' } },
564-
565-
],
566-
data: dataBase.ia[props.editIndex]?.action || []
567-
568-
}
569-
return v
570-
})
571588
572589
573590

0 commit comments

Comments
 (0)