This commit is contained in:
landaiqing 2023-12-29 00:32:47 +08:00
parent 77373c2129
commit 8d3c8259e8
5 changed files with 231 additions and 188 deletions

View File

@ -9,22 +9,12 @@
<el-col :span="24"> <el-col :span="24">
<el-button @click="openAddCategoryFun()" type="primary" plain size="medium" round >创建Banner</el-button> <el-button @click="openAddCategoryFun()" type="primary" plain size="medium" round >创建Banner</el-button>
</el-col> </el-col>
<el-col :span="24" style="margin-top:20px">
<el-input
placeholder="请输入内容"
v-model="searchCate"
clearable
style="width:200px">
</el-input>
<el-button type="success" plain size="medium" round style="margin-left:10px">查询目录</el-button>
</el-col>
</el-row> </el-row>
<el-table class="MyTable" <el-table class="MyTable"
:data="List" :data="List"
header-row-class-name="table_header_class" header-row-class-name="table_header_class"
border> border>
<el-table-column <el-table-column
align="center" align="center"
type="index" type="index"
:index="hIndex" :index="hIndex"
@ -35,14 +25,30 @@
<el-table-column <el-table-column
align="center" align="center"
prop="name" prop="id"
label="分类名称" label="id"
width="50">
</el-table-column>
<el-table-column
align="center"
prop="imgUrl"
label="图片链接"
width="180"> width="180">
<template slot-scope="scope">
<div class="ButtonBlock">
<el-image :src="scope.row.imgUrl">
<div slot="error" class="image-slot">
<i class="el-icon-picture-outline"></i>
</div>
</el-image>
</div>
</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
align="center" align="center"
prop="id" prop="url"
label="分类编号" label="跳转链接"
width="150"> width="150">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
@ -53,8 +59,8 @@
</el-table-column> </el-table-column>
<el-table-column <el-table-column
align="center" align="center"
prop="urlNumber" prop="weigh"
label="包含网址数" label="权重"
width="100"> width="100">
</el-table-column> </el-table-column>
<!-- <el-table-column align="center" key="status" prop="status" label="启用状态" width="90" >--> <!-- <el-table-column align="center" key="status" prop="status" label="启用状态" width="90" >-->
@ -83,18 +89,11 @@
<!-- </el-switch>--> <!-- </el-switch>-->
<!-- </template>--> <!-- </template>-->
<!-- </el-table-column>--> <!-- </el-table-column>-->
<el-table-column
align="center"
prop="weigh"
label="权重"
width="80">
</el-table-column>
<el-table-column prop="date" label="操作" width="160"> <el-table-column prop="date" label="操作" width="160">
<template slot-scope="scope"> <template slot-scope="scope">
<div class="ButtonBlock"> <div class="ButtonBlock">
<img class="MyButton" @click="handleEdit(scope.row)" <img class="MyButton" @click="handleDelete(scope.row.id)"
src="../../../assets/img/EditButton.svg" style="width:60px">
<img class="MyButton" @click="handleDelete(scope.row)"
src="../../../assets/img/DeleteButton.svg" style="width:60px"> src="../../../assets/img/DeleteButton.svg" style="width:60px">
</div> </div>
</template> </template>
@ -107,33 +106,22 @@
> >
<el-form ref="form" :rules="rules" class="login_container" :model="form" <el-form ref="form" :rules="rules" class="login_container" :model="form"
style="margin-top:-10px" status-icon label-width="100px" > style="margin-top:-10px" status-icon label-width="100px" >
<el-form-item label="分类名" prop="name"> <el-form-item label="图片链接" prop="imgUrl">
<el-input v-model="form.name" placeholder='分类名称' clearable></el-input> <el-input v-model="form.imgUrl" placeholder='图片链接' clearable></el-input>
</el-form-item> </el-form-item>
<el-form-item label="分类权重" prop="weigh" > <el-form-item label="权重" prop="weigh" >
<el-input v-model="form.weigh" placeholder='分类权重' clearable ></el-input> <el-input v-model="form.weigh" placeholder='权重填0即可' clearable ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="用户id" prop="userId" style="display: none"> <el-form-item label="跳转链接" prop="url">
<el-input v-model="form.userId" placeholder='用户id' clearable ></el-input> <el-input v-model="form.url" placeholder='跳转链接' clearable ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="编号" prop="id" style="display: none"> <el-form-item label="状态" prop="bannerStatus">
<el-input v-model="form.id" placeholder='id' clearable ></el-input> <el-input v-model="form.bannerStatus" placeholder='状态填0即可' clearable ></el-input>
</el-form-item> </el-form-item>
<!-- <el-form-item label="是否启用" prop="status">-->
<!-- <el-radio-group v-model="form.status" >-->
<!-- <el-radio :label="0">有效</el-radio>-->
<!-- <el-radio :label="1">无效</el-radio>-->
<!-- </el-radio-group>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="是否公开" prop="needLogin">-->
<!-- <el-radio-group v-model="form.needLogin" >-->
<!-- <el-radio :label="1">公开</el-radio>-->
<!-- <el-radio :label="0">私有</el-radio>-->
<!-- </el-radio-group>-->
<!-- </el-form-item>-->
<el-form-item> <el-form-item>
<div style="display: flex;flex-direction: row;align-items: center;flex-wrap: nowrap;justify-content: space-between"> <div style="display: flex;flex-direction: row;align-items: center;flex-wrap: nowrap;justify-content: space-between">
<el-button @click="addCategory('form',titlename)" type="primary" style=";margin-top:10px">确认</el-button> <el-button @click="addCategory('form')" type="primary" style=";margin-top:10px">确认</el-button>
</div> </div>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -154,43 +142,34 @@ export default {
titlename:null, titlename:null,
// //
openAddCategory:false, openAddCategory:false,
//
dialogVisible:false,
//
isEdit:true,
searchCate:'',
userId:null,
List:[], List:[],
form:{ form:{
name:'', imgUrl:null,
weigh:'', url:null,
needLogin:'', weigh:null,
status:'', bannerStatus:null,
userId:'',
id:'',
}, },
// //
rules: { rules: {
name: [{ required: 'true', message: '请输入分类名', trigger: 'blur' }], imgUrl: [{ required: 'true', message: '请输入图片链接', trigger: 'blur' }],
url: [{ required: 'true', message: '请输入跳转链接', trigger: 'blur' }],
weigh: [{ required: 'true', message: '请输入权重', trigger: 'blur' }], weigh: [{ required: 'true', message: '请输入权重', trigger: 'blur' }],
// needLogin: [{ required: 'true', message: '', trigger: 'blur' }], bannerStatus: [{ required: 'true', message: '请输入状态', trigger: 'blur' }],
// status: [{ required: 'true', message: '', trigger: 'blur' }],
userId: [{ required: 'true', message: '登录信息有误', trigger: 'blur' }],
} }
} }
}, },
mounted() { mounted() {
this.getFormatDate(); this.GetBannerData();
}, },
created() { created() {
this.getUserInfo();
// this.GetData();
}, },
computed: {}, computed: {},
methods: { methods: {
// //
handleDelete(index) { handleDelete(id) {
var that=this; var that=this;
this.$confirm('此操作将永久删除该Banner, 是否继续?', '提示', { this.$confirm('此操作将永久删除该Banner, 是否继续?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
@ -198,18 +177,18 @@ export default {
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
axios({ axios({
method: 'post', method: 'get',
// //
url: '/api/banners/delete_url', url: '/api/banners/delete_url',
// URL // URL
params: { params: {
Id: this.form.id, id: id,
} }
}).then(function (res) { }).then(function (res) {
if (res.data.code === 500) { if (res.data.code !== 200) {
Vue.prototype.$notify.error({ Vue.prototype.$notify.error({
title: '错误', title: '错误',
message: res.data.msg, message: "删除失败",
offset: 50 offset: 50
}); });
} else { } else {
@ -219,7 +198,7 @@ export default {
type: 'success', type: 'success',
offset: 50 offset: 50
}); });
that.GetData(); that.GetBannerData();
} }
}); });
@ -235,20 +214,7 @@ export default {
closeDialog() { closeDialog() {
var that = this; var that = this;
// //
this.GetData();
//
that.form = {
name:'',
weigh:'',
needLogin:'',
status:'',
userId:'',
id:'',
}
//
this.dialogVisible = false;
this.openAddCategory=false; this.openAddCategory=false;
that.getUserInfo();
}, },
// : // :
openAddCategoryFun(){ openAddCategoryFun(){
@ -257,84 +223,38 @@ export default {
_this.titlename="新增Banner"; _this.titlename="新增Banner";
this.openAddCategory=true; this.openAddCategory=true;
}, },
//
handleEdit(index) {
var _this = this;
this.openAddCategoryFun();
_this.titlename="编辑Banner";
//
this.form = index;
},
// //
addCategory(rulelist,flag){ addCategory(rulelist){
var _this = this; var _this = this;
_this.$refs[rulelist].validate((valid)=>{ _this.$refs[rulelist].validate((valid)=>{
if(valid){ if(valid){
if(flag == "新增分类"){
axios({ axios({
method: 'post', method: 'post',
// //
url: '/api/UrlAndCate/insertCateByUser', url: '/api/banners/add_banner',
// URL // URL
params: { params: this.form,
name: this.form.name,
weigh: this.form.weigh,
status: 0,
need_login: 0,
userId: this.form.userId,
}
}).then(function (res) { }).then(function (res) {
if (res.data.code === 500) { if (res.data.code !== 200) {
Vue.prototype.$notify.error({ Vue.prototype.$notify.error({
title: '错误', title: '错误',
message: res.data.msg, message: "添加失败",
offset: 50 offset: 50
}); });
} else { } else {
_this.closeDialog(); _this.closeDialog();
_this.GetBannerData();
Vue.prototype.$notify({ Vue.prototype.$notify({
title: '成功', title: '成功',
message: ('i', {style: 'color: teal'}, "更新成功!"), message: ('i', {style: 'color: teal'}, "添加成功!"),
type: 'success', type: 'success',
offset: 50 offset: 50
}); });
} }
}).catch((error)=>{ }).catch((error)=>{
}) })
}else if(flag == "编辑分类"){
axios({
method: 'post',
//
url: '/api/UrlAndCate/updateUrlCate',
// URL
params: {
id: this.form.id,
weigh: this.form.weigh,
status: 0,
name: this.form.name,
}
}).then(function (res) {
if (res.data.code === 500) {
Vue.prototype.$notify.error({
title: '错误',
message: res.data.msg,
offset: 50
});
} else {
_this.closeDialog();
Vue.prototype.$notify({
title: '成功',
message: ('i', {style: 'color: teal'}, "更新成功!"),
type: 'success',
offset: 50
});
}
}).catch((error)=>{
})
}
} }
}) })
@ -342,58 +262,26 @@ export default {
}, },
// //
getFormatDate() {
var that = this;
console.log(that.List.length + "changdu");
for(let i = 0 ; i < that.List.length; i++){
var date = new Date(that.List[i].createtime);// 10*1000131000
var Y = date.getFullYear() + '年';
var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '月';
var D = date.getDate() + '日 ';
console.log("date: " + Y + M + D);
that.List[i].createtime = "" + Y + M + D;
}
},
// //
hIndex(index){ hIndex(index){
var linenum = parseInt( parseInt(index) + parseInt(1)) var linenum = parseInt( parseInt(index) + parseInt(1))
return linenum; return linenum;
}, },
// ID
getUserInfo() { GetBannerData(){
let _this = this;
if(localStorage.getItem("Authorization") && localStorage.getItem("userId")){
_this.userId = localStorage.getItem("userId")
_this.GetData();
} else {
Vue.prototype.$notify.error({
title: '错误',
message: "登录状态失效,请重新登录!",
offset: 0
});
}
},
GetData(){
// //
var that = this; var that = this;
axios({ axios({
method:'post', method:'get',
url:'/api/UrlAndCate/returnCateByUserId', url:'/api/banners/view_banner',
params:{
userId: that.userId
}
}).then(function(res){ }).then(function(res){
that.List = res.data.data; that.List = res.data;
for(let i = 0 ; i < that.List.length; i++){
var date = new Date(that.List[i].createtime);// 10*1000131000 }).catch((error)=>{
var Y = date.getFullYear() + '年';
var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '月';
var D = date.getDate() + '日 ';
that.List[i].createtime = "" + Y + M + D;
}
}) })
// /selectAllArticleByadmin
that.form.userId = that.userId;
}, },

View File

@ -125,8 +125,6 @@
</el-form> </el-form>
</el-dialog> </el-dialog>
</div> </div>
</div> </div>
</template> </template>
<script> <script>

View File

@ -1,23 +1,180 @@
<template> <template>
<div class="main" style="text-shadow: 0 0 20px var(--font-border);overflow: scroll">
<div class="HeadLine" style="margin-top:30px;margin-left:15px;">
<div class="HeadSquare" ></div>
<div class="TitleFont" style="color:var(--theme-color)"><i class="el-icon-s-grid"></i>用户管理</div>
</div>
<div class="base-style" style="margin-top:20px;font-family: SimHei;font-size:18px;font-weight:600;margin-left:20px">
<el-table class="MyTable"
:data="list"
header-row-class-name="table_header_class"
border>
<el-table-column
align="center"
prop="id"
label="用户id"
width="50">
</el-table-column>
<el-table-column
align="center"
prop="userLogin"
label="登录用户名"
width="150">
</el-table-column>
<el-table-column
align="center"
prop="userPassword"
label="密码"
width="160">
</el-table-column>
<el-table-column
align="center"
prop="phone"
label="电话"
width="100">
</el-table-column>
<el-table-column
align="center"
prop="avatar"
label="头像"
width="120">
<template slot-scope="scope">
<div class="ButtonBlock">
<el-image :src="scope.row.avatar">
<div slot="error" class="image-slot">
<el-avatar icon="el-icon-user-solid"></el-avatar>
</div>
</el-image>
</div>
</template>
</el-table-column>
<el-table-column
align="center"
prop="nickname"
label="昵称"
width="100">
</el-table-column>
<el-table-column
align="center"
prop="userEmail"
label="邮箱"
width="100">
</el-table-column>
<el-table-column
align="center"
prop="userStatus"
label="状态"
width="100">
</el-table-column>
<el-table-column
align="center"
prop="userRegistered"
label="注册时间"
width="100">
</el-table-column>
<el-table-column
align="center"
prop="roleId"
label="角色"
width="100">
<template slot-scope="scope">
<span v-if="scope.row.roleId===1">普通用户</span>
<span v-if="scope.row.roleId===0">管理员</span>
</template>
</el-table-column>
</el-table>
</div>
</div>
</template> </template>
<script> <script>
import axios from "axios";
export default { export default {
name: "UserManage", name: "UserManage",
data() { data() {
return {} return {
list:[],
}
}, },
mounted() { mounted() {
this.getUserData();
}, },
created() { created() {
}, },
computed: {}, computed: {},
methods: {} methods: {
getUserData(){
//
var that = this;
axios({
method:'get',
url:'/api//getAllUsers',
}).then(function(res){
that.list = res.data;
}).catch((error)=>{
})
},
}
} }
</script> </script>
<style scoped> <style scoped>
.base-style{
display: flex;
flex-direction: column;
}
/**表格样式,直接复制**/
::v-deep .table_header_class th{
background-color: var(--table-bg-color)!important;
color:var(--theme-color);
text-align: center;
}
.MyTable{
margin-top:10px;
width: 100%;
background-color:var(--table-bg-color);
color:var(--theme-color);
border-radius: 5px;
}
::v-deep .el-table__body tr:hover > td {
background-color: var(--table-bg-color-hover) !important;
}
::v-deep .el-table tr,
.el-table th.el-table__cell {
background-color: var(--table-bg-color);
border: var(--table-border) solid 3px;
}
::v-deep .el-table--border{
border: var(--table-border) solid 3px;
}
.login_container {
width: 400px;
border: 1px solid #eaeaea;
margin: 100px auto;
padding: 35px 35px 15px 35px;
box-sizing: border-box;
border-radius: 15px;
background-color: #fff;
box-shadow: 0 0 25px #cac6c6;
.login_title{
color: #505458;
text-align: center;
margin-bottom: 40px;}
}
::v-deep .el-dialog__body{
background-image: url("../../../assets/img/SkyPic.jpg");
margin-top:15px;
height:400px;
}
</style> </style>

View File

@ -389,10 +389,10 @@ export default {
urlId:index.urlId, urlId:index.urlId,
} }
}).then(function (res) { }).then(function (res) {
if (res.data.code === 500) { if (res.data.code !== 500) {
Vue.prototype.$notify.error({ Vue.prototype.$notify.error({
title: '错误', title: '错误',
message: res.data.msg, message: "删除失败",
offset: 50 offset: 50
}); });
} else { } else {

View File

@ -28,7 +28,7 @@
</keep-alive> </keep-alive>
<div class="overlay-app"></div> <div class="overlay-app"></div>
</div> </div>
<div v-if="icp_info!==''" style="z-index: 9999;display: flex;flex-direction: row;margin-bottom: -30px"> <div v-if="icp_info!==''" style="display: flex;flex-direction: row;margin-bottom: -30px">
<el-link style="color: var(--theme-color);" :underline="false" href="https://beian.miit.gov.cn/" target="_blank">备案号 </el-link> <el-link style="color: var(--theme-color);" :underline="false" href="https://beian.miit.gov.cn/" target="_blank">备案号 </el-link>
<el-link style="color: var(--theme-color);" :underline="false" href="https://beian.miit.gov.cn/" target="_blank"> {{icp_info}}</el-link> <el-link style="color: var(--theme-color);" :underline="false" href="https://beian.miit.gov.cn/" target="_blank"> {{icp_info}}</el-link>
</div> </div>