Skip to content

Commit

Permalink
fix: 修复资源管理器单选模式下选择后无法取消的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
kanyxmo committed Apr 16, 2024
1 parent 41b913c commit 44285c5
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/components/ma-resource/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
import uploadConfig from '@/config/upload'
import MaTreeSlider from '@cps/ma-treeSlider/index.vue'
import commonApi from '@/api/common'
import { xor } from 'lodash'
import tool from '@/utils/tool'
import { useI18n } from 'vue-i18n'
import { Message } from '@arco-design/web-vue'
Expand Down Expand Up @@ -162,32 +163,30 @@

const selectFile = (item, index) => {

if ( ! props.multiple && selecteds.value ) {
if (props.onlyData && item.url != selecteds.value) return
if (! props.onlyData && item.id != selecteds.value.id) return
}

const children = rl.value.children
const className = 'item rounded-sm'

if (! /^(http|https)/g.test(item.url)) {
item.url = tool.attachUrl(item.url, getStoreMode(item.storage_mode))
}
if (children[index].className.indexOf('active') !== -1) {
children[index].className = className
if (props.multiple) {
selecteds.value.map((file, idx) => {
if (props.onlyData && file == item.url) selecteds.value.splice(idx, 1)
if (! props.onlyData && file.id == item.id) selecteds.value.splice(idx, 1)
selecteds.value.splice(idx, 1)
})
} else {
selecteds.value = ''
}
} else {
children[index].className = className + ' active'
if (props.multiple) {
children[index].className = className + ' active'
selecteds.value.push(props.onlyData ? item[props.returnType] : item)
} else {
selecteds.value = props.onlyData ? item[props.returnType] : item
if (document.querySelectorAll('.item.active').length < 1) {
children[index].className = className + ' active'
selecteds.value = props.onlyData ? item[props.returnType] : item
}
}
}
}
Expand Down

0 comments on commit 44285c5

Please sign in to comment.