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

77 lines
2.0 KiB
Vue
Raw Normal View History

2023-11-24 06:49:25 +00:00
<template>
2024-07-01 01:45:59 +00:00
<el-dialog
:title="$t('views.application.applicationForm.dialogues.addDataset')"
v-model="dialogVisible"
width="600"
append-to-body
>
2023-12-01 03:36:04 +00:00
<template #header="{ titleId, titleClass }">
2023-11-30 08:35:52 +00:00
<div class="my-header flex">
2024-07-01 01:45:59 +00:00
<h4 :id="titleId" :class="titleClass">
{{ $t('views.application.applicationForm.dialogues.addDataset') }}
</h4>
2023-11-30 08:35:52 +00:00
<el-button link class="ml-16" @click="refresh">
2024-07-01 01:45:59 +00:00
<el-icon class="mr-4"><Refresh /></el-icon
>{{ $t('views.application.applicationForm.dialogues.refresh') }}
2023-11-30 08:35:52 +00:00
</el-button>
</div>
</template>
<el-row :gutter="12" v-loading="loading">
<el-col :span="12" v-for="(item, index) in data" :key="index" class="mb-16">
<CardCheckbox value-field="id" :data="item" v-model="checkList">
2024-01-02 09:32:41 +00:00
<span class="ellipsis">
2023-12-04 09:24:00 +00:00
{{ item.name }}
</span>
2023-11-30 08:35:52 +00:00
</CardCheckbox>
</el-col>
</el-row>
2023-11-24 06:49:25 +00:00
<template #footer>
<span class="dialog-footer">
2024-07-01 01:45:59 +00:00
<el-button @click.prevent="dialogVisible = false">
{{ $t('views.application.applicationForm.buttons.cancel') }}
</el-button>
<el-button type="primary" @click="submitHandle">
{{ $t('views.application.applicationForm.buttons.confirm') }}
</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: () => []
2023-11-30 08:35:52 +00:00
},
loading: Boolean
2023-11-27 03:21:56 +00:00
})
2023-11-30 08:35:52 +00:00
const emit = defineEmits(['addData', 'refresh'])
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-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
}
2023-11-30 08:35:52 +00:00
const refresh = () => {
emit('refresh')
}
2023-11-24 06:49:25 +00:00
defineExpose({ open })
</script>
<style lang="scss" scope></style>