能力挂接 组件服务 置顶功能

This commit is contained in:
a0049873 2022-11-08 17:16:19 +08:00
parent a5be25cec4
commit 7ba6767cda
2 changed files with 198 additions and 148 deletions

View File

@ -2,7 +2,7 @@ import Cookies from 'js-cookie'
import qs from 'qs' import qs from 'qs'
import { deepClone } from '@/utils/form-generator/index' import { deepClone } from '@/utils/form-generator/index'
export default { export default {
data() { data () {
/* eslint-disable */ /* eslint-disable */
return { return {
// 设置属性 // 设置属性
@ -38,99 +38,132 @@ export default {
} }
/* eslint-enable */ /* eslint-enable */
}, },
created() { created () {
if (this.mixinViewModuleOptions.createdIsNeed) { if (this.mixinViewModuleOptions.createdIsNeed) {
this.query() this.query()
} }
}, },
activated() { activated () {
if (this.mixinViewModuleOptions.activatedIsNeed) { if (this.mixinViewModuleOptions.activatedIsNeed) {
this.query() this.query()
} }
}, },
methods: { methods: {
// 获取数据列表 // 获取数据列表
query() { query () {
this.dataListLoading = true this.dataListLoading = true
this.$http.get( if (this.mixinViewModuleOptions.getDataListURL !== '/resource/pageWithAttrs') {
this.mixinViewModuleOptions.getDataListURL + '?' + qs.stringify({ this.$http.get(
// order: this.order, this.mixinViewModuleOptions.getDataListURL + '?' + qs.stringify({
// orderField: this.orderField, // order: this.order,
// type: '组件服务', // orderField: this.orderField,
name: '', // type: '组件服务',
page: this.mixinViewModuleOptions.getDataListIsPage ? this.page : null, name: '',
limit: this.mixinViewModuleOptions.getDataListIsPage ? this.limit : null, page: this.mixinViewModuleOptions.getDataListIsPage ? this.page : null,
...this.dataForm limit: this.mixinViewModuleOptions.getDataListIsPage ? this.limit : null,
}) ...this.dataForm
})
).then(({ data: res }) => { ).then(({ data: res }) => {
if (res.code !== 0) { if (res.code !== 0) {
this.dataList = [] this.dataList = []
this.total = 0 this.total = 0
return this.$message.error(res.msg) return this.$message.error(res.msg)
}
this.dataList = this.mixinViewModuleOptions.getDataListIsPage ? res.data.list : res.data
this.dataList.map((item, index) => {
if (this.dataList[index].type != null) {
switch (item.type) {
case 1: this.dataList[index].type = '省'; break
case 2: this.dataList[index].type = '市'; break
case 3: this.dataList[index].type = '区'; break
case 4: this.dataList[index].type = '企业'; break
}
} }
if (item.children != null) { this.dataList = this.mixinViewModuleOptions.getDataListIsPage ? res.data.list : res.data
item.children.map((item2, index2) => { this.dataList.map((item, index) => {
switch (item2.type) { if (this.dataList[index].type != null) {
case 1: this.dataList[index].children[index2].type = '省'; break switch (item.type) {
case 2: this.dataList[index].children[index2].type = '市'; break case 1: this.dataList[index].type = '省'; break
case 3: this.dataList[index].children[index2].type = '区'; break case 2: this.dataList[index].type = '市'; break
case 4: this.dataList[index].children[index2].type = '企业'; break case 3: this.dataList[index].type = '区'; break
case 4: this.dataList[index].type = '企业'; break
} }
}
if (item.children != null) {
item.children.map((item2, index2) => {
switch (item2.type) {
case 1: this.dataList[index].children[index2].type = '省'; break
case 2: this.dataList[index].children[index2].type = '市'; break
case 3: this.dataList[index].children[index2].type = '区'; break
case 4: this.dataList[index].children[index2].type = '企业'; break
}
})
}
})
// 我的代办特殊处理
if (this.mixinViewModuleOptions.getDataListURL === '/act/task/myToDoTaskPage') {
this.$http.get('/sys/user/info').then(userRes => {
console.log('当前用户信息===========>', userRes.data.data.id)
const userId = userRes.data.data.id
// this.dataList = this.dataList.filter(item => {
// // userId creator
// console.log(item.params.creator)
// if (!(item.params.creator === userId) && !(item.params.userId === userId)) {
// return item
// }
// })
this.total = this.mixinViewModuleOptions.getDataListIsPage ? res.data.total : 0
})
} else {
this.total = this.mixinViewModuleOptions.getDataListIsPage ? res.data.total : 0
}
console.log('数据列表', this.dataList, this.mixinViewModuleOptions.getDataListURL)
if (this.dataList[0].type === '组件服务') {
this.dataList.map(val => {
val.infoList2 = val.infoList.filter(item => item.attrType === '应用领域' || item.attrType === '组件类型')
})
} else if (this.dataList[0].type === '应用资源') {
this.dataList.map(val => {
val.infoList2 = val.infoList.filter(item => item.attrType === '应用领域')
}) })
} }
if (this.mixinViewModuleOptions.requestCallback) {
this.mixinViewModuleOptions.requestCallback(res.data)
}
this.dataListLoading = false
}).catch(() => {
this.dataListLoading = false
}) })
// 我的代办特殊处理 } else {
if (this.mixinViewModuleOptions.getDataListURL === '/act/task/myToDoTaskPage') { this.$http.post(
this.$http.get('/sys/user/info').then(userRes => { this.mixinViewModuleOptions.getDataListURL, {
console.log('当前用户信息===========>', userRes.data.data.id) pageNum: this.mixinViewModuleOptions.getDataListIsPage ? this.page : null,
const userId = userRes.data.data.id pageSize: this.mixinViewModuleOptions.getDataListIsPage ? this.limit : null,
// this.dataList = this.dataList.filter(item => { ...this.dataForm
// // userId creator }
// console.log(item.params.creator) ).then(({ data: res }) => {
// if (!(item.params.creator === userId) && !(item.params.userId === userId)) { if (res.code !== 0) {
// return item this.dataList = []
// } this.total = 0
// }) return this.$message.error(res.msg)
this.total = this.mixinViewModuleOptions.getDataListIsPage ? res.data.total : 0 }
}) this.dataList = this.mixinViewModuleOptions.getDataListIsPage ? res.data.records : res.data
} else {
this.total = this.mixinViewModuleOptions.getDataListIsPage ? res.data.total : 0 this.total = this.mixinViewModuleOptions.getDataListIsPage ? res.data.total : 0
} if (this.dataList[0].type === '组件服务') {
console.log('数据列表', this.dataList, this.mixinViewModuleOptions.getDataListURL) this.dataList.map(val => {
if (this.dataList[0].type === '组件服务') { val.infoList2 = val.infoList.filter(item => item.attrType === '应用领域' || item.attrType === '组件类型')
this.dataList.map(val => { })
val.infoList2 = val.infoList.filter(item => item.attrType === '应用领域' || item.attrType === '组件类型') } else if (this.dataList[0].type === '应用资源') {
}) this.dataList.map(val => {
} else if (this.dataList[0].type === '应用资源') { val.infoList2 = val.infoList.filter(item => item.attrType === '应用领域')
this.dataList.map(val => { })
val.infoList2 = val.infoList.filter(item => item.attrType === '应用领域') }
}) if (this.mixinViewModuleOptions.requestCallback) {
} this.mixinViewModuleOptions.requestCallback(res.data)
if (this.mixinViewModuleOptions.requestCallback) { }
this.mixinViewModuleOptions.requestCallback(res.data) this.dataListLoading = false
} }).catch(() => {
this.dataListLoading = false this.dataListLoading = false
}).catch(() => { })
this.dataListLoading = false }
})
}, },
// 多选 // 多选
dataListSelectionChangeHandle(val) { dataListSelectionChangeHandle (val) {
this.dataListSelections = val this.dataListSelections = val
}, },
// 排序 // 排序
dataListSortChangeHandle(data) { dataListSortChangeHandle (data) {
if (!data.order || !data.prop) { if (!data.order || !data.prop) {
this.order = '' this.order = ''
this.orderField = '' this.orderField = ''
@ -141,13 +174,13 @@ export default {
this.query() this.query()
}, },
// 分页, 每页条数 // 分页, 每页条数
pageSizeChangeHandle(val) { pageSizeChangeHandle (val) {
this.page = 1 this.page = 1
this.limit = val this.limit = val
this.query() this.query()
}, },
// 分页, 当前页 // 分页, 当前页
pageCurrentChangeHandle(val) { pageCurrentChangeHandle (val) {
this.page = val this.page = val
this.query() this.query()
}, },
@ -156,7 +189,7 @@ export default {
this.query() this.query()
}, },
// 新增 // 新增
addOrUpdateHandle(id) { addOrUpdateHandle (id) {
this.addOrUpdateVisible = true this.addOrUpdateVisible = true
this.disabled = false this.disabled = false
this.$nextTick(() => { this.$nextTick(() => {
@ -167,7 +200,7 @@ export default {
}, },
// 组件服务新增 // 组件服务新增
addOrUpdateHandleAI(id) { addOrUpdateHandleAI (id) {
// const infoList = [] // const infoList = []
let showList = [] let showList = []
this.$http.get('category/getCategoryTree').then(({ data: res }) => { this.$http.get('category/getCategoryTree').then(({ data: res }) => {
@ -225,7 +258,7 @@ export default {
}, 100) }, 100)
}, },
// 应用资源新增 // 应用资源新增
addOrUpdateHandleServe(id) { addOrUpdateHandleServe (id) {
// const infoList = [] // const infoList = []
let showList = [] let showList = []
this.$http.get('category/getCategoryTree').then(({ data: res }) => { this.$http.get('category/getCategoryTree').then(({ data: res }) => {
@ -283,7 +316,7 @@ export default {
}, 100) }, 100)
}, },
// 修改 // 修改
UpdateHandle(val) { UpdateHandle (val) {
this.addOrUpdateVisible = true this.addOrUpdateVisible = true
this.disabled = false this.disabled = false
const cloneVal = deepClone(val) const cloneVal = deepClone(val)
@ -308,7 +341,7 @@ export default {
}) })
}, },
// 关闭当前窗口 // 关闭当前窗口
closeCurrentTab(data) { closeCurrentTab (data) {
var tabName = this.$store.state.contentTabsActiveName var tabName = this.$store.state.contentTabsActiveName
this.$store.state.contentTabs = this.$store.state.contentTabs.filter(item => item.name !== tabName) this.$store.state.contentTabs = this.$store.state.contentTabs.filter(item => item.name !== tabName)
if (this.$store.state.contentTabs.length <= 0) { if (this.$store.state.contentTabs.length <= 0) {
@ -320,7 +353,7 @@ export default {
} }
}, },
// 删除 // 删除
deleteHandle(id) { deleteHandle (id) {
if (this.mixinViewModuleOptions.deleteIsBatch && !id && this.dataListSelections.length <= 0) { if (this.mixinViewModuleOptions.deleteIsBatch && !id && this.dataListSelections.length <= 0) {
return this.$message({ return this.$message({
message: this.$t('prompt.deleteBatch'), message: this.$t('prompt.deleteBatch'),
@ -354,46 +387,46 @@ export default {
}).catch(() => { }) }).catch(() => { })
}, },
deleteHandle2(id) { deleteHandle2 (id) {
if(id==undefined && this.dataListSelections.length < 1){ if (id == undefined && this.dataListSelections.length < 1) {
this.$message({ this.$message({
type: 'info', type: 'info',
message: '请选择要删除的数据' message: '请选择要删除的数据'
}) })
}else{ } else {
this.$confirm('确认是否删除?', '提示', { this.$confirm('确认是否删除?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
const ids = [] const ids = []
if (id) { if (id) {
ids.push(id) ids.push(id)
} else { } else {
if (this.dataListSelections.length > 0) { if (this.dataListSelections.length > 0) {
this.dataListSelections.forEach(item => { this.dataListSelections.forEach(item => {
ids.push(item.id) ids.push(item.id)
}) })
}
} }
} this.$http.post('/resource/delete', { ids: ids }).then(res => {
this.$http.post('/resource/delete', { ids: ids }).then(res => { console.log('删除成功', res)
console.log('删除成功', res) this.$message({
this.$message({ type: 'success',
type: 'success', message: '删除成功!'
message: '删除成功!' })
}); this.getDataList()
this.getDataList() })
}) }).catch(() => {
}).catch(() => {
// this.$message({ // this.$message({
// type: 'info', // type: 'info',
// message: '已取消删除' // message: '已取消删除'
// }); // });
}); })
} }
}, },
// 导出 // 导出
exportHandle() { exportHandle () {
var params = qs.stringify({ var params = qs.stringify({
token: Cookies.get('ucsToken'), token: Cookies.get('ucsToken'),
...this.dataForm ...this.dataForm

View File

@ -130,7 +130,14 @@
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
v-if="scope.row.infoList.filter(val=>val.attrType=='组件类型')[0].attrValue == '智能算法'" v-if="scope.row.infoList.filter(val=>val.attrType=='组件类型')[0].attrValue == '智能算法' && scope.row.pinTop == 1"
type="text"
size="small"
@click="noToppingCapacity(scope.row)"
>取消置顶</el-button
>
<el-button
v-if="scope.row.infoList.filter(val=>val.attrType=='组件类型')[0].attrValue == '智能算法' &&scope.row.pinTop != 1"
type="text" type="text"
size="small" size="small"
@click="toppingCapacity(scope.row)" @click="toppingCapacity(scope.row)"
@ -268,7 +275,7 @@ export default {
] ]
}, },
mixinViewModuleOptions: { mixinViewModuleOptions: {
getDataListURL: '/resource/page', getDataListURL: '/resource/pageWithAttrs',
getDataListIsPage: true, getDataListIsPage: true,
exportURL: '/ability/bsabilityai/export', exportURL: '/ability/bsabilityai/export',
deleteURL: '/resource/delete', deleteURL: '/resource/delete',
@ -279,11 +286,12 @@ export default {
fieldArr: dictionaries.fieldArr, fieldArr: dictionaries.fieldArr,
shareFormArr: dictionaries.shareFormArr, shareFormArr: dictionaries.shareFormArr,
dataForm: { dataForm: {
name: '', orderField: 'pin_top',
creator: '', orderType: 'DESC',
infoList: [],
delFlag: 0, delFlag: 0,
selectType: 0, type: '组件服务',
type: '组件服务' name: ''
}, },
// qp: false, // qp: false,
// //
@ -323,31 +331,45 @@ export default {
message: '置顶成功', message: '置顶成功',
type: 'success' type: 'success'
}) })
this.reset()
} else { } else {
this.$message({ this.$message({
message: '置顶失败', message: '置顶失败',
type: 'warning' type: 'warning'
}) })
this.reset()
}
})
},
noToppingCapacity (item) {
this.$http.put('/resource/cancel_pin_top/' + item.id).then(res => {
if (res.data.code == 0) {
this.$message({
message: '取消置顶成功',
type: 'success'
})
this.reset()
} else {
this.$message({
message: '取消置顶失败',
type: 'warning'
})
this.reset()
} }
}) })
}, },
reset () { reset () {
this.$http this.$http
.get( .post(
this.mixinViewModuleOptions.getDataListURL + this.mixinViewModuleOptions.getDataListURL, {
'?' + pageNum: 1,
qs.stringify({ pageSize: 10,
// order: this.order, orderType: 'DESC',
// orderField: this.orderField, infoList: [],
// type: '', delFlag: 0,
page: 1, type: '组件服务',
limit: 10, name: ''
creator: '', }
selectType: 0,
delFlag: 0,
type: '组件服务',
name: ''
})
) )
.then(({ data: res }) => { .then(({ data: res }) => {
this.dataForm.name = '' this.dataForm.name = ''
@ -357,7 +379,7 @@ export default {
return this.$message.error(res.msg) return this.$message.error(res.msg)
} }
this.dataList = this.mixinViewModuleOptions.getDataListIsPage this.dataList = this.mixinViewModuleOptions.getDataListIsPage
? res.data.list ? res.data.records
: res.data : res.data
this.dataList.map((item, index) => { this.dataList.map((item, index) => {
const dataListSinforList = [] const dataListSinforList = []
@ -492,21 +514,16 @@ export default {
getDataList2 (names) { getDataList2 (names) {
if (names != null) { if (names != null) {
this.$http this.$http
.get( .post(
this.mixinViewModuleOptions.getDataListURL + this.mixinViewModuleOptions.getDataListURL, {
'?' + pageNum: 1,
qs.stringify({ pageSize: 10,
// order: this.order, orderType: 'DESC',
// orderField: this.orderField, infoList: [],
// type: '', delFlag: 0,
pageNum: 1, type: '组件服务',
pageSize: this.limit, name: names
type: '组件服务', }
creator: '',
selectType: 0,
delFlag: 0,
name: names
})
) )
.then(({ data: res }) => { .then(({ data: res }) => {
if (res.code !== 0) { if (res.code !== 0) {
@ -514,8 +531,8 @@ export default {
this.total = 0 this.total = 0
return this.$message.error(res.msg) return this.$message.error(res.msg)
} }
if (res.data.list.length >= 0) { if (res.data.records.length >= 0) {
this.dataList = res.data.list this.dataList = res.data.records
this.total = this.mixinViewModuleOptions.getDataListIsPage this.total = this.mixinViewModuleOptions.getDataListIsPage
? res.data.total ? res.data.total
: 0 : 0