。。。
parent
a627ebdc19
commit
ab1d04c72d
|
@ -0,0 +1,66 @@
|
|||
import axios from "axios";
|
||||
|
||||
axios.defaults.withCredentials = true;
|
||||
// 请求头,headers 信息
|
||||
axios.defaults.headers["X-Requested-With"] = "XMLHttpRequest";
|
||||
axios.defaults.headers = {
|
||||
name: "cc",
|
||||
token: "",
|
||||
};
|
||||
|
||||
|
||||
|
||||
// 请求拦截器,内部根据返回值,重新组装,统一管理。
|
||||
axios.interceptors.response.use(
|
||||
(res) => {
|
||||
return res.data;
|
||||
},
|
||||
(error) => {
|
||||
ElMessage.closeAll();
|
||||
ElMessage.error(error || "请求错误");
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
// post请求
|
||||
export function postJsonRequest(url, params) {
|
||||
return axios({
|
||||
method: "post",
|
||||
url: url,
|
||||
data: params,
|
||||
// responseType: 'arraybuffer',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
}
|
||||
// get请求
|
||||
export function getRequest(url, params) {
|
||||
return axios({
|
||||
method: "get",
|
||||
// responseType: 'arraybuffer',
|
||||
params: {
|
||||
...params,
|
||||
},
|
||||
url: url,
|
||||
});
|
||||
}
|
||||
|
||||
export function deleteRequest(url, params) {
|
||||
return axios({
|
||||
method: "delete",
|
||||
data: params,
|
||||
// responseType: 'arraybuffer',
|
||||
url: url,
|
||||
});
|
||||
}
|
||||
export const putRequest = (url, params) => {
|
||||
return axios({
|
||||
method: "put",
|
||||
data: params,
|
||||
// responseType: 'arraybuffer',
|
||||
url: url,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
};
|
|
@ -0,0 +1,14 @@
|
|||
import {
|
||||
getRequest,
|
||||
postJsonRequest,
|
||||
deleteRequest,
|
||||
putRequest
|
||||
} from './api.js';
|
||||
const myApi = {
|
||||
|
||||
getProjects(params) {
|
||||
return postJsonRequest('/api/honeywell/inncon/list/project', params);
|
||||
}
|
||||
}
|
||||
export default myApi;
|
||||
|
|
@ -1,34 +1,22 @@
|
|||
<template>
|
||||
<el-card>
|
||||
<el-row>
|
||||
<el-col :span="6">
|
||||
<el-card>
|
||||
<el-button :icon="Plus" circle @click="
|
||||
<el-card class="home-div">
|
||||
<el-card class="card-div">
|
||||
<el-button :icon="Plus" circle @click="
|
||||
add_project_info.name = '';
|
||||
add_project_info.description = '';
|
||||
add_project_info.enable = true;
|
||||
" />
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="6" v-for="(item, index) in projects" :key="index">
|
||||
<el-card>
|
||||
<p>{{ item.name }}</p>
|
||||
<p>{{ item.description }}</p>
|
||||
<p>{{ item.content }}</p>
|
||||
<el-button type="primary" round>管理</el-button>
|
||||
<el-button type="success" round @click="
|
||||
update_project_info.name = item.name;
|
||||
update_project_info.new_name = item.name;
|
||||
update_project_info.description = item.description;
|
||||
update_project_info.content = item.content || null;
|
||||
update_project_info.enable = true;
|
||||
">编辑</el-button>
|
||||
<el-button type="danger" round @click="remove_project(item)">删除</el-button>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
<el-card class="card-div" v-for="(item, index) in projects" :key="index">
|
||||
<p>{{ item.name }}</p>
|
||||
<p>{{ item.description }}</p>
|
||||
<p>{{ item.content }}</p>
|
||||
<el-button type="primary">管理</el-button>
|
||||
<el-button type="success" @click="openUpdateDialog(item)">编辑</el-button>
|
||||
<el-button type="danger" @click="openRemove(item)">删除</el-button>
|
||||
</el-card>
|
||||
</el-card>
|
||||
<el-dialog v-model="add_project_info.enable" title="新增项目" width="500">
|
||||
<el-dialog v-model="add_project_info.enable" title="新增项目" width="500" center>
|
||||
<el-form :model="add_project_info">
|
||||
<el-form-item label="项目名称">
|
||||
<el-input v-model="add_project_info.name" />
|
||||
|
@ -36,13 +24,15 @@
|
|||
<el-form-item label="项目描述">
|
||||
<el-input v-model="add_project_info.description" type="textarea" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="add_project">确定</el-button>
|
||||
<el-button @click="add_project_info.enable = false">取消</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="add_project_info.enable = false">取消</el-button>
|
||||
<el-button type="primary" @click="add_project">确定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<el-dialog v-model="update_project_info.enable" title="修改项目" width="500">
|
||||
<el-dialog v-model="update_project_info.enable" title="修改项目" width="500" center>
|
||||
<el-form :model="update_project_info">
|
||||
<el-form-item label="项目名称">
|
||||
<el-input v-model="update_project_info.name" disabled />
|
||||
|
@ -53,87 +43,78 @@
|
|||
<el-form-item label="项目描述">
|
||||
<el-input v-model="update_project_info.description" type="textarea" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="update_project">确定</el-button>
|
||||
<el-button @click="update_project_info.enable = false">取消</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="update_project_info.enable = false">取消</el-button>
|
||||
<el-button type="primary" @click="update_project">确定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup>
|
||||
import { onMounted, reactive, ref } from "vue";
|
||||
import { Plus } from "@element-plus/icons-vue";
|
||||
import { ref, reactive } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { onMounted } from "vue";
|
||||
import { ElMessage,ElMessageBox } from "element-plus";
|
||||
import myApi from "@/api/myApi.js";
|
||||
import axios from "axios";
|
||||
axios.defaults.headers = {
|
||||
name: "cc",
|
||||
token: "",
|
||||
};
|
||||
|
||||
const projects = ref();
|
||||
|
||||
const get_projects = () => {
|
||||
axios({
|
||||
method: "post",
|
||||
url: "http://10.10.10.4:3000/api/honeywell/inncon/list/project",
|
||||
data: {
|
||||
action: 100,
|
||||
},
|
||||
}).then((response) => {
|
||||
var data = response.data;
|
||||
if (data.code === 0) {
|
||||
projects.value = data.data;
|
||||
} else {
|
||||
ElMessage({
|
||||
message: data.message,
|
||||
type: "warning",
|
||||
});
|
||||
}
|
||||
}).catch((error) => {
|
||||
|
||||
onMounted(() => {
|
||||
get_projects();
|
||||
})
|
||||
|
||||
const get_projects = async () => {
|
||||
const param = {
|
||||
action: 100,
|
||||
}
|
||||
const res = await myApi.getProjects(param);
|
||||
if (res.code === 0) {
|
||||
projects.value = res.data;
|
||||
} else {
|
||||
ElMessage({
|
||||
message: error,
|
||||
message: res.message,
|
||||
type: "warning",
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const openUpdateDialog = (item) => {
|
||||
update_project_info.name = item.name;
|
||||
update_project_info.new_name = item.name;
|
||||
update_project_info.description = item.description;
|
||||
update_project_info.content = item.content || null;
|
||||
update_project_info.enable = true;
|
||||
}
|
||||
|
||||
const add_project_info = reactive({
|
||||
enable: false,
|
||||
name: "",
|
||||
description: "",
|
||||
});
|
||||
|
||||
const add_project = () => {
|
||||
axios({
|
||||
method: "post",
|
||||
url: "http://10.10.10.4:3000/api/honeywell/inncon/list/project",
|
||||
data: {
|
||||
action: 101,
|
||||
data: add_project_info,
|
||||
},
|
||||
}).then((response) => {
|
||||
var data = response.data;
|
||||
if (data.code === 0) {
|
||||
ElMessage({
|
||||
message: "新增成功",
|
||||
type: "success",
|
||||
});
|
||||
get_projects();
|
||||
add_project_info.enable = false;
|
||||
} else {
|
||||
ElMessage({
|
||||
message: data.message+'['+data.data+']',
|
||||
type: "warning",
|
||||
});
|
||||
}
|
||||
}).catch((error) => {
|
||||
const add_project = async () => {
|
||||
const param = {
|
||||
action: 101,
|
||||
data: add_project_info,
|
||||
}
|
||||
const res = await myApi.getProjects(param);
|
||||
console.log(res);
|
||||
if (res.code === 0) {
|
||||
ElMessage({
|
||||
message: error,
|
||||
message: "新增成功",
|
||||
type: "success",
|
||||
});
|
||||
get_projects();
|
||||
add_project_info.enable = false;
|
||||
} else {
|
||||
ElMessage({
|
||||
message: res.message + '[' + res.data + ']',
|
||||
type: "warning",
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const update_project_info = reactive({
|
||||
enable: false,
|
||||
|
@ -143,70 +124,95 @@ const update_project_info = reactive({
|
|||
content: null,
|
||||
});
|
||||
|
||||
const update_project = () => {
|
||||
axios({
|
||||
method: "post",
|
||||
url: "http://10.10.10.4:3000/api/honeywell/inncon/list/project",
|
||||
data: {
|
||||
action: 102,
|
||||
data: update_project_info,
|
||||
},
|
||||
}).then((response) => {
|
||||
var data = response.data;
|
||||
if (data.code === 0) {
|
||||
ElMessage({
|
||||
message: "更新成功",
|
||||
type: "success",
|
||||
});
|
||||
get_projects();
|
||||
update_project_info.enable = false;
|
||||
} else {
|
||||
ElMessage({
|
||||
message: data.message+'['+data.data+']',
|
||||
type: "warning",
|
||||
});
|
||||
}
|
||||
}).catch((error) => {
|
||||
const update_project = async () => {
|
||||
const param = {
|
||||
action: 102,
|
||||
data: update_project_info,
|
||||
}
|
||||
const res = await myApi.getProjects(param);
|
||||
console.log(res);
|
||||
if (res.code === 0) {
|
||||
ElMessage({
|
||||
message: error,
|
||||
message: "更新成功",
|
||||
type: "success",
|
||||
});
|
||||
get_projects();
|
||||
update_project_info.enable = false;
|
||||
} else {
|
||||
ElMessage({
|
||||
message: res.message + '[' + res.data + ']',
|
||||
type: "warning",
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const remove_project = (project) => {
|
||||
axios({
|
||||
method: "post",
|
||||
url: "http://10.10.10.4:3000/api/honeywell/inncon/list/project",
|
||||
const openRemove = (item) => {
|
||||
ElMessageBox.confirm(
|
||||
'确定删除项目?',
|
||||
'删除项目',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
remove_project(item);
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage({
|
||||
type: 'info',
|
||||
message: '取消删除',
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const remove_project = async (project) => {
|
||||
const param = {
|
||||
action: 103,
|
||||
data: {
|
||||
action: 103,
|
||||
data: {
|
||||
name: project.name
|
||||
},
|
||||
name: project.name
|
||||
},
|
||||
}).then((response) => {
|
||||
var data = response.data;
|
||||
if (data.code === 0) {
|
||||
ElMessage({
|
||||
message: "删除成功",
|
||||
type: "success",
|
||||
});
|
||||
get_projects();
|
||||
} else {
|
||||
ElMessage({
|
||||
message: data.message+'['+data.data+']',
|
||||
type: "warning",
|
||||
});
|
||||
}
|
||||
}).catch((error) => {
|
||||
}
|
||||
const res = await myApi.getProjects(param);
|
||||
if (res.code === 0) {
|
||||
ElMessage({
|
||||
message: error,
|
||||
message: "删除成功",
|
||||
type: "success",
|
||||
});
|
||||
get_projects();
|
||||
} else {
|
||||
ElMessage({
|
||||
message: res.message + '[' + res.data + ']',
|
||||
type: "warning",
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
get_projects();
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.home-div {
|
||||
height: 800px;
|
||||
overflow: auto;
|
||||
|
||||
::v-deep>.el-card__body {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
}
|
||||
|
||||
.card-div {
|
||||
height: 200px;
|
||||
width: 24%;
|
||||
margin: 0.4%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -1,7 +1,23 @@
|
|||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { defineConfig } from 'vite';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import path from 'path'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'~': path.resolve(__dirname, './'),
|
||||
'@': path.resolve(__dirname, 'src')
|
||||
}
|
||||
},
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://api.shikicc.com:58909',
|
||||
changeOrigin: true,
|
||||
rewrite: path => path.replace(/^\/api/, '/api')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue