hi-ucs/front/src/views/capacityOnTheShelf/Application.vue

899 lines
27 KiB
Vue

<!--
* @Author: hisense.liangjunhua
* @Date: 2022-06-13 10:22:27
* @LastEditors: hisense.wuhongjian
* @LastEditTime: 2022-08-04 16:11:50
* @Description: 应用上架
-->
<template>
<div class="box">
<!-- <div class="header">能力上架申请</div> -->
<div class="top">
<div
v-for="(nav, index) in navList"
:key="nav"
:class="[index <= navList2.indexOf(showView) ? 'finish' : 'ff']"
>
<div class="wai">
<span class="bg-box">
<span>{{ index + 1 }}</span>
</span>
<span class="bg-name">{{ nav.name }}</span>
</div>
<div class="line" v-if="index !== navList.length - 1"></div>
</div>
</div>
<div class="vue-box">
<put-on-the-shelf
v-if="showView === '基本信息' && refData.name"
ref="refPutOnTheShelf"
:refData="refData"
:dataFrom="dataFrom"
:videoList="videoList"
:imgList="imgList"
:externalField="[
'应用名称',
'应用描述',
'归属部门',
'部门联系人',
'部门联系人电话',
'共享条件',
]"
:required="required"
:notFilled="notFilled"
></put-on-the-shelf>
<put-on-the-shelf
v-else-if="showView === '功能介绍'"
ref="refPutOnTheShelf"
:refData="refData"
:dataFrom="dataFrom"
:configure="gnjs"
@next="next()"
@back="back()"
:required="required"
:notFilled="notFilled"
></put-on-the-shelf>
<put-on-the-shelf
v-else-if="showView === '关联组件'"
ref="refPutOnTheShelf"
:refData="refData"
:dataFrom="dataFrom"
:configure="glzj"
@next="next()"
@back="back()"
:required="required"
:notFilled="notFilled"
></put-on-the-shelf>
<put-on-the-shelf
ref="refPutOnTheShelf"
v-else-if="showView === '部署与应用'"
:refData="refData"
:dataFrom="dataFrom"
:externalField="['共享类型', '访问地址']"
:configure="bs"
@submit="submit()"
@back="back()"
@preview="preview()"
:required="required"
:notFilled="notFilled"
></put-on-the-shelf>
<!-- <application-essential-information
v-if="showView === '基本信息' && refData.name"
:refData="refData"
:dataFrom="dataFrom"
:videoList="videoList"
:imgList="imgList"
></application-essential-information>
<application-function-introduction
v-else-if="showView === '功能介绍'"
:refData="refData"
:dataFrom="dataFrom"
></application-function-introduction>
<application-associated-components
v-else-if="showView === '关联组件'"
:refData="refData"
:dataFrom="dataFrom"
></application-associated-components>
<application-deployment-use
v-else-if="showView === '部署与应用'"
:refData="refData"
:dataFrom="dataFrom"
:fileList="fileList"
:imgList="imgList"
></application-deployment-use> -->
</div>
<div class="btn" :class="showView === '基本信息' ? 'first' : ''">
<a-popconfirm
v-if="
showView == '功能介绍' &&
gnjs[0].list.filter((val) => val.note1 !== '').length > 0 &&
gnjs[0].list.filter((val) => val.note1 !== '').length !==
gnjs[0].list.length
"
title="如果信息未填写完整将会被丢弃,是否返回上一步?"
ok-text="是"
cancel-text="否"
@confirm="changeGnjs('上一步')"
@cancel="cancel"
>
<button class="buzhou">上一步</button>
</a-popconfirm>
<button class="buzhou" v-else-if="showView == '功能介绍'" @click="changeGnjs('上一步')">
上一步
</button>
<!-- 分割线 -->
<button
class="buzhou"
v-show="showView !== '基本信息' && showView === '部署与应用'"
@click="back()"
>
上一步
</button>
<a-popconfirm
v-if="
showView === '部署与应用' &&
bs[0].list.filter(
(val) => val.note1 !== '' && val.name !== '常见问题'
).length > 0
"
title="如果常见问题未填写完整将会被丢弃,是否进行预览?"
ok-text="是"
cancel-text="否"
@confirm="changeBs('预览')"
@cancel="cancel"
>
<button class="buzhou">预览</button>
</a-popconfirm>
<button class="buzhou" v-else-if="showView === '部署与应用'" @click="preview()">
预览
</button>
<button class="buzhou" v-show="showView === '基本信息'" @click="next()">下一步</button>
<a-popconfirm
v-if="
showView == '功能介绍' &&
gnjs[0].list.filter((val) => val.note1 !== '').length > 0 &&
gnjs[0].list.filter((val) => val.note1 !== '').length !==
gnjs[0].list.length
"
title="如果信息未填写完整将会被丢弃,是否进行下一步?"
ok-text="是"
cancel-text="否"
@confirm="changeGnjs('下一步')"
@cancel="cancel"
>
<button class="buzhou">下一步</button>
</a-popconfirm>
<button class="buzhou" v-else-if="showView == '功能介绍'" @click="changeGnjs('下一步')">
下一步
</button>
<a-popconfirm
v-if="
showView === '部署与应用' &&
bs[0].list.filter(
(val) => val.note1 !== '' && val.name !== '常见问题'
).length > 0
"
title="如果常见问题未填写完整将会被丢弃,是否进行提交?"
ok-text="是"
cancel-text="否"
@confirm="changeBs('提交')"
@cancel="cancel"
>
<button class="buzhou">提交</button>
</a-popconfirm>
<button class="buzhou" v-else-if="showView === '部署与应用'" @click="submit()">
提交
</button>
<button class="quxiao" @click="close()">取消</button>
</div>
</div>
</template>
<script setup>
// import ApplicationEssentialInformation from '@/views/capacityOnTheShelf/components/ApplicationEssentialInformation.vue'
// import ApplicationFunctionIntroduction from '@/views/capacityOnTheShelf/components/ApplicationFunctionIntroduction.vue'
// import ApplicationAssociatedComponents from '@/views/capacityOnTheShelf/components/ApplicationAssociatedComponents.vue'
// import ApplicationDeploymentUse from '@/views/capacityOnTheShelf/components/ApplicationDeploymentUse.vue'
import PutOnTheShelf from '@/views/capacityOnTheShelf/components/PutOnTheShelf.vue'
import { ref, onBeforeUnmount } from 'vue'
import { useRouter } from 'vue-router'
import { getCategoryTree } from '@/api/personalCenter'
import { shangjiainsert, shangjiaapply } from '@/api/personalCenter'
import {
getUser,
getUserInfo,
selectOne,
updateRes,
relaunch,
} from '@/api/home'
import { message } from 'ant-design-vue'
import mybus from '@/myplugins/mybus'
const showView = ref('基本信息')
const router = useRouter()
let shiyongshouce = ref({})
const navList = ref([])
const navList2 = ref([])
const fileList = ref({})
const imgList = ref({})
const videoList = ref({})
const data = ref({})
const refData = ref({})
const submitFlag = ref(true)
const dataFrom = ref({
infoList: [],
delFlag: 0,
type: '应用资源',
deptId: '',
})
const gnjs = ref([
{
name: '功能介绍',
list: [
{
name: '功能名称',
field: 'name',
type: 'input',
note1: '',
},
{
name: '功能描述',
field: 'desc',
type: 'textArea',
note1: '',
},
{
name: '功能图片',
field: 'img',
type: 'image',
note1: '',
},
],
},
])
const glzj = ref([
{
name: '关联组件',
list: [
{
name: '关联组件名称',
field: 'name',
type: 'input',
note1: '',
},
{
name: '关联组件描述',
field: 'desc',
type: 'textArea',
note1: '',
},
{
name: '关联组件地址',
field: 'url',
type: 'input',
note1: '',
},
],
},
])
const bs = ref([
{
name: '常见问题',
list: [
{
name: '问题',
field: 'question',
type: 'textArea',
note1: '',
},
{
name: '答复',
field: 'answer',
type: 'textArea',
note1: '',
},
],
},
])
const required = ref([
'归属部门',
'部门联系人',
'部门联系人电话',
'应用领域',
'共享条件',
'应用名称',
'应用描述',
'应用类型',
'应用状态',
])
const notFilled = ref([])
getUser().then((res) => {
dataFrom.value.deptId = res.data.data.deptId
})
const back = () => {
navList.value.forEach((val, index) => {
if (val.key === showView.value && index > 0) {
showView.value = navList2.value[index - 1]
refData.value = data.value.filter(
(item) => item.name === showView.value
)[0]
console.log('表单数据=============>', dataFrom.value)
}
})
}
const next = () => {
notFilled.value = []
console.log(dataFrom.value, notFilled.value, 'dataFrom.value.name')
if (!dataFrom.value.name) {
notFilled.value.push('应用名称')
}
if (!dataFrom.value.shareCondition) {
notFilled.value.push('共享条件')
}
if (!dataFrom.value.description) {
notFilled.value.push('应用描述')
}
if (!dataFrom.value.deptId) {
notFilled.value.push('归属部门')
}
if (!dataFrom.value.deptContacts) {
notFilled.value.push('部门联系人')
}
if (!dataFrom.value.deptPhone) {
notFilled.value.push('部门联系人电话')
}
if (
!dataFrom.value.infoList.filter(
(val) => val.attrType === '应用领域'
)[0] ||
!dataFrom.value.infoList.filter((val) => val.attrType === '应用领域')[0]
.attrValue
) {
notFilled.value.push('应用领域')
}
if (
!dataFrom.value.infoList.filter(
(val) => val.attrType === '应用状态'
)[0] ||
!dataFrom.value.infoList.filter((val) => val.attrType === '应用状态')[0]
.attrValue
) {
notFilled.value.push('应用状态')
}
if (
!dataFrom.value.infoList.filter(
(val) => val.attrType === '应用类型'
)[0] ||
!dataFrom.value.infoList.filter((val) => val.attrType === '应用类型')[0]
.attrValue
) {
notFilled.value.push('应用类型')
}
// if (
// !dataFrom.value.infoList.filter(
// (val) => val.attrType === '共享条件'
// )[0] ||
// !dataFrom.value.infoList.filter((val) => val.attrType === '共享条件')[0]
// .attrValue
// ) {
// notFilled.value.push('共享条件')
// }
if (notFilled.value.length > 0) {
message.warning('请填写必填字段')
console.log(notFilled.value)
} else {
let i = -1
navList.value.forEach((val, index) => {
if (val.key === showView.value && index < navList.value.length - 1) {
i = index + 1
}
})
if (i !== -1) {
showView.value = navList2.value[i]
refData.value = data.value.filter(
(item) => item.name === showView.value
)[0]
console.log('表单数据=============>', dataFrom.value, refData.value)
}
}
}
const submit = () => {
console.log('提交数据=============>', dataFrom.value)
if (submitFlag.value) {
submitFlag.value = false
dataFrom.value.infoList = dataFrom.value.infoList.filter(
(item) => item.attrValue !== ''
)
if (resourceId) {
delete dataFrom.value.createDate
delete dataFrom.value.updateDate
dataFrom.value.infoList.map((del) => {
delete del.createDate
delete del.updateDate
})
updateRes(dataFrom.value).then((upres) => {
if (upres.data.code == 0) {
relaunch({ data: dataFrom.value, taskId: taskId }).then((res) => {
console.log('驳回================>', res)
if (res.data.code == 0) {
message.success('重新发起流程成功!')
submitFlag.value = true
window.setTimeout(() => {
window.close()
}, 1000)
} else {
message.error('重新发起流程失败!')
submitFlag.value = true
}
})
} else {
message.error('数据更新失败!')
submitFlag.value = true
}
})
} else {
shangjiainsert(dataFrom.value).then((res) => {
const instanceId = res.data.data
dataFrom.value.id = res.data.data
getUser().then((res6) => {
getUserInfo(res6.data.data.id).then((res2) => {
const deptId = dataFrom.value.deptId
const userId = res2.data.data.id
const userName = res2.data.data.realName
const params = {
instanceId: instanceId,
deptId: deptId,
userId: userId,
userName: userName,
resourceDTO: [dataFrom.value],
}
shangjiaapply(params).then((res3) => {
console.log('res3', res3)
if (res3.data.code == 0) {
message.success('上架申请提交成功,请注意查看消息通知!')
window.setTimeout(() => {
window.close()
submitFlag.value = true
}, 1000)
}
})
})
})
})
}
}
}
// 预览
const preview = () => {
dataFrom.value.infoList = dataFrom.value.infoList.filter(
(item) => item.attrValue !== ''
)
console.log('预览==============>', dataFrom.value)
window.sessionStorage.setItem('preview', JSON.stringify(dataFrom.value))
const newpage = router.resolve({
path: '/details',
})
window.open(newpage.href, '_blank')
}
const init = () => {
getCategoryTree().then((res) => {
// console.clear()
res.data.data = res.data.data.filter(
(item) => item.name === '应用资源'
)[0]
navList.value = []
navList2.value = []
res.data.data.children.forEach((val) => {
console.log(val)
navList.value.push({
name: val.name,
key: val.name,
})
navList2.value.push(val.name)
// 回填数据
if (resourceId) {
val.children.map((item) => {
if (item.children.length > 0) {
item.children.map((child) => {
switch (child.name) {
case '应用名称':
child.note1 = echoData.value.name
break
case '应用描述':
child.note1 = echoData.value.description
break
case '共享条件':
child.note1 = echoData.value.shareCondition
break
case '归属部门':
child.note1 = echoData.value.deptId
break
case '部门联系人':
child.note1 = echoData.value.deptContacts
break
case '部门联系人电话':
child.note1 = echoData.value.deptPhone
break
case '接口请求方式':
child.note1 = echoData.value.apiMethodType
break
case '应用领域':
case '发布端':
if (
echoData.value.infoList &&
echoData.value.infoList.filter(
(fil) => fil.attrType == child.name
)[0]
) {
child.note1 = echoData.value.infoList.filter(
(fil) => fil.attrType == child.name
)[0].attrValue
child.note2 = echoData.value.infoList
.filter((fil) => fil.attrType == child.name)[0]
.attrValue.split(';')
}
break
case '应用展示视频':
if (
echoData.value.infoList &&
echoData.value.infoList.filter(
(fil) => fil.attrType == child.name
)[0]
) {
videoList.value = [
{
uid: echoData.value.infoList.filter(
(fil) => fil.attrType == child.name
)[0].id,
name:
echoData.value.infoList.filter(
(fil) => fil.attrType == child.name
)[0].note3 || '--',
status: 'done',
url: echoData.value.infoList.filter(
(fil) => fil.attrType == child.name
)[0].attrValue,
thumbUrl: echoData.value.infoList.filter(
(fil) => fil.attrType == child.name
)[0].attrValue,
},
]
}
break
case '应用图片':
if (
echoData.value.infoList &&
echoData.value.infoList.filter(
(fil) => fil.attrType == child.name
)[0]
) {
imgList.value = [
{
uid: echoData.value.infoList.filter(
(fil) => fil.attrType == child.name
)[0].id,
name:
echoData.value.infoList.filter(
(fil) => fil.attrType == child.name
)[0].note3 || '--',
status: 'done',
url: echoData.value.infoList.filter(
(fil) => fil.attrType == child.name
)[0].attrValue,
thumbUrl: echoData.value.infoList.filter(
(fil) => fil.attrType == child.name
)[0].attrValue,
},
]
}
break
default:
if (
echoData.value.infoList &&
echoData.value.infoList.filter(
(fil) => fil.attrType == child.name
)[0]
) {
child.note1 = echoData.value.infoList.filter(
(fil) => fil.attrType == child.name
)[0].attrValue
}
break
}
})
}
console.log('item================>', item, echoData.value)
})
}
})
data.value = res.data.data.children
refData.value = data.value.filter(
(item) => item.name === showView.value
)[0]
console.log('所有编目结构==============>', res.data.data)
})
}
const resourceId = router.currentRoute.value.query.id
const taskId = router.currentRoute.value.query.taskId
const echoData = ref({})
if (resourceId) {
// 回显数据
selectOne(resourceId).then((res) => {
echoData.value = res.data.data
dataFrom.value = echoData.value
init()
// console.log('驳回修改===================>', echoData.value)
})
} else {
init()
}
// 特殊字段处理
const refPutOnTheShelf = ref(null)
const changeGnjs = (type) => {
refPutOnTheShelf.value.add('功能介绍', true, type)
console.log(refPutOnTheShelf.value)
}
const changeBs = (type) => {
console.log(refPutOnTheShelf)
refPutOnTheShelf.value.add('常见问题', true, type)
}
mybus.on('chageDataFrom', (obj) => {
if (obj.attrType == '技术文档' && obj.attrValue != null) {
shiyongshouce.value = obj
}
dataFrom.value.infoList = dataFrom.value.infoList.filter(
(item) => item.attrType !== obj.attrType
)
if (obj.attrValue == [] || obj.attrValue == '[]' || obj.attrValue == null) {
obj.attrValue = ''
}
dataFrom.value.infoList.push(obj)
if (shiyongshouce.value.attrValue) {
dataFrom.value.infoList.map((syscitem, syscindex) => {
if (syscitem.attrType == '技术文档') {
dataFrom.value.infoList[syscindex] = shiyongshouce.value
}
})
}
console.log('数据变更=================》', obj, dataFrom.value.infoList)
})
mybus.on('chageFileList', (obj) => {
fileList.value = obj
})
mybus.on('chageImgList', (obj) => {
imgList.value = obj
})
mybus.on('chageVideoList', (obj) => {
videoList.value = obj
})
//datafrom外面数据
mybus.on('chageDataFromDwon', (obj) => {
switch (obj.attrType) {
case '应用名称':
dataFrom.value.name = obj.attrValue
break
case '应用描述':
dataFrom.value.description = obj.attrValue
break
case '共享条件':
dataFrom.value.shareCondition = obj.attrValue
break
case '共享类型':
dataFrom.value.shareType = obj.attrValue
break
case '服务接口':
dataFrom.value.apiUrl = obj.attrValue
break
case '接口请求方式':
dataFrom.value.apiMethodType = obj.attrValue
break
case '访问地址':
dataFrom.value.link = obj.attrValue
break
case '归属部门':
dataFrom.value.deptId = obj.attrValue
if (obj.attrValueTwo) {
dataFrom.value.deptName = obj.attrValueTwo.label
}
break
case '部门联系人':
dataFrom.value.deptContacts = obj.attrValue
break
case '部门联系人电话':
dataFrom.value.deptPhone = obj.attrValue
break
}
// console.log('dataFrom.value', dataFrom.value)
})
const close = () => {
window.close()
}
onBeforeUnmount(() => {
mybus.off('chageDataFrom')
mybus.off('chageFileList')
mybus.off('chageImgList')
mybus.off('chageDataFromDwon')
})
</script>
<style lang="less" scoped>
.box {
position: relative;
top: 0.64rem;
// margin: 0.15rem 3rem;
padding: 0.1rem;
background: #fff;
.header {
font-size: 0.28rem;
font-weight: 600;
}
.vue-box {
padding: 0 1rem;
}
.top {
font-size: 16px;
margin: 0.32px 0.4px 0;
padding: 24px 24pxs;
display: flex;
justify-content: center;
.ff {
color: #b3b3b3;
display: inline-flex;
justify-content: center;
align-items: center;
.wai {
margin-top: 14px;
.bg-box {
display: flex;
justify-content: center;
align-items: center;
width: 32px;
height: 32px;
border-radius: 50%;
// border: 0.01rem solid rgb(214, 214, 214);
margin: 0px 16px;
transition: all 0.3s ease;
span {
display: flex;
justify-content: center;
align-items: center;
width: 32px;
height: 32px;
border-radius: 50%;
border: 1px solid #d9d9d9;
}
}
.bg-name {
color: #b3b3b3;
}
}
.line {
// margin-left: 16px;
width: 326px;
height: 2px;
background: #d9d9d9;
}
}
.finish {
color: #fff;
display: inline-flex;
justify-content: center;
align-items: center;
.wai {
margin-top: 14px;
.bg-box {
display: flex;
justify-content: center;
align-items: center;
width: 32px;
height: 32px;
border-radius: 50%;
// border: 0.01rem solid rgb(214, 214, 214);
margin: 0px 16px;
transition: all 0.3s ease;
span {
background: #0058e1;
display: flex;
justify-content: center;
align-items: center;
width: 32px;
height: 32px;
border-radius: 50%;
border: 1px solid solid #0058e1;
}
}
.bg-name {
color: #212121;
font-weight: bold;
}
}
.line {
// margin-left: 16px;
width: 326px;
height: 2px;
background: #0058e1;
}
}
.btn {
display: flex;
justify-content: space-around;
padding: 0.1rem 3.5rem 0;
button {
cursor: pointer;
font-size: 0.14rem;
width: 0.8rem;
height: 0.35rem;
text-align: center;
color: #fff;
border: 0.01rem solid #9ccefa;
span {
background: #0087ff;
border: 0.01rem solid #0087ff;
}
}
.line {
background: #0087ff;
}
button:nth-of-type(1) {
color: #0087ff;
background: #e1edfa;
}
button:nth-of-type(2) {
background: #01c5dc;
}
}
.first {
justify-content: center;
}
}
.btn {
display: flex;
justify-content: center;
padding: 0.1rem 3.5rem 0;
// button {
// cursor: pointer;
// font-size: 14px;
// text-align: center;
// color: #fff;
// border: none;
// border-radius: 0.06rem;
// background: #0087ff;
// margin-right:12px;
// margin-right:12px;
.quxiao{
margin-right:12px;
cursor: pointer;
width: 90px;
height: 32px;
background: #ffffff;
color:#0058e1;
border-radius: 2px;
border: 1px #0058e1 solid;
}
// .quxiao:hover{
// background: #0058e1;
// color:#ffffff;
// }
.buzhou{
margin-right:12px;
cursor: pointer;
background: #0058e1;
color:#ffffff;
width: 90px;
height: 32px;
border-radius: 2px;
border: 1px #0058e1 solid;
}
// .buzhou:hover{
// background: #ffffff;
// color:#0058e1;
// }
}
.first {
justify-content: center;
}
}
</style>