main
cc 2024-03-28 08:17:16 +00:00
parent ab2644fd69
commit fb300fd1f2
7 changed files with 234 additions and 49 deletions

View File

@ -30,13 +30,14 @@ axios.interceptors.response.use(
}
);
// post请求
export function postJsonRequest(url, params) {
export function postJsonRequest(url,action, params) {
return axios({
method: "post",
url: url,
data: params,
headers: {
"Content-Type": "application/json",
action
},
});
}

View File

@ -1,15 +1,23 @@
import {
postJsonRequest,downloadRequest
} from './api.js';
import { postJsonRequest, downloadRequest } from "./api.js";
const myApi = {
getProjects(params) {
return postJsonRequest('/api/honeywell/inncon/list/project', params);
return postJsonRequest("/api/honeywell/inncon/list/project", params);
},
userAPI(action,params) {
return postJsonRequest("/api/honeywell/user",action, params);
},
download(params) {
return downloadRequest('/api/honeywell/inncon/list/project', params);
}
}
export default myApi;
return downloadRequest("/api/honeywell/inncon/list/project", params);
},
};
const actionNum = {
QueryUser: 90000,
CreateUser: 90001,
UpdateUser: 90002,
DeleteUser: 90003,
QueryRole: 90100,
};
export { myApi, actionNum };

View File

@ -1,33 +1,40 @@
import { createRouter, createWebHashHistory } from 'vue-router';
import Home from '../views/Home.vue';
import Project from '../views/Project.vue';
import Room from '../views/Room.vue';
import Login from '../views/Login.vue';
import { createRouter, createWebHashHistory } from "vue-router";
import Home from "../views/Home.vue";
import Project from "../views/Project.vue";
import Room from "../views/Room.vue";
import Login from "../views/Login.vue";
import User from "../views/User.vue";
const routes = [
{
path: '/',
redirect: '/home'
path: "/",
// redirect: "/home",
redirect: "/user",
},
{
path: '/home',
name: 'home',
component: Home
path: "/home",
name: "home",
component: Home,
},
{
path: '/login',
name: 'login',
component: Login
path: "/login",
name: "login",
component: Login,
},
{
path: '/project',
name: 'project',
component: Project
path: "/project",
name: "project",
component: Project,
},
{
path: '/room',
name: 'room',
component: Room
path: "/room",
name: "room",
component: Room,
},
{
path: "/user",
name: "user",
component: User,
},
];

View File

@ -63,7 +63,7 @@
import { onMounted, reactive, ref } from "vue";
import { Plus, SwitchButton } from "@element-plus/icons-vue";
import { ElMessage, ElMessageBox } from "element-plus";
import myApi from "@/api/myApi.js";
import {myApi} from "@/api/myApi.js";
import { useRouter } from 'vue-router'
import { localRemove } from '@/utils';
const router = useRouter()

View File

