添加项目权限校验方法

This commit is contained in:
lcj
2025-03-10 09:58:54 +08:00
parent 55df453d4c
commit 3e3f6f8aab
7 changed files with 216 additions and 205 deletions

View File

@ -5,7 +5,7 @@ VITE_APP_TITLE = RuoYi-Vue-Plus多租户管理系统
VITE_APP_ENV = 'development'
# 开发环境
VITE_APP_BASE_API = 'http://192.168.110.5:8899'
VITE_APP_BASE_API = 'http://192.168.110.2:8899'
# 应用访问路径 例如使用前缀 /admin/
VITE_APP_CONTEXT_PATH = '/'

View File

@ -1,6 +1,6 @@
export interface ProjectVO {
/**
*
* id
*/
id: string | number;
@ -108,7 +108,6 @@ export interface ProjectVO {
* 是否删除0正常 1删除
*/
isDelete: number;
}
export interface ProjectForm extends BaseEntity {
@ -221,11 +220,9 @@ export interface ProjectForm extends BaseEntity {
* 是否删除0正常 1删除
*/
isDelete?: number;
}
export interface ProjectQuery extends PageQuery {
/**
* 项目名称
*/
@ -331,6 +328,3 @@ export interface ProjectQuery extends PageQuery {
*/
params?: any;
}

View File

@ -20,8 +20,8 @@
</template>
<script setup name="Index" lang="ts">
import { ref } from "vue";
import { useRouter } from "vue-router";
import { ref } from 'vue';
import { useRouter } from 'vue-router';
const router = useRouter();

View File

@ -1,7 +1,6 @@
<template>
<div class="p-2">
<transition :enter-active-class="proxy?.animate.searchAnimate.enter"
:leave-active-class="proxy?.animate.searchAnimate.leave">
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
@ -12,8 +11,7 @@
<el-input v-model="queryParams.projectId" placeholder="请输入项目id" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="资质情况" prop="qualification">
<el-input v-model="queryParams.qualification" placeholder="请输入资质情况" clearable
@keyup.enter="handleQuery" />
<el-input v-model="queryParams.qualification" placeholder="请输入资质情况" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
@ -28,20 +26,20 @@
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd"
v-hasPermi="['materials:company:add']">新增</el-button>
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['materials:company:add']">新增 </el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()"
v-hasPermi="['materials:company:edit']">修改</el-button>
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['materials:company:edit']"
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()"
v-hasPermi="['materials:company:remove']">删除</el-button>
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['materials:company:remove']"
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport"
v-hasPermi="['materials:company:export']">导出</el-button>
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['materials:company:export']">导出 </el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
@ -59,13 +57,15 @@
<el-table-column label="公司名称" align="center" prop="companyName" />
<el-table-column label="公司状态" align="center" prop="status">
<template #default="{ row }">
<span :style="{
<span
:style="{
color: row.status === 0 ? 'green' : 'red',
backgroundColor: row.status === 0 ? '#E6F9E6' : '#FDE2E2',
padding: '5px 10px',
borderRadius: '5px',
display: 'inline-block'
}">
}"
>
{{ row.status === 0 ? '正常' : '不正常' }}
</span>
</template>
@ -76,19 +76,16 @@
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
v-hasPermi="['materials:company:edit']"></el-button>
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['materials:company:edit']"></el-button>
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
v-hasPermi="['materials:company:remove']"></el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['materials:company:remove']"></el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize" @pagination="getList" />
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
<!-- 添加或修改公司对话框 -->
@ -114,7 +111,6 @@
</div>
</template>
</el-dialog>
</div>
</template>
@ -147,8 +143,8 @@ const initFormData: CompanyForm = {
projectId: undefined,
status: undefined,
remark: undefined,
qualification: undefined,
}
qualification: undefined
};
const data = reactive<PageData<CompanyForm, CompanyQuery>>({
form: { ...initFormData },
queryParams: {
@ -158,13 +154,10 @@ const data = reactive<PageData<CompanyForm, CompanyQuery>>({
projectId: undefined,
status: undefined,
qualification: undefined,
params: {
}
params: {}
},
rules: {
id: [
{ required: true, message: "主键id不能为空", trigger: "blur" }
],
id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }]
}
});
@ -174,58 +167,58 @@ const { queryParams, form, rules } = toRefs(data);
const getList = async () => {
loading.value = true;
const res = await listCompany(queryParams.value);
companyList.value = res.records;
companyList.value = res.data.records;
total.value = res.total;
loading.value = false;
}
};
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
}
};
/** 表单重置 */
const reset = () => {
form.value = { ...initFormData };
companyFormRef.value?.resetFields();
}
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
}
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
}
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: CompanyVO[]) => {
ids.value = selection.map(item => item.id);
ids.value = selection.map((item) => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
}
};
/** 新增按钮操作 */
const handleAdd = () => {
reset();
dialog.visible = true;
dialog.title = "添加公司";
}
dialog.title = '添加公司';
};
/** 修改按钮操作 */
const handleUpdate = async (row?: CompanyVO) => {
reset();
const _id = row?.id || ids.value[0]
const _id = row?.id || ids.value[0];
const res = await getCompany(_id);
Object.assign(form.value, res.data);
dialog.visible = true;
dialog.title = "修改公司";
}
dialog.title = '修改公司';
};
/** 提交按钮 */
const submitForm = () => {
@ -233,38 +226,41 @@ const submitForm = () => {
if (valid) {
buttonLoading.value = true;
if (form.value.id) {
await updateCompany(form.value).finally(() => buttonLoading.value = false);
await updateCompany(form.value).finally(() => (buttonLoading.value = false));
} else {
await addCompany(form.value).finally(() => buttonLoading.value = false);
await addCompany(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess("操作成功");
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
}
});
}
};
/** 删除按钮操作 */
const handleDelete = async (row?: CompanyVO) => {
const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除公司编号为"' + _ids + '"的数据项?').finally(() => loading.value = false);
await proxy?.$modal.confirm('是否确认删除公司编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
await delCompany(_ids);
proxy?.$modal.msgSuccess("删除成功");
proxy?.$modal.msgSuccess('删除成功');
await getList();
}
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download('materials/company/export', {
proxy?.download(
'materials/company/export',
{
...queryParams.value
}, `company_${new Date().getTime()}.xlsx`)
}
},
`company_${new Date().getTime()}.xlsx`
);
};
onMounted(() => {
getList();
});
import { useUserStoreHook } from '@/store/modules/user';
// 获取用户 store
const userStore = useUserStoreHook();
@ -275,18 +271,14 @@ const currentProject = computed(() => userStore.selectedProject);
const materialsInventoryList = computed(() => {
// 如果有选中的项目,则只显示该项目的数据
if (currentProject.value && currentProject.value.id) {
return companyList.value.filter(item =>
item.projectId === currentProject.value.id
);
return companyList.value.filter((item) => item.projectId === currentProject.value.id);
}
// 没有选中项目则显示所有数据
return companyList.value;
});
// 根据 projectId 获取对应的 projectName
const getProjectName = (projectId) => {
const project = projectList.value.find(p => p.id === projectId);
const project = projectList.value.find((p) => p.id === projectId);
return project ? project.name : projectId; // 如果找不到对应的项目名,则显示 ID
};
</script>

