提交 5b19e6d9 authored 作者: 王腾飞's avatar 王腾飞

1120

上级 381d8748
......@@ -141,6 +141,46 @@ export function updateMetaDataPlanListAPI(data) { //更新元数据方案
})
}
export function getLableListAPI(params) { //分页查询标签
return request({
url: `${requestPath.common}/label/page`,
method: 'get',
params
})
}
export function addLableAPI(data) { //分页查询标签
return request({
url: `${requestPath.common}/label/save`,
method: 'post',
data
})
}
export function updateLableAPI(data) { //更新标签
return request({
url: `${requestPath.common}/label/update`,
method: 'post',
data
})
}
export function getLableDetailByIdAPI(params) { //根据id查询标签
return request({
url: `${requestPath.common}/label/get/` + params,
method: 'get',
params
})
}
export function deleteLableItemAPI(data) { //根据id查询标签
return request({
url: `${requestPath.common}/label/delete/` + data,
method: 'post',
data
})
}
......
......@@ -278,6 +278,15 @@ export const asyncRouterMap = [{
routerIds: ['090401'],
},
hidden:true
},{
path: 'resourcelable',
component: _import('submission/metadatamange/resourcelable'),
name: 'resourcelable',
meta: {
title: '资源标签',
routerIds: ['090402'],
search: true
},
}]
}]
},
......
......@@ -442,7 +442,8 @@ export default {
}
.entityBox {
width:69.27%;
height:53%;
height:60%;
max-height:702px;
background:#fff;
margin:2.9% auto;
padding:0 30px;
......
......@@ -6,9 +6,9 @@
</div>
<div class="metaDataForm">
<h2>添加元数据方案</h2>
<el-form label-width="86px" :model="formData">
<el-form-item label="资源类型:" v-if="!this.$route.query.flag">
<el-select v-model="formData.type" placeholder="请选择">
<el-form label-width="92px" :model="formData" ref="formData" :rules="rules">
<el-form-item label="资源类型:" v-if="!this.$route.query.flag" prop="type">
<el-select v-model="formData.type" placeholder="请选择资源类型">
<el-option
v-for="item in options"
:key="item.value"
......@@ -17,10 +17,10 @@
</el-option>
</el-select>
</el-form-item>
<el-form-item label="方案名称:">
<el-form-item label="方案名称:" prop="name">
<el-input autocomplete="off" placeholder="请输入方案名称" v-model="formData.name"></el-input>
</el-form-item>
<el-form-item label="方案描述:">
<el-form-item label="方案描述:" prop="description">
<el-input type="textarea" v-model="formData.description" placeholder="请输入方案描述"></el-input>
</el-form-item>
<el-form-item label="是否启用:">
......@@ -71,6 +71,39 @@ export default {
}],
value: '',
valueisOn: true,
rules: {
type: [
{
required: true,
message: '请选择资源类型',
trigger: 'change'
}
],
name: [
{
required: true,
message: '请输入方案名称',
trigger: 'click'
},
{
required: true,
message: '请输入方案名称',
trigger: 'change'
}
],
description: [
{
required: true,
message: '请输入方案描述',
trigger: 'click'
},
{
required: true,
message: '请输入方案描述',
trigger: 'change'
}
]
}
}
},
mounted() {
......@@ -104,27 +137,35 @@ export default {
}
},
saveInfo() {
if (!this.$route.query.flag) {
addNewPlanAPI(this.formData)
.then(res => {
console.log(res, 'YUIIII')
if (res.data.code === 0) {
this.$message.success('添加元数据方案保存成功')
} else {
this.$message.error('添加元数据方案保存失败')
}
})
} else {
updateMetaDataPlanListAPI(this.formData)
.then(res => {
if (res.data.code === 0) {
this.$message.success('更新元数据方案保存成功')
this.$refs.formData.validate(valid => {
if (valid) {
if (!this.$route.query.flag) {
addNewPlanAPI(this.formData)
.then(res => {
console.log(res, 'YUIIII')
if (res.data.code === 0) {
this.$message.success('添加元数据方案保存成功')
this.$router.back(-1)
} else {
this.$message.error('添加元数据方案保存失败')
}
})
} else {
this.$message.error('更新元数据方案保存失败')
updateMetaDataPlanListAPI(this.formData)
.then(res => {
if (res.data.code === 0) {
this.$message.success('更新元数据方案保存成功')
this.$router.back(-1)
} else {
this.$message.error('更新元数据方案保存失败')
}
})
}
})
}
this.$router.back(-1)
} else {
this.$message.warning('尚有未通过的验证')
}
})
}
}
}
......
......@@ -86,4 +86,11 @@
margin-left: 10px;
vertical-align: bottom;
}
}
.resourceLableBox {
.el-textarea__inner {
height:100%;
resize:none;
}
}
\ No newline at end of file
<template>
<div class="resourceLableBox" v-loading="loading">
<div class="metaDataTop">
<em>标签管理</em>
<span @click='refPage'>刷新</span>
</div>
<div class="listBox">
<h2>系统标签列表</h2>
<el-button type="primary" icon="el-icon-plus" size="middle" class="addNewPlanBtn" @click="addLableFn">添加标签</el-button>
<el-table
:data="tableData"
border
style="width: 100%"
ref="listTable"
@sort-change="sortFn">
<el-table-column
prop="name"
label="标签名"
align="center"
width="180">
</el-table-column>
<el-table-column
prop="description"
align="center"
label="标签说明">
</el-table-column>
<el-table-column
prop="num"
sortable="custom"
align="center"
label="关联资源数量">
</el-table-column>
<el-table-column
prop="createrName"
sortable="custom"
align="center"
label="创建者">
</el-table-column>
<el-table-column
prop="createTime"
sortable="custom"
align="center"
label="创建时间">
</el-table-column>
<el-table-column label="操作" align="center">
<template slot-scope="scope">
<el-button
size="mini"
type="success"
icon="el-icon-edit"
@click="updateLable(scope.row)"
>编辑</el-button>
<el-button
size="mini"
type="danger"
icon="el-icon-delete"
@click="deleteLableItem(scope.row, scope.$index)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-if="totalCount>0" :total="totalCount" @pagesize="pagesizeFun" @currentPage="currentPageFun"></pagination>
<el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible">
<el-form :model="addLableForm" ref="addLableForm" :rules="rules">
<el-form-item label="标签名:" :label-width="formLabelWidth" prop="name">
<el-input v-model="addLableForm.name" autocomplete="off" placeholder="请输入标签名"></el-input>
</el-form-item>
<el-form-item label="标签说明:" :label-width="formLabelWidth" prop="description">
<el-input type="textarea" v-model="addLableForm.description" autocomplete="off" placeholder="请输入标签说明" style="height:150px;"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">取 消</el-button>
<el-button type="primary" @click="addLable" v-if="dialogTitle === '添加新标签项目'">确 定</el-button>
<el-button type="primary" @click="updateLableFn" v-else>确 定</el-button>
</div>
</el-dialog>
</div>
</div>
</template>
<script>
import {
getLableListAPI,
addLableAPI,
updateLableAPI,
getLableDetailByIdAPI,
deleteLableItemAPI
} from '@/api/resourcecommit'
import pagination from '@/components/pagination/pagination'
export default {
name: 'resourcelable',
components: {
pagination
},
data() {
return {
searchForm: {
search: null,
pageNum: 1,
pageSize: 30,
orderBy: null,
},
dialogFormVisible: false,
addLableForm: {
id: null,
name: null,
description: null
},
formLabelWidth: '92px',
tableData: [],
dialogTitle: '添加新标签项目',
totalCount: null,
loading:false,
rules: {
name: [
{
required: true,
message: '请输入标签名',
trigger: 'click'
},
{
required: true,
message: '请输入标签名',
trigger: 'change'
}
],
description: [
{
required: true,
message: '请输入标签说明',
trigger: 'click'
},
{
required: true,
message: '请输入标签说明',
trigger: 'change'
}
]
}
}
},
mounted() {
this.getLableList();
this.bus.$off('searchList').$on('searchList', content => {
this.searchForm.search=content;
this.getLableList();
});
},
methods: {
getLableList() {
getLableListAPI(this.searchForm)
.then(res => {
console.log(res, '2222222');
if (res.data.code === 0) {
this.tableData = res.data.data.list;
this.totalCount = res.data.data.total;
}
})
},
addLableFn() {
this.dialogFormVisible = true;
this.dialogTitle = '添加新标签项目';
},
addLable() {
this.$refs.addLableForm.validate(valid => {
if (valid) {
addLableAPI(this.addLableForm)
.then(res => {
if (res.data.code === 0) {
this.$message.success('添加标签成功');
this.addLableForm = {
id: null,
name: null,
description: null
}
this.getLableList();
this.dialogFormVisible = false
} else {
this.$message.error('添加标签失败')
}
})
} else {
this.$message.warning('尚有验证未通过')
}
})
},
updateLable(row) {
this.dialogFormVisible = true;
this.dialogTitle = '编辑标签项目';
console.log(row, 'uiuiiii')
this.addLableForm.id = row.id;
getLableDetailByIdAPI(row.id)
.then(res => {
console.log(res, '我是根据id查询出来的详情');
if (res.data.code === 0) {
this.addLableForm = res.data.data;
}
})
},
updateLableFn() {
this.$refs.addLableForm.validate(valid => {
if (valid) {
updateLableAPI(this.addLableForm)
.then(res => {
console.log(res, '8888')
if (res.data.code === 0) {
this.$message.success('更新资源标签成功')
this.dialogFormVisible = false;
this.addLableForm = {
id: null,
name: null,
description: null
}
this.getLableList();
} else {
this.$message.error('更新资源标签失败')
}
})
} else {
this.$message.warning('尚有验证未通过')
}
})
},
deleteLableItem(row, index) {
deleteLableItemAPI(row.id)
.then(res => {
console.log(res, '11');
if (res.data.code === 0) {
this.tableData.splice(index, 1)
this.$message.success('删除成功')
this.getLableList();
} else {
this.$message.success('删除失败')
}
})
},
pagesizeFun(val){
this.searchForm.pageSize = val;
this.getLableList()
},
currentPageFun(val){
this.searchForm.pageNum = val;
this.getLableList()
},
sortFn({ column, prop, order }) {
if (order === 'descending') {
this.searchForm.orderBy = prop + ' desc'
console.log(this.searchForm.orderBy, '1111')
} else {
this.searchForm.orderBy = prop + ' asc'
}
this.getLableList();
},
resetSeach() {
this.searchForm = {
search: null,
pageNum: 1,
pageSize: 30,
orderBy: null,
}
this.$refs.listTable.clearSort();
this.getLableList();
},
refPage() {
this.loading=true;
this.resetSeach()
setTimeout(()=>{
this.loading=false;
},1000)
}
},
beforeDestroy() {
this.bus.$off('searchList');
}
}
</script>
<style lang="less" scoped>
.resourceLableBox {
width:100%;
padding:37px 40px 20px;
display:flex;
flex-direction:column;
height:100%;
}
.metaDataTop {
width:100%;
padding-bottom:23px;
em {
color:#3F4560;
font-size:20px;
font-style:normal;
}
span {
float:right;
width:50px;
font-size:14px;
color:#868BA3;
background:url(../../../assets/img/sx.png) no-repeat;
background-size:12px 12px;
background-position:37px 2px;
cursor:pointer;
}
}
.listBox {
width:100%;
background:#fff;
padding:0 10px 20px;
h2 {
font-size:16px;
color:#222;
font-weight:500;
margin-bottom:10px;
}
.addNewPlanBtn {
float:right;
margin-bottom:10px;
}
}
.el-textarea__inner {
height:100%;
}
</style>
<style lang="scss">
@import './index.scss'
</style>
\ No newline at end of file
......@@ -597,16 +597,19 @@ export default {
console.log(this.formData.formationTime,"()***")
},
getMetaDataPlanList() {
getMetaDataPlanListAPI()
.then(res => {
console.log(res, '333333');
if (res.data.code === 0) {
this.options = res.data.data;
this.options.map((item, index) => {
this.$set(item, 'value', item.id)
})
}
})
getMetaDataPlanListAPI()
.then(res => {
console.log(res, '333333');
if (res.data.code === 0) {
this.options = res.data.data;
for (var i = this.options.length - 1; i >= 0; i--) {
if (this.options[i].status === 0) {
this.options.splice(i, 1)
this.$set(this.options[i], 'value', this.options[i].id)
}
}
}
})
},
changeMetaDataVal1(val) {
console.log(val, '小明不愛學習');
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论