hi-ucs/back/src/views/modules/ability/components/combine-ability.vue

476 lines
12 KiB
Vue
Raw Normal View History

<template>
<div class="ability-box">
<div class="top">
<div class="type">{{ type }}</div>
2022-08-26 18:55:19 +08:00
<el-button type="primary" size="small" @click="clickOpen">添加</el-button>
</div>
2022-07-25 19:07:07 +08:00
<el-dialog :visible.sync="showModal" title="请选择" @close="close" :close-on-click-modal="false"
:close-on-press-escape="false" :key="showKey" append-to-body>
2022-08-26 18:55:19 +08:00
<div class="relate-application-content" v-if="type==='组件服务'">
<el-transfer v-model="selectedArray" filterable :filter-method="filterMethod" filter-placeholder="请输入名称"
:titles="nameArray" :props="{
key: 'id',
label: 'name',
}" :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',
2022-07-25 19:07:07 +08:00
}" :data="transferData">
</el-transfer>
2022-08-26 18:55:19 +08:00
<el-input
v-model="searchValue"
placeholder="请输入名称"
></el-input>
<el-button @click="rest" class="restClick">重置</el-button>
</div>
2022-08-26 18:55:19 +08:00
<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()">{{
$t("confirm")
}}</el-button>
</template>
</el-dialog>
2022-08-10 15:47:24 +08:00
<DisplayList :displayList="displayList" showKey="name"></DisplayList>
</div>
</template>
<script>
2022-07-25 19:07:07 +08:00
import InfrastructureModal from '../assignedScene/components/infrastructure-modal.vue'
import DisplayList from '../assignedScene/components/display-list.vue'
2022-07-25 19:07:07 +08:00
2022-08-26 09:27:34 +08:00
const sjzyArray = [
{
zyname: '城阳区图书馆总分馆、社区图书室明细信息',
sjcczl: 0.02,
zycode: '307013110716000007',
ygxjghjls: 0,
jghxxjlzs: 0,
neibukeshi: '',
xgxt: '城阳区图书馆及总分馆、社区图书室明细信息',
ygxdsjccl: 0,
zygszl: 'et',
ykfjghjls: 0,
syqk: 0,
zyformat: '电子表格',
guid: '277c51e0-066b-441d-9262-6e53ce6fc99a',
TGBM: '城阳区文化和旅游局',
ykfdsjccl: 0
},
{
zyname: '2021年度西海岸新区科技型中小企业名单信息',
sjcczl: 0,
zycode: '307013109000000010',
ygxjghjls: 0,
jghxxjlzs: 0,
neibukeshi: '高新技术科',
xgxt: '2021年度西海岸新区科技型中小企业名单信息企业名称入库编号。',
ygxdsjccl: 0,
zygszl: 'access',
ykfjghjls: 0,
syqk: 0,
zyformat: '数据库',
guid: '6ed1a478-443a-48ee-8af0-4c7ac2681a94',
TGBM: '青岛西海岸新区工业和信息化局(区科技局、区大数据局)',
ykfdsjccl: 0
},
{
zyname: '西海岸新区高新技术企业名单信息',
sjcczl: 0,
zycode: '307013109000000012',
ygxjghjls: 0,
jghxxjlzs: 0,
neibukeshi: '高新技术科',
xgxt: '西海岸新区高新技术企业名单信息',
ygxdsjccl: 0,
zygszl: 'access',
ykfjghjls: 0,
syqk: 0,
zyformat: '数据库',
guid: '770a9127-e7fd-4a6b-ba17-c80cf06ab670',
TGBM: '青岛西海岸新区工业和信息化局(区科技局、区大数据局)',
ykfdsjccl: 0
},
{
zyname: '西海岸新区高新技术企业认定补助名单信息',
sjcczl: 0,
zycode: '307013109000000011',
ygxjghjls: 0,
jghxxjlzs: 0,
neibukeshi: '高新技术科',
xgxt: '西海岸新区高新技术企业认定补助名单信息,企业名称、扶持项目。',
ygxdsjccl: 0,
zygszl: 'access',
ykfjghjls: 0,
syqk: 0,
zyformat: '数据库',
guid: 'ae52c5f8-ef6e-4ae9-a657-79dcb6f65643',
TGBM: '青岛西海岸新区工业和信息化局(区科技局、区大数据局)',
ykfdsjccl: 0
},
{
zyname: '青岛西海岸新区第六批区级非物质文化遗产代表性项目名录',
sjcczl: 0,
zycode: '307013109026000037',
ygxjghjls: 0,
jghxxjlzs: 0,
neibukeshi: '艺术科',
xgxt: '青岛西海岸新区第六批区级非物质文化遗产代表性项目名录,如项目类别、序号、项目名称、申报单位',
ygxdsjccl: 0,
zygszl: 'et',
ykfjghjls: 0,
syqk: 0,
zyformat: '电子表格',
guid: '6d80a3b1-744e-4292-a904-0168d640b1fc',
TGBM: '青岛西海岸新区文化和旅游局(区新闻出版广电局、区文物局)',
ykfdsjccl: 0
}
]
2022-08-26 09:27:34 +08:00
const res = {
code: 0,
msg: 'success',
data: {
PageCount: '2115',
data: sjzyArray,
rows: '10573'
}
}
const keyObj = {
"数据资源": {
2022-08-26 09:27:34 +08:00
idKey: 'id',
nameKey: 'name'
},
"组件服务": {
2022-08-26 09:27:34 +08:00
idKey: 'id',
nameKey: 'name'
}
}
export default {
props: {
type: {
type: String,
default: ''
},
2022-08-26 09:27:34 +08:00
nameArray: {
type: Array,
default: () => ['未选择名称', '已选择名称']
},
2022-08-26 09:27:34 +08:00
// 最多选择的数据个数
maxNum: {
type: Number,
default: 10
},
2022-08-26 09:27:34 +08:00
getDataParams: {
type: Object,
default: () => {
return {
methods: 'get',
url: '',
postData: {}
}
}
}
2022-08-26 09:27:34 +08:00
},
data () {
return {
showKey: 0,
showModal: false,
transferData: [],
selectedArray: [],
allData: [],
2022-08-26 18:55:19 +08:00
displayList: [], // 用于展示的list
total: 0,
currentPage: 1,
newNum: 1,
searchValue: ''
}
2022-08-26 09:27:34 +08:00
},
watch: {
showModal (newVal) {
if (newVal) {
this.getData()
}
2022-08-26 18:55:19 +08:00
},
newNum (newVal) {
if (newVal) {
this.getDataParams.postData.pageNum = newVal
this.getData()
}
},
searchValue (newVal) {
if (newVal) {
this.getDataParams.postData.serviceName = newVal
this.getData()
}
2022-08-26 09:27:34 +08:00
}
},
methods: {
async getDataInfo (dataForm) {
await this.getData()
const arr = []
const attrValue = dataForm.fuseResourceList.filter(v => v.type == this.type)
if (attrValue.length > 0) {
attrValue.map(val => {
const _obj = {
type: val.type,
id: val.resourceId,
name: val.resource && val.resource.name
}
arr.push(_obj)
})
}
2022-08-26 09:27:34 +08:00
// 展示
this.displayList = JSON.parse(JSON.stringify(arr))
// 已选中
this.selectedArray = arr.map(v => v.id)
this.$nextTick(() => {
console.log(999, this.displayList)
})
},
2022-08-26 09:27:34 +08:00
// 获取列表
getData () {
if (this.getDataParams.url === '') {
return
}
2022-08-26 18:55:19 +08:00
if (this.type === '组件服务') {
this.$http[this.getDataParams.methods](this.getDataParams.url, {
params: this.getDataParams.postData
}).then(res => {
console.log('res.data----获取列表-------->', res.data)
if (res.data.code !== 0) {
return this.$message.error(res.msg)
}
this.transferData = []
this.allData = [];
(res.data.data || []).map(v => {
this.transferData.push({
type: this.type,
id: v[keyObj[this.type].idKey],
name: v[keyObj[this.type].nameKey] || '--'
})
2022-08-26 09:27:34 +08:00
})
2022-08-26 18:55:19 +08:00
this.allData = JSON.parse(JSON.stringify(this.transferData))
console.log(this.allData, 'this.transferData')
}).catch(err => {
this.$message.error(err)
2022-08-26 09:27:34 +08:00
})
2022-08-26 18:55:19 +08:00
} 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)
})
}
},
2022-08-26 09:27:34 +08:00
filterMethod (query, item) {
2022-08-26 18:55:19 +08:00
console.log('1111111111111111111111111')
2022-08-26 09:27:34 +08:00
return item.name && item.name.indexOf(query) > -1
},
2022-08-26 09:27:34 +08:00
confirmSubmitHandle () {
if (this.selectedArray.length > this.maxNum) {
return this.$message.error('最多选择十条数据!')
}
this.showModal = false
this.displayList = []
this.allData.map(v => {
if (this.selectedArray.includes(v.id)) {
this.displayList.push(v)
}
2022-08-26 09:27:34 +08:00
})
this.$emit('update', {
title: this.type,
list: this.selectedArray
})
},
2022-08-26 09:27:34 +08:00
getDisplay (displayList) {
this.displayList = []
this.displayList = displayList
2022-07-25 19:07:07 +08:00
},
2022-08-26 09:27:34 +08:00
close () {
this.showModal = false
// this.selectedArray = []
2022-08-26 09:27:34 +08:00
this.allData = []
this.transferData = []
2022-08-26 18:55:19 +08:00
},
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()
2022-08-26 09:27:34 +08:00
}
},
2022-08-26 18:55:19 +08:00
components: { InfrastructureModal, DisplayList },
mounted () {
console.log(this.type, 'this.type')
}
}
</script>
<style lang="scss" scoped>
.ability-box {
2022-08-26 18:55:19 +08:00
margin-bottom: 10px;
2022-08-26 18:55:19 +08:00
.show-box {
display: flex;
justify-content: flex-start;
align-items: flex-start;
}
2022-08-26 18:55:19 +08:00
.top {
display: flex;
align-items: center;
justify-content: flex-start;
}
2022-08-26 18:55:19 +08:00
.type {
padding-right: 12px;
font-size: 14px;
color: #606266;
width: 100px;
box-sizing: border-box;
text-align: right;
line-height: 40px;
height: 40px;
}
2022-08-26 18:55:19 +08:00
.list-box {
display: flex;
align-items: center;
justify-content: flex-start;
flex-wrap: wrap;
margin-left: 100px;
}
2022-08-26 18:55:19 +08:00
.list-item {
font-size: 14px;
color: #606266;
width: 380px;
text-align: left;
margin-right: 10px;
line-height: 40px;
height: 40px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
</style>
<style lang="scss" scoped>
.icon-input ::v-deep .el-input__inner {
2022-08-26 18:55:19 +08:00
cursor: pointer;
}
::v-deep .el-dialog__body {
2022-08-26 18:55:19 +08:00
height: 580px;
overflow: auto;
}
::v-deep .el-checkbox-button__inner {
2022-08-26 18:55:19 +08:00
width: 130px;
margin: 0 10px 5px;
border-left: unset !important;
border-radius: unset !important;
border: 1px solid #dcdfe6 !important;
}
.relate-application-content {
2022-08-26 18:55:19 +08:00
height: 100%;
::v-deep .el-transfer {
height: 100%;
2022-08-26 18:55:19 +08:00
}
2022-08-26 18:55:19 +08:00
::v-deep .el-transfer-panel {
width: 39.5%;
height: 100%;
}
2022-08-26 18:55:19 +08:00
::v-deep .el-transfer-panel__body {
height: 100%;
}
2022-08-26 18:55:19 +08:00
::v-deep .el-transfer-panel__list.is-filterable {
height: calc(100% - 102px);
}
}
.dataTransfer {
position: relative;
height: 100%;
::v-deep .el-transfer {
height: 100%;
}
2022-08-26 18:55:19 +08:00
::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>