feat: 字典左侧选中数据传递
This commit is contained in:
parent
e3cafb9e35
commit
12055d5e7a
|
|
@ -12,10 +12,10 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<j-tree :tree-data="listData" :fieldNames="{title:'name',key:'id'}" blockNode>
|
<j-tree :tree-data="listData" :fieldNames="{title:'name',key:'id'}" blockNode @select="selectDic" :selectedKeys="selectedKeys">
|
||||||
<template #title="item">
|
<template #title="item">
|
||||||
<div class="treeItem">
|
<div class="treeItem">
|
||||||
<div>{{ item.name }}</div>
|
<div class="itemText">{{ item.name }}</div>
|
||||||
<div>
|
<div>
|
||||||
<j-popconfirm :title="item.data.status === 1 ? '确定禁用?' : '确定启用?'" @confirm="()=>updateDic(item.data)">
|
<j-popconfirm :title="item.data.status === 1 ? '确定禁用?' : '确定启用?'" @confirm="()=>updateDic(item.data)">
|
||||||
<j-switch v-model:checked="item.status" :checkedValue="1" :unCheckedValue="0"></j-switch>
|
<j-switch v-model:checked="item.status" :checkedValue="1" :unCheckedValue="0"></j-switch>
|
||||||
|
|
@ -37,10 +37,12 @@
|
||||||
import { getDicList ,deleteDictionary,addDictionary} from '@/api/system/dictionary';
|
import { getDicList ,deleteDictionary,addDictionary} from '@/api/system/dictionary';
|
||||||
import Save from './save/index.vue'
|
import Save from './save/index.vue'
|
||||||
import { onlyMessage } from '@/utils/comm';
|
import { onlyMessage } from '@/utils/comm';
|
||||||
|
const emit = defineEmits(['selectData'])
|
||||||
const saveShow = ref(false)
|
const saveShow = ref(false)
|
||||||
const addType = ref('add')
|
const addType = ref('add')
|
||||||
const listData = ref<any[]>([])
|
const listData = ref<any[]>([])
|
||||||
const editData = ref()
|
const editData = ref()
|
||||||
|
const selectedKeys = ref([])
|
||||||
const showSave = () =>{
|
const showSave = () =>{
|
||||||
saveShow.value = true
|
saveShow.value = true
|
||||||
addType.value = 'add'
|
addType.value = 'add'
|
||||||
|
|
@ -96,6 +98,16 @@ const updateDic = (data:any)=>{
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 切换选中字典
|
||||||
|
*/
|
||||||
|
const selectDic = (selectKeys:any)=>{
|
||||||
|
selectedKeys.value = selectKeys
|
||||||
|
const selectData = listData.value.filter((item:any)=>{
|
||||||
|
return item.id = selectKeys[0]
|
||||||
|
})[0]
|
||||||
|
emit('selectData',selectData)
|
||||||
|
}
|
||||||
onMounted(()=>{
|
onMounted(()=>{
|
||||||
queryData()
|
queryData()
|
||||||
})
|
})
|
||||||
|
|
@ -110,5 +122,8 @@ onMounted(()=>{
|
||||||
.treeItem{
|
.treeItem{
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
.itemText{
|
||||||
|
line-height: 32px
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div class="des_head">
|
||||||
|
<div>字典ID:<span>{{ data.id }}</span></div>
|
||||||
|
<div>说明:<span>{{ data.describe }}</span></div>
|
||||||
|
<div>创建日期:<span>{{ data.name }}</span></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
const props = defineProps({
|
||||||
|
data:{
|
||||||
|
type:Object,
|
||||||
|
default:{}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.des_head{
|
||||||
|
padding: 10px 20px;
|
||||||
|
background-color: rgb(242, 242, 242);
|
||||||
|
span{
|
||||||
|
color:rgb(127, 127, 127)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -3,9 +3,11 @@
|
||||||
<FullPage>
|
<FullPage>
|
||||||
<div class="dictionary_contain">
|
<div class="dictionary_contain">
|
||||||
<div class="dictionary_left">
|
<div class="dictionary_left">
|
||||||
<Left/>
|
<Left @selectData="selectData"/>
|
||||||
|
</div>
|
||||||
|
<div class="dictionary_right">
|
||||||
|
<Right :data="data"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="dictionary_right"></div>
|
|
||||||
</div>
|
</div>
|
||||||
</FullPage>
|
</FullPage>
|
||||||
</page-container>
|
</page-container>
|
||||||
|
|
@ -13,6 +15,11 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import Left from './components/Left.vue'
|
import Left from './components/Left.vue'
|
||||||
|
import Right from './components/Right/index.vue'
|
||||||
|
const data = ref()
|
||||||
|
const selectData = (i:any)=>{
|
||||||
|
data.value= i
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.dictionary_contain{
|
.dictionary_contain{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue