diff --git a/plus-ui/src/api/materials/company/index.ts b/plus-ui/src/api/materials/company/index.ts new file mode 100644 index 00000000..c3f8ec6d --- /dev/null +++ b/plus-ui/src/api/materials/company/index.ts @@ -0,0 +1,63 @@ +import request from '@/utils/request'; +import { AxiosPromise } from 'axios'; +import { CompanyVO, CompanyForm, CompanyQuery } from '@/api/materials/company/types'; + +/** + * 查询公司列表 + * @param query + * @returns {*} + */ + +export const listCompany = (query?: CompanyQuery): AxiosPromise => { + return request({ + url: '/materials/company/list', + method: 'get', + params: query + }); +}; + +/** + * 查询公司详细 + * @param id + */ +export const getCompany = (id: string | number): AxiosPromise => { + return request({ + url: '/materials/company/' + id, + method: 'get' + }); +}; + +/** + * 新增公司 + * @param data + */ +export const addCompany = (data: CompanyForm) => { + return request({ + url: '/materials/company', + method: 'post', + data: data + }); +}; + +/** + * 修改公司 + * @param data + */ +export const updateCompany = (data: CompanyForm) => { + return request({ + url: '/materials/company', + method: 'put', + data: data + }); +}; + +/** + * 删除公司 + * @param id + */ +export const delCompany = (id: string | number | Array) => { + return request({ + url: '/materials/company/' + id, + method: 'delete' + }); +}; diff --git a/plus-ui/src/api/materials/company/types.ts b/plus-ui/src/api/materials/company/types.ts new file mode 100644 index 00000000..8fb437dc --- /dev/null +++ b/plus-ui/src/api/materials/company/types.ts @@ -0,0 +1,96 @@ +export interface CompanyVO { + /** + * 主键id + */ + id: string | number; + + /** + * 公司名称 + */ + companyName: string; + + /** + * 项目id + */ + projectId: string | number; + + /** + * 帐号状态(0正常 1停用) + */ + status: string; + + /** + * 备注 + */ + remark: string; + + /** + * 资质情况 + */ + qualification: string; + +} + +export interface CompanyForm extends BaseEntity { + /** + * 主键id + */ + id?: string | number; + + /** + * 公司名称 + */ + companyName?: string; + + /** + * 项目id + */ + projectId?: string | number; + + /** + * 帐号状态(0正常 1停用) + */ + status?: string; + + /** + * 备注 + */ + remark?: string; + + /** + * 资质情况 + */ + qualification?: string; + +} + +export interface CompanyQuery extends PageQuery { + + /** + * 公司名称 + */ + companyName?: string; + + /** + * 项目id + */ + projectId?: string | number; + + /** + * 帐号状态(0正常 1停用) + */ + status?: string; + + /** + * 资质情况 + */ + qualification?: string; + + /** + * 日期范围参数 + */ + params?: any; +} + + + diff --git a/plus-ui/src/api/materials/materials/index.ts b/plus-ui/src/api/materials/materials/index.ts new file mode 100644 index 00000000..c2fef314 --- /dev/null +++ b/plus-ui/src/api/materials/materials/index.ts @@ -0,0 +1,63 @@ +import request from '@/utils/request'; +import { AxiosPromise } from 'axios'; +import { MaterialsVO, MaterialsForm, MaterialsQuery } from '@/api/materials/materials/types'; + +/** + * 查询材料名称列表 + * @param query + * @returns {*} + */ + +export const listMaterials = (query?: MaterialsQuery): AxiosPromise => { + return request({ + url: '/materials/materials/list', + method: 'get', + params: query + }); +}; + +/** + * 查询材料名称详细 + * @param id + */ +export const getMaterials = (id: string | number): AxiosPromise => { + return request({ + url: '/materials/materials/' + id, + method: 'get' + }); +}; + +/** + * 新增材料名称 + * @param data + */ +export const addMaterials = (data: MaterialsForm) => { + return request({ + url: '/materials/materials', + method: 'post', + data: data + }); +}; + +/** + * 修改材料名称 + * @param data + */ +export const updateMaterials = (data: MaterialsForm) => { + return request({ + url: '/materials/materials', + method: 'put', + data: data + }); +}; + +/** + * 删除材料名称 + * @param id + */ +export const delMaterials = (id: string | number | Array) => { + return request({ + url: '/materials/materials/' + id, + method: 'delete' + }); +}; diff --git a/plus-ui/src/api/materials/materials/types.ts b/plus-ui/src/api/materials/materials/types.ts new file mode 100644 index 00000000..a22fad51 --- /dev/null +++ b/plus-ui/src/api/materials/materials/types.ts @@ -0,0 +1,291 @@ +export interface MaterialsVO { + /** + * 主键id + */ + id: string | number; + + /** + * 材料名称 + */ + materialsName: string; + + /** + * 公司id + */ + companyId: string | number; + + /** + * 项目id + */ + projectId: string | number; + + /** + * 规格型号名称 + */ + typeSpecificationName: string; + + /** + * 规格型号文件路径 + */ + typeSpecificationUrl: string; + + /** + * 合格证编号名称 + */ + certificateConformityName: string; + + /** + * 合格证编号文件路径 + */ + certificateConformityUrl: string; + + /** + * 质量说明书编号 + */ + qualityName: string; + + /** + * 质量说明书文件路径 + */ + qualityUrl: string; + + /** + * 检验报告编号 + */ + inspectionReportName: string; + + /** + * 检验报告文件路径 + */ + inspectionReportUrl: string; + + /** + * 复试报告编号 + */ + reexamineReportName: string; + + /** + * 复试报告文件路径 + */ + reexamineReportUrl: string; + + /** + * 使用部位 + */ + usePart: string; + + /** + * 计量单位 + */ + weightId: string | number; + + /** + * 备注 + */ + remark: string; + + /** + * 预计材料数量 + */ + quantityCount: string; + + /** + * 状态(0正常 1停用) + */ + status: string; + +} + +export interface MaterialsForm extends BaseEntity { + /** + * 主键id + */ + id?: string | number; + + /** + * 材料名称 + */ + materialsName?: string; + + /** + * 公司id + */ + companyId?: string | number; + + /** + * 项目id + */ + projectId?: string | number; + + /** + * 规格型号名称 + */ + typeSpecificationName?: string; + + /** + * 规格型号文件路径 + */ + typeSpecificationUrl?: string; + + /** + * 合格证编号名称 + */ + certificateConformityName?: string; + + /** + * 合格证编号文件路径 + */ + certificateConformityUrl?: string; + + /** + * 质量说明书编号 + */ + qualityName?: string; + + /** + * 质量说明书文件路径 + */ + qualityUrl?: string; + + /** + * 检验报告编号 + */ + inspectionReportName?: string; + + /** + * 检验报告文件路径 + */ + inspectionReportUrl?: string; + + /** + * 复试报告编号 + */ + reexamineReportName?: string; + + /** + * 复试报告文件路径 + */ + reexamineReportUrl?: string; + + /** + * 使用部位 + */ + usePart?: string; + + /** + * 计量单位 + */ + weightId?: string | number; + + /** + * 备注 + */ + remark?: string; + + /** + * 预计材料数量 + */ + quantityCount?: string; + + /** + * 状态(0正常 1停用) + */ + status?: string; + +} + +export interface MaterialsQuery extends PageQuery { + + /** + * 材料名称 + */ + materialsName?: string; + + /** + * 公司id + */ + companyId?: string | number; + + /** + * 项目id + */ + projectId?: string | number; + + /** + * 规格型号名称 + */ + typeSpecificationName?: string; + + /** + * 规格型号文件路径 + */ + typeSpecificationUrl?: string; + + /** + * 合格证编号名称 + */ + certificateConformityName?: string; + + /** + * 合格证编号文件路径 + */ + certificateConformityUrl?: string; + + /** + * 质量说明书编号 + */ + qualityName?: string; + + /** + * 质量说明书文件路径 + */ + qualityUrl?: string; + + /** + * 检验报告编号 + */ + inspectionReportName?: string; + + /** + * 检验报告文件路径 + */ + inspectionReportUrl?: string; + + /** + * 复试报告编号 + */ + reexamineReportName?: string; + + /** + * 复试报告文件路径 + */ + reexamineReportUrl?: string; + + /** + * 使用部位 + */ + usePart?: string; + + /** + * 计量单位 + */ + weightId?: string | number; + + /** + * 预计材料数量 + */ + quantityCount?: string; + + /** + * 状态(0正常 1停用) + */ + status?: string; + + /** + * 日期范围参数 + */ + params?: any; +} + + + diff --git a/plus-ui/src/api/materials/materialsInventory/index.ts b/plus-ui/src/api/materials/materialsInventory/index.ts new file mode 100644 index 00000000..70dccea1 --- /dev/null +++ b/plus-ui/src/api/materials/materialsInventory/index.ts @@ -0,0 +1,63 @@ +import request from '@/utils/request'; +import { AxiosPromise } from 'axios'; +import { MaterialsInventoryVO, MaterialsInventoryForm, MaterialsInventoryQuery } from '@/api/materials/materialsInventory/types'; + +/** + * 查询材料出/入库列表 + * @param query + * @returns {*} + */ + +export const listMaterialsInventory = (query?: MaterialsInventoryQuery): AxiosPromise => { + return request({ + url: '/materials/materialsInventory/list', + method: 'get', + params: query + }); +}; + +/** + * 查询材料出/入库详细 + * @param id + */ +export const getMaterialsInventory = (id: string | number): AxiosPromise => { + return request({ + url: '/materials/materialsInventory/' + id, + method: 'get' + }); +}; + +/** + * 新增材料出/入库 + * @param data + */ +export const addMaterialsInventory = (data: MaterialsInventoryForm) => { + return request({ + url: '/materials/materialsInventory', + method: 'post', + data: data + }); +}; + +/** + * 修改材料出/入库 + * @param data + */ +export const updateMaterialsInventory = (data: MaterialsInventoryForm) => { + return request({ + url: '/materials/materialsInventory', + method: 'put', + data: data + }); +}; + +/** + * 删除材料出/入库 + * @param id + */ +export const delMaterialsInventory = (id: string | number | Array) => { + return request({ + url: '/materials/materialsInventory/' + id, + method: 'delete' + }); +}; diff --git a/plus-ui/src/api/materials/materialsInventory/types.ts b/plus-ui/src/api/materials/materialsInventory/types.ts new file mode 100644 index 00000000..ed2697b4 --- /dev/null +++ b/plus-ui/src/api/materials/materialsInventory/types.ts @@ -0,0 +1,201 @@ +export interface MaterialsInventoryVO { + /** + * 主键id + */ + id: string | number; + + /** + * 材料id + */ + materialsId: string | number; + + /** + * 项目id + */ + projectId: string | number; + + /** + * 出入库状态 + */ + outPut: string; + + /** + * 出/入库的数量 + */ + number: number; + + /** + * 出/入库操作时间 + */ + outPutTime: string; + + /** + * 剩余库存数量(记录最后一次操作留下的库存数) + */ + residue: string | number; + + /** + * 操作人(入库人、领料人) + */ + operator: string; + + /** + * 材料出入证明 + */ + path: string; + + /** + * 处理方式 + */ + disposition: string; + + /** + * 交接单位(班组) + */ + recipient: string; + + /** + * 领用人 + */ + shipper: string; + + /** + * 备注 + */ + remark: string; + +} + +export interface MaterialsInventoryForm extends BaseEntity { + /** + * 主键id + */ + id?: string | number; + + /** + * 材料id + */ + materialsId?: string | number; + + /** + * 项目id + */ + projectId?: string | number; + + /** + * 出入库状态 + */ + outPut?: string; + + /** + * 出/入库的数量 + */ + number?: number; + + /** + * 出/入库操作时间 + */ + outPutTime?: string; + + /** + * 剩余库存数量(记录最后一次操作留下的库存数) + */ + residue?: string | number; + + /** + * 操作人(入库人、领料人) + */ + operator?: string; + + /** + * 材料出入证明 + */ + path?: string; + + /** + * 处理方式 + */ + disposition?: string; + + /** + * 交接单位(班组) + */ + recipient?: string; + + /** + * 领用人 + */ + shipper?: string; + + /** + * 备注 + */ + remark?: string; + +} + +export interface MaterialsInventoryQuery extends PageQuery { + + /** + * 材料id + */ + materialsId?: string | number; + + /** + * 项目id + */ + projectId?: string | number; + + /** + * 出入库状态 + */ + outPut?: string; + + /** + * 出/入库的数量 + */ + number?: number; + + /** + * 出/入库操作时间 + */ + outPutTime?: string; + + /** + * 剩余库存数量(记录最后一次操作留下的库存数) + */ + residue?: string | number; + + /** + * 操作人(入库人、领料人) + */ + operator?: string; + + /** + * 材料出入证明 + */ + path?: string; + + /** + * 处理方式 + */ + disposition?: string; + + /** + * 交接单位(班组) + */ + recipient?: string; + + /** + * 领用人 + */ + shipper?: string; + + /** + * 日期范围参数 + */ + params?: any; +} + + + diff --git a/plus-ui/src/components/ProjectSelector/index.vue b/plus-ui/src/components/ProjectSelector/index.vue index 9bdd76d0..78ff1598 100644 --- a/plus-ui/src/components/ProjectSelector/index.vue +++ b/plus-ui/src/components/ProjectSelector/index.vue @@ -1,21 +1,16 @@ @@ -25,16 +20,24 @@ import { ref, computed, watch } from 'vue'; import { useUserStore } from '@/store/modules/user'; const userStore = useUserStore(); -const projects = computed(() => userStore.projects); +const projects = computed(() => [ + { id: '', name: '全部工程项目' }, // 添加空选项 + ...userStore.projects +]); + const selectedProjectId = ref(userStore.selectedProject?.id || ''); // 监听 userStore.selectedProject 变化,更新 selectedProjectId -watch(() => userStore.selectedProject, (newProject) => { - selectedProjectId.value = newProject?.id || ''; -}, { deep: true }); +watch( + () => userStore.selectedProject, + (newProject) => { + selectedProjectId.value = newProject?.id ?? ''; // 避免 undefined 导致 placeholder 显示 + }, + { deep: true } +); const handleSelect = (projectId: string) => { - const selectedProject = projects.value.find(p => p.id === projectId); + const selectedProject = projects.value.find((p) => p.id === projectId); if (selectedProject) { userStore.setSelectedProject(selectedProject); } @@ -100,4 +103,4 @@ const handleSelect = (projectId: string) => { } } } - \ No newline at end of file + diff --git a/plus-ui/src/router/index.ts b/plus-ui/src/router/index.ts index 41ddc5c8..d89e9c95 100644 --- a/plus-ui/src/router/index.ts +++ b/plus-ui/src/router/index.ts @@ -91,7 +91,7 @@ export const constantRoutes: RouteRecordRaw[] = [ }, { path: '/test', - component: () => import('@/views/personnelManagement/project/projectRelevancy/component/ShuttleFrame.vue'), + component: () => import('@/views/materials/materials/index.vue'), hidden: true } ]; diff --git a/plus-ui/src/store/modules/user.ts b/plus-ui/src/store/modules/user.ts index eb75d6e3..57a6c689 100644 --- a/plus-ui/src/store/modules/user.ts +++ b/plus-ui/src/store/modules/user.ts @@ -6,6 +6,16 @@ import defAva from '@/assets/images/profile.jpg'; import store from '@/store'; import { defineStore } from 'pinia'; +// 添加两个函数用于操作localStorage +const saveSelectedProjectToStorage = (project) => { + localStorage.setItem('selectedProject', JSON.stringify(project)); +}; + +const getSelectedProjectFromStorage = () => { + const stored = localStorage.getItem('selectedProject'); + return stored ? JSON.parse(stored) : null; +}; + export const useUserStore = defineStore('user', () => { const token = ref(getToken()); const name = ref(''); @@ -17,7 +27,9 @@ export const useUserStore = defineStore('user', () => { const permissions = ref>([]); // 用户权限编码集合 → 判断按钮权限 const projects = ref>([]); - const selectedProject = ref<{ id: string; name: string } | null>(projects.value[0]); // 默认选中第一个 + // 从localStorage获取缓存的项目,如果没有则默认为null + const selectedProject = ref<{ id: string; name: string } | null>(getSelectedProjectFromStorage()); + /** * 登录 * @param userInfo @@ -54,30 +66,31 @@ export const useUserStore = defineStore('user', () => { userId.value = user.userId; tenantId.value = user.tenantId; - // **新增项目数据获取** const [projectErr, projectRes] = await to(getUserProject()); if (projectRes?.data) { - const projectList = projectRes.data.map(p => ({ + const projectList = projectRes.data.map((p) => ({ id: p.projectId, name: p.projectName || '未知项目' })); setProjects(projectList); - if (projectList.length > 0) { + // 如果有缓存的选中项目,且该项目在当前项目列表中存在,则使用缓存的项目 + const storedProject = getSelectedProjectFromStorage(); + if (storedProject && projectList.some((p) => p.id === storedProject.id)) { + setSelectedProject(storedProject); + } else if (projectList.length > 0) { + // 否则默认选择第一个项目 setSelectedProject(projectList[0]); } } - - return Promise.resolve(); } return Promise.reject(err); }; - // 注销 const logout = async (): Promise => { await logoutApi(); @@ -85,6 +98,8 @@ export const useUserStore = defineStore('user', () => { roles.value = []; permissions.value = []; removeToken(); + // 清除项目缓存 + localStorage.removeItem('selectedProject'); }; const setAvatar = (value: string) => { @@ -97,11 +112,14 @@ export const useUserStore = defineStore('user', () => { const setSelectedProject = (project: { id: string; name: string }) => { selectedProject.value = project; + // 将选中的项目保存到localStorage + saveSelectedProjectToStorage(project); + // ** 切换项目后,需要清空当前项目下的所有缓存数据 ** // 清空 pinia 缓存 // store.$reset(); - // console.log("选择的新项目名称:" + selectedProject.value.name) - // console.log("选择的新项目id:" + selectedProject.value.id) + // console.log("选择的新项目名称:" + selectedProject.value.name) + // console.log("选择的新项目id:" + selectedProject.value.id) }; return { diff --git a/plus-ui/src/views/materials/company/index.vue b/plus-ui/src/views/materials/company/index.vue new file mode 100644 index 00000000..977705aa --- /dev/null +++ b/plus-ui/src/views/materials/company/index.vue @@ -0,0 +1,292 @@ + + + diff --git a/plus-ui/src/views/materials/materials/index.vue b/plus-ui/src/views/materials/materials/index.vue new file mode 100644 index 00000000..151387eb --- /dev/null +++ b/plus-ui/src/views/materials/materials/index.vue @@ -0,0 +1,398 @@ + + + diff --git a/plus-ui/src/views/materials/materialsInventory/index.vue b/plus-ui/src/views/materials/materialsInventory/index.vue new file mode 100644 index 00000000..a0c69f60 --- /dev/null +++ b/plus-ui/src/views/materials/materialsInventory/index.vue @@ -0,0 +1,362 @@ + + + diff --git a/plus-ui/src/views/personnelManagement/project/project/index.vue b/plus-ui/src/views/personnelManagement/project/project/index.vue index f8982420..aa1704e7 100644 --- a/plus-ui/src/views/personnelManagement/project/project/index.vue +++ b/plus-ui/src/views/personnelManagement/project/project/index.vue @@ -52,7 +52,7 @@ - + --> @@ -92,12 +92,12 @@ - + - + + + +