View File

@ -65,16 +65,20 @@
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['materials:materials:add']">新增</el-button>
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['materials:materials:add']"> 新增 </el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['materials:materials:edit']">修改</el-button>
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['materials:materials:edit']"
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['materials:materials:remove']">删除</el-button>
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['materials:materials:remove']"
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['materials:materials:export']">导出</el-button>
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['materials:materials:export']">导出 </el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
@ -106,15 +110,17 @@
<el-table-column label="计量单位" align="center" prop="weightId" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="预计材料数量" align="center" prop="quantityCount" />
<el-table-column label="状态" align="center" prop="status" >
<el-table-column label="状态" align="center" prop="status">
<template #default="{ row }">
<span :style="{
<span
:style="{
color: row.status === 0 ? 'green' : 'red',
backgroundColor: row.status === 0 ? '#E6F9E6' : '#FDE2E2',
padding: '5px 10px',
borderRadius: '5px',
display: 'inline-block'
}">
}"
>
{{ row.status === 0 ? '正常' : '异常' }}
</span>
</template>
@ -241,10 +247,10 @@ const initFormData: MaterialsForm = {
weightId: undefined,
remark: undefined,
quantityCount: undefined,
status: undefined,
}
status: undefined
};
const data = reactive<PageData<MaterialsForm, MaterialsQuery>>({
form: {...initFormData},
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
@ -266,13 +272,10 @@ const data = reactive<PageData<MaterialsForm, MaterialsQuery>>({
weightId: undefined,
quantityCount: undefined,
status: undefined,
params: {
}
params: {}
},
rules: {
id: [
{ required: true, message: "主键id不能为空", trigger: "blur" }
],
id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }]
}
});
@ -282,58 +285,58 @@ const { queryParams, form, rules } = toRefs(data);
const getList = async () => {
loading.value = true;
const res = await listMaterials(queryParams.value);
materialsList.value = res.records;
materialsList.value = res.data.records;
total.value = res.total;
loading.value = false;
}
};
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
}
};
/** 表单重置 */
const reset = () => {
form.value = {...initFormData};
form.value = { ...initFormData };
materialsFormRef.value?.resetFields();
}
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
}
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
}
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: MaterialsVO[]) => {
ids.value = selection.map(item => item.id);
ids.value = selection.map((item) => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
}
};
/** 新增按钮操作 */
const handleAdd = () => {
reset();
dialog.visible = true;
dialog.title = "添加材料名称";
}
dialog.title = '添加材料名称';
};
/** 修改按钮操作 */
const handleUpdate = async (row?: MaterialsVO) => {
reset();
const _id = row?.id || ids.value[0]
const _id = row?.id || ids.value[0];
const res = await getMaterials(_id);
Object.assign(form.value, res.data);
dialog.visible = true;
dialog.title = "修改材料名称";
}
dialog.title = '修改材料名称';
};
/** 提交按钮 */
const submitForm = () => {
@ -341,33 +344,36 @@ const submitForm = () => {
if (valid) {
buttonLoading.value = true;
if (form.value.id) {
await updateMaterials(form.value).finally(() => buttonLoading.value = false);
await updateMaterials(form.value).finally(() => (buttonLoading.value = false));
} else {
await addMaterials(form.value).finally(() => buttonLoading.value = false);
await addMaterials(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess("操作成功");
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
}
});
}
};
/** 删除按钮操作 */
const handleDelete = async (row?: MaterialsVO) => {
const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除材料名称编号为"' + _ids + '"的数据项?').finally(() => loading.value = false);
await proxy?.$modal.confirm('是否确认删除材料名称编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
await delMaterials(_ids);
proxy?.$modal.msgSuccess("删除成功");
proxy?.$modal.msgSuccess('删除成功');
await getList();
}
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download('materials/materials/export', {
proxy?.download(
'materials/materials/export',
{
...queryParams.value
}, `materials_${new Date().getTime()}.xlsx`)
}
},
`materials_${new Date().getTime()}.xlsx`
);
};
import { useUserStoreHook } from '@/store/modules/user';
// 获取用户 store
@ -379,16 +385,14 @@ const currentProject = computed(() => userStore.selectedProject);
const materialsInventoryList = computed(() => {
// 如果有选中的项目,则只显示该项目的数据
if (currentProject.value && currentProject.value.id) {
return materialsList.value.filter(item =>
item.projectId === currentProject.value.id
);
return materialsList.value.filter((item) => item.projectId === currentProject.value.id);
}
// 没有选中项目则显示所有数据
return materialsList.value;
});
// 根据 projectId 获取对应的 projectName
const getProjectName = (projectId) => {
const project = projectList.value.find(p => p.id === projectId);
const project = projectList.value.find((p) => p.id === projectId);
return project ? project.name : projectId; // 如果找不到对应的项目名,则显示 ID
};

