|
| 1 | +<template> |
| 2 | + <LayoutContainer :header="$t('views.document.importDocument')" class="create-dataset"> |
| 3 | + <template #backButton> |
| 4 | + <back-button @click="back"></back-button> |
| 5 | + </template> |
| 6 | + <div class="create-dataset__main flex" v-loading="loading"> |
| 7 | + <div class="create-dataset__component main-calc-height"> |
| 8 | + <el-scrollbar> |
| 9 | + <div class="upload-document p-24"> |
| 10 | + <h4 class="title-decoration-1 mb-8"> |
| 11 | + {{ $t('views.document.feishu.selectDocument') }} |
| 12 | + </h4> |
| 13 | + <el-form |
| 14 | + ref="FormRef" |
| 15 | + :model="form" |
| 16 | + :rules="rules" |
| 17 | + label-position="top" |
| 18 | + require-asterisk-position="right" |
| 19 | + > |
| 20 | + <div class="mt-16 mb-16"> |
| 21 | + <el-radio-group v-model="form.fileType" class="app-radio-button-group"> |
| 22 | + <el-radio-button value="txt">{{ |
| 23 | + $t('views.document.fileType.txt.label') |
| 24 | + }}</el-radio-button> |
| 25 | + </el-radio-group> |
| 26 | + </div> |
| 27 | + <div class="update-info flex p-8-12 border-r-4 mb-16"> |
| 28 | + <div class="mt-4"> |
| 29 | + <AppIcon iconName="app-warning-colorful" style="font-size: 16px"></AppIcon> |
| 30 | + </div> |
| 31 | + <div class="ml-16 lighter"> |
| 32 | + <p>{{ $t('views.document.feishu.tip1') }}</p> |
| 33 | + <p>{{ $t('views.document.feishu.tip2') }}</p> |
| 34 | + </div> |
| 35 | + </div> |
| 36 | + <div class="card-never border-r-4 mb-16"> |
| 37 | + <el-checkbox |
| 38 | + v-model="allCheck" |
| 39 | + :label="$t('views.document.feishu.allCheck')" |
| 40 | + size="large" |
| 41 | + class="ml-24" |
| 42 | + /> |
| 43 | + </div> |
| 44 | + |
| 45 | + <el-tree :props="props" :load="loadNode" lazy show-checkbox /> |
| 46 | + </el-form> |
| 47 | + </div> |
| 48 | + </el-scrollbar> |
| 49 | + </div> |
| 50 | + </div> |
| 51 | + <div class="create-dataset__footer text-right border-t"> |
| 52 | + <el-button @click="router.go(-1)">{{ $t('common.cancel') }}</el-button> |
| 53 | + |
| 54 | + <el-button @click="submit" type="primary"> |
| 55 | + {{ $t('views.document.buttons.import') }} |
| 56 | + </el-button> |
| 57 | + </div> |
| 58 | + </LayoutContainer> |
| 59 | +</template> |
| 60 | +<script setup lang="ts"> |
| 61 | +import { ref, reactive, computed, onUnmounted } from 'vue' |
| 62 | +import { useRouter, useRoute } from 'vue-router' |
| 63 | +
|
| 64 | +import documentApi from '@/api/document' |
| 65 | +import { MsgConfirm, MsgSuccess } from '@/utils/message' |
| 66 | +import { t } from '@/locales' |
| 67 | +import type Node from 'element-plus/es/components/tree/src/model/node' |
| 68 | +
|
| 69 | +interface Tree { |
| 70 | + name: string |
| 71 | + leaf?: boolean |
| 72 | +} |
| 73 | +const router = useRouter() |
| 74 | +const route = useRoute() |
| 75 | +const { |
| 76 | + query: { id } // id为datasetID,有id的是上传文档 |
| 77 | +} = route |
| 78 | +
|
| 79 | +const loading = ref(false) |
| 80 | +const disabled = ref(false) |
| 81 | +const allCheck = ref(false) |
| 82 | +const form = ref({ |
| 83 | + fileType: 'txt', |
| 84 | + fileList: [] as any |
| 85 | +}) |
| 86 | +
|
| 87 | +const rules = reactive({ |
| 88 | + fileList: [ |
| 89 | + { required: true, message: t('views.document.upload.requiredMessage'), trigger: 'change' } |
| 90 | + ] |
| 91 | +}) |
| 92 | +
|
| 93 | +const props = { |
| 94 | + label: 'name', |
| 95 | + children: 'zones', |
| 96 | + isLeaf: 'leaf' |
| 97 | +} |
| 98 | +
|
| 99 | +const loadNode = (node: Node, resolve: (data: Tree[]) => void) => { |
| 100 | + if (node.level === 0) { |
| 101 | + return resolve([{ name: 'region' }]) |
| 102 | + } |
| 103 | + if (node.level > 1) return resolve([]) |
| 104 | +
|
| 105 | + setTimeout(() => { |
| 106 | + const data: Tree[] = [ |
| 107 | + { |
| 108 | + name: 'leaf', |
| 109 | + leaf: true |
| 110 | + }, |
| 111 | + { |
| 112 | + name: 'zone' |
| 113 | + } |
| 114 | + ] |
| 115 | +
|
| 116 | + resolve(data) |
| 117 | + }, 500) |
| 118 | +} |
| 119 | +
|
| 120 | +function submit() { |
| 121 | + loading.value = true |
| 122 | +} |
| 123 | +function back() { |
| 124 | + router.go(-1) |
| 125 | +} |
| 126 | +</script> |
| 127 | +<style lang="scss" scoped> |
| 128 | +.create-dataset { |
| 129 | + &__component { |
| 130 | + width: 100%; |
| 131 | + margin: 0 auto; |
| 132 | + overflow: hidden; |
| 133 | + } |
| 134 | + &__footer { |
| 135 | + padding: 16px 24px; |
| 136 | + position: fixed; |
| 137 | + bottom: 0; |
| 138 | + left: 0; |
| 139 | + background: #ffffff; |
| 140 | + width: 100%; |
| 141 | + box-sizing: border-box; |
| 142 | + } |
| 143 | + .upload-document { |
| 144 | + width: 70%; |
| 145 | + margin: 0 auto; |
| 146 | + margin-bottom: 20px; |
| 147 | + } |
| 148 | +} |
| 149 | +</style> |
0 commit comments