修复权限以及供应商入库
This commit is contained in:
@ -28,10 +28,10 @@ export interface ContractorVO {
|
||||
* 管理人联系电话
|
||||
*/
|
||||
custodianPhone: string;
|
||||
/**
|
||||
/**
|
||||
* 分包类型
|
||||
*/
|
||||
contractorType?: string;
|
||||
contractorType?: string;
|
||||
|
||||
/**
|
||||
* 公司相关文件
|
||||
@ -54,6 +54,14 @@ export interface ContractorForm extends BaseEntity {
|
||||
* 主键id
|
||||
*/
|
||||
id?: string | number;
|
||||
/**
|
||||
* 供应商id
|
||||
*/
|
||||
supplierId?: string | number;
|
||||
/**
|
||||
* 供应商
|
||||
*/
|
||||
supplier?: string;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
@ -127,10 +135,10 @@ export interface ContractorQuery extends PageQuery {
|
||||
* 管理人联系电话
|
||||
*/
|
||||
custodianPhone?: string;
|
||||
/**
|
||||
/**
|
||||
* 分包类型
|
||||
*/
|
||||
contractorType?: string;
|
||||
contractorType?: string;
|
||||
|
||||
/**
|
||||
* 日期范围参数
|
||||
|
@ -8,7 +8,7 @@ import { SupplierInputVO, SupplierInputForm, SupplierInputQuery } from '@/api/su
|
||||
* @returns {*}
|
||||
*/
|
||||
|
||||
export const listSupplierInput = (query?: SupplierInputQuery): AxiosPromise<SupplierInputVO[]> => {
|
||||
export const listSupplierInput = (query?: any): AxiosPromise<SupplierInputVO[]> => {
|
||||
return request({
|
||||
url: '/supplierInput/supplierInput/list',
|
||||
method: 'get',
|
||||
|
@ -56,7 +56,13 @@ const handleSelect = async (projectId: string) => {
|
||||
text: '项目切换中...',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
setTimeout(() => {
|
||||
if (loadingInstance && loadingInstance.visible) {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}, 3000);
|
||||
await changeProject(projectId);
|
||||
console.log('切换项目', selectedProject);
|
||||
|
||||
// 更新项目 & 权限
|
||||
userStore.setSelectedProject(selectedProject);
|
||||
|
@ -10,6 +10,8 @@ import useUserStore from '@/store/modules/user';
|
||||
import useSettingsStore from '@/store/modules/settings';
|
||||
import usePermissionStore from '@/store/modules/permission';
|
||||
|
||||
let isFirst = false;
|
||||
|
||||
NProgress.configure({ showSpinner: false });
|
||||
const whiteList = ['/login', '/register', '/social-callback', '/register*', '/register/*', '/materials/purchaseDoc/uploadCode'];
|
||||
|
||||
@ -17,57 +19,64 @@ const isWhiteList = (path: string) => {
|
||||
return whiteList.some((pattern) => isPathMatch(pattern, path));
|
||||
};
|
||||
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
router.beforeEach(async (to, from) => {
|
||||
NProgress.start();
|
||||
if (to.path == '/indexEquipment' || to.path == '/materials/purchaseDoc/uploadCode' || to.path == '/codeDetail') {
|
||||
next();
|
||||
} else if (getToken()) {
|
||||
to.meta.title && useSettingsStore().setTitle(to.meta.title);
|
||||
/* has token*/
|
||||
if (to.path === '/login') {
|
||||
next({ path: '/' });
|
||||
NProgress.done();
|
||||
} else if (isWhiteList(to.path)) {
|
||||
next();
|
||||
} else {
|
||||
if (useUserStore().roles.length === 0 || $cache.local.getJSON('isCheckRole')) {
|
||||
isRelogin.show = true;
|
||||
// 判断当前用户是否已拉取完user_info信息
|
||||
const [err] = await tos(useUserStore().getInfo());
|
||||
if (err) {
|
||||
await useUserStore().logout();
|
||||
ElMessage.error(err);
|
||||
next({ path: '/' });
|
||||
} else {
|
||||
isRelogin.show = false;
|
||||
const accessRoutes = await usePermissionStore().generateRoutes();
|
||||
// 根据roles权限生成可访问的路由表
|
||||
accessRoutes.forEach((route) => {
|
||||
if (!isHttp(route.path)) {
|
||||
router.addRoute(route); // 动态添加可访问路由表
|
||||
console.log('🚀 ~ route:', route);
|
||||
}
|
||||
});
|
||||
$cache.local.remove('isCheckRole');
|
||||
|
||||
// @ts-expect-error hack方法 确保addRoutes已完成
|
||||
next({ path: to.path, replace: true, params: to.params, query: to.query, hash: to.hash, name: to.name as string }); // hack方法 确保addRoutes已完成
|
||||
}
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 没有token
|
||||
if (isWhiteList(to.path)) {
|
||||
// 在免登录白名单,直接进入
|
||||
next();
|
||||
} else {
|
||||
const redirect = encodeURIComponent(to.fullPath || '/');
|
||||
next(`/login?redirect=${redirect}`); // 否则全部重定向到登录页
|
||||
NProgress.done();
|
||||
}
|
||||
// 特殊页面放行
|
||||
if (['/indexEquipment', '/materials/purchaseDoc/uploadCode', '/codeDetail'].includes(to.path)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 已登录
|
||||
if (getToken()) {
|
||||
if (to.meta.title) useSettingsStore().setTitle(to.meta.title);
|
||||
|
||||
if (to.path === '/login') {
|
||||
NProgress.done();
|
||||
return { path: '/' };
|
||||
}
|
||||
|
||||
if (isWhiteList(to.path)) {
|
||||
return true;
|
||||
}
|
||||
if ((!isFirst && useUserStore().roles.length === 0) || $cache.local.getJSON('isCheckRole') === 'true') {
|
||||
isFirst = true;
|
||||
isRelogin.show = true;
|
||||
|
||||
const [err] = await tos(useUserStore().getInfo());
|
||||
|
||||
if (err) {
|
||||
await useUserStore().logout();
|
||||
ElMessage.error(err);
|
||||
NProgress.done();
|
||||
return { path: '/' };
|
||||
}
|
||||
|
||||
isRelogin.show = false;
|
||||
const accessRoutes = await usePermissionStore().generateRoutes();
|
||||
accessRoutes.forEach((route) => {
|
||||
if (!isHttp(route.path)) router.addRoute(route);
|
||||
});
|
||||
|
||||
$cache.local.remove('isCheckRole');
|
||||
|
||||
// 确保路由已添加后再跳转
|
||||
return { ...to, replace: true };
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
isFirst = false;
|
||||
}
|
||||
|
||||
// 未登录
|
||||
if (isWhiteList(to.path)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const redirect = encodeURIComponent(to.fullPath || '/');
|
||||
NProgress.done();
|
||||
return { path: `/login?redirect=${redirect}` };
|
||||
});
|
||||
|
||||
router.afterEach(() => {
|
||||
|
@ -88,6 +88,7 @@ export const useUserStore = defineStore('user', () => {
|
||||
}
|
||||
}
|
||||
const [err, res] = await to(getUserInfo());
|
||||
console.log(111111111111);
|
||||
|
||||
if (res) {
|
||||
const data = res.data;
|
||||
|
@ -133,8 +133,8 @@
|
||||
></el-col>
|
||||
<el-col :span="12" :offset="0"
|
||||
><el-form-item label="供应商" prop="supplier">
|
||||
<el-select v-model="form.supplier" value-key="id" placeholder="请选择供应商" clearable filterable @change="">
|
||||
<el-option v-for="item in supplierOptions" :key="item.id" :label="item.name" :value="item.name"> </el-option>
|
||||
<el-select v-model="form.supplierId" value-key="id" placeholder="请选择供应商" clearable filterable @change="">
|
||||
<el-option v-for="item in supplierOptions" :key="item.id" :label="item.supplierName" :value="item.id"> </el-option>
|
||||
</el-select> </el-form-item
|
||||
></el-col>
|
||||
<el-col :span="12" :offset="0"
|
||||
@ -268,6 +268,7 @@ import { useUserStoreHook } from '@/store/modules/user';
|
||||
import { getToken } from '@/utils/auth';
|
||||
import logisticsDetail from './comm/logisticsDetail.vue';
|
||||
import { FormRules } from 'element-plus';
|
||||
import { listSupplierInput } from '@/api/supplierInput/supplierInput';
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
@ -307,6 +308,8 @@ const initFormData: any = {
|
||||
docCode: undefined,
|
||||
supplier: undefined,
|
||||
reason: undefined,
|
||||
supplierId: undefined,
|
||||
|
||||
name: undefined,
|
||||
arrivalDate: undefined,
|
||||
designDirectorTel: undefined,
|
||||
@ -479,6 +482,7 @@ const submitForm = () => {
|
||||
form.value.associationList = form.value.planId?.map((item: any) => ({
|
||||
planId: item
|
||||
}));
|
||||
form.value.supplier = supplierOptions.value.find((item) => item.id == form.value.supplierId)?.supplierName;
|
||||
|
||||
if (form.value.id) {
|
||||
await updatePurchaseDoc(form.value).finally(() => (buttonLoading.value = false));
|
||||
@ -514,10 +518,10 @@ const getBatchList = async () => {
|
||||
};
|
||||
|
||||
const getSupplierList = async () => {
|
||||
const res = await listContractor({
|
||||
const res = await listSupplierInput({
|
||||
projectId: currentProject.value?.id,
|
||||
pageNum: 1,
|
||||
contractorType: 4,
|
||||
state: 'finish',
|
||||
pageSize: 10000
|
||||
});
|
||||
supplierOptions.value = res.rows;
|
||||
|
@ -81,6 +81,11 @@
|
||||
<el-form-item label="公司名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入公司名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="供应商" prop="supplier">
|
||||
<el-select v-model="form.supplierId" value-key="id" placeholder="请选择供应商" clearable filterable @change="">
|
||||
<el-option v-for="item in supplierOptions" :key="item.id" :label="item.supplierName" :value="item.id"> </el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="负责人" prop="principal">
|
||||
<el-input v-model="form.principal" placeholder="请输入负责人" />
|
||||
</el-form-item>
|
||||
@ -121,6 +126,7 @@ import { ContractorForm, ContractorQuery, ContractorVO } from '@/api/project/con
|
||||
import ContractorFileDialog from '@/views/project/contractor/component/ContractorFileDialog.vue';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
import { getDicts, listData } from '@/api/system/dict/data';
|
||||
import { listSupplierInput } from '@/api/supplierInput/supplierInput';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
|
||||
@ -152,6 +158,8 @@ const initFormData: ContractorForm = {
|
||||
principalPhone: undefined,
|
||||
custodian: undefined,
|
||||
custodianPhone: undefined,
|
||||
supplierId: undefined,
|
||||
supplier: undefined,
|
||||
contractorType: undefined,
|
||||
fileMap: undefined,
|
||||
remark: undefined,
|
||||
@ -257,6 +265,8 @@ const submitForm = () => {
|
||||
if (valid) {
|
||||
form.value.projectId = currentProject.value?.id;
|
||||
buttonLoading.value = true;
|
||||
form.value.supplier = supplierOptions.value.find((item) => item.id == form.value.supplierId)?.supplierName;
|
||||
|
||||
if (form.value.id) {
|
||||
await updateContractor(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
@ -278,15 +288,16 @@ const handleDelete = async (row?: ContractorVO) => {
|
||||
await getList();
|
||||
};
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
proxy?.download(
|
||||
'project/contractor/export',
|
||||
{
|
||||
...queryParams.value
|
||||
},
|
||||
`contractor_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
/** 获取供应商 */
|
||||
const supplierOptions = ref([]);
|
||||
const getSupplierList = async () => {
|
||||
const res = await listSupplierInput({
|
||||
projectId: currentProject.value?.id,
|
||||
pageNum: 1,
|
||||
state: 'finish',
|
||||
pageSize: 10000
|
||||
});
|
||||
supplierOptions.value = res.rows;
|
||||
};
|
||||
|
||||
/** 文件操作 **/
|
||||
@ -304,6 +315,7 @@ const listeningProject = watch(
|
||||
queryParams.value.projectId = nid;
|
||||
form.value.projectId = nid;
|
||||
console.log('监听项目id', queryParams.value.projectId, form.value.projectId);
|
||||
getSupplierList();
|
||||
getList();
|
||||
}
|
||||
);
|
||||
@ -314,5 +326,6 @@ onUnmounted(() => {
|
||||
onMounted(() => {
|
||||
getDictList();
|
||||
getList();
|
||||
getSupplierList();
|
||||
});
|
||||
</script>
|
||||
|
@ -275,6 +275,7 @@
|
||||
<el-row class="mb-4">
|
||||
<el-col :span="24">
|
||||
<el-form-item label="入库资料" prop="inputFile">
|
||||
<template #label> <span class="text-red">*</span> 入库资料 </template>
|
||||
<file-upload
|
||||
v-model="form.inputFile"
|
||||
:fileType="['doc', 'docx', 'pdf']"
|
||||
|
Reference in New Issue
Block a user