<template>
<div class="isShowSelectScene" style="width: 100%;height: 100%;">
<a-table
v-if="ishowTable"
:columns="sceneColumns"
:data-source="sceneData"
:rowKey="(record) => record.sceneId"
bordered
:row-selection="rowSelection"
>
<!--場(chǎng)景類(lèi)別-->
<template #type="{ record }">
<span v-if="record.type == 1">設(shè)備級(jí)</span>
<span v-else-if="record.type == 2">
系統(tǒng)級(jí)
</span>
<span v-else>
分系統(tǒng)級(jí)
</span>
</template>
<!--場(chǎng)景內(nèi)容-->
<template #sceneContent="{ record }">
<span
style="display: inline-block;width: 140px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
{{record.sceneContent}}
</span>
</template>
</a-table>
</div>
</template>
<script setup>
import {computed, defineEmits, defineExpose, defineProps, onMounted, ref} from 'vue';
import {getSceneListApi} from "../../../../../../common/api/scene/sceneApi.js"
// 接收父組件傳遞的方法
let myEmit = defineEmits(['changeSelectSonSceneId'])
let isShowSelectScene = ref(true)
const sceneColumns = [
{
title: '場(chǎng)景名稱(chēng)',
dataIndex: 'sceneName',
key: 'sceneName',
// width:'20%',
// slots: {
// title: 'customTitle',
// customRender: 'name',
// },
},
{
title: '場(chǎng)景類(lèi)別',
dataIndex: 'type',
key: 'type',
slots: {customRender: 'type'},
// width:'10%',
},
{
title: '場(chǎng)景內(nèi)容',
key: 'sceneContent',
dataIndex: 'sceneContent',
width: '20%',
slots: {customRender: 'sceneContent'},
},
{
title: '創(chuàng)建人',
dataIndex: 'createUserName',
key: 'createUserName',
// width:'10%',
},
{
title: '創(chuàng)建時(shí)間',
key: 'createTime',
dataIndex: 'createTime',
// width:'20%',
}
]
let sceneData = ref([])
let dataListSelectionKeys = ref([])
let selectOnSelectChange = (selectedRowKeys, selectedRows) => {
myEmit('changeSelectSonSceneId', selectedRowKeys)
// props.currentSelectSonSceneId = selectedRowKeys
// console.log(props.currentSelectSonSceneId)
}
onMounted(() => {
let apiData = {
treeType: '0',
type:'3'
}
getSceneList(apiData)
})
let getSceneList = (apiData) => {
apiData.treeType = apiData.treeType === '0' ? '' : apiData.treeType
getSceneListApi(apiData).then(res => {
sceneData.value = res.data
})
}
// 編輯調(diào)用
let toFatherMethod = (record) => {
}
// 暴露給父組件的值
defineExpose({isShowSelectScene, toFatherMethod})
// 暴露給父組件的方法
// 接收父組件的值
let props = defineProps(
{
selectDeptData: {
type: Object,
default: () => {
}
},
ishowTable:{
type:Boolean,
default:()=>true
},
nowSelectLevel: {
type: String,
default: () => ""
},
currentSelectSonSceneId: {
type: Array,
default: () => []
},
defaultChecked: {
type: String,
default: () => ''
}
}
)
// 接收父組件傳遞的方法
// let myEmit = defineEmits(['getSceneList'])
let submitSceneInfo = () => {
}
const rowSelection = computed(() => {
return {
type: 'radio', // 是否為單選
// 設(shè)置了這個(gè)屬性便無(wú)法選中
// selectedRowKeys: dataListSelectionKeys,
onChange: (selectedRowKeys, selectedRows, event) => {
//selectedRowKeys 為你點(diǎn)擊選框時(shí)這一頁(yè)選中的所有key
//selectedRows 為你點(diǎn)擊選框時(shí)這一頁(yè)選中的所有數(shù)據(jù)
myEmit('changeSelectSonSceneId', selectedRowKeys)
// props.currentSelectSonSceneId = selectedRowKeys
// 是個(gè)數(shù)組
},
onSelect: (record, selected, selectedRows, nativeEvent) => {
//record 點(diǎn)擊某一條的所有數(shù)據(jù)
//selected 點(diǎn)擊的一條是否被選中
},
onSelectAll: (selected, selectedRows, changeRows) => {
//selected 點(diǎn)擊全選是否選中
//selectedRows 點(diǎn)擊全選判斷所有的選中數(shù)據(jù)
//changeRows 所有改變選中狀態(tài)的數(shù)據(jù)
},
getCheckboxProps: record => {
console.log(props)
return {
// 全部默認(rèn)禁止選中
disabled: props.defaultChecked ? true : false,
// 某幾項(xiàng)默認(rèn)禁止選中(R: 當(dāng)state等于1時(shí))
// disabled: record.state == 1,
// 某幾項(xiàng)默認(rèn)選中(R: 當(dāng)state等于1時(shí))
defaultChecked: record.sceneId === props.defaultChecked
}
}
}
})
</script>
<style lang="less">
.addSceneModal {
}
</style>
表格每行實(shí)現(xiàn)單選
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀(guān)點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀(guān)點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 原文: element-ui Table表格結(jié)合CheckBox實(shí)現(xiàn)單選效果 最近做項(xiàng)目遇到一個(gè)需求,需要實(shí)現(xiàn)一個(gè)...
- 需求:選中該表格行,在地圖上顯示該行地理位置信息 實(shí)現(xiàn)多選效果非常簡(jiǎn)單,手動(dòng)添加一個(gè)el-table-column...
- 原創(chuàng)地址:http://www.itdecent.cn/p/30bb5878040c[https://www.j...
- 原因是循環(huán)表格的數(shù)據(jù)時(shí)候id一樣,在方法里傳一個(gè)參this,下定義方法的時(shí)候,傳一個(gè)obj參數(shù),$(obj)