Compare commits
2 Commits
fd0d380ae9
...
7ad6f1f093
| Author | SHA1 | Date |
|---|---|---|
|
|
7ad6f1f093 | |
|
|
9840e6d823 |
|
|
@ -1,5 +1,5 @@
|
|||
# backend service base url, prod environment
|
||||
VITE_SERVICE_BASE_URL=http://154.219.110.17:8080
|
||||
VITE_SERVICE_BASE_URL=http://154.219.110.17:8080/api
|
||||
|
||||
# other backend service base url, prod environment
|
||||
# VITE_OTHER_SERVICE_BASE_URL= `{
|
||||
|
|
|
|||
11
.env.test
11
.env.test
|
|
@ -1,7 +1,8 @@
|
|||
# backend service base url, test environment
|
||||
VITE_SERVICE_BASE_URL=http://localhost:8080/api/
|
||||
VITE_SERVICE_BASE_URL=http://localhost:8080/api
|
||||
#VITE_SERVICE_BASE_URL=http://154.219.110.17:8080/api
|
||||
|
||||
# other backend service base url, test environment
|
||||
VITE_OTHER_SERVICE_BASE_URL= `{
|
||||
"demo": "http://localhost:9528"
|
||||
}`
|
||||
# # other backend service base url, test environment
|
||||
# VITE_OTHER_SERVICE_BASE_URL= `{
|
||||
# "demo": "http://localhost:9528"
|
||||
# }`
|
||||
|
|
|
|||
|
|
@ -7,22 +7,45 @@ export {}
|
|||
/* prettier-ignore */
|
||||
declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
ABreadcrumb: typeof import('ant-design-vue/es')['Breadcrumb']
|
||||
ABreadcrumbItem: typeof import('ant-design-vue/es')['BreadcrumbItem']
|
||||
AButton: typeof import('ant-design-vue/es')['Button']
|
||||
ACard: typeof import('ant-design-vue/es')['Card']
|
||||
ACheckbox: typeof import('ant-design-vue/es')['Checkbox']
|
||||
ACol: typeof import('ant-design-vue/es')['Col']
|
||||
ADescriptions: typeof import('ant-design-vue/es')['Descriptions']
|
||||
ADescriptionsItem: typeof import('ant-design-vue/es')['DescriptionsItem']
|
||||
ADivider: typeof import('ant-design-vue/es')['Divider']
|
||||
ADrawer: typeof import('ant-design-vue/es')['Drawer']
|
||||
ADropdown: typeof import('ant-design-vue/es')['Dropdown']
|
||||
AEmpty: typeof import('ant-design-vue/es')['Empty']
|
||||
AForm: typeof import('ant-design-vue/es')['Form']
|
||||
AFormItem: typeof import('ant-design-vue/es')['FormItem']
|
||||
AInput: typeof import('ant-design-vue/es')['Input']
|
||||
AInputNumber: typeof import('ant-design-vue/es')['InputNumber']
|
||||
AInputPassword: typeof import('ant-design-vue/es')['InputPassword']
|
||||
AInputSearch: typeof import('ant-design-vue/es')['InputSearch']
|
||||
AMenu: typeof import('ant-design-vue/es')['Menu']
|
||||
AMenuDivider: typeof import('ant-design-vue/es')['MenuDivider']
|
||||
AMenuItem: typeof import('ant-design-vue/es')['MenuItem']
|
||||
AModal: typeof import('ant-design-vue/es')['Modal']
|
||||
APagination: typeof import('ant-design-vue/es')['Pagination']
|
||||
APopconfirm: typeof import('ant-design-vue/es')['Popconfirm']
|
||||
APopover: typeof import('ant-design-vue/es')['Popover']
|
||||
AppProvider: typeof import('./../components/common/app-provider.vue')['default']
|
||||
ARadio: typeof import('ant-design-vue/es')['Radio']
|
||||
ARadioGroup: typeof import('ant-design-vue/es')['RadioGroup']
|
||||
ARow: typeof import('ant-design-vue/es')['Row']
|
||||
ASegmented: typeof import('ant-design-vue/es')['Segmented']
|
||||
ASelect: typeof import('ant-design-vue/es')['Select']
|
||||
ASelectOption: typeof import('ant-design-vue/es')['SelectOption']
|
||||
ASpace: typeof import('ant-design-vue/es')['Space']
|
||||
ASpin: typeof import('ant-design-vue/es')['Spin']
|
||||
AStatistic: typeof import('ant-design-vue/es')['Statistic']
|
||||
ASwitch: typeof import('ant-design-vue/es')['Switch']
|
||||
ATable: typeof import('ant-design-vue/es')['Table']
|
||||
ATag: typeof import('ant-design-vue/es')['Tag']
|
||||
ATooltip: typeof import('ant-design-vue/es')['Tooltip']
|
||||
ATree: typeof import('ant-design-vue/es')['Tree']
|
||||
AWatermark: typeof import('ant-design-vue/es')['Watermark']
|
||||
BetterScroll: typeof import('./../components/custom/better-scroll.vue')['default']
|
||||
|
|
@ -31,6 +54,19 @@ declare module 'vue' {
|
|||
DarkModeContainer: typeof import('./../components/common/dark-mode-container.vue')['default']
|
||||
ExceptionBase: typeof import('./../components/common/exception-base.vue')['default']
|
||||
FullScreen: typeof import('./../components/common/full-screen.vue')['default']
|
||||
IconAntDesignReloadOutlined: typeof import('~icons/ant-design/reload-outlined')['default']
|
||||
IconAntDesignSettingOutlined: typeof import('~icons/ant-design/setting-outlined')['default']
|
||||
IconCarbonAdd: typeof import('~icons/carbon/add')['default']
|
||||
IconGridiconsFullscreen: typeof import('~icons/gridicons/fullscreen')['default']
|
||||
IconGridiconsFullscreenExit: typeof import('~icons/gridicons/fullscreen-exit')['default']
|
||||
'IconIc:roundPlus': typeof import('~icons/ic/round-plus')['default']
|
||||
IconIcRoundDelete: typeof import('~icons/ic/round-delete')['default']
|
||||
IconIcRoundPlus: typeof import('~icons/ic/round-plus')['default']
|
||||
IconIcRoundRefresh: typeof import('~icons/ic/round-refresh')['default']
|
||||
IconIcRoundRemove: typeof import('~icons/ic/round-remove')['default']
|
||||
IconIcRoundSearch: typeof import('~icons/ic/round-search')['default']
|
||||
IconMdiDrag: typeof import('~icons/mdi/drag')['default']
|
||||
IconMdiRefresh: typeof import('~icons/mdi/refresh')['default']
|
||||
LangSwitch: typeof import('./../components/common/lang-switch.vue')['default']
|
||||
LookForward: typeof import('./../components/custom/look-forward.vue')['default']
|
||||
MenuToggler: typeof import('./../components/common/menu-toggler.vue')['default']
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@
|
|||
import axios from 'axios';
|
||||
import { localStg } from '@/utils/storage';
|
||||
|
||||
let baseUrl = import.meta.env.VITE_SERVICE_BASE_URL
|
||||
|
||||
// 封装网络请求的接口
|
||||
export const apiRequest = async (method: 'GET' | 'POST' | 'PUT' | 'DELETE', path: string, data?: any) => {
|
||||
let url = "http://localhost:8080" + path;
|
||||
let url = baseUrl + path;
|
||||
const token = localStg.get('token'); // 获取 token
|
||||
try {
|
||||
const response = await axios({
|
||||
|
|
@ -21,8 +23,8 @@ export const apiRequest = async (method: 'GET' | 'POST' | 'PUT' | 'DELETE', path
|
|||
}
|
||||
};
|
||||
|
||||
export const apiRequestGet = async (path: string) => {
|
||||
let url = "http://localhost:8080" + path;
|
||||
export const apiRequestGet = async (path: string, params?:any) => {
|
||||
let url = baseUrl + path;
|
||||
const token = localStg.get('token'); // 获取 token
|
||||
try {
|
||||
return axios.get(
|
||||
|
|
@ -31,6 +33,26 @@ export const apiRequestGet = async (path: string) => {
|
|||
headers: {
|
||||
Authorization: `Bearer ${token}`, // 添加 Authorization 头
|
||||
},
|
||||
params: params,
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
throw new Error('请求失败'); // 抛出错误
|
||||
}
|
||||
};
|
||||
|
||||
export const apiRequestPost = async (path: string,data:any, params?:any) => {
|
||||
let url = baseUrl + path;
|
||||
const token = localStg.get('token'); // 获取 token
|
||||
try {
|
||||
return axios.post(
|
||||
url,
|
||||
data,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`, // 添加 Authorization 头
|
||||
},
|
||||
params: params,
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -6,44 +6,46 @@
|
|||
<div class="toolbar">
|
||||
<a-button type="primary" @click="showAddModal(null)">添加部门</a-button>
|
||||
</div>
|
||||
<a-tree
|
||||
v-if="treeData.length > 0"
|
||||
:tree-data="treeData"
|
||||
show-line
|
||||
:default-expand-all="true"
|
||||
:selected-keys.sync="selectedKeys"
|
||||
>
|
||||
<template #title="{ dataRef }">
|
||||
<div class="tree-node">
|
||||
<span>{{ dataRef.departmentName }}</span>
|
||||
<div class="node-actions">
|
||||
<a-button
|
||||
size="small"
|
||||
type="link"
|
||||
@click="showAddModal(dataRef)"
|
||||
>
|
||||
添加子部门
|
||||
</a-button>
|
||||
<a-button
|
||||
size="small"
|
||||
type="link"
|
||||
@click="showEditModal(dataRef)"
|
||||
>
|
||||
编辑
|
||||
</a-button>
|
||||
<a-button
|
||||
size="small"
|
||||
type="link"
|
||||
danger
|
||||
@click="confirmDelete(dataRef)"
|
||||
>
|
||||
删除
|
||||
</a-button>
|
||||
<a-spin :spinning="loading">
|
||||
<a-tree
|
||||
v-if="treeData.length > 0"
|
||||
:tree-data="treeData"
|
||||
show-line
|
||||
:default-expand-all="true"
|
||||
:selected-keys.sync="selectedKeys"
|
||||
>
|
||||
<template #title="{ dataRef }">
|
||||
<div class="tree-node">
|
||||
<span>{{ dataRef.departmentName }}</span>
|
||||
<div class="node-actions">
|
||||
<a-button
|
||||
size="small"
|
||||
type="link"
|
||||
@click="showAddModal(dataRef)"
|
||||
>
|
||||
添加子部门
|
||||
</a-button>
|
||||
<a-button
|
||||
size="small"
|
||||
type="link"
|
||||
@click="showEditModal(dataRef)"
|
||||
>
|
||||
编辑
|
||||
</a-button>
|
||||
<a-button
|
||||
size="small"
|
||||
type="link"
|
||||
danger
|
||||
@click="confirmDelete(dataRef)"
|
||||
>
|
||||
删除
|
||||
</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</a-tree>
|
||||
<a-empty v-else description="暂无数据" />
|
||||
</template>
|
||||
</a-tree>
|
||||
<a-empty v-else description="暂无数据" />
|
||||
</a-spin>
|
||||
</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
|
@ -74,10 +76,13 @@
|
|||
import { ref, onMounted } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import axios from 'axios';
|
||||
import { apiRequestGet } from '@/utils/api'
|
||||
import { apiRequestGet } from '@/utils/api';
|
||||
import { localStg } from '@/utils/storage';
|
||||
|
||||
// 部门树数据
|
||||
const treeData = ref([]);
|
||||
// 加载状态
|
||||
const loading = ref(false);
|
||||
// 弹窗相关
|
||||
const modalVisible = ref(false);
|
||||
const modalTitle = ref('添加部门');
|
||||
|
|
@ -97,7 +102,8 @@ const selectedKeys = ref([]);
|
|||
// 获取部门数据
|
||||
const fetchDepartments = async () => {
|
||||
try {
|
||||
const response = await apiRequestGet('/api/department/allDepartment');
|
||||
loading.value = true; // 开始加载
|
||||
const response = await apiRequestGet('/department/allDepartment');
|
||||
|
||||
if (response.data.success) {
|
||||
// 过滤重复数据并构建树结构
|
||||
|
|
@ -125,6 +131,8 @@ const fetchDepartments = async () => {
|
|||
}
|
||||
} catch (error) {
|
||||
message.error('请求失败: ' + error.message);
|
||||
} finally {
|
||||
loading.value = false; // 结束加载
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -195,11 +203,14 @@ const confirmDelete = (dept) => {
|
|||
content: `确定要删除部门 ${dept.departmentName} 吗?`,
|
||||
async onOk() {
|
||||
try {
|
||||
loading.value = true; // 开始加载
|
||||
await axios.delete(`http://localhost:8080/api/departments/${dept.key}`);
|
||||
message.success('删除成功');
|
||||
fetchDepartments(); // 刷新数据
|
||||
} catch (error) {
|
||||
message.error('删除失败: ' + error.message);
|
||||
} finally {
|
||||
loading.value = false; // 结束加载
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
import { message, Tag as ATag, Divider as ADivider } from 'ant-design-vue';
|
||||
import axios from 'axios';
|
||||
import { localStg } from '@/utils/storage';
|
||||
|
||||
import { apiRequestGet } from '@/utils/api';
|
||||
// 表格列配置
|
||||
const columns = [
|
||||
{
|
||||
|
|
@ -132,15 +132,11 @@
|
|||
try {
|
||||
// 请求远端接口
|
||||
const token = localStg.get('token');
|
||||
const response = await axios.get('http://localhost:8080/api/employees/allEmployees', {
|
||||
params: {
|
||||
let params = {
|
||||
page: pagination.value.current,
|
||||
size: pagination.value.pageSize,
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}` // 添加 Authorization 头
|
||||
}
|
||||
});
|
||||
const response = await apiRequestGet('/employees/allEmployees', params);
|
||||
|
||||
if (response.data.success) {
|
||||
dataSource.value = response.data.data;
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ const fetchData = async () => {
|
|||
code: searchForm.code || undefined,
|
||||
type: searchForm.type || undefined,
|
||||
};
|
||||
const response = await apiRequestGet('/api/facilities/list', { params });
|
||||
const response = await apiRequestGet('/facilities/list', params);
|
||||
if (response.data.success) {
|
||||
dataSource.value = response.data.data;
|
||||
pagination.total = response.data.total || response.data.data.length;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
import axios from 'axios'; // 用于 HTTP 请求
|
||||
import { useRouter } from 'vue-router'; // 用于导航,假设您使用了 Vue Router
|
||||
import { localStg } from '@/utils/storage';
|
||||
|
||||
import { apiRequestPost } from '@/utils/api'; // 假设您有一个 API 请求的工具函数
|
||||
const formRef = ref(); // 表单引用
|
||||
const router = useRouter(); // 获取路由实例
|
||||
|
||||
|
|
@ -71,12 +71,7 @@
|
|||
try {
|
||||
//await formRef.value.validate(); // 验证表单
|
||||
|
||||
const token = localStg.get('token'); // 替换为你的 token 键
|
||||
const response = await axios.post('http://localhost:8080/api/work-orders', formState,{
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}` // 添加 Authorization 头
|
||||
}
|
||||
}); // 发送 POST 请求
|
||||
const response = await apiRequestPost('/work-orders', formState); // 发送 POST 请求
|
||||
|
||||
if (response.data.success) {
|
||||
message.success('工单创建成功!');
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import { ref, onMounted } from 'vue';
|
|||
import { Table as ATable, Tag as ATag } from 'ant-design-vue';
|
||||
import axios from 'axios';
|
||||
import { localStg } from '@/utils/storage';
|
||||
|
||||
import { apiRequestGet } from '@/utils/api';
|
||||
// 表格列定义
|
||||
const columns = [
|
||||
{
|
||||
|
|
@ -131,14 +131,11 @@ const fetchData = async (page = 1, pageSize = 10) => {
|
|||
const token = localStg.get('token'); // 替换为你的 token 键
|
||||
|
||||
try {
|
||||
const response = await axios.get('http://localhost:8080/api/work-orders/my-orders', {
|
||||
const response = await apiRequestGet('/work-orders/my-orders', {
|
||||
params: {
|
||||
page: page - 1, // 后端通常从0开始计数
|
||||
size: pageSize,
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}` // 添加 Authorization 头
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (response.data.success) {
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ export default {
|
|||
loading.value = true;
|
||||
try {
|
||||
// 模拟分页参数传递给后端
|
||||
const response = await apiRequestGet("/api/inspection-plans/employee/my-plan")
|
||||
const response = await apiRequestGet("/inspection-plans/employee/my-plan")
|
||||
|
||||
if (response.data.success) {
|
||||
planData.value = response.data.data;
|
||||
|
|
|
|||
Loading…
Reference in New Issue