123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <template>
- <CzrDialog
- :show="show"
- title="选择知识库"
- @onClose="$emit('update:show', false)"
- @onSubmit="onSubmit"
- width="62.5rem"
- height="auto"
- :loading="state.loading"
- >
- <div class="bm-form">
- <template v-for="item in state.list">
- <div
- class="knowledge-item __hover"
- :class="{ active: item.id == state.active.id }"
- @click="() => (state.active = item)"
- >
- <img src="@/assets/images/answer.png" />
- <div v-title>{{ item.name }}</div>
- </div>
- </template>
- </div>
- </CzrDialog>
- </template>
- <script setup lang="ts">
- import {
- computed,
- getCurrentInstance,
- nextTick,
- reactive,
- ref,
- watch,
- } from 'vue'
- import { ElMessage, ElMessageBox } from 'element-plus'
- import { useDialogStore, useDictionaryStore } from '@/stores'
- import { useRouter } from 'vue-router'
- const router = useRouter()
- const DictionaryStore = useDictionaryStore()
- const DialogStore = useDialogStore()
- const emit = defineEmits(['update:show', 'refresh'])
- const { proxy } = getCurrentInstance()
- const props = defineProps({
- show: { default: false },
- transfer: <any>{},
- })
- const state: any = reactive({
- loading: false,
- list: [],
- active: '',
- })
- watch(
- () => props.show,
- (n) => {
- if (n) {
- initDictionary()
- }
- },
- )
- const initDictionary = () => {
- const arr: any = []
- for (let i = 1; i <= 100; i++) {
- arr.push({
- id: i,
- name: '部门知识库-新_' + i,
- })
- }
- state.list = arr
- }
- const onSubmit = () => {
- let tips = '请确认是否将'
- if (props.transfer.row) {
- tips += props.transfer.row.name
- } else {
- tips += props.transfer.list.length + '个'
- if (props.transfer.type === 'text') {
- tips += '文档'
- } else if (props.transfer.type === 'qa') {
- tips += '问答'
- } else if (props.transfer.type === 'stage') {
- tips += '分段'
- }
- }
- tips += `迁移至${state.active.name}?`
- if (state.active.id) {
- DialogStore.confirm({
- content: tips,
- onSubmit: () => {
- state.loading = true
- ElMessage.success(`迁移成功!`)
- emit('update:show', false)
- emit('refresh')
- state.loading = false
- },
- })
- } else {
- ElMessage.warning(`请选择知识库!`)
- }
- }
- </script>
- <style lang="scss" scoped>
- .bm-form {
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- gap: 1rem;
- max-height: 36rem;
- overflow-y: auto;
- .knowledge-item {
- height: 5.25rem;
- box-shadow: 0rem 0.25rem 0.63rem 0rem rgba(40, 83, 247, 0.05);
- border-radius: 0.63rem;
- border: var(--czr-border);
- display: flex;
- align-items: center;
- padding: 0 1.5rem;
- font-weight: bold;
- font-size: 1.25rem;
- color: #2e3238;
- gap: 1rem;
- > img {
- width: 2.13rem;
- height: 2.12rem;
- }
- &.active {
- background: #f3f5fe;
- box-shadow: 0rem 0.25rem 0.63rem 0rem rgba(40, 83, 247, 0.05);
- border-color: var(--czr-main-color);
- }
- }
- }
- </style>
|