no message

main
LX 2024-03-21 09:46:25 +08:00
parent 8497f61842
commit 5fa6b58a69
7 changed files with 958 additions and 49 deletions

View File

@ -11,13 +11,6 @@
router
>
<el-submenu index="/home">
<template slot="title">
<i class="el-icon-s-home"></i>
<span slot="title">系统管理</span>
</template>
<el-menu-item index="/main">用户管理</el-menu-item>
</el-submenu>
<el-menu-item :index="'/'+item.menuClick" v-for="(item,i) in menu" :key="i">
@ -50,4 +43,4 @@ export default {
<style scoped>
</style>
</style>

View File

@ -1,13 +0,0 @@
<template>
<span>admin</span>
</template>
<script>
export default {
name: "admin"
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,470 @@
<template>
<div class="div1">
<div class="div2" style="padding-bottom: 10px">
<div style="float: right">
<el-select v-model="xb" clearable filterable placeholder="请选择性别" style="width: 100px">
<el-option
v-for="item in xbs"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<el-input v-model="name"
placeholder="请输入姓名"
style="width: 200px;margin-left: 5px"
class="input-with-select"
@keyup.enter.native="queryUser">
<el-button class="el-input-group__prepend" slot="append" icon="el-icon-search" @click="queryUser"></el-button>
</el-input>
<el-button type="success" icon="el-icon-refresh-left" style="margin-left: 5px;" @click="rest"></el-button>
</div>
<div class="div3" style="">
<el-button type="primary" icon="el-icon-plus" @click="add"></el-button>
<el-button type="success" icon="el-icon-edit" @click="mod"></el-button>
<el-button type="danger" icon="el-icon-delete" @click="del"></el-button>
<el-button type="warning" icon="el-icon-download" @click="exportExcel"></el-button>
</div>
</div>
<el-dialog :title="title"
:visible.sync="centerDialogVisible"
width="30%"
:before-close="handleClose"
center>
<el-form ref="form"
:model="form"
:rules="rules"
label-width="80px">
<el-form-item label="账号" prop="userNo">
<el-input v-model="form.userNo" style="width: 300px;"></el-input>
</el-form-item>
<el-form-item label="姓名" prop="userName">
<el-input v-model="form.userName" style="width: 300px;"></el-input>
</el-form-item>
<el-form-item label="年龄" prop="age">
<el-input v-model.number="form.age" style="width: 300px;" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="性别">
<el-radio-group v-model="form.sex">
<el-radio label='1'></el-radio>
<el-radio label='0'></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="电话" prop="phone">
<el-input v-model="form.phone" style="width: 300px;"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancelDialog"> </el-button>
<el-button type="primary" @click="addUser"> </el-button>
</div>
</el-dialog>
<el-table
:header-cell-style="{background:'#000',color:'#fff'}"
:data="tableData"
id="educe-table"
ref="tableData"
@selection-change="handleSelectionChange"
@select="selectionRow"
style="width: 100%;">
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column
fixed
label="序号"
v-if="false"
width="180">
<template slot-scope="scope">
<span style="margin-left: 10px">{{ scope.row.id }}</span>
</template>
</el-table-column>
<el-table-column
fixed
label="账号"
width="180">
<template slot-scope="scope">
<el-popover trigger="hover" placement="top">
<p>账号: {{ scope.row.userNo }}</p>
<p>电话: {{ scope.row.phone }}</p>
<div slot="reference" class="name-wrapper">
<el-tag size="medium">{{ scope.row.userNo }}</el-tag>
</div>
</el-popover>
</template>
</el-table-column>
<el-table-column
label="姓名"
width="180">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<span>{{ scope.row.userName }}</span>
</div>
</template>
</el-table-column>
<el-table-column
label="年龄"
width="180">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<span>{{ scope.row.age }}</span>
</div>
</template>
</el-table-column>
<el-table-column
label="电话"
width="180">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<span>{{ scope.row.phone }}</span>
</div>
</template>
</el-table-column>
<el-table-column
label="性别"
width="180">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<el-tag size="medium" :type="scope.row.sex ===0 ? 'primary' : 'success'">
{{ scope.row.sex === 0 ? '女' : '男' }}
</el-tag>
</div>
</template>
</el-table-column>
<el-table-column
label="角色"
width="180">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<el-tag size="medium"
:type="scope.row.roleId ===0 ? 'danger' : (scope.row.roleId ===1 ? 'primary':'success') ">
{{ scope.row.roleId === 0 ? '超级管理员' : (scope.row.roleId === 1 ? '管理员' : '用户') }}
</el-tag>
</div>
</template>
</el-table-column>
<el-table-column
fixed="right"
label="操作"
width="100">
<template slot-scope="scope">
<!-- <el-button
size="small"
@click="handleEdit(scope.$index, scope.row)">编辑
</el-button>
<el-button
size="small"
type="danger"
@click="handleDelete(scope.$index, scope.row)">删除
</el-button>-->
<el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
<el-button type="text" size="small" @click="editUser(scope.row)"></el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="pageNum"
:page-sizes="[10, 50, 150, 200]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
</template>
<script>
import {outFile} from "@/util/excel.vue";
export default {
name: "Main",
data() {
//
let checkuserNo = (rule, value, callback) => {
let id=0;
if(this.form.id>0){
id=this.form.id;
}
this.$axios.get(this.$httpUrl + '/user/queryuserNo?id='+id+'&userNo='+ this.form.userNo).then(res => res.data)
.then(res => {
if (res.code == 200) {
callback(new Error(this.form.userNo + '账号已存在!'));
} else {
callback();
}
})
.catch(function (err) {
console.log(err);
})
};
return {
tableData: [],
pageSize: 10,
pageNum: 1,
total: 3,
name: '',
xb: '',
zh:'',
xbs: [
{
value: '1',
label: '男'
},
{
value: '0',
label: '女'
}
],
form: {
id: '',
userNo: '',
userName: '',
passWord:'123456',
age: '',
sex: '1',
phone: '',
roleId: '2'
},
rules: {
userNo: [
{required: true, message: '请输入账号', trigger: 'blur'},
{ validator: checkuserNo, trigger: 'blur' }
],
userName: [
{required: true, message: '请输入姓名', trigger: 'blur'},
],
age: [
{required: true, message: '年龄不能为空'},
{type: 'number', message: '年龄必须为数字值'}
]
},
multipleSelection:[],
centerDialogVisible: false,
title:''
}
},
methods: {
handleEdit(index, row) {
console.log(index, row);
},
handleDelete(index, row) {
console.log(index, row);
},
handleSizeChange(val) {
console.log(`每页 ${val}`);
this.pageNum = 1;
this.pageSize = val;
this.queryUser();
},
handleCurrentChange(val) {
console.log(`当前页: ${val}`);
this.pageNum = val;
this.queryUser();
},
queryUser() {
//
this.$axios.post(this.$httpUrl + '/user/queryUser', {
pageSize: this.pageSize,
pageNum: this.pageNum,
param: {
name: this.name,
xb: this.xb
}
}).then(res => res.data)
.then(res => {
if (res.code == 200) {
this.tableData = res.data
this.total = res.total
} else {
this.$message.error('获取数据失败');
}
})
.catch(function (err) {
console.log(err);
})
},
rest() {
//
this.name = '',
this.xb = ''
},
add() {
//
this.title="新增用户"
this.centerDialogVisible = true;
//
this.$nextTick(() => {
this.resetForm()
})
},
resetForm() {
this.$refs["form"].resetFields();
this.$data.form=JSON.parse(JSON.stringify(this.$options.data().form))
},
handleClose(){
//
this.centerDialogVisible=false;
this.form.sex='1';
},
cancelDialog(){
//
this.centerDialogVisible=false;
this.resetForm();
this.form.sex='1';
this.$refs.tableData.clearSelection()
},
addUser() {
//
this.$refs["form"].validate((valid) => {
if (valid) {
this.$axios.post(this.$httpUrl + '/user/addorupdate', this.form).then(res => res.data)
.then(res => {
if (res.code == 200) {
this.$message({
message: res.msg,
type: 'success'
});
this.centerDialogVisible = false;//退
this.queryUser();//
this.resetForm();
} else {
this.$message.error(res.msg);
}
})
.catch(function (err) {
console.log(err);
})
} else {
return false;
}
});
},
editUser(row){
//
this.title="编辑用户"
this.centerDialogVisible = true;
this.$nextTick(() => {
this.form=JSON.parse(JSON.stringify(row));
this.form.sex=row.sex+''
this.$refs.tableData.toggleRowSelection(row, true);//
})
},
handleSelectionChange(val) {
this.multipleSelection = val;
let planIdList = [];
for (let item of this.multipleSelection) {
planIdList.push(item.id);
}
console.log(planIdList);
},
selectionRow(selection,row){
},
mod(){
//
if(this.$refs.tableData.selection.length==1){
this.title="编辑用户"
this.centerDialogVisible = true;
for (let item of this.multipleSelection) {
this.form=JSON.parse(JSON.stringify(item));
this.form.sex=item.sex+''
}
}else{
this.$message.error('请选中一条记录!');
}
},
del(){
//
if(this.$refs.tableData.selection.length==0){
this.$message.error('请至少选中一条记录!');
}else{
this.$confirm('此操作将永久删除, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let ids=[];
for (let item of this.multipleSelection) {
ids.push(item.id)
}
this.$axios.get(this.$httpUrl + '/user/deleteUser?ids='+ids.toString()).then(res => res.data)
.then(res => {
if (res.code == 200) {
this.$message({
message: res.msg,
type: 'success'
});
this.queryUser()//
} else {
this.$message.error(res.msg);
}
})
.catch(function (err) {
console.log(err);
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
}
},
exportExcel(){
this.fixs = false
this.$nextTick(() => {
outFile('educe-table', '(用户)')
this.fixs = true
})
}
},
beforeMount() {
this.queryUser();
}
}
</script>
<style lang="scss" scoped>
</style>

View File

@ -0,0 +1,470 @@
<template>
<div class="div1">
<div class="div2" style="padding-bottom: 10px">
<div style="float: right">
<el-select v-model="xb" clearable filterable placeholder="请选择性别" style="width: 100px">
<el-option
v-for="item in xbs"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<el-input v-model="name"
placeholder="请输入姓名"
style="width: 200px;margin-left: 5px"
class="input-with-select"
@keyup.enter.native="queryUser">
<el-button class="el-input-group__prepend" slot="append" icon="el-icon-search" @click="queryUser"></el-button>
</el-input>
<el-button type="success" icon="el-icon-refresh-left" style="margin-left: 5px;" @click="rest"></el-button>
</div>
<div class="div3" style="">
<el-button type="primary" icon="el-icon-plus" @click="add"></el-button>
<el-button type="success" icon="el-icon-edit" @click="mod"></el-button>
<el-button type="danger" icon="el-icon-delete" @click="del"></el-button>
<el-button type="warning" icon="el-icon-download" @click="exportExcel"></el-button>
</div>
</div>
<el-dialog :title="title"
:visible.sync="centerDialogVisible"
width="30%"
:before-close="handleClose"
center>
<el-form ref="form"
:model="form"
:rules="rules"
label-width="80px">
<el-form-item label="账号" prop="userNo">
<el-input v-model="form.userNo" style="width: 300px;"></el-input>
</el-form-item>
<el-form-item label="姓名" prop="userName">
<el-input v-model="form.userName" style="width: 300px;"></el-input>
</el-form-item>
<el-form-item label="年龄" prop="age">
<el-input v-model.number="form.age" style="width: 300px;" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="性别">
<el-radio-group v-model="form.sex">
<el-radio label='1'></el-radio>
<el-radio label='0'></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="电话" prop="phone">
<el-input v-model="form.phone" style="width: 300px;"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancelDialog"> </el-button>
<el-button type="primary" @click="addUser"> </el-button>
</div>
</el-dialog>
<el-table
:header-cell-style="{background:'#000',color:'#fff'}"
:data="tableData"
id="educe-table"
ref="tableData"
@selection-change="handleSelectionChange"
@select="selectionRow"
style="width: 100%;">
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column
fixed
label="序号"
v-if="false"
width="180">
<template slot-scope="scope">
<span style="margin-left: 10px">{{ scope.row.id }}</span>
</template>
</el-table-column>
<el-table-column
fixed
label="账号"
width="180">
<template slot-scope="scope">
<el-popover trigger="hover" placement="top">
<p>账号: {{ scope.row.userNo }}</p>
<p>电话: {{ scope.row.phone }}</p>
<div slot="reference" class="name-wrapper">
<el-tag size="medium">{{ scope.row.userNo }}</el-tag>
</div>
</el-popover>
</template>
</el-table-column>
<el-table-column
label="姓名"
width="180">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<span>{{ scope.row.userName }}</span>
</div>
</template>
</el-table-column>
<el-table-column
label="年龄"
width="180">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<span>{{ scope.row.age }}</span>
</div>
</template>
</el-table-column>
<el-table-column
label="电话"
width="180">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<span>{{ scope.row.phone }}</span>
</div>
</template>
</el-table-column>
<el-table-column
label="性别"
width="180">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<el-tag size="medium" :type="scope.row.sex ===0 ? 'primary' : 'success'">
{{ scope.row.sex === 0 ? '女' : '男' }}
</el-tag>
</div>
</template>
</el-table-column>
<el-table-column
label="角色"
width="180">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<el-tag size="medium"
:type="scope.row.roleId ===0 ? 'danger' : (scope.row.roleId ===1 ? 'primary':'success') ">
{{ scope.row.roleId === 0 ? '超级管理员' : (scope.row.roleId === 1 ? '管理员' : '用户') }}
</el-tag>
</div>
</template>
</el-table-column>
<el-table-column
fixed="right"
label="操作"
width="100">
<template slot-scope="scope">
<!-- <el-button
size="small"
@click="handleEdit(scope.$index, scope.row)">编辑
</el-button>
<el-button
size="small"
type="danger"
@click="handleDelete(scope.$index, scope.row)">删除
</el-button>-->
<el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
<el-button type="text" size="small" @click="editUser(scope.row)"></el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="pageNum"
:page-sizes="[10, 50, 150, 200]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
</template>
<script>
import {outFile} from "@/util/excel.vue";
export default {
name: "Main",
data() {
//
let checkuserNo = (rule, value, callback) => {
let id=0;
if(this.form.id>0){
id=this.form.id;
}
this.$axios.get(this.$httpUrl + '/user/queryuserNo?id='+id+'&userNo='+ this.form.userNo).then(res => res.data)
.then(res => {
if (res.code == 200) {
callback(new Error(this.form.userNo + '账号已存在!'));
} else {
callback();
}
})
.catch(function (err) {
console.log(err);
})
};
return {
tableData: [],
pageSize: 10,
pageNum: 1,
total: 3,
name: '',
xb: '',
zh:'',
xbs: [
{
value: '1',
label: '男'
},
{
value: '0',
label: '女'
}
],
form: {
id: '',
userNo: '',
userName: '',
passWord:'123456',
age: '',
sex: '1',
phone: '',
roleId: '2'
},
rules: {
userNo: [
{required: true, message: '请输入账号', trigger: 'blur'},
{ validator: checkuserNo, trigger: 'blur' }
],
userName: [
{required: true, message: '请输入姓名', trigger: 'blur'},
],
age: [
{required: true, message: '年龄不能为空'},
{type: 'number', message: '年龄必须为数字值'}
]
},
multipleSelection:[],
centerDialogVisible: false,
title:''
}
},
methods: {
handleEdit(index, row) {
console.log(index, row);
},
handleDelete(index, row) {
console.log(index, row);
},
handleSizeChange(val) {
console.log(`每页 ${val}`);
this.pageNum = 1;
this.pageSize = val;
this.queryUser();
},
handleCurrentChange(val) {
console.log(`当前页: ${val}`);
this.pageNum = val;
this.queryUser();
},
queryUser() {
//
this.$axios.post(this.$httpUrl + '/user/queryUser', {
pageSize: this.pageSize,
pageNum: this.pageNum,
param: {
name: this.name,
xb: this.xb
}
}).then(res => res.data)
.then(res => {
if (res.code == 200) {
this.tableData = res.data
this.total = res.total
} else {
this.$message.error('获取数据失败');
}
})
.catch(function (err) {
console.log(err);
})
},
rest() {
//
this.name = '',
this.xb = ''
},
add() {
//
this.title="新增用户"
this.centerDialogVisible = true;
//
this.$nextTick(() => {
this.resetForm()
})
},
resetForm() {
this.$refs["form"].resetFields();
this.$data.form=JSON.parse(JSON.stringify(this.$options.data().form))
},
handleClose(){
//
this.centerDialogVisible=false;
this.form.sex='1';
},
cancelDialog(){
//
this.centerDialogVisible=false;
this.resetForm();
this.form.sex='1';
this.$refs.tableData.clearSelection()
},
addUser() {
//
this.$refs["form"].validate((valid) => {
if (valid) {
this.$axios.post(this.$httpUrl + '/user/addorupdate', this.form).then(res => res.data)
.then(res => {
if (res.code == 200) {
this.$message({
message: res.msg,
type: 'success'
});
this.centerDialogVisible = false;//退
this.queryUser();//
this.resetForm();
} else {
this.$message.error(res.msg);
}
})
.catch(function (err) {
console.log(err);
})
} else {
return false;
}
});
},
editUser(row){
//
this.title="编辑用户"
this.centerDialogVisible = true;
this.$nextTick(() => {
this.form=JSON.parse(JSON.stringify(row));
this.form.sex=row.sex+''
this.$refs.tableData.toggleRowSelection(row, true);//
})
},
handleSelectionChange(val) {
this.multipleSelection = val;
let planIdList = [];
for (let item of this.multipleSelection) {
planIdList.push(item.id);
}
console.log(planIdList);
},
selectionRow(selection,row){
},
mod(){
//
if(this.$refs.tableData.selection.length==1){
this.title="编辑用户"
this.centerDialogVisible = true;
for (let item of this.multipleSelection) {
this.form=JSON.parse(JSON.stringify(item));
this.form.sex=item.sex+''
}
}else{
this.$message.error('请选中一条记录!');
}
},
del(){
//
if(this.$refs.tableData.selection.length==0){
this.$message.error('请至少选中一条记录!');
}else{
this.$confirm('此操作将永久删除, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let ids=[];
for (let item of this.multipleSelection) {
ids.push(item.id)
}
this.$axios.get(this.$httpUrl + '/user/deleteUser?ids='+ids.toString()).then(res => res.data)
.then(res => {
if (res.code == 200) {
this.$message({
message: res.msg,
type: 'success'
});
this.queryUser()//
} else {
this.$message.error(res.msg);
}
})
.catch(function (err) {
console.log(err);
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
}
},
exportExcel(){
this.fixs = false
this.$nextTick(() => {
outFile('educe-table', '(用户)')
this.fixs = true
})
}
},
beforeMount() {
this.queryUser();
}
}
</script>
<style lang="scss" scoped>
</style>

View File

@ -8,7 +8,7 @@ import VueRouter from "vue-router";
import router from "@/router/router";
import store from "@/store/store";
Vue.prototype.$axios=axios;
Vue.prototype.$httpUrl='http://192.168.56.138:8081';
Vue.prototype.$httpUrl='http://192.168.56.147:8081';
Vue.config.productionTip = false;
Vue.use(VueRouter)
Vue.use(ElementUI,{size:'small'});

View File

@ -17,39 +17,23 @@ const routes=[
meta:{
title:'首页'
},
component: () => import('../components/Home')
component: () => import('../components/duochaxun/demo1.vue')
},
{
path:'/admin',
name:'admin',
path:'/demo1',
name:'demo1',
meta:{
title:'超级管理员'
title:'测试1'
},
component: () => import('../components/admin/Admin')
component: () => import('@/components/duochaxun/demo1.vue')
},
{
path:'/user',
name:'user',
path:'/demo2',
name:'demo2',
meta:{
title:'用户'
title:'测试2'
},
component: () => import('../components/user/User')
},
{
path:'/admin',
name:'admin',
meta:{
title:'管理员'
},
component: () => import('../components/admin/Admin')
},
{
path:'/main',
name:'main',
meta:{
title:'用户管理'
},
component: () => import('../components/Main')
component: () => import('@/components/duochaxun/demo2.vue')
}
]
}

View File

@ -61,16 +61,21 @@ public class UserController {
menu.put("menuCode",i);
if(i==1) {
menu.put("menuName", "库存汇总查询");
menu.put("menuComponent","/demo1");
menu.put("menuClick","demo1");
}else if(i==2) {
menu.put("menuName", "入库明细查询");
menu.put("menuComponent","/demo2");
menu.put("menuClick","demo2");
}else if(i==3) {
menu.put("menuName", "出库明细查询");
menu.put("menuComponent","/demo2");
menu.put("menuClick","demo2");
}
menu.put("menuLevel",i);
menu.put("menuParentCode",i);
menu.put("menuClick","admin"+i);
menu.put("menuRight", "0,1");
menu.put("menuComponent","/admin"+i);
menu.put("menuIcon","el-icon-s-home");
array.add(menu);
}