Compare commits

..

2 Commits

Author SHA1 Message Date
gaoyuanwei bfc88508d8 Merge branch 'hi-ucs-dev' of http://192.168.124.50:80/wuhongjian/hi-ucs into hi-ucs-dev 2022-08-26 18:55:56 +08:00
gaoyuanwei 244123dd74 赋能案例--数据资源 2022-08-26 18:55:19 +08:00
2 changed files with 329 additions and 199 deletions

View File

@ -94,19 +94,20 @@
</template>
<script>
import debounce from "lodash/debounce";
import qs from "qs";
import SceneUseStep from './components/scene-use-step.vue';
import SceneOneInput from './components/scene-one-input.vue';
import CombineAbility from '../components/combine-ability.vue';
import CommonQuestion from '../components/common-question.vue';
import debounce from 'lodash/debounce'
import qs from 'qs'
import SceneUseStep from './components/scene-use-step.vue'
import SceneOneInput from './components/scene-one-input.vue'
import CombineAbility from '../components/combine-ability.vue'
import CommonQuestion from '../components/common-question.vue'
import InfrastructureModal from './components/infrastructure-modal.vue'
import Cookies from 'js-cookie'
import upload from '@/views/modules/components/upload'
let btnArray = ['基本信息', '场景痛点', '解决方案', '组合能力', '更多能力', '使用步骤']
const btnArray = ['基本信息', '场景痛点', '解决方案', '组合能力', '更多能力', '使用步骤']
// \
export const getJson = (type) => {
if (type === '组件服务') {
return {
methods: 'get',
url: '/census/center/selectResourceListByType',
@ -114,20 +115,33 @@ export const getJson = (type) => {
type
}
}
} else {
return {
methods: 'post',
url: '/resource/getDataResource',
postData: {
serviceName: '', //
orderField: 'fbrq', //
orderType: 'desc',
pageNum: 1, //
pageSize: 15 //
}
}
}
}
export const getDescJson = (text) => {
return {
descObj: {
text: `${text}描述`,
key: 'description'
},
}
}
}
//
export const getListParams = {
'数据资源': getJson('数据资源'),
'组件服务': getJson('组件服务'),
'基础设施': ''
数据资源: getJson('数据资源'),
组件服务: getJson('组件服务'),
基础设施: ''
}
//
export const modalTypeText = {
@ -136,13 +150,13 @@ export const modalTypeText = {
}
export const getFuseResourceList = (abilityListObj) => {
let arr = []
const arr = []
let length = 0
for (const key in abilityListObj) {
if (Object.hasOwnProperty.call(abilityListObj, key)) {
const itemArray = abilityListObj[key];
const itemArray = abilityListObj[key]
itemArray.map((v, i) => {
let index = (i + 1) + length
const index = (i + 1) + length
arr.push({
resourceId: v,
type: key,
@ -162,7 +176,7 @@ export default {
SceneOneInput,
upload,
CommonQuestion,
InfrastructureModal,
InfrastructureModal
},
data () {
return {
@ -172,70 +186,70 @@ export default {
text: '能力名称',
key: 'name'
},
...getDescJson('能力'),
...getDescJson('能力')
},
painKeyTextObj: getDescJson('痛点'),
solutionKeyTextObj: getDescJson('方案'),
dataForm: {
"name": "",
"applicationArea": "",
"description": "",
"fuseAttrList": [
name: '',
applicationArea: '',
description: '',
fuseAttrList: [
{
"attrType": "使用步骤",
"attrValue": [{ question: "", answer: "" }],
attrType: '使用步骤',
attrValue: [{ question: '', answer: '' }]
},
{
"attrType": "更多能力",
"attrValue": [{ name: "", description: "" }],
attrType: '更多能力',
attrValue: [{ name: '', description: '' }]
},
{
"attrType": "场景痛点",
"attrValue": [{ description: "" }],
attrType: '场景痛点',
attrValue: [{ description: '' }]
},
{
"attrType": "解决方案",
"attrValue": [{ description: "" }],
attrType: '解决方案',
attrValue: [{ description: '' }]
},
{
"attrType": "服务图片",
"attrValue": "",
},
attrType: '服务图片',
attrValue: ''
}
],
"fuseResourceList": [],
fuseResourceList: []
},
rules: {
name: [
{
required: true,
message: "请输入名称",
trigger: "change",
},
message: '请输入名称',
trigger: 'change'
}
],
description: [
{
required: true,
message: "请输入描述",
trigger: "change",
},
],
message: '请输入描述',
trigger: 'change'
}
]
},
checkList: JSON.parse(JSON.stringify(btnArray)),
btnList: JSON.parse(JSON.stringify(btnArray)),
addOrUpdateVisibleCopy: this.addOrUpdateVisible,
displayInfo: {
'name': '名称',
'description': '描述',
name: '名称',
description: '描述'
},
modalTypeText: modalTypeText,
refsParseArray: {
'sceneUseUpDom': '使用步骤',
'moreAbilityDom': '更多能力',
'scenePainDom': '场景痛点',
'solutionDom': '解决方案',
'zjfwDom': '组件服务',
'sjzyDom': '数据资源',
'jcssDom': '基础设施',
sceneUseUpDom: '使用步骤',
moreAbilityDom: '更多能力',
scenePainDom: '场景痛点',
solutionDom: '解决方案',
zjfwDom: '组件服务',
sjzyDom: '数据资源',
jcssDom: '基础设施'
},
getListParams: getListParams,
abilityListObj: {},
@ -244,8 +258,8 @@ export default {
handleExceed () {
this.$message({ type: 'error', message: '最多支持一张图片上传' })
},
imageUrl: '',
};
imageUrl: ''
}
},
props: {
modalType: {
@ -263,22 +277,22 @@ export default {
this.dataForm = newVal
},
deep: true,
immediate: true,
immediate: true
},
addOrUpdateVisible: {
handler (newVal) {
this.addOrUpdateVisibleCopy = newVal;
this.addOrUpdateVisibleCopy = newVal
if (this.modalType == 'add' && newVal) {
localStorage.setItem('InfrastructureSearchData', JSON.stringify({}))
this.getDetail(this.dataForm)
}
},
immediate: true,
immediate: true
}
},
methods: {
clearForm () {
this.$refs.dataForm && this.$refs.dataForm.resetFields();
this.$refs.dataForm && this.$refs.dataForm.resetFields()
},
closeModal () {
this.$emit('closeModal')
@ -286,7 +300,7 @@ export default {
//
updateDataForm (data) {
if (Object.keys(this.getListParams).includes(data.title)) {
this.abilityListObj[data.title] = data.list;
this.abilityListObj[data.title] = data.list
} else {
// 使
this.operateFuseAttrList(data.title, data)
@ -298,8 +312,8 @@ export default {
operateFuseAttrList (title, data) {
if (this.dataForm.fuseAttrList.every(v => v.attrType !== title)) {
this.dataForm.fuseAttrList.push({
'attrType': title,
'attrValue': JSON.stringify(data.list)
attrType: title,
attrValue: JSON.stringify(data.list)
})
} else {
this.dataForm.fuseAttrList.map(v => {
@ -311,70 +325,70 @@ export default {
},
//
changeBtn (data) {
this.checkList = data;
this.checkList = data
},
//
dataFormSubmitHandle: debounce(
function () {
this.$refs.dataForm.validate((valid) => {
if (!valid) {
this.$message.error("请检查表单是否填写完整");
return false;
this.$message.error('请检查表单是否填写完整')
return false
}
let methodsObj = {
'add': 'post',
'update': 'put'
const methodsObj = {
add: 'post',
update: 'put'
}
this.dataForm.fuseResourceList = this.getFuseResourceList()
if (this.imageUrl == '') {
this.$message.error("请上传图片!");
return;
this.$message.error('请上传图片!')
return
}
this.dataForm.fuseAttrList.find(v => v.attrType == '服务图片').attrValue = this.imageUrl || '';
let _obj = Object.assign({}, this.dataForm, {
this.dataForm.fuseAttrList.find(v => v.attrType == '服务图片').attrValue = this.imageUrl || ''
const _obj = Object.assign({}, this.dataForm, {
type: '赋能场景'
})
console.log('this.dataForm------表单提交------>', this.dataForm);
console.log('this.dataForm------表单提交------>', this.dataForm)
this.$http
[methodsObj[this.modalType]]("/fuse", _obj)
[methodsObj[this.modalType]]('/fuse', _obj)
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg);
return this.$message.error(res.msg)
}
this.$message({
message: this.$t("prompt.success"),
type: "success",
message: this.$t('prompt.success'),
type: 'success',
duration: 500,
onClose: () => {
this.$refs.dataForm && this.$refs.dataForm.resetFields();
this.$emit("refreshDataList");
this.$emit("closeModal");
},
});
this.$refs.dataForm && this.$refs.dataForm.resetFields()
this.$emit('refreshDataList')
this.$emit('closeModal')
}
})
})
.catch((err) => {
this.$message.error(err)
});
});
})
})
},
1000,
{ leading: true, trailing: false }
),
//
getDetail (data) {
console.log('data---详情--------->', data);
this.dataForm = data;
console.log('data---详情--------->', data)
this.dataForm = data
this.$nextTick(() => {
for (const key in this.refsParseArray) {
this.$refs[key] && this.$refs[key].getDataInfo && this.$refs[key].getDataInfo(data)
}
let _imgObj = data.fuseAttrList.find(v => v.attrType == '服务图片') || {};
this.imageUrl = _imgObj.attrValue;
const _imgObj = data.fuseAttrList.find(v => v.attrType == '服务图片') || {}
this.imageUrl = _imgObj.attrValue
// --
Object.keys(this.getListParams).map(k => {
let arr = data.fuseResourceList.filter(v => v.type == k);
let arr2 = [];
const arr = data.fuseResourceList.filter(v => v.type == k)
const arr2 = []
arr.map(v => {
arr2.push(v.resourceId)
})
@ -422,12 +436,12 @@ export default {
return this.$message.error(res.msg)
}
this.imageUrl = res.data
},
}
},
beforeDestroy () {
this.clearForm()
},
};
}
}
</script>
<style lang="scss" scoped>
@ -466,10 +480,8 @@ export default {
<style lang="scss" scoped>
.mod-sys__menu {
.menu-list,
.icon-list {
.el-input__inner,
.el-input__suffix {
cursor: pointer;

View File

@ -2,12 +2,12 @@
<div class="ability-box">
<div class="top">
<div class="type">{{ type }}</div>
<el-button type="primary" size="small" @click="showModal = true">添加</el-button>
<el-button type="primary" size="small" @click="clickOpen">添加</el-button>
</div>
<el-dialog :visible.sync="showModal" title="请选择" @close="close" :close-on-click-modal="false"
:close-on-press-escape="false" :key="showKey" append-to-body>
<div class="relate-application-content">
<div class="relate-application-content" v-if="type==='组件服务'">
<el-transfer v-model="selectedArray" filterable :filter-method="filterMethod" filter-placeholder="请输入名称"
:titles="nameArray" :props="{
key: 'id',
@ -15,6 +15,28 @@
}" :data="transferData">
</el-transfer>
</div>
<div v-else-if="type==='数据资源'" class="dataTransfer">
<el-transfer v-model="selectedArray" filter-placeholder="请输入名称"
:titles="nameArray" :props="{
key: 'id',
label: 'name',
}" :data="transferData">
</el-transfer>
<el-input
v-model="searchValue"
placeholder="请输入名称"
></el-input>
<el-button @click="rest" class="restClick">重置</el-button>
</div>
<el-pagination
v-if="type==='数据资源'"
:current-page="currentPage"
:page-size="15"
layout="total, prev, pager, next"
:total="total"
@current-change="pageCurrentChangeHandle"
>
</el-pagination>
<template slot="footer">
<el-button @click="showModal = false">{{ $t("cancel") }}</el-button>
<el-button type="primary" @click="confirmSubmitHandle()">{{
@ -173,7 +195,11 @@ export default {
transferData: [],
selectedArray: [],
allData: [],
displayList: [] // list
displayList: [], // list
total: 0,
currentPage: 1,
newNum: 1,
searchValue: ''
}
},
watch: {
@ -181,6 +207,18 @@ export default {
if (newVal) {
this.getData()
}
},
newNum (newVal) {
if (newVal) {
this.getDataParams.postData.pageNum = newVal
this.getData()
}
},
searchValue (newVal) {
if (newVal) {
this.getDataParams.postData.serviceName = newVal
this.getData()
}
}
},
methods: {
@ -212,6 +250,7 @@ export default {
if (this.getDataParams.url === '') {
return
}
if (this.type === '组件服务') {
this.$http[this.getDataParams.methods](this.getDataParams.url, {
params: this.getDataParams.postData
}).then(res => {
@ -229,11 +268,37 @@ export default {
})
})
this.allData = JSON.parse(JSON.stringify(this.transferData))
console.log(this.allData, 'this.transferData')
}).catch(err => {
this.$message.error(err)
})
} else if (this.type === '数据资源') {
this.getDataParams.postData.pageNum = this.newNum
this.$http[this.getDataParams.methods](this.getDataParams.url,
this.getDataParams.postData
).then(res => {
console.log('res.data----获取列表-------->', res.data)
this.total = Number(res.data.data.rows)
if (res.data.code !== 0) {
return this.$message.error(res.msg)
}
this.transferData = []
this.allData = [];
(res.data.data.data || []).map(v => {
this.transferData.push({
type: this.type,
id: v.guid,
name: v.zyname || '--'
})
})
this.allData = JSON.parse(JSON.stringify(this.transferData))
}).catch(err => {
this.$message.error(err)
})
}
},
filterMethod (query, item) {
console.log('1111111111111111111111111')
return item.name && item.name.indexOf(query) > -1
},
confirmSubmitHandle () {
@ -261,9 +326,29 @@ export default {
// this.selectedArray = []
this.allData = []
this.transferData = []
},
pageCurrentChangeHandle (val) {
console.log(this.newNum, val, 'wowowo')
this.newNum = val
},
clickOpen () {
this.searchValue = ''
this.getDataParams.postData.serviceName = ''
this.currentPage = 1
this.showModal = true
this.getData()
},
rest () {
this.currentPage = 1
this.searchValue = ''
this.getDataParams.postData.serviceName = ''
this.getData()
}
},
components: { InfrastructureModal, DisplayList }
components: { InfrastructureModal, DisplayList },
mounted () {
console.log(this.type, 'this.type')
}
}
</script>
<style lang="scss" scoped>
@ -354,4 +439,37 @@ export default {
height: calc(100% - 102px);
}
}
.dataTransfer {
position: relative;
height: 100%;
::v-deep .el-transfer {
height: 100%;
}
::v-deep .el-transfer-panel {
width: 39.5%;
height: 100%;
}
::v-deep .el-transfer-panel__body {
height: 100%;
}
::v-deep .el-transfer-panel__list {
height: calc(100% - 102px);
margin-top: 4rem;
}
::v-deep .el-input {
position: absolute;
font-size: 14px;
display: inline-block;
width: 30%;
top: 52px;
left: 12px;
}
.restClick {
position: absolute;
top: 52px;
left: 284px;
}
}
</style>