2025-08-14 22:08:39 +08:00
|
|
|
|
<template>
|
2025-08-15 15:21:07 +08:00
|
|
|
|
<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>
|
|
|
|
|
<el-button 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
|
|
|
|
|
style="width: 100%; margin-bottom: 20px; height: calc(100vh - 305px)"
|
|
|
|
|
:header-cell-style="{ 'background-color': '#f5f7fa', 'font-weight': 'bold' }"
|
|
|
|
|
: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>
|
|
|
|
|
<el-table-column prop="supplier" label="供应商" align="center"></el-table-column>
|
|
|
|
|
<el-table-column prop="findType" label="类型" align="center">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<el-tag :type="scope.row.findType === '1' ? 'success' : 'info'">
|
|
|
|
|
{{ scope.row.findType === '1' ? '采购' : '材料' }}
|
|
|
|
|
</el-tag>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column prop="installationQuantity" label="安装量" align="center"></el-table-column>
|
|
|
|
|
<el-table-column prop="contractSigning" label="合同签订时间" width="180" align="center">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
{{ formatDate(scope.row.contractSigning) }}
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column prop="createTime" label="创建时间" width="180" align="center">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
{{ formatDate(scope.row.createTime) }}
|
|
|
|
|
</template>
|
|
|
|
|
</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>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
|
|
|
|
|
<!-- 分页 -->
|
|
|
|
|
<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)
|
|
|
|
|
}} 条
|
2025-08-15 10:58:12 +08:00
|
|
|
|
</div>
|
2025-08-15 15:21:07 +08:00
|
|
|
|
<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>
|
2025-08-15 10:58:12 +08:00
|
|
|
|
</div>
|
2025-08-15 15:21:07 +08:00
|
|
|
|
</div>
|
2025-08-15 22:47:41 +08:00
|
|
|
|
<!-- 新增/编辑对话框 -->
|
|
|
|
|
<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">
|
|
|
|
|
<el-form-item label="材料名称" prop="name">
|
|
|
|
|
<el-input v-model="formData.name" placeholder="请输入材料名称"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="规格" prop="specification">
|
|
|
|
|
<el-input v-model="formData.specification" placeholder="请输入规格"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="供应商" prop="supplier">
|
|
|
|
|
<el-input v-model="formData.supplier" placeholder="请输入供应商"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="运算周期(天)" prop="executionCycle">
|
|
|
|
|
<el-input v-model.number="formData.executionCycle" placeholder="请输入运算周期" type="number"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="安装量" prop="installationQuantity">
|
|
|
|
|
<el-input v-model="formData.installationQuantity" placeholder="请输入安装量"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="安装比例" prop="installationRatio">
|
|
|
|
|
<el-input v-model="formData.installationRatio" placeholder="请输入安装比例" suffix="%"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
|
<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-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="生产周期(天)" prop="productionPhase">
|
|
|
|
|
<el-input v-model.number="formData.productionPhase" placeholder="请输入生产周期" type="number"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
|
<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-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item label="备注" prop="remark">
|
|
|
|
|
<el-input v-model="formData.remark" placeholder="请输入备注信息" type="textarea" :rows="3"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
<div class="flex justify-end gap-2">
|
|
|
|
|
<el-button @click="dialogVisible = false">取消</el-button>
|
|
|
|
|
<el-button type="primary" @click="handleSave" :loading="saveLoading"> 保存 </el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</el-dialog>
|
2025-08-15 10:58:12 +08:00
|
|
|
|
</div>
|
2025-08-15 22:47:41 +08:00
|
|
|
|
|
2025-08-14 22:08:39 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
2025-08-15 03:04:40 +08:00
|
|
|
|
<script setup>
|
|
|
|
|
import { ref, reactive, onMounted, computed, toRaw } from 'vue';
|
|
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
2025-08-14 22:08:39 +08:00
|
|
|
|
import { useUserStoreHook } from '@/store/modules/user';
|
2025-08-15 03:04:40 +08:00
|
|
|
|
import { useRouter } from 'vue-router';
|
2025-08-14 22:08:39 +08:00
|
|
|
|
const userStore = useUserStoreHook();
|
2025-08-15 03:04:40 +08:00
|
|
|
|
const router = useRouter();
|
2025-08-14 22:08:39 +08:00
|
|
|
|
const currentProject = computed(() => userStore.selectedProject);
|
2025-08-15 10:58:12 +08:00
|
|
|
|
import { useMaterialsQueryList, newMaterialsAdd, materialsEdit, materialsDel, queryMaterialsInfo } from '@/api/materials/usageMaterials/index';
|
2025-08-15 03:04:40 +08:00
|
|
|
|
// 表格数据相关
|
|
|
|
|
const tableData = ref([]);
|
|
|
|
|
const total = ref(0);
|
|
|
|
|
const currentPage = ref(1);
|
|
|
|
|
const pageSize = ref(10);
|
|
|
|
|
const loading = ref(false);
|
2025-08-15 22:47:41 +08:00
|
|
|
|
const saveLoading = ref(false);
|
2025-08-15 03:04:40 +08:00
|
|
|
|
|
|
|
|
|
// 搜索表单
|
|
|
|
|
const searchForm = reactive({
|
2025-08-15 10:58:12 +08:00
|
|
|
|
findType: '3', // 默认查询所有
|
|
|
|
|
keyword: ''
|
2025-08-14 22:08:39 +08:00
|
|
|
|
});
|
2025-08-15 03:04:40 +08:00
|
|
|
|
|
|
|
|
|
// 对话框相关
|
|
|
|
|
const dialogVisible = ref(false);
|
|
|
|
|
const dialogType = ref('add'); // add 或 edit
|
|
|
|
|
const dialogWidth = ref('70%');
|
|
|
|
|
const isFullscreen = ref(false);
|
|
|
|
|
const deleteDialogVisible = ref(false);
|
|
|
|
|
const formRef = ref(null);
|
|
|
|
|
const deleteLoading = ref(false);
|
|
|
|
|
const currentRow = ref(null);
|
|
|
|
|
|
2025-08-14 22:08:39 +08:00
|
|
|
|
// 表单数据
|
|
|
|
|
const formData = reactive({
|
2025-08-15 10:58:12 +08:00
|
|
|
|
id: '',
|
|
|
|
|
name: '',
|
|
|
|
|
specification: '',
|
|
|
|
|
supplier: '',
|
|
|
|
|
findType: 2, // 默认采购
|
|
|
|
|
installationQuantity: '',
|
|
|
|
|
installationRatio: '',
|
|
|
|
|
contractSigning: '',
|
|
|
|
|
productionPhase: null,
|
|
|
|
|
executionCycle: null,
|
|
|
|
|
projectId: currentProject.value?.id,
|
|
|
|
|
supplyRequirements: '',
|
|
|
|
|
// purchaseSubmission: '',
|
|
|
|
|
// submissionMaterials: '',
|
|
|
|
|
remark: '',
|
|
|
|
|
createTime: '',
|
|
|
|
|
createBy: null,
|
|
|
|
|
updateTime: '',
|
|
|
|
|
updateBy: null
|
2025-08-14 22:08:39 +08:00
|
|
|
|
});
|
2025-08-15 03:04:40 +08:00
|
|
|
|
|
2025-08-14 22:08:39 +08:00
|
|
|
|
// 表单验证规则
|
|
|
|
|
const formRules = reactive({
|
2025-08-15 10:58:12 +08:00
|
|
|
|
name: [
|
|
|
|
|
{ required: true, message: '请输入材料名称', trigger: 'blur' },
|
|
|
|
|
{ max: 50, message: '材料名称不能超过50个字符', trigger: 'blur' }
|
|
|
|
|
],
|
|
|
|
|
supplier: [
|
|
|
|
|
{ required: true, message: '请输入供应商', trigger: 'blur' },
|
|
|
|
|
{ max: 100, message: '供应商名称不能超过100个字符', trigger: 'blur' }
|
|
|
|
|
],
|
|
|
|
|
findType: [{ required: true, message: '请选择类型', trigger: 'change' }]
|
2025-08-14 22:08:39 +08:00
|
|
|
|
});
|
2025-08-15 03:04:40 +08:00
|
|
|
|
|
|
|
|
|
// 格式化日期
|
|
|
|
|
const formatDate = (dateString) => {
|
2025-08-15 10:58:12 +08:00
|
|
|
|
if (!dateString) return '-';
|
|
|
|
|
const date = new Date(dateString);
|
|
|
|
|
return date
|
|
|
|
|
.toLocaleString('zh-CN', {
|
|
|
|
|
year: 'numeric',
|
|
|
|
|
month: '2-digit',
|
|
|
|
|
day: '2-digit',
|
|
|
|
|
hour: '2-digit',
|
|
|
|
|
minute: '2-digit',
|
|
|
|
|
second: '2-digit'
|
|
|
|
|
})
|
|
|
|
|
.replace(',', ' ');
|
2025-08-15 03:04:40 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 表格行样式
|
|
|
|
|
const tableRowClassName = ({ row, rowIndex }) => {
|
2025-08-15 10:58:12 +08:00
|
|
|
|
return rowIndex % 2 === 0 ? 'bg-white' : 'bg-gray-50';
|
2025-08-15 03:04:40 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 获取数据
|
|
|
|
|
const fetchData = async () => {
|
2025-08-15 10:58:12 +08:00
|
|
|
|
loading.value = true;
|
|
|
|
|
try {
|
|
|
|
|
const res = await useMaterialsQueryList({
|
|
|
|
|
projectId: currentProject.value?.id,
|
|
|
|
|
findType: 1
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tableData.value = res.rows;
|
|
|
|
|
total.value = res.total;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
ElMessage.error('获取数据失败:' + error.message);
|
|
|
|
|
console.error(error);
|
|
|
|
|
} finally {
|
2025-08-15 15:21:07 +08:00
|
|
|
|
loading.value = false;//
|
2025-08-15 10:58:12 +08:00
|
|
|
|
}
|
2025-08-15 03:04:40 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 搜索
|
|
|
|
|
const handleSearch = () => {
|
2025-08-15 10:58:12 +08:00
|
|
|
|
currentPage.value = 1; // 重置到第一页
|
|
|
|
|
fetchData();
|
2025-08-15 03:04:40 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 刷新数据
|
|
|
|
|
const refreshData = () => {
|
2025-08-15 10:58:12 +08:00
|
|
|
|
fetchData();
|
|
|
|
|
ElMessage.success('数据已刷新');
|
2025-08-15 03:04:40 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 分页大小改变
|
|
|
|
|
const handleSizeChange = (val) => {
|
2025-08-15 10:58:12 +08:00
|
|
|
|
pageSize.value = val;
|
|
|
|
|
currentPage.value = 1;
|
|
|
|
|
fetchData();
|
2025-08-15 03:04:40 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 当前页改变
|
|
|
|
|
const handleCurrentChange = (val) => {
|
2025-08-15 10:58:12 +08:00
|
|
|
|
currentPage.value = val;
|
|
|
|
|
fetchData();
|
2025-08-15 03:04:40 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 新增
|
|
|
|
|
const handleAdd = () => {
|
2025-08-15 10:58:12 +08:00
|
|
|
|
dialogType.value = 'add';
|
|
|
|
|
resetForm();
|
|
|
|
|
dialogVisible.value = true;
|
2025-08-15 03:04:40 +08:00
|
|
|
|
};
|
|
|
|
|
|
2025-08-15 10:58:12 +08:00
|
|
|
|
//
|
2025-08-15 03:04:40 +08:00
|
|
|
|
|
|
|
|
|
// 编辑
|
|
|
|
|
const handleEdit = (row) => {
|
2025-08-15 10:58:12 +08:00
|
|
|
|
dialogType.value = 'edit';
|
|
|
|
|
currentRow.value = row;
|
|
|
|
|
resetForm();
|
|
|
|
|
|
|
|
|
|
// 填充表单数据
|
|
|
|
|
Object.keys(formData).forEach((key) => {
|
|
|
|
|
if (row.hasOwnProperty(key)) {
|
|
|
|
|
formData[key] = row[key];
|
|
|
|
|
}
|
|
|
|
|
});
|
2025-08-15 03:04:40 +08:00
|
|
|
|
|
2025-08-15 10:58:12 +08:00
|
|
|
|
dialogVisible.value = true;
|
2025-08-15 03:04:40 +08:00
|
|
|
|
};
|
|
|
|
|
const handleAddSon = (row) => {
|
2025-08-15 10:58:12 +08:00
|
|
|
|
ElMessageBox.confirm('确认提交', '提示', {
|
|
|
|
|
confirmButtonText: '确认',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
type: 'warning'
|
2025-08-15 03:04:40 +08:00
|
|
|
|
})
|
2025-08-15 10:58:12 +08:00
|
|
|
|
.then(() => {
|
|
|
|
|
materialsEdit({ id: row.id, purchaseSubmission: '1' }).then((res) => {
|
|
|
|
|
let { code } = res;
|
|
|
|
|
if (code === 200) {
|
|
|
|
|
ElMessage({
|
|
|
|
|
type: 'success',
|
|
|
|
|
message: '提交成功'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
ElMessage({
|
|
|
|
|
type: 'info',
|
|
|
|
|
message: '已取消提交'
|
|
|
|
|
});
|
|
|
|
|
});
|
2025-08-15 03:04:40 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 删除
|
|
|
|
|
const handleDelete = (row) => {
|
2025-08-15 10:58:12 +08:00
|
|
|
|
currentRow.value = row;
|
2025-08-15 15:21:07 +08:00
|
|
|
|
ElMessageBox.confirm(
|
|
|
|
|
'确定要删除这条记录吗?此操作不可撤销,请谨慎操作',
|
|
|
|
|
'提示',
|
|
|
|
|
{
|
|
|
|
|
confirmButtonText: '确认',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
type: 'warning',
|
|
|
|
|
}
|
|
|
|
|
).then(() => {
|
|
|
|
|
confirmDelete();
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
ElMessage({
|
|
|
|
|
type: 'info',
|
|
|
|
|
message: '已取消删除',
|
|
|
|
|
})
|
|
|
|
|
})
|
2025-08-15 03:04:40 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 确认删除
|
|
|
|
|
const confirmDelete = async () => {
|
2025-08-15 10:58:12 +08:00
|
|
|
|
if (!currentRow.value) return;
|
|
|
|
|
|
|
|
|
|
deleteLoading.value = true;
|
|
|
|
|
try {
|
|
|
|
|
// 模拟API请求
|
|
|
|
|
const res = await materialsDel(currentRow.value.id);
|
|
|
|
|
const { code } = res;
|
|
|
|
|
if (code === 200) {
|
|
|
|
|
ElMessage.success('删除成功');
|
|
|
|
|
deleteDialogVisible.value = false;
|
|
|
|
|
fetchData();
|
|
|
|
|
} else {
|
|
|
|
|
ElMessage.error('删除失败');
|
2025-08-15 03:04:40 +08:00
|
|
|
|
}
|
2025-08-15 10:58:12 +08:00
|
|
|
|
} catch (error) {
|
|
|
|
|
ElMessage.error('删除失败:' + error.message);
|
|
|
|
|
console.error(error);
|
|
|
|
|
} finally {
|
|
|
|
|
deleteLoading.value = false;
|
|
|
|
|
}
|
2025-08-15 03:04:40 +08:00
|
|
|
|
};
|
2025-08-15 10:58:12 +08:00
|
|
|
|
//
|
2025-08-15 03:04:40 +08:00
|
|
|
|
|
|
|
|
|
// 保存
|
|
|
|
|
const handleSave = async () => {
|
2025-08-15 10:58:12 +08:00
|
|
|
|
// 表单验证
|
|
|
|
|
if (!formRef.value) return;
|
|
|
|
|
const valid = await formRef.value.validate();
|
|
|
|
|
if (!valid) return;
|
|
|
|
|
|
|
|
|
|
saveLoading.value = true;
|
|
|
|
|
try {
|
|
|
|
|
// 模拟API请求
|
|
|
|
|
const form = toRaw(formData);
|
|
|
|
|
|
|
|
|
|
if (dialogType.value === 'add') {
|
|
|
|
|
// 新增
|
|
|
|
|
formData.projectId = currentProject.value?.id;
|
|
|
|
|
const res = await newMaterialsAdd(formData);
|
|
|
|
|
let { code } = res;
|
|
|
|
|
if (code === 200) {
|
|
|
|
|
ElMessage.success('新增成功');
|
|
|
|
|
fetchData();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 编辑
|
|
|
|
|
const res = await materialsEdit(formData);
|
|
|
|
|
let { code } = res;
|
|
|
|
|
if (code === 200) {
|
|
|
|
|
ElMessage.success('保存成功');
|
|
|
|
|
fetchData();
|
|
|
|
|
}
|
2025-08-15 03:04:40 +08:00
|
|
|
|
}
|
2025-08-15 10:58:12 +08:00
|
|
|
|
|
|
|
|
|
dialogVisible.value = false;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
ElMessage.error('保存失败:' + error.message);
|
|
|
|
|
console.error(error);
|
|
|
|
|
} finally {
|
|
|
|
|
saveLoading.value = false;
|
|
|
|
|
}
|
2025-08-15 03:04:40 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 重置表单
|
|
|
|
|
const resetForm = () => {
|
2025-08-15 10:58:12 +08:00
|
|
|
|
if (formRef.value) {
|
|
|
|
|
formRef.value.resetFields();
|
|
|
|
|
}
|
2025-08-15 03:04:40 +08:00
|
|
|
|
|
2025-08-15 10:58:12 +08:00
|
|
|
|
// 重置表单数据
|
|
|
|
|
Object.keys(formData).forEach((key) => {
|
|
|
|
|
formData[key] = '';
|
|
|
|
|
});
|
2025-08-15 03:04:40 +08:00
|
|
|
|
|
2025-08-15 10:58:12 +08:00
|
|
|
|
// 设置默认值
|
|
|
|
|
formData.findType = 1;
|
|
|
|
|
formData.id = '';
|
2025-08-15 03:04:40 +08:00
|
|
|
|
};
|
|
|
|
|
// 关闭对话框
|
|
|
|
|
const handleDialogClose = () => {
|
2025-08-15 10:58:12 +08:00
|
|
|
|
resetForm();
|
|
|
|
|
dialogVisible.value = false;
|
2025-08-15 03:04:40 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 跳转
|
|
|
|
|
const jumpRouter = (row) => {
|
|
|
|
|
router.push({
|
2025-08-15 22:47:41 +08:00
|
|
|
|
path: `/materials/usageMaterials/purchaseIndexSon`,
|
2025-08-15 03:04:40 +08:00
|
|
|
|
query: {
|
|
|
|
|
id: row.id,
|
|
|
|
|
type: 'update'
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
// 初始化页面
|
2025-08-14 22:08:39 +08:00
|
|
|
|
onMounted(() => {
|
2025-08-15 10:58:12 +08:00
|
|
|
|
fetchData();
|
2025-08-15 03:04:40 +08:00
|
|
|
|
});
|
2025-08-14 22:08:39 +08:00
|
|
|
|
</script>
|
2025-08-15 03:04:40 +08:00
|
|
|
|
|
2025-08-15 22:47:41 +08:00
|
|
|
|
<style scoped></style>
|