顶部项目列表联动中间表格刷新
This commit is contained in:
@ -97,7 +97,10 @@ export interface ContractorQuery extends PageQuery {
|
||||
* 负责人
|
||||
*/
|
||||
principal?: string;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
projectId: string | number;
|
||||
/**
|
||||
* 负责人联系电话
|
||||
*/
|
||||
|
@ -37,10 +37,17 @@ watch(
|
||||
);
|
||||
|
||||
const handleSelect = (projectId: string) => {
|
||||
const oldId = userStore.getSelectedProjectFromStorage()
|
||||
console.log(projectId,oldId.id);
|
||||
|
||||
if (projectId!=oldId.id) {
|
||||
location.reload()
|
||||
}
|
||||
const selectedProject = projects.value.find((p) => p.id === projectId);
|
||||
if (selectedProject) {
|
||||
userStore.setSelectedProject(selectedProject);
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -136,6 +136,7 @@ export const useUserStore = defineStore('user', () => {
|
||||
setAvatar,
|
||||
setProjects,
|
||||
setSelectedProject,
|
||||
getSelectedProjectFromStorage,
|
||||
projects,
|
||||
selectedProject
|
||||
};
|
||||
|
@ -103,6 +103,7 @@
|
||||
import { addContractor, delContractor, getContractor, listContractor, updateContractor } from '@/api/project/contractor';
|
||||
import { ContractorForm, ContractorQuery, ContractorVO } from '@/api/project/contractor/types';
|
||||
import ContractorFileDialog from '@/views/project/contractor/component/ContractorFileDialog.vue';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
|
||||
@ -117,7 +118,20 @@ const total = ref(0);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const contractorFormRef = ref<ElFormInstance>();
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
//监听项目改变
|
||||
// watch(
|
||||
// () => currentProject.value,
|
||||
// (newId, oldId) => {
|
||||
// /* ... */
|
||||
// queryParams.value.projectId=newId.id
|
||||
// // getList()
|
||||
|
||||
// }
|
||||
// )
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
@ -145,6 +159,7 @@ const data = reactive<PageData<ContractorForm, ContractorQuery>>({
|
||||
principalPhone: undefined,
|
||||
custodian: undefined,
|
||||
custodianPhone: undefined,
|
||||
projectId: currentProject.value.id,
|
||||
params: {}
|
||||
},
|
||||
rules: {
|
||||
|
Reference in New Issue
Block a user