创新实训——知识库管理页面

添加知识库内容

点击插入按钮,可在知识库中新添加一个文件。

created() {
    console.log('created')
    this.KBId = this.$route.query.kbId
    console.log(this.KBId)
    getChunks(this.KBId).then((res) => {
      console.log(res)
      this.lists = res.data
    }).catch((err) => {
      console.log(err)
    });
  }

显示知识库详情

页面可显示已添加的知识库内容,点击显示框可以打开一个dialog,出现内容的弹框,可在其中对知识库内容进行修改。

methods: {
    toDetail() {
      this.$router.push('/knDetail')
    },
    back() {
      this.$router.back()
    },

    toAdd() {
      this.tempInfo = {}
      this.dialogVisible = true
    },
    openFileSelector() {
      //创建input元素
      const input = document.createElement('input');
      input.type = 'file';
      input.click();

      //监听文件选择事件
      input.onchange = (event) => {
        const file = event.target.files[0];
        //处理选中的文件
        console.log(file);
      }
    },
    edit(item) {
      this.currentIndex = item.chunkId
      this.isEdit = true
      this.tempInfo = item
      this.dialogVisible = true
    },
    confirm() {
      if (this.isEdit) {
        let myObj = this.lists.find(box => box.chunkId == this.currentIndex)
        console.log(myObj)
        myObj = this.tempInfo
        this.dialogVisible = false
        this.isEdit = false
      }
      else {
        this.tempInfo.chunkId = this.lists[this.lists.length - 1].chunkId + 1
        this.lists.push(this.tempInfo)
        this.dialogVisible = false
        this.isEdit = false
      }
    }
  }

使用 overflow: auto; 处理详情框中文字过多的溢出问题。

从本地文件中选择

点击选择文件按钮,可从本地文件中选择想要添加进知识库的文件,将其插入用户创建的知识库中,形成个人的知识库。

openFileSelector() {
      //创建input元素
      const input = document.createElement('input');
      input.type = 'file';
      input.click();

      //监听文件选择事件
      input.onchange = (event) => {
        const file = event.target.files[0];
        //处理选中的文件
        console.log(file);
      }
    }

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值