能力挂接增加知识库

This commit is contained in:
guoyue 2022-11-30 19:39:57 +08:00
parent b0b4368667
commit 25c45024f7
3 changed files with 568 additions and 1 deletions

View File

@ -0,0 +1,561 @@
<!-- 知识库 -->
<template>
<el-card shadow="never" class="aui-card--fill">
<div class="mod-ability__bsabilityai">
<el-form :inline="true" :model="dataForm">
<el-form-item>
<el-input v-model="dataForm.name" placeholder="名称" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="getDataList2(dataForm.name)">{{
$t('query')
}}</el-button>
</el-form-item>
<el-form-item>
<el-button type="info" @click="exportHandle()">{{
$t('export')
}}</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="showPutOnTheShelf()">上架</el-button>
</el-form-item>
<el-form-item>
<el-button v-if="$hasPermission('ability:knowledgeBase:delete')" type="danger" @click="deleteHandle2()">{{
$t('deleteBatch')
}}</el-button>
</el-form-item>
<el-form-item>
<el-button @click="reset">重置</el-button>
</el-form-item>
</el-form>
<el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle"
style="width: 100%" height="650px">
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
<af-table-column :show-overflow-tooltip="true" width="280" prop="name" label="名称" header-align="center"
align="center"></af-table-column>
<af-table-column :show-overflow-tooltip="true" prop="description" label="描述" header-align="center"
align="center"></af-table-column>
<!-- <af-table-column :show-overflow-tooltip="true" width="280" prop="deptName" label="归属部门" header-align="center"
align="center"></af-table-column>
<af-table-column :show-overflow-tooltip="true" width="280" prop="deptContacts" label="部门联系人"
header-align="center" align="center"></af-table-column>
<af-table-column :show-overflow-tooltip="true" width="280" prop="deptPhone" label="部门联系人电话"
header-align="center" align="center"></af-table-column>
<af-table-column :show-overflow-tooltip="true" width="280" prop="shareCondition" label="共享条件"
header-align="center" align="center"></af-table-column> -->
<template v-if="dataList[0] && dataList[0].infoList2">
<af-table-column
:show-overflow-tooltip="true"
width="280"
v-for="(item, index) in dataList[0].infoList2"
:key="index"
:label="item.attrType"
header-align="center"
align="center"
>
<template slot-scope="scope">
{{ findValue(scope.row.infoList2, item.attrType) }}
</template>
</af-table-column>
</template>
<el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
<template slot-scope="scope">
<el-button v-if="$hasPermission('ability:knowledgeBase:update')" type="text" size="small"
@click="UpdateData(scope.row)">{{ $t('update') }}</el-button>
<el-button v-if="$hasPermission('ability:knowledgeBase:delete')" type="text" size="small"
@click="deleteHandle2(scope.row.id)">{{ $t('delete') }}</el-button>
<el-button type="text" size="small" @click="showDetail(scope.row)">详情</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="Number(total)"
layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
@current-change="pageCurrentChangeHandle">
</el-pagination>
</div>
<!-- 选择类型 -->
<el-dialog title="选择类型" :visible.sync="showPutOnTheShelfFlag" :close-on-click-modal="false"
:close-on-press-escape="false" :before-close="clear" width="30%">
<el-radio v-model="radio" v-for="(data, i) in insertList.children" :label="data.name" :key="i">
</el-radio>
<span slot="footer" class="dialog-footer">
<el-button @click="clear"> </el-button>
<el-button type="primary" @click="showPutOnTheShelfVue"> </el-button>
</span>
</el-dialog>
<el-dialog :title="submitFrom.id ? '修改' + radio : '上架' + radio" :visible.sync="showPutOnTheShelfFlag2"
:close-on-click-modal="false" :close-on-press-escape="false" :destroy-on-close="true" :before-close="clear"
width="50%">
<putOnTheShelf ref="putOnTheShelf" :putOnTheShelfList="putOnTheShelfList" @changeInfoList="changeInfoList"
:type="radio" :typeInput="typeInput" :required="required" :notFilled="notFilled" @submitData="submitData">
</putOnTheShelf>
<span slot="footer" class="dialog-footer">
<el-button @click="clear"> </el-button>
<el-button type="primary" @click="submitData"> </el-button>
</span>
</el-dialog>
</el-card>
</template>
<script>
import mixinViewModule from '@/mixins/view-module'
import dictionaries from '@/utils/dictionaries'
import qs from 'qs'
import { pinyin } from 'pinyin-pro'
import putOnTheShelf from '@/views/modules/putOnTheShelf'
export default {
mixins: [mixinViewModule],
data() {
return {
required: [],
// required: ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''],
notFilled: [],
insertList: [],
putOnTheShelfList: [],
radio: '',
showPutOnTheShelfFlag: false,
showPutOnTheShelfFlag2: false,
submitFrom: {
type: '知识库',
deptId: '',
delFlag: 0,
infoList: [
{
attrType: '知识库类型',
attrValue: '',
delFlag: 0
}
]
},
mixinViewModuleOptions: {
getDataListURL: '/resource/page',
getDataListIsPage: true,
exportURL: '/ability/bsabilityai/export',
deleteURL: '/resource/delete',
deleteIsBatch: true
},
disabled: false,
dataForm: {
name: '',
creator: '',
delFlag: 0,
selectType: 0,
type: '知识库'
},
typeInput: '知识库',
uuidOne: '',
uuidTwo: '',
uuidSnum: ''
}
},
watch: {},
components: {
putOnTheShelf
},
created() {
this.dataForm.name = ''
this.dataForm.type = '知识库'
},
mounted() {
// window.addEventListener('resize', this.a)
// this.fullScreen()
},
methods: {
reset() {
this.$http
.get(
this.mixinViewModuleOptions.getDataListURL +
'?' +
qs.stringify({
page: 1,
limit: 10,
creator: '',
selectType: 0,
delFlag: 0,
type: '知识库',
name: ''
})
)
.then(({ data: res }) => {
this.dataForm.name = ''
if (res.code !== 0) {
this.dataList = []
this.total = 0
return this.$message.error(res.msg)
}
this.dataList = this.mixinViewModuleOptions.getDataListIsPage
? res.data.list
: res.data
this.dataList.map((item, index) => {
const dataListSinforList = []
item.infoList.map((itemson, indexson) => {
if (
itemson.attrType === '知识库类型'
) {
dataListSinforList.push(itemson)
}
})
this.dataList[index].infoList2 = dataListSinforList
})
console.log('this.dataList', this.dataList)
this.total = this.mixinViewModuleOptions.getDataListIsPage
? res.data.total
: 0
if (this.mixinViewModuleOptions.requestCallback) {
this.mixinViewModuleOptions.requestCallback(res.data)
}
this.dataListLoading = false
})
.catch(() => {
this.dataListLoading = false
})
},
findValue(list, type) {
const found = list.find((item) => item.attrType === type)
if (found) {
return found.attrValue
} else {
return '暂无数据'
}
},
showDetail(val) {
console.log(val)
window.open(window.SITE_CONFIG.previewUrl + '#/details?id=' + val.id)
},
getDataList2(names) {
if (names != null) {
this.$http
.get(
this.mixinViewModuleOptions.getDataListURL +
'?' +
qs.stringify({
pageNum: 1,
pageSize: this.limit,
type: '知识库',
creator: '',
selectType: 0,
delFlag: 0,
name: names
})
)
.then(({ data: res }) => {
if (res.code !== 0) {
this.dataList = []
this.total = 0
return this.$message.error(res.msg)
}
if (res.data.list.length !== 0) {
this.dataList = res.data.list
this.total = this.mixinViewModuleOptions.getDataListIsPage
? res.data.total
: 0
if (this.mixinViewModuleOptions.requestCallback) {
this.mixinViewModuleOptions.requestCallback(res.data)
}
this.dataListLoading = false
this.dataList.map((item, index) => {
const dataListSinforList = []
item.infoList.map((itemson, indexson) => {
if (
itemson.attrType === '知识库类型'
) {
dataListSinforList.push(itemson)
}
})
this.dataList[index].infoList2 = dataListSinforList
})
} else {
this.$message.error('未查询到相关信息')
this.reset()
}
})
.catch(() => {
this.dataListLoading = false
})
} else {
this.$message.error('查询信息不能为空')
}
},
//
clear() {
console.log('清空----------------------------------------')
this.notFilled = []
this.showPutOnTheShelfFlag = false
this.showPutOnTheShelfFlag2 = false
this.insertList = []
this.putOnTheShelfList = []
this.radio = ''
this.submitFrom = {
type: '知识库',
deptId: '',
delFlag: 0,
infoList: [
{
attrType: '知识库类型',
attrValue: '',
delFlag: 0
}
]
}
this.reset()
},
showPutOnTheShelf() {
this.showPutOnTheShelfFlag = true
this.$http.get('/category/getCategoryTree').then((res) => {
console.log('res------获取知识库类型------>', res);
this.insertList = res.data.data.filter(
(item) => item.name === '知识库'
)[0]
})
},
showPutOnTheShelfVue() {
this.showPutOnTheShelfFlag = false
this.showPutOnTheShelfFlag2 = true
if (this.submitFrom.infoList[0]) {
this.submitFrom.infoList[0].attrValue = this.radio
}
this.putOnTheShelfList = this.insertList.children.filter(
(item) => item.name === this.radio
)[0].children
if (this.putOnTheShelfList[0] && this.putOnTheShelfList[0].children && this.putOnTheShelfList[0].children && this.putOnTheShelfList[0].children[0].children) {
this.putOnTheShelfList[0].children[0].children.forEach(v => {
if (v.name == '发布日期') {
//
v.type = 'date'
}
})
}
console.log('this.putOnTheShelfList------------>', this.putOnTheShelfList[0].children[0].children);
},
changeInfoList(obj) {
console.log(obj, this.submitFrom)
this.submitFrom.infoList = this.submitFrom.infoList.filter(
(item) => item.attrType !== obj.attrType
)
this.submitFrom.infoList.push(obj)
},
submitData() {
console.log('提交11111111111===============>', this.putOnTheShelfList, this.submitFrom)
const arr = []
this.putOnTheShelfList.map((item) => {
item.children.map((child) => {
if (child.children) {
child.children.map((val) => {
arr.push(val.name)
if (
val.type === 'input' ||
val.type === 'textArea' ||
val.type === 'select' ||
val.type === 'checkBox' ||
val.type === 'radio'
) {
this.submitFrom.infoList = this.submitFrom.infoList.filter(
(item) => item.attrType !== val.name
)
}
switch (val.name) {
case '标准名称':
case '模型名称':
this.submitFrom.name = val.note1
break;
case '标准简介':
case '模型描述':
this.submitFrom.description = val.note1
break;
case '联系方式':
this.submitFrom.deptPhone = val.note1
break;
default:
if (
val.type !== 'image' &&
val.type !== 'file' &&
val.type !== 'video'
) {
this.submitFrom.infoList.push({
attrType: val.name,
attrValue: val.note1,
delFlag: 0
})
} else {
if (
this.submitFrom.infoList.filter(
(value) => value.attrType === val.name
).length === 0
) {
this.submitFrom.infoList.push({
attrType: val.name,
attrValue: val.note1,
delFlag: 0,
note2: val.note2 || null
})
}
}
break;
}
})
}
})
})
this.submitFrom.infoList = this.submitFrom.infoList.sort(
(a, b) => arr.indexOf(a.attrType) - arr.indexOf(b.attrType)
)
console.log('this.submitFrom------------>', this.submitFrom);
this.notFilled = []
if (!this.submitFrom.name) {
this.notFilled.push('标准名称')
this.notFilled.push('模型名称')
}
// if (this.radio === '' && !this.submitFrom.apiMethodType) {
// if ((this.submitFrom.infoList.filter(val => val.attrType === '使')[0].attrValue === '')) {
// this.notFilled.push('')
// }
// }
// if (this.radio === '' && (!this.submitFrom.infoList.filter(val => val.attrType === '')[0] || !this.submitFrom.infoList.filter(val => val.attrType === '')[0].attrValue)) {
// this.notFilled.push('')
// }
// console.log(this.submitFrom, this.notFilled, '')
if (this.notFilled.length > 0) {
this.$message({
message: '请填写必填字段!',
type: 'warning'
})
} else {
if (this.submitFrom.id) {
//
this.submitFrom.infoList.map((val) => {
if (val.attrType === '知识库类型') {
val.attrValue = this.radio
}
})
console.log('编辑===============>', this.submitFrom)
console.log(this.submitFrom.infoList, '===============abc')
//
const newArr = this.submitFrom.infoList.filter(
(element, index, self) => {
return (
self.findIndex((x) => x.attrType === element.attrType) === index
)
}
)
this.submitFrom.infoList = newArr
//
this.submitFrom.infoList = this.submitFrom.infoList.filter(item => item.attrValue)
this.$http
.put('/resource/update', this.submitFrom)
.then(({ data: res }) => {
if (res.code !== 0) {
this.$message.error('修改失败!')
} else {
this.$message.success('修改成功!')
this.clear()
}
})
.catch(() => { })
} else {
console.log('提交11111111111===============>', this.putOnTheShelfList, this.submitFrom)
this.$http
.post('/resource/insert?source= b', this.submitFrom)
.then(({ data: res }) => {
if (res.code !== 0) {
this.$message.error('上架失败!')
} else {
this.$message.success('上架成功!')
this.clear()
}
})
.catch(() => { })
}
}
},
//
UpdateData(item) {
this.$http.get('/category/getCategoryTree').then((res) => {
this.insertList = res.data.data.filter(
(item) => item.name === '知识库'
)[0]
console.log('this.insertList-------www----->', this.insertList);
this.radio = item.infoList.filter(
(val) => val.attrType === '知识库类型'
)[0].attrValue
this.putOnTheShelfList = this.insertList.children.filter(
(item) => item.name === this.radio
)[0].children;
if (this.putOnTheShelfList[0] && this.putOnTheShelfList[0].children && this.putOnTheShelfList[0].children && this.putOnTheShelfList[0].children[0].children) {
this.putOnTheShelfList[0].children[0].children.forEach(v => {
if (v.name == '发布日期') {
//
v.type = 'date'
}
})
}
this.putOnTheShelfList.map((parent) => {
console.log('parent-------ssss----->', parent);
parent.children.map((child) => {
if (child.children) {
child.children.map((data) => {
switch (data.name) {
case '模型名称':
case '标准名称':
data.note1 = item.name
break
case '标准简介':
case '模型描述':
data.note1 = item.description
break
case '联系方式':
data.note1 = item.deptPhone
break
// case '':
// data.note1 = item.deptId
// break
default:
// eslint-disable-next-line no-case-declarations
const obj1 = item.infoList.filter(
(val) => val.attrType === data.name
)[0]
if (obj1) {
data.note1 = obj1.attrValue
}
break
}
if (
data.type === 'image' ||
data.type === 'file' ||
data.type === 'video'
) {
const obj1 = item.infoList.filter(
(val) => val.attrType === data.name
)[0]
if (obj1) {
data.note2 = obj1.note2
}
}
})
}
})
})
this.submitFrom.id = item.id
this.showPutOnTheShelfFlag2 = true
})
}
}
}
</script>
<style lang="scss" scoped>
.el-tooltip__popper {
max-width: 50%;
}
// ::v-deep .el-table .cell {
// width: 200px;
// }
::v-deep .el-upload-list__item-name {
width: 400px;
}
</style>

