UnisKB/ui/src/views/application/components/AddDatasetDialog.vue

63 lines
1.7 KiB
Vue
Raw Normal View History

2023-11-24 06:49:25 +00:00
<template>
<el-dialog title="添加关联数据集" v-model="dialogVisible" width="600">
2023-11-24 11:02:52 +00:00
<el-checkbox-group v-model="checkList" class="app-custom-checkbox-group">
2023-11-27 03:21:56 +00:00
<el-row :gutter="12" v-loading="loading">
<el-col :span="12" v-for="(item, index) in data" :key="index" class="mb-16">
2023-11-24 11:02:52 +00:00
<el-card shadow="hover">
<div class="title flex-between">
<div class="flex align-center">
<AppAvatar class="mr-12" shape="square" :size="32">
<img src="@/assets/icon_document.svg" style="width: 58%" alt="" />
</AppAvatar>
2023-11-27 03:21:56 +00:00
<h4 class="ellipsis-1">{{ item.name }}</h4>
2023-11-24 11:02:52 +00:00
</div>
2023-11-27 03:21:56 +00:00
<el-checkbox :label="item.id" />
2023-11-24 11:02:52 +00:00
</div>
</el-card>
</el-col>
</el-row>
</el-checkbox-group>
2023-11-24 06:49:25 +00:00
<template #footer>
<span class="dialog-footer">
<el-button @click.prevent="dialogVisible = false"> 取消 </el-button>
2023-11-24 11:02:52 +00:00
<el-button type="primary" @click="submitHandle"> </el-button>
2023-11-24 06:49:25 +00:00
</span>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue'
2023-11-27 03:21:56 +00:00
const props = defineProps({
data: {
type: Array<any>,
default: () => []
}
})
const emit = defineEmits(['addData'])
2023-11-24 06:49:25 +00:00
2023-11-27 03:21:56 +00:00
const loading = ref(false)
2023-11-24 06:49:25 +00:00
const dialogVisible = ref<boolean>(false)
2023-11-24 11:02:52 +00:00
const checkList = ref([])
2023-11-24 06:49:25 +00:00
watch(dialogVisible, (bool) => {
if (!bool) {
2023-11-24 11:02:52 +00:00
checkList.value = []
2023-11-27 03:21:56 +00:00
loading.value = false
2023-11-24 06:49:25 +00:00
}
})
2023-11-27 03:21:56 +00:00
const open = (checked: any) => {
checkList.value = checked
2023-11-24 06:49:25 +00:00
dialogVisible.value = true
}
2023-11-27 03:21:56 +00:00
const submitHandle = () => {
emit('addData', checkList.value)
dialogVisible.value = false
2023-11-24 06:49:25 +00:00
}
defineExpose({ open })
</script>
<style lang="scss" scope></style>