View File

@ -55,16 +55,28 @@
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['materials:materialsInventory:add']">新增</el-button>
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['materials:materialsInventory:add']">新增 </el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['materials:materialsInventory:edit']">修改</el-button>
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['materials:materialsInventory:edit']"
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['materials:materialsInventory:remove']">删除</el-button>
<el-button
type="danger"
plain
icon="Delete"
:disabled="multiple"
@click="handleDelete()"
v-hasPermi="['materials:materialsInventory:remove']"
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['materials:materialsInventory:export']">导出</el-button>
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['materials:materialsInventory:export']"
>导出
</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
@ -98,10 +110,22 @@
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['materials:materialsInventory:edit']"></el-button>
<el-button
link
type="primary"
icon="Edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['materials:materialsInventory:edit']"
></el-button>
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['materials:materialsInventory:remove']"></el-button>
<el-button
link
type="primary"
icon="Delete"
@click="handleDelete(scope.row)"
v-hasPermi="['materials:materialsInventory:remove']"
></el-button>
</el-tooltip>
</template>
</el-table-column>
@ -125,11 +149,7 @@
<el-input v-model="form.number" placeholder="请输入出/入库的数量" />
</el-form-item>
<el-form-item label="出/入库操作时间" prop="outPutTime">
<el-date-picker clearable
v-model="form.outPutTime"
type="datetime"
value-format="YYYY-MM-DD HH:mm:ss"
placeholder="请选择出/入库操作时间">
<el-date-picker clearable v-model="form.outPutTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择出/入库操作时间">
</el-date-picker>
</el-form-item>
<el-form-item label="剩余库存数量" prop="residue">
@ -165,7 +185,13 @@
</template>
<script setup name="MaterialsInventory" lang="ts">
import { listMaterialsInventory, getMaterialsInventory, delMaterialsInventory, addMaterialsInventory, updateMaterialsInventory } from '@/api/materials/materialsInventory';
import {
listMaterialsInventory,
getMaterialsInventory,
delMaterialsInventory,
addMaterialsInventory,
updateMaterialsInventory
} from '@/api/materials/materialsInventory';
import { MaterialsInventoryVO, MaterialsInventoryQuery, MaterialsInventoryForm } from '@/api/materials/materialsInventory/types';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -204,11 +230,11 @@ const initFormData: MaterialsInventoryForm = {
materialsVo: {
id: undefined,
materialsName: undefined,
materialsCode: undefined,
materialsCode: undefined
}
}
};
const data = reactive<PageData<MaterialsInventoryForm, MaterialsInventoryQuery>>({
form: {...initFormData},
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
@ -223,21 +249,16 @@ const data = reactive<PageData<MaterialsInventoryForm, MaterialsInventoryQuery>>
disposition: undefined,
recipient: undefined,
shipper: undefined,
params: {
},
params: {},
materialsVo: {
id: undefined,
materialsName: undefined,
materialsCode: undefined,
materialsCode: undefined
}
},
rules: {
id: [
{ required: true, message: "主键id不能为空", trigger: "blur" }
],
materialsId: [
{ required: true, message: "材料id不能为空", trigger: "blur" }
],
id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }],
materialsId: [{ required: true, message: '材料id不能为空', trigger: 'blur' }]
}
});
@ -247,58 +268,58 @@ const { queryParams, form, rules } = toRefs(data);
const getList = async () => {
loading.value = true;
const res = await listMaterialsInventory(queryParams.value);
materialsInventoryList.value = res.records;
materialsInventoryList.value = res.data.records;
total.value = res.total;
loading.value = false;
}
};
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
}
};
/** 表单重置 */
const reset = () => {
form.value = {...initFormData};
form.value = { ...initFormData };
materialsInventoryFormRef.value?.resetFields();
}
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
}
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
}
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: MaterialsInventoryVO[]) => {
ids.value = selection.map(item => item.id);
ids.value = selection.map((item) => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
}
};
/** 新增按钮操作 */
const handleAdd = () => {
reset();
dialog.visible = true;
dialog.title = "添加材料出/入库";
}
dialog.title = '添加材料出/入库';
};
/** 修改按钮操作 */
const handleUpdate = async (row?: MaterialsInventoryVO) => {
reset();
const _id = row?.id || ids.value[0]
const _id = row?.id || ids.value[0];
const res = await getMaterialsInventory(_id);
Object.assign(form.value, res.data);
dialog.visible = true;
dialog.title = "修改材料出/入库";
}
dialog.title = '修改材料出/入库';
};
/** 提交按钮 */
const submitForm = () => {
@ -306,33 +327,36 @@ const submitForm = () => {
if (valid) {
buttonLoading.value = true;
if (form.value.id) {
await updateMaterialsInventory(form.value).finally(() => buttonLoading.value = false);
await updateMaterialsInventory(form.value).finally(() => (buttonLoading.value = false));
} else {
await addMaterialsInventory(form.value).finally(() => buttonLoading.value = false);
await addMaterialsInventory(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess("操作成功");
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
}
});
}
};
/** 删除按钮操作 */
const handleDelete = async (row?: MaterialsInventoryVO) => {
const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除材料出/入库编号为"' + _ids + '"的数据项?').finally(() => loading.value = false);
await proxy?.$modal.confirm('是否确认删除材料出/入库编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
await delMaterialsInventory(_ids);
proxy?.$modal.msgSuccess("删除成功");
proxy?.$modal.msgSuccess('删除成功');
await getList();
}
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download('materials/materialsInventory/export', {
proxy?.download(
'materials/materialsInventory/export',
{
...queryParams.value
}, `materialsInventory_${new Date().getTime()}.xlsx`)
}
},
`materialsInventory_${new Date().getTime()}.xlsx`
);
};
import { useUserStoreHook } from '@/store/modules/user';
// 获取用户 store
@ -344,16 +368,14 @@ const currentProject = computed(() => userStore.selectedProject);
const materialsInventoryListNew = computed(() => {
// 如果有选中的项目,则只显示该项目的数据
if (currentProject.value && currentProject.value.id) {
return materialsInventoryList.value.filter(item =>
item.projectId === currentProject.value.id
);
return materialsInventoryList.value.filter((item) => item.projectId === currentProject.value.id);
}
// 没有选中项目则显示所有数据
return materialsInventoryList.value;
});
// 根据 projectId 获取对应的 projectName
const getProjectName = (projectId) => {
const project = projectList.value.find(p => p.id === projectId);
const project = projectList.value.find((p) => p.id === projectId);
return project ? project.name : projectId; // 如果找不到对应的项目名,则显示 ID
};
onMounted(() => {

View File

@ -68,20 +68,20 @@
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['project:project:add']">新增</el-button>
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['project:project:add']">新增 </el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['project:project:edit']"
>修改</el-button
>
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['project:project:remove']"
>删除</el-button
>
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['project:project:export']">导出</el-button>
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['project:project:export']">导出 </el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
@ -288,7 +288,7 @@ const { queryParams, form, rules } = toRefs(data);
const getList = async () => {
loading.value = true;
const res = await listProject(queryParams.value);
projectList.value = res.records;
projectList.value = res.data.records;
total.value = res.total;
loading.value = false;
};
@ -327,7 +327,6 @@ const handleAdd = () => {
reset();
dialog.visible = true;
dialog.title = '添加项目';
};
/** 修改按钮操作 */