hi-ucs/back/src/views/modules/ability/bsabilityai.vue

1057 lines
34 KiB
Vue
Raw Normal View History

2022-06-14 09:32:49 +08:00
<template>
<el-card shadow="never" class="aui-card--fill">
<div class="mod-ability__bsabilityai">
2022-06-21 18:04:15 +08:00
<el-form :inline="true" :model="dataForm">
2022-06-14 09:32:49 +08:00
<el-form-item>
<el-input
v-model="dataForm.name"
placeholder="名称"
clearable
></el-input>
</el-form-item>
<el-form-item>
2022-06-21 18:04:15 +08:00
<el-button type="primary" @click="getDataList2(dataForm.name)">{{
2022-07-18 18:53:04 +08:00
$t('query')
2022-06-14 09:32:49 +08:00
}}</el-button>
</el-form-item>
<el-form-item>
2022-11-17 15:37:09 +08:00
<el-button type="primary" @click="exportHandle()">{{
2022-07-18 18:53:04 +08:00
$t('export')
2022-06-14 09:32:49 +08:00
}}</el-button>
</el-form-item>
2022-07-11 15:41:18 +08:00
<!-- <el-form-item>
2022-06-14 09:32:49 +08:00
<el-button
v-if="$hasPermission('ability:bsabilityai:save')"
type="primary"
@click="addOrUpdateHandleAI()"
>挂接</el-button
>
2022-07-11 15:41:18 +08:00
</el-form-item> -->
2022-07-08 15:51:55 +08:00
<el-form-item>
2022-07-18 18:53:04 +08:00
<el-button type="primary" @click="showPutOnTheShelf()"
2022-07-08 15:51:55 +08:00
>上架</el-button
>
</el-form-item>
2022-06-14 09:32:49 +08:00
<el-form-item>
<el-button
v-if="$hasPermission('ability:bsabilityai:delete')"
2022-11-17 15:37:09 +08:00
type="primary"
2022-06-14 09:32:49 +08:00
@click="deleteHandle2()"
2022-07-18 18:53:04 +08:00
>{{ $t('deleteBatch') }}</el-button
2022-06-14 09:32:49 +08:00
>
</el-form-item>
<el-form-item>
2022-11-17 15:37:09 +08:00
<el-button type="primary" @click="reset">重置</el-button>
2022-06-14 09:32:49 +08:00
</el-form-item>
</el-form>
<el-table
v-loading="dataListLoading"
:data="dataList"
border
@selection-change="dataListSelectionChangeHandle"
2022-06-21 18:04:15 +08:00
style="width: 100%"
2022-07-26 16:50:02 +08:00
height="650px"
2022-06-14 09:32:49 +08:00
>
<el-table-column
type="selection"
header-align="center"
align="center"
width="50"
></el-table-column>
<af-table-column
2022-07-05 15:00:38 +08:00
:show-overflow-tooltip="true"
width="280"
2022-06-14 09:32:49 +08:00
prop="name"
label="组件名称"
header-align="center"
align="center"
></af-table-column>
<af-table-column
:show-overflow-tooltip="true"
width="280"
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>
2022-07-16 10:00:27 +08:00
<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">
2022-06-14 09:32:49 +08:00
<af-table-column
2022-07-18 18:53:04 +08:00
:show-overflow-tooltip="true"
2022-07-25 17:20:51 +08:00
width="280"
v-for="(item, index) in dataList[0].infoList2"
2022-06-14 09:32:49 +08:00
:key="index"
:label="item.attrType"
header-align="center"
align="center"
>
<template slot-scope="scope">
{{ findValue(scope.row.infoList2, item.attrType) }}
2022-06-14 09:32:49 +08:00
</template>
</af-table-column>
2022-07-22 15:46:13 +08:00
</template>
2022-06-14 09:32:49 +08:00
<el-table-column
:label="$t('handle')"
fixed="right"
header-align="center"
align="center"
2022-07-26 16:50:02 +08:00
width="150"
2022-06-14 09:32:49 +08:00
>
<template slot-scope="scope">
2022-08-15 14:36:54 +08:00
<el-button
2022-11-08 17:16:19 +08:00
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"
2022-06-14 09:32:49 +08:00
type="text"
size="small"
2022-08-15 14:36:54 +08:00
@click="toppingCapacity(scope.row)"
>置顶</el-button
>
2022-07-11 15:41:18 +08:00
<el-button
v-if="$hasPermission('ability:bsabilityai:update')"
type="text"
size="small"
@click="UpdateData(scope.row)"
2022-07-18 18:53:04 +08:00
>{{ $t('update') }}</el-button
2022-06-14 09:32:49 +08:00
>
<el-button
v-if="$hasPermission('ability:bsabilityai:delete')"
type="text"
size="small"
@click="deleteHandle2(scope.row.id)"
2022-07-18 18:53:04 +08:00
>{{ $t('delete') }}</el-button
2022-06-14 09:32:49 +08:00
>
2022-11-21 11:15:40 +08:00
<el-button
v-if="superAdmin == 1"
type="text"
size="small"
@click="deleteCompletely(scope.row)"
>完全删除</el-button
>
2022-06-14 09:32:49 +08:00
<el-button type="text" size="small" @click="showDetail(scope.row)"
2022-07-18 18:24:28 +08:00
>详情</el-button
2022-06-14 09:32:49 +08:00
>
<el-button type="text" size="small" @click="showDocument(scope.row)"
2022-08-03 14:05:42 +08:00
>技术文档</el-button
2022-06-14 09:32:49 +08:00
>
2022-07-18 18:53:04 +08:00
<el-button
type="text"
size="small"
@click="showRelateApplication(scope.row)"
>关联应用</el-button
>
2022-06-14 09:32:49 +08:00
</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>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update
:disabled="disabled"
v-if="addOrUpdateVisible"
ref="addOrUpdate"
@refreshDataList="getDataList"
></add-or-update>
2022-07-18 18:53:04 +08:00
<relate-application
v-if="relateApplicationVisible"
ref="relateApplication"
:nameArray="['未关联应用名称', '已关联应用名称']"
:relateInfo="relateInfo"
@isShowRelatePopup="handleIsShowRelatePopup"
></relate-application>
2022-06-14 09:32:49 +08:00
</div>
2022-07-08 15:51:55 +08:00
<el-dialog
title="选择组件类型"
:visible.sync="showPutOnTheShelfFlag"
2022-07-18 18:53:04 +08:00
:close-on-click-modal="false"
:close-on-press-escape="false"
:before-close="clear"
width="30%"
>
2022-07-08 15:51:55 +08:00
<el-radio v-model="radio" label="智能算法">智能算法</el-radio>
<el-radio v-model="radio" label="图层服务">图层服务</el-radio>
<el-radio v-model="radio" label="开发组件">开发组件</el-radio>
<el-radio v-model="radio" label="业务组件">业务组件</el-radio>
<span slot="footer" class="dialog-footer">
<el-button @click="clear"> </el-button>
2022-07-18 18:53:04 +08:00
<el-button type="primary" @click="showPutOnTheShelfVue"
> </el-button
>
2022-07-08 15:51:55 +08:00
</span>
</el-dialog>
<el-dialog
2022-07-18 18:53:04 +08:00
:title="submitFrom.id ? '修改' + radio : '上架' + radio"
2022-07-08 15:51:55 +08:00
:visible.sync="showPutOnTheShelfFlag2"
2022-07-18 18:53:04 +08:00
:close-on-click-modal="false"
:close-on-press-escape="false"
:destroy-on-close="true"
:before-close="clear"
width="60%"
2022-07-18 18:53:04 +08:00
>
<putOnTheShelf
ref="putOnTheShelf"
2022-07-18 18:53:04 +08:00
:putOnTheShelfList="putOnTheShelfList"
@changeInfoList="changeInfoList"
:type="radio"
:typeInput="typeInput"
:required="required"
:notFilled="notFilled"
@submitData="submitData"
2022-07-18 18:53:04 +08:00
></putOnTheShelf>
2022-07-08 15:51:55 +08:00
<span slot="footer" class="dialog-footer">
<el-button @click="clear"> </el-button>
<el-button type="primary" @click="submitData"> </el-button>
</span>
</el-dialog>
2022-06-14 09:32:49 +08:00
</el-card>
</template>
<script>
2022-07-05 15:00:38 +08:00
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './bsabilityai-add-or-update'
import dictionaries from '@/utils/dictionaries'
import qs from 'qs'
2022-07-27 10:54:34 +08:00
import { pinyin } from 'pinyin-pro'
2022-07-05 15:00:38 +08:00
import RelateApplication from './bsabilityai-relate-application.vue'
2022-07-08 15:51:55 +08:00
import putOnTheShelf from '@/views/modules/putOnTheShelf'
import Cookies from 'js-cookie'
2022-06-14 09:32:49 +08:00
export default {
mixins: [mixinViewModule],
2022-07-05 15:00:38 +08:00
data () {
2022-06-14 09:32:49 +08:00
return {
2022-11-21 11:15:40 +08:00
superAdmin: '',
required: ['归属部门', '部门联系人', '部门联系人电话', '应用领域', '共享条件', '算法名称', '算法描述', '图层名称', '图层描述', '组件名称', '组件描述', '组件地址', '服务地址', '服务接口', '接口请求方式', '算法类别'],
notFilled: [],
2022-07-08 15:51:55 +08:00
insertList: [],
putOnTheShelfList: [],
radio: '',
showPutOnTheShelfFlag: false,
showPutOnTheShelfFlag2: false,
routePath: '',
2022-07-08 15:51:55 +08:00
submitFrom: {
type: '组件服务',
deptId: '',
delFlag: 0,
infoList: [
{
attrType: '组件类型',
attrValue: '',
delFlag: 0
}
]
},
2022-06-14 09:32:49 +08:00
mixinViewModuleOptions: {
2022-11-08 17:16:19 +08:00
getDataListURL: '/resource/pageWithAttrs',
2022-06-14 09:32:49 +08:00
getDataListIsPage: true,
2022-07-05 15:00:38 +08:00
exportURL: '/ability/bsabilityai/export',
deleteURL: '/resource/delete',
2022-12-16 16:06:57 +08:00
deleteIsBatch: true
2022-06-14 09:32:49 +08:00
},
disabled: false,
sceneArr: dictionaries.sceneArr,
fieldArr: dictionaries.fieldArr,
shareFormArr: dictionaries.shareFormArr,
dataForm: {
2022-11-08 17:16:19 +08:00
orderField: 'pin_top',
orderType: 'DESC',
infoList: [],
2022-06-14 09:32:49 +08:00
delFlag: 0,
2022-11-08 17:16:19 +08:00
type: '组件服务',
name: '',
2022-12-16 16:06:57 +08:00
deptIds: [],
region: true
2022-06-14 09:32:49 +08:00
},
2022-07-26 16:50:02 +08:00
// qp: false,
2022-06-22 16:40:01 +08:00
// 关联应用弹窗
relateApplicationVisible: false,
relateInfo: {
id: '',
responseData: {},
linkType: ''
2022-07-11 16:12:59 +08:00
},
2022-07-27 10:54:34 +08:00
typeInput: '组件服务',
uuidOne: '',
uuidTwo: '',
uuidSnum: ''
2022-07-05 15:00:38 +08:00
}
2022-06-14 09:32:49 +08:00
},
watch: {},
components: {
2022-06-21 18:04:15 +08:00
AddOrUpdate,
2022-07-08 15:51:55 +08:00
RelateApplication,
putOnTheShelf
2022-06-14 09:32:49 +08:00
},
2022-07-05 15:00:38 +08:00
created () {
this.dataForm.name = ''
this.dataForm.type = '组件服务'
2022-11-21 11:15:40 +08:00
this.$http.get('/sys/user/info').then(res => {
console.log('res', res.data.data, !res.data.data.superAdmin, this.$store.state.user.roleIdList)
2022-11-21 11:15:40 +08:00
this.superAdmin = res.data.data.superAdmin
})
2022-06-14 09:32:49 +08:00
},
2022-07-05 15:00:38 +08:00
mounted () {
2022-07-26 16:50:02 +08:00
// window.addEventListener('resize', this.a)
// this.fullScreen()
2022-06-14 09:32:49 +08:00
},
methods: {
2022-08-15 14:36:54 +08:00
// 置顶
toppingCapacity (item) {
this.$http.put('/resource/pin_top/' + item.id).then(res => {
console.log('置顶', res.data.code)
if (res.data.code == 0) {
this.$message({
message: '置顶成功',
type: 'success'
})
2022-11-08 17:16:19 +08:00
this.reset()
2022-08-15 14:36:54 +08:00
} else {
this.$message({
message: '置顶失败',
type: 'warning'
})
2022-11-08 17:16:19 +08:00
this.reset()
}
})
},
exportHandle () {
window.open(window.SITE_CONFIG.apiURL + '/resource/export?token=' + Cookies.get('ucsToken') + '&' + qs.stringify({
name: this.dataForm.name,
type: '组件服务',
orderField: 'pin_top',
orderType: 'DESC',
delFlag: 0
}))
},
2022-11-08 17:16:19 +08:00
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()
2022-08-15 14:36:54 +08:00
}
})
},
2022-07-05 15:00:38 +08:00
reset () {
2022-06-21 18:04:15 +08:00
this.$http
2022-11-08 17:16:19 +08:00
.post(
this.mixinViewModuleOptions.getDataListURL, {
pageNum: 1,
pageSize: 10,
orderType: 'DESC',
2022-11-10 15:08:53 +08:00
orderField: 'pin_top',
2022-11-08 17:16:19 +08:00
infoList: [],
delFlag: 0,
type: '组件服务',
name: '',
2022-12-16 16:06:57 +08:00
deptIds: [],
region: true
2022-11-08 17:16:19 +08:00
}
2022-06-21 18:04:15 +08:00
)
2022-06-14 09:32:49 +08:00
.then(({ data: res }) => {
2022-07-05 15:00:38 +08:00
this.dataForm.name = ''
2022-06-14 09:32:49 +08:00
if (res.code !== 0) {
2022-07-05 15:00:38 +08:00
this.dataList = []
this.total = 0
return this.$message.error(res.msg)
2022-06-14 09:32:49 +08:00
}
this.dataList = this.mixinViewModuleOptions.getDataListIsPage
2022-11-08 17:16:19 +08:00
? res.data.records
2022-07-05 15:00:38 +08:00
: res.data
this.dataList.map((item, index) => {
const dataListSinforList = []
item.infoList.map((itemson, indexson) => {
if (
itemson.attrType === '应用领域' ||
itemson.attrType === '组件类型'
) {
dataListSinforList.push(itemson)
}
})
this.dataList[index].infoList2 = dataListSinforList
})
2022-07-16 10:00:27 +08:00
console.log('this.dataList', this.dataList)
2022-06-14 09:32:49 +08:00
this.total = this.mixinViewModuleOptions.getDataListIsPage
? res.data.total
2022-07-05 15:00:38 +08:00
: 0
2022-06-14 09:32:49 +08:00
if (this.mixinViewModuleOptions.requestCallback) {
2022-07-05 15:00:38 +08:00
this.mixinViewModuleOptions.requestCallback(res.data)
2022-06-14 09:32:49 +08:00
}
2022-07-05 15:00:38 +08:00
this.dataListLoading = false
2022-06-14 09:32:49 +08:00
})
.catch(() => {
2022-07-05 15:00:38 +08:00
this.dataListLoading = false
})
2022-06-14 09:32:49 +08:00
},
2022-07-05 15:00:38 +08:00
findValue (list, type) {
const found = list.find((item) => item.attrType === type)
2022-06-14 09:32:49 +08:00
if (found) {
2022-07-05 15:00:38 +08:00
return found.attrValue
2022-06-14 09:32:49 +08:00
} else {
2022-07-05 15:00:38 +08:00
return '暂无数据'
2022-06-14 09:32:49 +08:00
}
},
2022-07-05 15:00:38 +08:00
showDetail (val) {
2022-07-18 18:24:28 +08:00
console.log(val)
2022-12-28 17:13:31 +08:00
window.open(window.SITE_CONFIG.previewUrl + '#/details?id=' + val.id + '&&hiddenBackFlag=true')
2022-06-14 09:32:49 +08:00
// this.addOrUpdateHandle(id)
2022-07-18 18:24:28 +08:00
// this.addOrUpdateVisible = true
// this.disabled = false
// this.$nextTick(() => {
// this.$refs.addOrUpdate.UpdateState = false
// this.$refs.addOrUpdate.dataFormShowDetails = val
// this.$refs.addOrUpdate.init()
// })
// this.disabled = true
2022-06-14 09:32:49 +08:00
},
2022-07-27 10:54:34 +08:00
// 创建uuid
uuid (len, radix) {
var chars =
'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
var uuid = []
var i
radix = radix || chars.length
if (len) {
// Compact form
for (i = 0; i < len; i++) uuid[i] = chars[0 | (Math.random() * radix)]
} else {
// rfc4122, version 4 form
var r
// rfc4122 requires these characters
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-'
uuid[14] = '4'
// Fill in random data. At i==19 set the high bits of clock sequence as
// per rfc4122, sec. 4.1.5
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | (Math.random() * 16)
uuid[i] = chars[i == 19 ? (r & 0x3) | 0x8 : r]
}
}
}
return uuid.join('')
},
uuidSplice () {
this.uuidOne = this.uuid(13, 16)
this.uuidTwo = this.uuid(13, 16)
this.uuidSnum = this.uuidOne + this.uuidTwo
this.uuidSnum = this.uuidSnum.replace(/\s+/g, '')
console.log('this.uuidOne', this.uuidSnum)
},
2022-07-05 15:00:38 +08:00
showDocument (val) {
2022-07-27 10:54:34 +08:00
// 第一步:创建文档
// 不存在文档时创建空文档
this.uuidSplice()
const uuidParam = val.infoList.filter((item) => {
if (item.attrType === '技术文档') {
return item
}
})
if (uuidParam.length > 0) {
this.uuidSnum = uuidParam[0].attrValue.split('/')[1].split('.')[0]
} else {
const type = pinyin(val.type, {
pattern: 'initial'
}).replace(/\s*/g, '')
const obj = {
attrType: '技术文档',
attrValue: type + '/' + this.uuidSnum + '.md',
delFlag: 0
}
val.infoList.push(obj)
}
// 存在时加入文档
this.$http
.put('/resource/update', val)
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.$message({
message: this.$t('prompt.success'),
type: 'success',
duration: 500,
onClose: () => {
// 打开这个空的开发文档
window.open(
window.SITE_CONFIG.frontUrl + '?id=' + this.uuidSnum + '&&type=' + val.type,
'_blank'
)
}
})
})
.catch(() => {})
// 第二部update列数据成功后打开文档编辑
2022-06-14 09:32:49 +08:00
},
2022-07-05 15:00:38 +08:00
getDataList2 (names) {
2022-06-14 09:32:49 +08:00
if (names != null) {
2022-06-21 18:04:15 +08:00
this.$http
2022-11-08 17:16:19 +08:00
.post(
this.mixinViewModuleOptions.getDataListURL, {
pageNum: 1,
pageSize: 10,
orderType: 'DESC',
2022-11-10 15:08:53 +08:00
orderField: 'pin_top',
2022-11-08 17:16:19 +08:00
infoList: [],
delFlag: 0,
type: '组件服务',
name: names,
2022-12-16 16:06:57 +08:00
deptIds: [],
region: true
2022-11-08 17:16:19 +08:00
}
2022-06-21 18:04:15 +08:00
)
2022-06-14 09:32:49 +08:00
.then(({ data: res }) => {
if (res.code !== 0) {
2022-07-05 15:00:38 +08:00
this.dataList = []
this.total = 0
return this.$message.error(res.msg)
2022-06-14 09:32:49 +08:00
}
2022-11-08 17:16:19 +08:00
if (res.data.records.length >= 0) {
this.dataList = res.data.records
2022-06-14 09:32:49 +08:00
this.total = this.mixinViewModuleOptions.getDataListIsPage
? res.data.total
2022-07-05 15:00:38 +08:00
: 0
2022-06-14 09:32:49 +08:00
if (this.mixinViewModuleOptions.requestCallback) {
2022-07-05 15:00:38 +08:00
this.mixinViewModuleOptions.requestCallback(res.data)
2022-06-14 09:32:49 +08:00
}
2022-07-05 15:00:38 +08:00
this.dataListLoading = false
this.dataList.map((item, index) => {
const dataListSinforList = []
item.infoList.map((itemson, indexson) => {
if (
itemson.attrType === '应用领域' ||
itemson.attrType === '组件类型'
) {
dataListSinforList.push(itemson)
}
})
this.dataList[index].infoList2 = dataListSinforList
})
2022-06-14 09:32:49 +08:00
} else {
2022-07-05 15:00:38 +08:00
this.$message.error('未查询到相关信息')
this.reset()
2022-06-14 09:32:49 +08:00
}
})
.catch(() => {
2022-07-05 15:00:38 +08:00
this.dataListLoading = false
})
2022-06-14 09:32:49 +08:00
} else {
2022-07-05 15:00:38 +08:00
this.$message.error('查询信息不能为空')
2022-06-14 09:32:49 +08:00
}
},
2022-07-26 16:50:02 +08:00
// fullScreen () {
// if (window.outerHeight === screen.availHeight) {
// if (window.outerWidth === screen.availWidth) {
// this.qp = false
// } else {
// this.qp = true
// }
// } else {
// this.qp = true
// }
// },
2022-06-22 16:40:01 +08:00
// 点击关联应用按钮
2022-07-05 15:00:38 +08:00
showRelateApplication (row) {
2022-07-18 18:53:04 +08:00
this.$http
.get(
`dataResourceRel/queryApplicationRelByResourceId?referenceId=${row.id}`
)
.then(({ data: res }) => {
if (res && res.data) {
this.relateApplicationVisible = true
this.relateInfo = {
id: row.id,
responseData: res.data,
linkType: '2'
}
2022-07-05 15:00:38 +08:00
}
2022-07-18 18:53:04 +08:00
})
.catch(() => {})
2022-06-22 16:40:01 +08:00
},
// 是否展示关联应用弹窗
2022-07-05 15:00:38 +08:00
handleIsShowRelatePopup (type) {
this.relateApplicationVisible = type
2022-07-08 15:51:55 +08:00
},
2022-07-11 15:41:18 +08:00
// 新上架
2022-07-08 15:51:55 +08:00
clear () {
this.$router.push(this.routePath)
2022-07-11 16:10:59 +08:00
console.log('清空----------------------------------------')
this.notFilled = []
2022-07-08 15:51:55 +08:00
this.showPutOnTheShelfFlag = false
this.showPutOnTheShelfFlag2 = false
2022-07-11 16:10:59 +08:00
this.insertList = []
this.putOnTheShelfList = []
2022-07-08 15:51:55 +08:00
this.radio = ''
this.submitFrom = {
type: '组件服务',
deptId: '',
delFlag: 0,
infoList: [
{
attrType: '组件类型',
attrValue: '',
delFlag: 0
}
]
}
2022-07-11 15:41:18 +08:00
this.reset()
2022-07-08 15:51:55 +08:00
},
showPutOnTheShelf () {
this.showPutOnTheShelfFlag = true
2022-07-18 18:53:04 +08:00
this.$http.get('/category/getCategoryTree').then((res) => {
this.insertList = res.data.data.filter(
(item) => item.name === '组件服务'
2022-07-18 18:53:04 +08:00
)[0]
2022-07-08 15:51:55 +08:00
})
},
showPutOnTheShelfVue () {
this.routePath = this.$route.path
2022-07-08 15:51:55 +08:00
this.showPutOnTheShelfFlag = false
this.showPutOnTheShelfFlag2 = true
2022-07-08 17:05:55 +08:00
this.submitFrom.infoList[0].attrValue = this.radio
2022-07-18 18:53:04 +08:00
this.putOnTheShelfList = this.insertList.children.filter(
(item) => item.name === this.radio
)[0].children
2022-07-08 15:51:55 +08:00
},
2022-07-09 15:22:20 +08:00
changeInfoList (obj) {
2022-07-11 15:41:18 +08:00
console.log(obj, this.submitFrom)
2022-07-18 18:53:04 +08:00
this.submitFrom.infoList = this.submitFrom.infoList.filter(
(item) => item.attrType !== obj.attrType
)
2022-07-28 20:37:08 +08:00
this.submitFrom.infoList.push(obj)
2022-07-09 15:22:20 +08:00
},
changeAdd () {
const arr = []
switch (this.radio) {
case '智能算法':
arr.push('算法优势')
arr.push('计费标准信息')
break
case '开发组件':
case '业务组件':
arr.push('功能介绍')
break
}
arr.push('应用场景')
arr.push('常见问题')
this.$refs.putOnTheShelf.submit(arr)
},
2022-11-21 11:15:40 +08:00
// 完全删除
deleteCompletely (row) {
console.log('完全删除===', row)
this.$confirm('确认是否删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http.post('/resource/delResBySuAd?id=' + row.id).then(res => {
console.log('删除结果', res.data)
if (res.data.code == 0) {
this.$message({
type: 'success',
message: '删除成功!'
})
}
this.getDataList()
})
}).catch(() => {
// this.$message({
// type: 'info',
// message: '已取消删除'
// });
})
},
2022-07-08 15:51:55 +08:00
submitData () {
console.log('提交11111111111===============>', this.putOnTheShelfList, this.submitFrom)
2022-07-09 15:22:20 +08:00
const arr = []
2022-07-18 18:53:04 +08:00
this.putOnTheShelfList.map((item) => {
item.children.map((child) => {
2022-07-09 15:22:20 +08:00
if (child.children) {
2022-07-18 18:53:04 +08:00
if (
child.name === '算法优势' ||
child.name === '应用场景' ||
child.name === '功能介绍'
) {
2022-07-09 15:22:20 +08:00
arr.push(child.name)
2022-07-18 18:53:04 +08:00
if (
this.submitFrom.infoList.filter(
(value) => value.attrType === child.name
).length === 0
) {
2022-07-11 16:43:23 +08:00
this.submitFrom.infoList.push({
attrType: child.name,
attrValue: child.note1,
delFlag: 0
})
}
2022-07-09 15:22:20 +08:00
}
2022-07-18 18:53:04 +08:00
child.children.map((val) => {
2022-07-09 15:22:20 +08:00
arr.push(val.name)
2022-07-18 18:53:04 +08:00
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
)
2022-07-09 15:22:20 +08:00
}
if (val.note1 == '' || val.note1) {
2022-07-09 15:22:20 +08:00
switch (val.name) {
case '算法名称':
case '应用名称':
case '组件名称':
case '图层名称':
this.submitFrom.name = val.note1
break
case '算法描述':
case '应用描述':
case '组件描述':
case '图层描述':
this.submitFrom.description = val.note1
break
case '共享条件':
this.submitFrom.shareCondition = val.note1
break
case '共享类型':
this.submitFrom.shareType = val.note1
break
case '服务接口':
this.submitFrom.apiUrl = val.note1
break
case '接口请求方式':
this.submitFrom.apiMethodType = val.note1
break
case '访问地址':
this.submitFrom.link = val.note1
break
case '部门联系人':
this.submitFrom.deptContacts = val.note1
break
case '部门联系人电话':
this.submitFrom.deptPhone = val.note1
break
2022-07-11 15:41:18 +08:00
case '归属部门':
this.submitFrom.deptId = val.note1
break
case '能力类型':
this.submitFrom.type = val.note1
break
2022-07-09 15:22:20 +08:00
default:
2022-07-18 18:53:04 +08:00
if (
val.type !== 'image' &&
val.type !== 'file' &&
val.type !== 'video'
) {
2022-07-11 15:41:18 +08:00
this.submitFrom.infoList.push({
attrType: val.name,
attrValue: val.note1,
delFlag: 0
})
2022-07-11 16:43:23 +08:00
} else {
2022-07-18 18:53:04 +08:00
if (
this.submitFrom.infoList.filter(
(value) => value.attrType === val.name
).length === 0
) {
2022-07-11 16:43:23 +08:00
this.submitFrom.infoList.push({
attrType: val.name,
attrValue: val.note1,
delFlag: 0,
note2: val.note2 || null
})
}
2022-07-11 15:41:18 +08:00
}
2022-07-09 15:22:20 +08:00
break
}
}
})
}
})
})
2022-07-18 18:53:04 +08:00
this.submitFrom.infoList = this.submitFrom.infoList.sort(
(a, b) => arr.indexOf(a.attrType) - arr.indexOf(b.attrType)
)
this.notFilled = []
if (!this.submitFrom.name) {
this.notFilled.push('算法名称')
this.notFilled.push('图层名称')
this.notFilled.push('组件名称')
}
if (!this.submitFrom.description) {
this.notFilled.push('算法描述')
this.notFilled.push('图层描述')
this.notFilled.push('组件描述')
}
if (!this.submitFrom.shareCondition) {
this.notFilled.push('共享条件')
}
if (!this.submitFrom.deptContacts) {
this.notFilled.push('部门联系人')
}
2022-08-01 14:34:44 +08:00
if (!this.submitFrom.deptId) {
this.notFilled.push('归属部门')
}
if (!this.submitFrom.deptPhone) {
this.notFilled.push('部门联系人电话')
}
if (this.radio === '智能算法' && !this.submitFrom.apiUrl) {
if ((this.submitFrom.infoList.filter(val => val.attrType === '使用方式')[0].attrValue === '调用接口')) {
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('算法类别')
}
if (!this.submitFrom.infoList.filter(val => val.attrType === '应用领域')[0] || !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('服务地址')
}
if ((this.radio === '业务组件' || 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'
2022-07-15 16:16:50 +08:00
})
} else {
if (this.submitFrom.id) {
// 解决编辑无组件类型
this.submitFrom.infoList.map((val) => {
if (val.attrType === '组件类型') {
val.attrValue = this.radio
2022-07-15 16:16:50 +08:00
}
})
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
2022-07-28 20:37:08 +08:00
// 检验是否有空值
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(() => {})
}
2022-07-15 16:16:50 +08:00
}
2022-07-11 15:41:18 +08:00
},
// 新修改
UpdateData (item) {
2022-07-18 18:53:04 +08:00
this.$http.get('/category/getCategoryTree').then((res) => {
this.insertList = res.data.data.filter(
(item) => item.name === '组件服务'
2022-07-18 18:53:04 +08:00
)[0]
this.radio = item.infoList.filter(
(val) => val.attrType === '组件类型'
)[0].attrValue
this.putOnTheShelfList = this.insertList.children.filter(
(item) => item.name === this.radio
)[0].children
this.putOnTheShelfList.map((parent) => {
parent.children.map((child) => {
if (
child.name === '算法优势' ||
child.name === '应用场景' ||
child.name === '功能介绍'
) {
const obj = item.infoList.filter(
(val) => val.attrType === child.name
)[0]
2022-07-11 15:41:18 +08:00
if (obj) {
child.note1 = obj.attrValue
}
} else {
if (child.children) {
2022-07-18 18:53:04 +08:00
child.children.map((data) => {
if (
data.name === '计费标准信息' ||
data.name === '常见问题'
) {
const obj = item.infoList.filter(
(val) => val.attrType === child.name
)[0]
2022-07-11 15:41:18 +08:00
if (obj) {
data.note1 = obj.attrValue
}
} else {
switch (data.name) {
case '算法名称':
case '应用名称':
case '组件名称':
case '图层名称':
data.note1 = item.name
break
case '算法描述':
case '应用描述':
case '组件描述':
case '图层描述':
data.note1 = item.description
break
case '共享条件':
data.note1 = item.shareCondition
break
case '共享类型':
data.note1 = item.shareType
break
case '服务接口':
data.note1 = item.apiUrl
break
case '接口请求方式':
data.note1 = item.apiMethodType
break
case '访问地址':
data.note1 = item.link
break
case '部门联系人':
data.note1 = item.deptContacts
break
case '部门联系人电话':
data.note1 = item.deptPhone
break
case '归属部门':
data.note1 = item.deptId
break
case '能力类型':
data.note1 = item.type
break
default:
// eslint-disable-next-line no-case-declarations
2022-07-18 18:53:04 +08:00
const obj1 = item.infoList.filter(
(val) => val.attrType === data.name
)[0]
2022-07-11 15:41:18 +08:00
if (obj1) {
data.note1 = obj1.attrValue
}
break
}
2022-07-18 18:53:04 +08:00
if (
data.type === 'image' ||
data.type === 'file' ||
data.type === 'video'
) {
const obj1 = item.infoList.filter(
(val) => val.attrType === data.name
)[0]
2022-07-11 15:41:18 +08:00
if (obj1) {
data.note2 = obj1.note2
}
}
}
})
}
}
})
})
this.submitFrom.id = item.id
this.showPutOnTheShelfFlag2 = true
})
2022-06-22 16:40:01 +08:00
}
2022-07-05 15:00:38 +08:00
}
}
2022-06-14 09:32:49 +08:00
</script>
<style lang="scss" scoped>
.el-tooltip__popper {
max-width: 50%;
}
2022-07-14 11:02:12 +08:00
// ::v-deep .el-table .cell {
// width: 200px;
// }
2022-07-14 15:52:57 +08:00
::v-deep .el-upload-list__item-name {
width: 400px;
}
2022-06-14 09:32:49 +08:00
</style>