fix: 修复Sample菜单下的Sample列表存在的问题

This commit is contained in:
Xu Zhimeng 2023-09-27 15:38:36 +08:00
parent 0c06c5af79
commit e7533a7fe2
3 changed files with 25 additions and 20 deletions

View File

@ -37,6 +37,7 @@
import { JeecgListMixin } from '@/mixins/JeecgListMixin' import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '../../../../api/manage' import { getAction } from '../../../../api/manage'
import moment from 'moment' import moment from 'moment'
import { cloneDeep } from 'lodash'
const columns = [ const columns = [
{ {
@ -201,7 +202,7 @@ export default {
} }
this.selectedRowKeys = [] this.selectedRowKeys = []
this.visible = false this.visible = false
this.$emit('loadSample', this.selectionRows) this.$emit('loadSample', cloneDeep(this.selectionRows))
}, },
// //

View File

@ -1,11 +1,16 @@
<template> <template>
<a-menu class="spectra-list-in-menu"> <a-menu class="spectra-list-in-menu">
<a-menu-item class="spectra-list-in-menu-item" v-for="(item,index) in list" :key="`${item.sampleId}${index}`" @click="handleClick(item)"> <a-menu-item
class="spectra-list-in-menu-item"
v-for="(item, index) in list"
:key="`${item.sampleId}${index}`"
@click="handleClick(item)"
>
<span class="checkbox"> <span class="checkbox">
<a-icon v-if="item.checked" type="check" style="color: #0de30d" /> <a-icon v-if="item.checked" type="check" style="color: #0de30d" />
</span> </span>
<span class="name">{{ item.inputFileName }}</span> <span class="name">{{ item.inputFileName }}</span>
<a-icon type="delete" @click.stop="handleRemove(item)" /> <a-icon type="delete" @click.stop="handleRemove(item, index)" />
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
</template> </template>
@ -26,25 +31,25 @@ export default {
this.$forceUpdate() this.$forceUpdate()
}, },
handleRemove(spectraItem) { handleRemove(spectraItem, index) {
const index = this.list.findIndex(item => item == spectraItem)
this.list.splice(index, 1)
// //
if (spectraItem.checked) { if (spectraItem.checked) {
if (index == 0) { // //
// if (index == this.list.length - 1) {
this.handleClick(this.list[0])
} else {
//
this.handleClick(this.list[index - 1]) this.handleClick(this.list[index - 1])
} }
//
else {
this.handleClick(this.list[index + 1])
} }
}
this.list.splice(index, 1)
this.$forceUpdate() this.$forceUpdate()
} }
}, },
watch: { watch: {
list(newVal) { list(newVal) {
if (newVal.length) { if (newVal.length && !newVal.find(item => item.checked)) {
this.handleClick(newVal[0]) this.handleClick(newVal[0])
} }
} }

View File

@ -382,12 +382,12 @@ export default {
}, },
created() { created() {
this.$bus.$on('reanalyse', this.handleReanalyse) this.$bus.$on('reanalyse', this.handleReanalyse)
this.loadSelectedSample({ // this.loadSelectedSample({
sampleId: 426530, // sampleId: 426530,
sampleType: 'G', // sampleType: 'G',
dbName: 'auto', // dbName: 'auto',
inputFileName: 'CAX05_001-20230731_1528_S_FULL_37563.6.PHD', // inputFileName: 'CAX05_001-20230731_1528_S_FULL_37563.6.PHD',
}) // })
}, },
destroyed() { destroyed() {
@ -679,8 +679,7 @@ export default {
if (spectra) { if (spectra) {
this.loadSelectedSample(spectra) this.loadSelectedSample(spectra)
} else { } else {
this.analysisType = undefined this.handleCleanAll()
this.sampleData = {}
} }
}, },
}, },