View File

@ -82,6 +82,11 @@ js:
<el-radio v-for="item in options" :label="item.dictLabel" :key="item.dictLabel">{{item.dictLabel}}</el-radio>
</el-radio-group> -->
<a-textarea v-else-if="type == 'textArea'" @change="changeIiem(name,data.note1)" v-model:value="data.note1" :showCount="true" :maxlength="200" :placeholder="'请填写' + name" />
<div class="block" v-else-if="type == 'date'">
<el-date-picker v-model="data.note1" type="date" :placeholder="'选择' + name" value-format="yyyy-MM-dd">
</el-date-picker>
</div>
</div>
</template>
<script>

View File

@ -47,6 +47,7 @@
<input-select-checkbox :changeField='changeField' :list="[]" v-else-if="item.type == 'checkBox'" type="checkBox" :data="item" :name="item.name" :options="item.options"></input-select-checkbox>
<input-select-checkbox :changeField='changeField' :list="[]" v-else-if="item.type == 'radio'" type="radio" :data="item" :name="item.name" :options="item.options"></input-select-checkbox>
<input-select-checkbox :changeField='changeField' :list="[]" v-else-if="item.type == 'textArea'" type="textArea" :data="item" :name="item.name"></input-select-checkbox>
<input-select-checkbox :changeField='changeField' :list="[]" v-else-if="item.type == 'date'" type="date" :data="item" :name="item.name"></input-select-checkbox>
</div>
<div class="requiredTips" v-show="notFilled.indexOf(item.name) > -1 && (item.type=='input' || item.type=='textArea') && changeField.indexOf(item.name) == -1">请填写{{item.name}}</div>
<div class="requiredTips" v-show="notFilled.indexOf(item.name) > -1 && (item.type=='select' || item.type=='checkBox' || item.type=='radio') && changeField.indexOf(item.name) == -1">请选择{{item.name}}</div>