New file |
| | |
| | | import { DirectiveBinding } from 'vue'; |
| | | import { useUserStore } from '@/store'; |
| | | import { getUserResources } from "@/utils/auth"; |
| | | |
| | | function hasPermissionDirective(el: HTMLElement, binding: DirectiveBinding) { |
| | | |
| | | // 获取用户权限 |
| | | const userStore = useUserStore(); |
| | | const roleData = JSON.parse( getUserResources()) |
| | | const roleBtn = roleData.map((item: any) => item.component) |
| | | const permission = binding.value as string; |
| | | |
| | | if (!roleBtn.includes(permission)) { |
| | | el.style.display = 'none'; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | export default { |
| | | mounted(el: HTMLElement, binding: DirectiveBinding) { |
| | | |
| | | hasPermissionDirective(el, binding); |
| | | }, |
| | | updated(el: HTMLElement, binding: DirectiveBinding) { |
| | | |
| | | hasPermissionDirective(el, binding); |
| | | }, |
| | | }; |
| | |
| | | import { App } from 'vue'; |
| | | import permission from './permission'; |
| | | import hasPermi from './hasPermi'; |
| | | |
| | | export default { |
| | | install(Vue: App) { |
| | | Vue.directive('permission', permission); |
| | | Vue.directive('hasPermi', hasPermi); |
| | | }, |
| | | }; |
| | |
| | | import directive from './directive'; |
| | | import './mock'; |
| | | import App from './App.vue'; |
| | | |
| | | |
| | | |
| | | // Styles are imported via arco-plugin. See config/plugin/arcoStyleImport.ts in the directory for details |
| | | // 样式通过 arco-plugin 插件导入。详见目录文件 config/plugin/arcoStyleImport.ts |
| | | // https://arco.design/docs/designlab/use-theme-package |
| | |
| | | app.use(store); |
| | | app.use(i18n); |
| | | app.use(globalComponents); |
| | | |
| | | app.use(directive); |
| | | |
| | | |
| | | app.mount('#app'); |
| | | |
| | | // 添加全局方法 |
| | |
| | | |
| | | |
| | | type TargetContext = '_self' | '_parent' | '_blank' | '_top'; |
| | | |
| | | export const openWindow = ( |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | export const documentHeight:number = window.innerHeight - 320; |
| | | export default null; |
| | | |
| | | |
| | | |
| | |
| | | <template> |
| | | <a-button type="primary" @click="handleClick"> |
| | | <a-button type="primary" v-hasPermi="'/kb/data_add'" @click="handleClick"> |
| | | <template #icon> |
| | | <icon-plus /> |
| | | </template> |
| | |
| | | |
| | | <template> |
| | | <a-button type="primary" @click="handleClick" style="margin-left: 10px"> |
| | | <a-button |
| | | v-hasPermi="'/kb/create'" |
| | | type="primary" |
| | | @click="handleClick" |
| | | style="margin-left: 10px" |
| | | > |
| | | <template #icon> |
| | | <icon-plus /> |
| | | </template> |
| | | </a-button> |
| | | <a-modal v-model:visible="visible" title="创建知识库" @before-open="handleOpened" @cancel="handleCancel" :footer="false" title-align="start"> |
| | | <a-form ref="formRef" :rules="rules" :model="form" @submit="handleSubmit" > |
| | | <a-modal |
| | | v-model:visible="visible" |
| | | title="创建知识库" |
| | | @before-open="handleOpened" |
| | | @cancel="handleCancel" |
| | | :footer="false" |
| | | title-align="start" |
| | | > |
| | | <a-form ref="formRef" :rules="rules" :model="form" @submit="handleSubmit"> |
| | | <a-form-item field="name" label="名称"> |
| | | <a-input v-model="form.name" placeholder="请输入名称"/> |
| | | <a-input v-model="form.name" placeholder="请输入名称" /> |
| | | </a-form-item> |
| | | <a-form-item> |
| | | <div style="width: 100%;text-align: right"> |
| | | <div style="width: 100%; text-align: right"> |
| | | <a-button @click="visible = false">取消</a-button> |
| | | <a-button style="margin-left: 10px" type="primary" html-type="submit">确定</a-button> |
| | | <a-button style="margin-left: 10px" type="primary" html-type="submit" |
| | | >确定</a-button |
| | | > |
| | | </div> |
| | | </a-form-item> |
| | | </a-form> |
| | |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | import { onMounted ,onBeforeMount, reactive, ref } from "vue"; |
| | | import { kbcreate } from "@/api/kbList"; |
| | | import { Message } from '@arco-design/web-vue'; |
| | | import { onMounted, onBeforeMount, reactive, ref } from 'vue'; |
| | | import { kbcreate } from '@/api/kbList'; |
| | | import { Message } from '@arco-design/web-vue'; |
| | | |
| | | const visible = ref(false); |
| | | const form = reactive({ |
| | | name: '',// 用户名 |
| | | }); |
| | | const formRef = ref(null); |
| | | const visible = ref(false); |
| | | const form = reactive({ |
| | | name: '', // 用户名 |
| | | }); |
| | | const formRef = ref(null); |
| | | |
| | | const rules = { |
| | | name: [ |
| | | { |
| | | required: true, |
| | | message:'名称不允许为空', |
| | | }, |
| | | ], |
| | | } |
| | | const rules = { |
| | | name: [ |
| | | { |
| | | required: true, |
| | | message: '名称不允许为空', |
| | | }, |
| | | ], |
| | | }; |
| | | |
| | | const emit = defineEmits(['getknowledge', 'getKbdetail']); |
| | | |
| | | const emit = defineEmits(['getknowledge','getKbdetail']) |
| | | |
| | | const handleSubmit = async({values, errors}) => { |
| | | if(errors) return; |
| | | const handleSubmit = async ({ values, errors }) => { |
| | | if (errors) return; |
| | | let data = await kbcreate({ |
| | | name: values.name, |
| | | }) |
| | | if(data.code == 0){ |
| | | }); |
| | | if (data.code == 0) { |
| | | visible.value = false; |
| | | Message.success('创建成功'); |
| | | // emit('getKbdetail',data.data.kb_id); |
| | | emit("getknowledge",data.data.kb_id); |
| | | emit('getknowledge', data.data.kb_id); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | const handleClick = () => { |
| | | visible.value = true; |
| | | }; |
| | | const handleBeforeOk = (done) => { |
| | | formRef.value.validate().then(res => { |
| | | console.log('form:', form) |
| | | const handleClick = () => { |
| | | visible.value = true; |
| | | }; |
| | | const handleBeforeOk = (done) => { |
| | | formRef.value.validate().then((res) => { |
| | | console.log('form:', form); |
| | | if (!form.name) { |
| | | done(false) |
| | | }else { |
| | | done(false); |
| | | } else { |
| | | console.log('请求数据'); |
| | | |
| | | } |
| | | }) |
| | | }; |
| | | const handleCancel = () => { |
| | | visible.value = false; |
| | | } |
| | | }); |
| | | }; |
| | | const handleCancel = () => { |
| | | visible.value = false; |
| | | }; |
| | | |
| | | const handleOpened =(el) => { |
| | | Object.assign(form,{ |
| | | name: '',// 用户名 |
| | | }); |
| | | formRef.value.resetFields(); |
| | | } |
| | | const handleOpened = (el) => { |
| | | Object.assign(form, { |
| | | name: '', // 用户名 |
| | | }); |
| | | formRef.value.resetFields(); |
| | | }; |
| | | |
| | | onBeforeMount(()=>{ |
| | | |
| | | }) |
| | | onMounted(()=>{ |
| | | |
| | | |
| | | }) |
| | | </script> |
| | | onBeforeMount(() => {}); |
| | | onMounted(() => {}); |
| | | </script> |
| | |
| | | |
| | | <template> |
| | | <a-button type="text" :disabled="props.item.run == '1'" @click="handleClick" size="small"> |
| | | <a-button |
| | | type="text" |
| | | v-hasPermi="'/kb/rename'" |
| | | :disabled="props.item.run == '1'" |
| | | @click="handleClick" |
| | | size="small" |
| | | > |
| | | <template #icon> |
| | | <icon-edit /> |
| | | </template> |
| | | </a-button> |
| | | <a-modal v-model:visible="visible" title="重命名" @before-open="handleOpened" @cancel="handleCancel" :footer="false" title-align="start"> |
| | | <a-form ref="formRef" :rules="rules" :model="form" @submit="handleSubmit" > |
| | | <a-modal |
| | | v-model:visible="visible" |
| | | title="重命名" |
| | | @before-open="handleOpened" |
| | | @cancel="handleCancel" |
| | | :footer="false" |
| | | title-align="start" |
| | | > |
| | | <a-form ref="formRef" :rules="rules" :model="form" @submit="handleSubmit"> |
| | | <a-form-item field="name" label="名称"> |
| | | <a-input v-model="form.name" placeholder="请输入名称"/> |
| | | <a-input v-model="form.name" placeholder="请输入名称" /> |
| | | </a-form-item> |
| | | <a-form-item> |
| | | <div style="width: 100%;text-align: right"> |
| | | <div style="width: 100%; text-align: right"> |
| | | <a-button @click="visible = false">取消</a-button> |
| | | <a-button style="margin-left: 10px" type="primary" html-type="submit">确定</a-button> |
| | | <a-button style="margin-left: 10px" type="primary" html-type="submit" |
| | | >确定</a-button |
| | | > |
| | | </div> |
| | | </a-form-item> |
| | | </a-form> |
| | |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | import { onMounted ,onBeforeMount, reactive, ref } from "vue"; |
| | | import { kbdocumentrename, kbdocumentrm } from "@/api/kbList"; |
| | | import { Message } from "@arco-design/web-vue"; |
| | | import { onMounted, onBeforeMount, reactive, ref } from 'vue'; |
| | | import { kbdocumentrename, kbdocumentrm } from '@/api/kbList'; |
| | | import { Message } from '@arco-design/web-vue'; |
| | | |
| | | const visible = ref(false); |
| | | const loading = ref(false); |
| | | const form = reactive({ |
| | | name: '',// 用户名 |
| | | }); |
| | | const formRef = ref(null); |
| | | const visible = ref(false); |
| | | const loading = ref(false); |
| | | const form = reactive({ |
| | | name: '', // 用户名 |
| | | }); |
| | | const formRef = ref(null); |
| | | |
| | | const rules = { |
| | | name: [ |
| | | { |
| | | required: true, |
| | | message:'名称不允许为空', |
| | | }, |
| | | ], |
| | | } |
| | | const rules = { |
| | | name: [ |
| | | { |
| | | required: true, |
| | | message: '名称不允许为空', |
| | | }, |
| | | ], |
| | | }; |
| | | |
| | | const props = defineProps(['item']); |
| | | |
| | | const props = defineProps(['item']) |
| | | const emit = defineEmits(['upTabdateItem']); |
| | | |
| | | const emit = defineEmits(['upTabdateItem']) |
| | | |
| | | const handleSubmit = async ({values, errors}) => { |
| | | if (errors) return; |
| | | let data = await kbdocumentrename({ |
| | | doc_id:props.item.id, |
| | | name:form.name |
| | | }) |
| | | if(data.code == 0){ |
| | | Message.success('操作成功'); |
| | | visible.value = false; |
| | | emit("upTabdateItem",props.item.id,form.name); |
| | | } |
| | | } |
| | | |
| | | const handleClick = () => { |
| | | visible.value = true; |
| | | }; |
| | | const handleBeforeOk = (done) => { |
| | | formRef.value.validate().then(res => { |
| | | console.log('form:', form) |
| | | if (!form.name) { |
| | | done(false) |
| | | }else { |
| | | console.log('请求数据'); |
| | | |
| | | const handleSubmit = async ({ values, errors }) => { |
| | | if (errors) return; |
| | | let data = await kbdocumentrename({ |
| | | doc_id: props.item.id, |
| | | name: form.name, |
| | | }); |
| | | if (data.code == 0) { |
| | | Message.success('操作成功'); |
| | | visible.value = false; |
| | | emit('upTabdateItem', props.item.id, form.name); |
| | | } |
| | | }) |
| | | }; |
| | | const handleCancel = () => { |
| | | visible.value = false; |
| | | } |
| | | }; |
| | | |
| | | const handleOpened =(el) => { |
| | | console.log(props.item, 'props.item'); |
| | | Object.assign(form,props.item); |
| | | // formRef.value.resetFields(); |
| | | } |
| | | const handleClick = () => { |
| | | visible.value = true; |
| | | }; |
| | | const handleBeforeOk = (done) => { |
| | | formRef.value.validate().then((res) => { |
| | | console.log('form:', form); |
| | | if (!form.name) { |
| | | done(false); |
| | | } else { |
| | | console.log('请求数据'); |
| | | } |
| | | }); |
| | | }; |
| | | const handleCancel = () => { |
| | | visible.value = false; |
| | | }; |
| | | |
| | | onBeforeMount(()=>{ |
| | | const handleOpened = (el) => { |
| | | console.log(props.item, 'props.item'); |
| | | Object.assign(form, props.item); |
| | | // formRef.value.resetFields(); |
| | | }; |
| | | |
| | | }) |
| | | onMounted(()=>{ |
| | | |
| | | |
| | | }) |
| | | onBeforeMount(() => {}); |
| | | onMounted(() => {}); |
| | | </script> |
| | | |
| | | <script lang="ts"> |
| | | export default { |
| | | name: 'add', |
| | | methods: { |
| | | |
| | | } |
| | | }; |
| | | </script> |
| | | export default { |
| | | name: 'add', |
| | | methods: {}, |
| | | }; |
| | | </script> |
| | |
| | | <template #status="{ record }"> |
| | | <a-switch |
| | | v-model="record.status" |
| | | :disabled="!getAut('/kb/data_status')" |
| | | size="small" |
| | | checked-value="1" |
| | | unchecked-value="0" |
| | |
| | | type="text" |
| | | size="large" |
| | | @click="run(record)" |
| | | v-hasPermi="'/kb/data_analysis'" |
| | | :loading="record.loading" |
| | | > |
| | | <template #icon> |
| | |
| | | type="text" |
| | | :disabled="record.run == '1'" |
| | | @click="handleClick(record)" |
| | | v-hasPermi="'/kb/data_update'" |
| | | size="small" |
| | | > |
| | | <template #icon> |
| | | <icon-tool /> |
| | | </template> |
| | | </a-button> |
| | | <edit :item="record" @upTabdateItem="upTabdateItem" /> |
| | | <edit |
| | | :item="record" |
| | | v-hasPermi="'/kb/rename'" |
| | | @upTabdateItem="upTabdateItem" |
| | | /> |
| | | <a-popconfirm |
| | | :content="'确定删除吗'" |
| | | type="warning" |
| | |
| | | type="text" |
| | | size="small" |
| | | :disabled="record.run == '1'" |
| | | v-hasPermi="'/kb/data_delete'" |
| | | > |
| | | <template #icon> |
| | | <icon-delete /> |
| | |
| | | <a-button |
| | | type="text" |
| | | size="small" |
| | | v-hasPermi="'/kb/data_download'" |
| | | :disabled="record.run == '1'" |
| | | @click="onDownloadDocument(record)" |
| | | > |
| | |
| | | </a-card> |
| | | </a-scrollbar> |
| | | </a-tab-pane> |
| | | <a-tab-pane key="2" :title="t('dmx.list.test')"> |
| | | <a-tab-pane |
| | | key="2" |
| | | :title="t('dmx.list.test')" |
| | | v-if="getAut('/kb/test')" |
| | | > |
| | | <a-scrollbar |
| | | class="rt-container-main" |
| | | :style="{ height: documentHeight + 70 + 'px' }" |
| | |
| | | <test ref="testForm"></test> |
| | | </a-scrollbar> |
| | | </a-tab-pane> |
| | | <a-tab-pane key="3" :title="t('dmx.list.disposition')"> |
| | | <a-tab-pane |
| | | key="3" |
| | | :title="t('dmx.list.disposition')" |
| | | v-if="getAut('/kb/update')" |
| | | > |
| | | <a-scrollbar |
| | | class="rt-container-main" |
| | | :style="{ height: documentHeight + 70 + 'px' }" |
| | |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | import { |
| | | computed, |
| | | ref, |
| | | reactive, |
| | | watch, |
| | | nextTick, |
| | | onBeforeMount, |
| | | onMounted, onBeforeUnmount |
| | | } from "vue"; |
| | | import { |
| | | computed, |
| | | ref, |
| | | reactive, |
| | | watch, |
| | | nextTick, |
| | | onBeforeMount, |
| | | onMounted, |
| | | onBeforeUnmount, |
| | | } from 'vue'; |
| | | import { useI18n } from 'vue-i18n'; |
| | | import useLoading from '@/hooks/loading'; |
| | | import { |
| | |
| | | import { documentHeight, parseTime } from '@/utils'; |
| | | import { deleteLlm } from '@/api/model'; |
| | | import { userModelState } from '@/store'; |
| | | import { getUserResources } from '@/utils/auth'; |
| | | |
| | | let modelStore = userModelState(); |
| | | const httpUrl = modelStore.hrefUrl; |
| | |
| | | parser_idObj: {}, |
| | | }); |
| | | let tabs = ref([]); |
| | | let timer = null;// 定时器 |
| | | |
| | | |
| | | let timer = null; // 定时器 |
| | | |
| | | const selectTab = (index, item) => { |
| | | selectedTab.value = index; |
| | |
| | | ...basePagination, |
| | | }); |
| | | getKbdetail(kbobj.id); |
| | | }; |
| | | |
| | | const getAut = (val) => { |
| | | const roleData = JSON.parse(getUserResources()); |
| | | const roleBtn = roleData.map((item: any) => item.component); |
| | | return roleBtn.includes(val); |
| | | }; |
| | | |
| | | const basePagination: Pagination = { |
| | |
| | | pagination.current = params.page; |
| | | pagination.total = data.data.total; |
| | | |
| | | if(timer){ |
| | | if (timer) { |
| | | clearInterval(timer); |
| | | } |
| | | // 定时器查询文档 |
| | | timer = setInterval(async () => { |
| | | let params = { ...basePagination, kb_id: kbobj.id } |
| | | let params = { ...basePagination, kb_id: kbobj.id }; |
| | | const data = await queryKbDocumentList(params); |
| | | if (data.code == '0') { |
| | | parser_ids = kbtenantInfo.parser_ids.split(',').reduce((acc, pair) => { |
| | | const [key, value] = pair.split(':'); |
| | | acc[key] = value; |
| | | return acc; |
| | | }, {}); |
| | | parser_ids = kbtenantInfo.parser_ids |
| | | .split(',') |
| | | .reduce((acc, pair) => { |
| | | const [key, value] = pair.split(':'); |
| | | acc[key] = value; |
| | | return acc; |
| | | }, {}); |
| | | // console.log(parser_ids, 'parser_ids'); |
| | | kbtenantInfo.parser_idObj = parser_ids; |
| | | renderData.value = data.data.docs || []; |
| | |
| | | // console.log(renderData.value, 'renderData'); |
| | | } |
| | | }, 10000); |
| | | |
| | | |
| | | } |
| | | } catch (err) { |
| | | // you can report use errorHandler or other |
| | |
| | | kb_id: tabs.value[selectedTab.value].id, |
| | | ...basePagination, |
| | | }); |
| | | |
| | | |
| | | |
| | | } else { |
| | | // Message.error('解析失败'); |
| | | // row.run = '1'; |
| | |
| | | }); |
| | | onBeforeUnmount(() => { |
| | | clearInterval(timer); |
| | | }) |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped lang="less"> |