2024-01-11 06:40:00 +00:00
|
|
|
|
<template>
|
|
|
|
|
|
<el-dialog
|
2024-01-19 08:03:17 +00:00
|
|
|
|
title="导入文档"
|
2024-01-11 06:40:00 +00:00
|
|
|
|
v-model="dialogVisible"
|
|
|
|
|
|
:close-on-click-modal="false"
|
|
|
|
|
|
:close-on-press-escape="false"
|
|
|
|
|
|
:destroy-on-close="true"
|
|
|
|
|
|
>
|
2024-01-19 08:03:17 +00:00
|
|
|
|
<el-form
|
|
|
|
|
|
label-position="top"
|
|
|
|
|
|
ref="webFormRef"
|
|
|
|
|
|
:rules="rules"
|
|
|
|
|
|
:model="form"
|
|
|
|
|
|
require-asterisk-position="right"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-form-item label="文档地址" prop="source_url" v-if="isImport">
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
v-model="form.source_url"
|
|
|
|
|
|
placeholder="请输入文档地址,一行一个,地址不正确文档会导入失败。"
|
|
|
|
|
|
:rows="10"
|
|
|
|
|
|
type="textarea"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item v-else label="文档地址" prop="source_url">
|
|
|
|
|
|
<el-input v-model="form.source_url" placeholder="请输入文档地址" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="选择器">
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
v-model="form.selector"
|
|
|
|
|
|
placeholder="默认为 body,可输入 .classname/#idname/tagname"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
2024-01-11 06:40:00 +00:00
|
|
|
|
<template #footer>
|
|
|
|
|
|
<span class="dialog-footer">
|
|
|
|
|
|
<el-button @click.prevent="dialogVisible = false"> 取消 </el-button>
|
|
|
|
|
|
<el-button type="primary" @click="submit" :loading="loading"> 确定 </el-button>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
2024-01-19 08:03:17 +00:00
|
|
|
|
import { ref, reactive, watch } from 'vue'
|
|
|
|
|
|
import { useRoute } from 'vue-router'
|
|
|
|
|
|
import documentApi from '@/api/document'
|
2024-01-11 06:40:00 +00:00
|
|
|
|
import { MsgSuccess } from '@/utils/message'
|
|
|
|
|
|
|
2024-01-19 08:03:17 +00:00
|
|
|
|
const route = useRoute()
|
|
|
|
|
|
const {
|
|
|
|
|
|
params: { id }
|
|
|
|
|
|
} = route as any
|
2024-01-11 06:40:00 +00:00
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['refresh'])
|
|
|
|
|
|
const loading = ref<boolean>(false)
|
2024-01-19 08:03:17 +00:00
|
|
|
|
const isImport = ref<boolean>(false)
|
|
|
|
|
|
const form = ref<any>({
|
|
|
|
|
|
source_url: '',
|
|
|
|
|
|
selector: ''
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const rules = reactive({
|
|
|
|
|
|
source_url: [{ required: true, message: '请输入 Web 根地址', trigger: 'blur' }]
|
|
|
|
|
|
})
|
2024-01-11 06:40:00 +00:00
|
|
|
|
|
|
|
|
|
|
const dialogVisible = ref<boolean>(false)
|
|
|
|
|
|
|
|
|
|
|
|
watch(dialogVisible, (bool) => {
|
|
|
|
|
|
if (!bool) {
|
2024-01-19 08:03:17 +00:00
|
|
|
|
form.value = {
|
|
|
|
|
|
source_url: '',
|
|
|
|
|
|
selector: ''
|
|
|
|
|
|
}
|
|
|
|
|
|
isImport.value = false
|
2024-01-11 06:40:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2024-01-19 08:03:17 +00:00
|
|
|
|
const open = (row: any) => {
|
|
|
|
|
|
if (row) {
|
|
|
|
|
|
isImport.value = false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
isImport.value = true
|
|
|
|
|
|
}
|
2024-01-11 06:40:00 +00:00
|
|
|
|
dialogVisible.value = true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const submit = () => {
|
2024-01-19 08:03:17 +00:00
|
|
|
|
const obj = {
|
|
|
|
|
|
source_url_list: form.value.source_url.split('\n'),
|
|
|
|
|
|
selector: form.value.selector
|
|
|
|
|
|
}
|
|
|
|
|
|
documentApi.postWebDocument(id, obj, loading).then((res: any) => {
|
|
|
|
|
|
MsgSuccess('导入成功')
|
|
|
|
|
|
emit('refresh')
|
2024-01-11 06:40:00 +00:00
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
defineExpose({ open })
|
|
|
|
|
|
</script>
|
2024-01-19 08:03:17 +00:00
|
|
|
|
<style lang="scss" scoped></style>
|