优化逻辑bug
This commit is contained in:
@ -1,19 +1,36 @@
|
||||
<template>
|
||||
<div style="padding: 20px;">
|
||||
<div style="padding: 20px">
|
||||
<el-card class="mb-5">
|
||||
<el-button type="primary" icon="Plus" @click="handleAdd" class="transition-all duration-200 hover:shadow-md">
|
||||
<el-button
|
||||
type="primary"
|
||||
v-hasPermi="['cailiaoshebei:physicalsupply:add']"
|
||||
icon="Plus"
|
||||
@click="handleAdd"
|
||||
class="transition-all duration-200 hover:shadow-md"
|
||||
>
|
||||
新增
|
||||
</el-button>
|
||||
<el-button icon="Refresh" @click="refreshData" class="transition-all duration-200 hover:shadow-md"> 刷新
|
||||
<el-button
|
||||
v-hasPermi="['cailiaoshebei:physicalsupply:list']"
|
||||
icon="Refresh"
|
||||
@click="refreshData"
|
||||
class="transition-all duration-200 hover:shadow-md"
|
||||
>
|
||||
刷新
|
||||
</el-button>
|
||||
</el-card>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<div class="bg-white rounded-lg shadow-sm overflow-hidden transition-all duration-300 hover:shadow-md">
|
||||
<el-table v-loading="loading" :data="tableData" border stripe
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="tableData"
|
||||
border
|
||||
stripe
|
||||
style="width: 100%; margin-bottom: 20px; height: calc(100vh - 305px)"
|
||||
:header-cell-style="{ 'background-color': '#f5f7fa', 'font-weight': 'bold' }"
|
||||
:row-class-name="tableRowClassName">
|
||||
:row-class-name="tableRowClassName"
|
||||
>
|
||||
<el-table-column prop="id" label="ID" width="180" align="center"></el-table-column>
|
||||
<el-table-column prop="name" label="材料名称" align="center"></el-table-column>
|
||||
<el-table-column prop="specification" label="规格" align="center"></el-table-column>
|
||||
@ -38,14 +55,34 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="240" align="center" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button size="small" icon="Plus" @click="handleAddSon(scope.row)"
|
||||
class="text-blue-600 hover:text-blue-800 transition-colors"></el-button>
|
||||
<el-button size="small" icon="Edit" @click="handleEdit(scope.row)"
|
||||
class="text-blue-600 hover:text-blue-800 transition-colors"></el-button>
|
||||
<el-button size="small" icon="View" @click="jumpRouter(scope.row)"
|
||||
class="text-blue-600 hover:text-blue-800 transition-colors"></el-button>
|
||||
<el-button size="small" icon="Delete" @click="handleDelete(scope.row)"
|
||||
class="text-red-600 hover:text-red-800 transition-colors"></el-button>
|
||||
<el-button
|
||||
v-hasPermi="['cailiaoshebei:physicalsupplySon:add']"
|
||||
size="small"
|
||||
icon="Plus"
|
||||
@click="handleAddSon(scope.row)"
|
||||
class="text-blue-600 hover:text-blue-800 transition-colors"
|
||||
></el-button>
|
||||
<el-button
|
||||
v-hasPermi="['cailiaoshebei:physicalsupply:edit']"
|
||||
size="small"
|
||||
icon="Edit"
|
||||
@click="handleEdit(scope.row)"
|
||||
class="text-blue-600 hover:text-blue-800 transition-colors"
|
||||
></el-button>
|
||||
<el-button
|
||||
v-hasPermi="['cailiaoshebei:physicalsupplySon:list']"
|
||||
size="small"
|
||||
icon="View"
|
||||
@click="jumpRouter(scope.row)"
|
||||
class="text-blue-600 hover:text-blue-800 transition-colors"
|
||||
></el-button>
|
||||
<el-button
|
||||
v-hasPermi="['cailiaoshebei:physicalsupply:remove']"
|
||||
size="small"
|
||||
icon="Delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
class="text-red-600 hover:text-red-800 transition-colors"
|
||||
></el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -53,17 +90,27 @@
|
||||
<!-- 分页 -->
|
||||
<div class="flex items-center justify-between p-4 border-t">
|
||||
<div class="text-gray-500 text-sm">
|
||||
共 {{ total }} 条记录,当前显示第 {{ (currentPage - 1) * pageSize + 1 }} 至 {{ Math.min(currentPage * pageSize, total)
|
||||
}} 条
|
||||
共 {{ total }} 条记录,当前显示第 {{ (currentPage - 1) * pageSize + 1 }} 至 {{ Math.min(currentPage * pageSize, total) }} 条
|
||||
</div>
|
||||
<el-pagination v-model:current-page="currentPage" v-model:page-size="pageSize" :page-sizes="[10, 20, 50, 100]"
|
||||
:total="total" layout="prev, pager, next, jumper, sizes" @size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"></el-pagination>
|
||||
<el-pagination
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:total="total"
|
||||
layout="prev, pager, next, jumper, sizes"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
></el-pagination>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 新增/编辑对话框 -->
|
||||
<el-dialog v-model="dialogVisible" :title="dialogType === 'add' ? '新增记录' : '编辑记录'" :width="dialogWidth"
|
||||
:fullscreen="isFullscreen" :before-close="handleDialogClose">
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
:title="dialogType === 'add' ? '新增记录' : '编辑记录'"
|
||||
:width="dialogWidth"
|
||||
:fullscreen="isFullscreen"
|
||||
:before-close="handleDialogClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="120px" class="space-y-4">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
@ -107,8 +154,12 @@
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="合同签订时间" prop="contractSigning">
|
||||
<el-date-picker v-model="formData.contractSigning" type="datetime" placeholder="选择合同签订时间"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"></el-date-picker>
|
||||
<el-date-picker
|
||||
v-model="formData.contractSigning"
|
||||
type="datetime"
|
||||
placeholder="选择合同签订时间"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
@ -121,8 +172,7 @@
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="24">
|
||||
<el-form-item label="供货要求" prop="supplyRequirements">
|
||||
<el-input v-model="formData.supplyRequirements" placeholder="请输入供货要求" type="textarea"
|
||||
:rows="3"></el-input>
|
||||
<el-input v-model="formData.supplyRequirements" placeholder="请输入供货要求" type="textarea" :rows="3"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@ -143,7 +193,6 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -154,7 +203,7 @@ import { useRouter } from 'vue-router';
|
||||
const userStore = useUserStoreHook();
|
||||
const router = useRouter();
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
import { useMaterialsQueryList, newMaterialsAdd, materialsEdit, materialsDel, queryMaterialsInfo } from '@/api/materials/usageMaterials/index';
|
||||
import { useMaterialsQueryList, newMaterialsAdd, materialsEdit, materialsDel } from '@/api/materials/usageMaterials/index';
|
||||
// 表格数据相关
|
||||
const tableData = ref([]);
|
||||
const total = ref(0);
|
||||
@ -251,7 +300,7 @@ const fetchData = async () => {
|
||||
ElMessage.error('获取数据失败:' + error.message);
|
||||
console.error(error);
|
||||
} finally {
|
||||
loading.value = false;//
|
||||
loading.value = false; //
|
||||
}
|
||||
};
|
||||
|
||||
@ -332,22 +381,20 @@ const handleAddSon = (row) => {
|
||||
// 删除
|
||||
const handleDelete = (row) => {
|
||||
currentRow.value = row;
|
||||
ElMessageBox.confirm(
|
||||
'确定要删除这条记录吗?此操作不可撤销,请谨慎操作',
|
||||
'提示',
|
||||
{
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
).then(() => {
|
||||
confirmDelete();
|
||||
}).catch(() => {
|
||||
ElMessage({
|
||||
type: 'info',
|
||||
message: '已取消删除',
|
||||
})
|
||||
ElMessageBox.confirm('确定要删除这条记录吗?此操作不可撤销,请谨慎操作', '提示', {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
confirmDelete();
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage({
|
||||
type: 'info',
|
||||
message: '已取消删除'
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// 确认删除
|
||||
|
Reference in New Issue
Block a user