@ -25,7 +25,6 @@
<script>
import { reactive, ref, toRefs } from 'vue'
import { localSet } from '@/utils';
import bcrypt from 'bcryptjs'
export default {
name: 'Login',
setup() {
@ -48,9 +47,8 @@
const submitForm = async () => {
loginForm.value.validate(async (valid) => {
if (valid) {
const encryptedPassword = await bcrypt.hash(state.ruleForm.password, 10);
localSet('name', state.ruleForm.username);
localSet('token', encryptedPassword);
localSet('token', state.ruleForm.password);
window.location.href = '/';
} else {
console.log('error submit!!')

View File

@ -175,7 +175,7 @@
import { Delete } from "@element-plus/icons-vue";
import { onMounted, reactive } from "vue";
import { Plus } from "@element-plus/icons-vue";
import myApi from "@/api/myApi.js";
import {myApi} from "@/api/myApi.js";
import { useRoute, useRouter } from "vue-router";
import { ElMessage } from "element-plus";
const router = useRouter();

171
src/views/User.vue Normal file
View File

@ -0,0 +1,171 @@
<template>
<el-button :icon="Plus" type="success" round @click="new_user_click"></el-button>
<el-table :data="user_list">
<el-table-column type="index" label="序号" width="200" />
<el-table-column prop="name" label="名称" />
<el-table-column prop="email" label="邮箱" />
<el-table-column prop="enabled" label="状态">
<template #default="scope">
<span>{{ scope.row.enabled === 1 ? "启用" : "禁用" }}</span>
</template>
</el-table-column>
<el-table-column prop="role_name" label="类型" />
<el-table-column label="操作" width="200">
<template #default="scope">
<el-button type="primary" :icon="Edit" @click="edit_user_click(scope.row)" circle />
</template>
</el-table-column>
</el-table>
<!-- 编辑用户 -->
<el-dialog v-model="updateuserdialogVisible" title="编辑用户" width="500px">
<el-form :model="user_info" label-width="80px">
<el-form-item label="名称">
<el-input v-model="user_info.name" />
</el-form-item>
<el-form-item label="邮箱">
<el-input v-model="user_info.email" />
</el-form-item>
<el-form-item label="角色">
<el-select v-model="user_info.role_name">
<el-option label="普通用户" value="普通用户" />
<el-option label="AE用户" value="AE用户" />
<el-option label="TS用户" value="TS用户" />
</el-select>
</el-form-item>
<el-form-item label="状态">
<el-radio-group v-model="user_info.enabled">
<el-radio :value=1>启用</el-radio>
<el-radio :value=0>停用</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="删除">
<el-button type="danger" @click="delete_user_click"> </el-button>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="updateuserdialogVisible = false"> </el-button>
<el-button type="primary" @click="update_user_click"> </el-button>
</div>
</el-dialog>
<!-- 新增用户 -->
<el-dialog v-model="adduserdialogVisible" title="新增用户" width="500px">
<el-form :model="user_info" label-width="80px">
<el-form-item label="名称">
<el-input v-model="user_info.name" placeholder="请输入名称" />
</el-form-item>
<el-form-item label="密码">
<el-input v-model="user_info.password" placeholder="请输入密码" />
</el-form-item>
<el-form-item label="邮箱">
<el-input v-model="user_info.email" placeholder="请输入邮箱" />
</el-form-item>
<el-form-item label="角色">
<el-select v-model="user_info.role_id">
<el-option v-for="(item, index) in role_list" :key="index" :label="item.role_name"
:value="item.role_id" />
</el-select>
</el-form-item>
<el-form-item label="状态">
<el-radio-group v-model="user_info.enabled">
<el-radio :value=1>启用</el-radio>
<el-radio :value=0>停用</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="adduserdialogVisible = false"> </el-button>
<el-button type="primary" @click="add_user_click"> </el-button>
</div>
</el-dialog>
</template>
<script setup>
import { onMounted, ref, reactive } from "vue";
import { myApi, actionNum } from "@/api/myApi.js";
import { Plus, Edit } from '@element-plus/icons-vue'
const user_list = ref([]);
const role_list = ref([]);
const updateuserdialogVisible = ref(false);
const adduserdialogVisible = ref(false);
const user_info = reactive({
name: "",
email: "",
password: "",
enabled: 0,
role_id: 0,
role_name: "",
});
const get_user_list = async () => {
const res = await myApi.userAPI(actionNum.QueryUser, null);
if (res.code === 0) {
user_list.value = res.data;
} else {
ElMessage({
message: res.message,
type: "warning",
});
}
};
const get_role_list = async () => {
const res = await myApi.userAPI(actionNum.QueryRole, null);
if (res.code === 0) {
role_list.value = res.data;
} else {
ElMessage({
message: res.message,
type: "warning",
});
}
};
const add_user = async () => {
};
const update_user = async () => {
};
const delete_user = async () => {
};
const new_user_click = () => {
user_info.name = "";
user_info.password = "";
user_info.email = "";
user_info.enabled = 1;
user_info.role_id = 1;
get_role_list();
adduserdialogVisible.value = true;
};
const add_user_click = () => {
console.log("点击新增");
add_user();
adduserdialogVisible.value = false;
};
const edit_user_click = item => {
Object.assign(user_info, item);
updateuserdialogVisible.value = true;
};
const delete_user_click = () => {
console.log("点击删除");
delete_user();
updateuserdialogVisible.value = false;
};
const update_user_click = async () => {
console.log("点击更新");
update_user();
updateuserdialogVisible.value = false;
};
onMounted(() => {
get_user_list();
});
</script>