消息
This commit is contained in:
@ -5,7 +5,7 @@ VITE_APP_TITLE = 新能源项目管理平台
|
|||||||
VITE_APP_ENV = 'development'
|
VITE_APP_ENV = 'development'
|
||||||
|
|
||||||
# 开发环境
|
# 开发环境
|
||||||
VITE_APP_BASE_API = 'http://192.168.110.159:8898'
|
VITE_APP_BASE_API = 'http://192.168.110.180:8898'
|
||||||
|
|
||||||
# 无人机接口地址
|
# 无人机接口地址
|
||||||
|
|
||||||
|
@ -28,24 +28,25 @@ export const initSSE = (url: any) => {
|
|||||||
console.log(data.value);
|
console.log(data.value);
|
||||||
let label = '';
|
let label = '';
|
||||||
let route1 = '';
|
let route1 = '';
|
||||||
|
let detailId = '';
|
||||||
try {
|
try {
|
||||||
if (JSON.parse(data.value)) {
|
if (JSON.parse(data.value)) {
|
||||||
const obj = JSON.parse(data.value);
|
const obj = JSON.parse(data.value);
|
||||||
route1 = obj.route;
|
route1 = obj.route;
|
||||||
label = obj.message;
|
label = obj.message;
|
||||||
|
detailId = obj.detailId;
|
||||||
data.value = null;
|
data.value = null;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
label = data.value;
|
label = data.value;
|
||||||
}
|
}
|
||||||
console.log(route1);
|
if (!label) return;
|
||||||
console.log(label);
|
|
||||||
// if (!data.value) return;
|
|
||||||
useNoticeStore().addNotice({
|
useNoticeStore().addNotice({
|
||||||
message: label,
|
message: label,
|
||||||
read: false,
|
read: false,
|
||||||
time: new Date().toLocaleString(),
|
time: new Date().toLocaleString(),
|
||||||
route: route1
|
route: route1,
|
||||||
|
detailId: detailId
|
||||||
});
|
});
|
||||||
ElNotification({
|
ElNotification({
|
||||||
title: '消息',
|
title: '消息',
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
ref="fileUploadRef"
|
ref="fileUploadRef"
|
||||||
class="w-full"
|
class="w-full"
|
||||||
:auto-upload="false"
|
:auto-upload="false"
|
||||||
:data="{ projectId: currentProject.id }"
|
:data="{ projectId: form.projectId }"
|
||||||
:showFileList="showFileList"
|
:showFileList="showFileList"
|
||||||
:onUploadSuccess="handleUploadSuccess"
|
:onUploadSuccess="handleUploadSuccess"
|
||||||
:uploadUrl="`${form.id ? '/design/prelimScheme/update/' + form.id : '/design/prelimScheme/upload'}`"
|
:uploadUrl="`${form.id ? '/design/prelimScheme/update/' + form.id : '/design/prelimScheme/upload'}`"
|
||||||
|
@ -453,7 +453,7 @@ const handleDialogClose = () => {
|
|||||||
// 跳转
|
// 跳转
|
||||||
const jumpRouter = (row) => {
|
const jumpRouter = (row) => {
|
||||||
router.push({
|
router.push({
|
||||||
path: `/materials/usageMaterials/materialSon`,
|
path: `/materials/materialSon`,
|
||||||
query: {
|
query: {
|
||||||
id: row.id,
|
id: row.id,
|
||||||
type: 'update'
|
type: 'update'
|
||||||
|
@ -1,184 +1,203 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="min-h-screen bg-gray-50 flex flex-col">
|
<div class="min-h-screen bg-gray-50 flex flex-col">
|
||||||
<!-- 主要内容区 -->
|
<!-- 主要内容区 -->
|
||||||
<main class="flex-1 p-6">
|
<main class="flex-1 p-6">
|
||||||
<!-- 操作栏 -->
|
<!-- 操作栏 -->
|
||||||
<div class="bg-white rounded-lg shadow-sm p-4 mb-6 transition-all duration-300 hover:shadow-md">
|
<div class="bg-white rounded-lg shadow-sm p-4 mb-6 transition-all duration-300 hover:shadow-md">
|
||||||
<div class="flex flex-wrap items-center justify-between gap-4">
|
<div class="flex flex-wrap items-center justify-between gap-4">
|
||||||
<!-- 操作按钮 -->
|
<!-- 操作按钮 -->
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<el-button type="primary" icon="Plus" @click="handleAdd"
|
<el-button type="primary" icon="Plus" @click="handleAdd" class="transition-all duration-200 hover:shadow-md"> 新增 </el-button>
|
||||||
class="transition-all duration-200 hover:shadow-md">
|
<el-button icon="Refresh" @click="refreshData" class="transition-all duration-200 hover:shadow-md"> 刷新 </el-button>
|
||||||
新增
|
</div>
|
||||||
</el-button>
|
</div>
|
||||||
<el-button icon="Refresh" @click="refreshData"
|
</div>
|
||||||
class="transition-all duration-200 hover:shadow-md">
|
|
||||||
刷新
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 数据表格 -->
|
<!-- 数据表格 -->
|
||||||
<div class="bg-white rounded-lg shadow-sm overflow-hidden transition-all duration-300 hover:shadow-md">
|
<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
|
||||||
:header-cell-style="{ 'background-color': '#f5f7fa', 'font-weight': 'bold' }"
|
v-loading="loading"
|
||||||
:row-class-name="tableRowClassName">
|
:data="tableData"
|
||||||
<el-table-column prop="id" label="ID" width="80" align="center"></el-table-column>
|
border
|
||||||
<el-table-column prop="name" label="材料名称" min-width="150"></el-table-column>
|
stripe
|
||||||
<el-table-column prop="specification" label="规格" min-width="120"></el-table-column>
|
:header-cell-style="{ 'background-color': '#f5f7fa', 'font-weight': 'bold' }"
|
||||||
<el-table-column prop="supplier" label="供应商" min-width="150"></el-table-column>
|
:row-class-name="tableRowClassName"
|
||||||
<el-table-column prop="findType" label="类型" width="100" align="center">
|
>
|
||||||
<template #default="scope">
|
<el-table-column prop="id" label="ID" width="80" align="center"></el-table-column>
|
||||||
<el-tag :type="scope.row.findType === '1' ? 'success' : 'info'">
|
<el-table-column prop="name" label="材料名称" min-width="150"></el-table-column>
|
||||||
{{ scope.row.findType === '1' ? '采购' : '材料' }}
|
<el-table-column prop="specification" label="规格" min-width="120"></el-table-column>
|
||||||
</el-tag>
|
<el-table-column prop="supplier" label="供应商" min-width="150"></el-table-column>
|
||||||
</template>
|
<el-table-column prop="findType" label="类型" width="100" align="center">
|
||||||
</el-table-column>
|
<template #default="scope">
|
||||||
<el-table-column prop="installationQuantity" label="安装量" width="100"
|
<el-tag :type="scope.row.findType === '1' ? 'success' : 'info'">
|
||||||
align="center"></el-table-column>
|
{{ scope.row.findType === '1' ? '采购' : '材料' }}
|
||||||
<el-table-column prop="contractSigning" label="合同签订时间" width="180" align="center">
|
</el-tag>
|
||||||
<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)
|
|
||||||
}} 条
|
|
||||||
</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>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
<!-- 新增/编辑对话框 -->
|
|
||||||
<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>
|
</template>
|
||||||
</el-dialog>
|
</el-table-column>
|
||||||
<!-- 删除确认对话框 -->
|
<el-table-column prop="installationQuantity" label="安装量" width="100" align="center"></el-table-column>
|
||||||
<el-dialog v-model="deleteDialogVisible" title="确认删除" width="300px" :show-close="false">
|
<el-table-column prop="contractSigning" label="合同签订时间" width="180" align="center">
|
||||||
<div class="text-center py-4">
|
<template #default="scope">
|
||||||
<el-icon class="text-orange-500 text-4xl mb-3">
|
{{ formatDate(scope.row.contractSigning) }}
|
||||||
<WarningFilled />
|
|
||||||
</el-icon>
|
|
||||||
<p>确定要删除这条记录吗?</p>
|
|
||||||
<p class="text-gray-500 text-sm mt-2">此操作不可撤销,请谨慎操作</p>
|
|
||||||
</div>
|
|
||||||
<template #footer>
|
|
||||||
<div class="flex justify-center gap-2">
|
|
||||||
<el-button @click="deleteDialogVisible = false">取消</el-button>
|
|
||||||
<el-button type="danger" @click="confirmDelete" :loading="deleteLoading">
|
|
||||||
确认删除
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-table-column>
|
||||||
</div>
|
<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) }} 条
|
||||||
|
</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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<!-- 新增/编辑对话框 -->
|
||||||
|
<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>
|
||||||
|
<!-- 删除确认对话框 -->
|
||||||
|
<el-dialog v-model="deleteDialogVisible" title="确认删除" width="300px" :show-close="false">
|
||||||
|
<div class="text-center py-4">
|
||||||
|
<el-icon class="text-orange-500 text-4xl mb-3">
|
||||||
|
<WarningFilled />
|
||||||
|
</el-icon>
|
||||||
|
<p>确定要删除这条记录吗?</p>
|
||||||
|
<p class="text-gray-500 text-sm mt-2">此操作不可撤销,请谨慎操作</p>
|
||||||
|
</div>
|
||||||
|
<template #footer>
|
||||||
|
<div class="flex justify-center gap-2">
|
||||||
|
<el-button @click="deleteDialogVisible = false">取消</el-button>
|
||||||
|
<el-button type="danger" @click="confirmDelete" :loading="deleteLoading"> 确认删除 </el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@ -191,7 +210,7 @@ const userStore = useUserStoreHook();
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const currentProject = computed(() => userStore.selectedProject);
|
const currentProject = computed(() => userStore.selectedProject);
|
||||||
const { proxy } = getCurrentInstance();
|
const { proxy } = getCurrentInstance();
|
||||||
import { useMaterialsQueryList, newMaterialsAdd, materialsEdit, materialsDel, queryMaterialsInfo } from "@/api/materials/usageMaterials/index";
|
import { useMaterialsQueryList, newMaterialsAdd, materialsEdit, materialsDel, queryMaterialsInfo } from '@/api/materials/usageMaterials/index';
|
||||||
// 表格数据相关
|
// 表格数据相关
|
||||||
const tableData = ref([]);
|
const tableData = ref([]);
|
||||||
const total = ref(0);
|
const total = ref(0);
|
||||||
@ -201,8 +220,8 @@ const loading = ref(false);
|
|||||||
|
|
||||||
// 搜索表单
|
// 搜索表单
|
||||||
const searchForm = reactive({
|
const searchForm = reactive({
|
||||||
findType: '3', // 默认查询所有
|
findType: '3', // 默认查询所有
|
||||||
keyword: ''
|
keyword: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
// 对话框相关
|
// 对话框相关
|
||||||
@ -221,278 +240,268 @@ const submitLoading = ref(false);
|
|||||||
|
|
||||||
// 表单数据
|
// 表单数据
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
id: '',
|
id: '',
|
||||||
name: '',
|
name: '',
|
||||||
specification: '',
|
specification: '',
|
||||||
supplier: '',
|
supplier: '',
|
||||||
findType: 2, // 默认采购
|
findType: 2, // 默认采购
|
||||||
installationQuantity: '',
|
installationQuantity: '',
|
||||||
installationRatio: '',
|
installationRatio: '',
|
||||||
contractSigning: '',
|
contractSigning: '',
|
||||||
productionPhase: null,
|
productionPhase: null,
|
||||||
executionCycle: null,
|
executionCycle: null,
|
||||||
projectId: currentProject.value?.id,
|
projectId: currentProject.value?.id,
|
||||||
supplyRequirements: '',
|
supplyRequirements: '',
|
||||||
// purchaseSubmission: '',
|
// purchaseSubmission: '',
|
||||||
// submissionMaterials: '',
|
// submissionMaterials: '',
|
||||||
remark: '',
|
remark: '',
|
||||||
createTime: '',
|
createTime: '',
|
||||||
createBy: null,
|
createBy: null,
|
||||||
updateTime: '',
|
updateTime: '',
|
||||||
updateBy: null
|
updateBy: null
|
||||||
});
|
});
|
||||||
|
|
||||||
// 表单验证规则
|
// 表单验证规则
|
||||||
const formRules = reactive({
|
const formRules = reactive({
|
||||||
name: [
|
name: [
|
||||||
{ required: true, message: '请输入材料名称', trigger: 'blur' },
|
{ required: true, message: '请输入材料名称', trigger: 'blur' },
|
||||||
{ max: 50, message: '材料名称不能超过50个字符', trigger: 'blur' }
|
{ max: 50, message: '材料名称不能超过50个字符', trigger: 'blur' }
|
||||||
],
|
],
|
||||||
supplier: [
|
supplier: [
|
||||||
{ required: true, message: '请输入供应商', trigger: 'blur' },
|
{ required: true, message: '请输入供应商', trigger: 'blur' },
|
||||||
{ max: 100, message: '供应商名称不能超过100个字符', trigger: 'blur' }
|
{ max: 100, message: '供应商名称不能超过100个字符', trigger: 'blur' }
|
||||||
],
|
],
|
||||||
findType: [
|
findType: [{ required: true, message: '请选择类型', trigger: 'change' }]
|
||||||
{ required: true, message: '请选择类型', trigger: 'change' }
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 格式化日期
|
// 格式化日期
|
||||||
const formatDate = (dateString) => {
|
const formatDate = (dateString) => {
|
||||||
if (!dateString) return '-';
|
if (!dateString) return '-';
|
||||||
const date = new Date(dateString);
|
const date = new Date(dateString);
|
||||||
return date.toLocaleString('zh-CN', {
|
return date
|
||||||
year: 'numeric',
|
.toLocaleString('zh-CN', {
|
||||||
month: '2-digit',
|
year: 'numeric',
|
||||||
day: '2-digit',
|
month: '2-digit',
|
||||||
hour: '2-digit',
|
day: '2-digit',
|
||||||
minute: '2-digit',
|
hour: '2-digit',
|
||||||
second: '2-digit'
|
minute: '2-digit',
|
||||||
}).replace(',', ' ');
|
second: '2-digit'
|
||||||
|
})
|
||||||
|
.replace(',', ' ');
|
||||||
};
|
};
|
||||||
|
|
||||||
// 表格行样式
|
// 表格行样式
|
||||||
const tableRowClassName = ({ row, rowIndex }) => {
|
const tableRowClassName = ({ row, rowIndex }) => {
|
||||||
return rowIndex % 2 === 0 ? 'bg-white' : 'bg-gray-50';
|
return rowIndex % 2 === 0 ? 'bg-white' : 'bg-gray-50';
|
||||||
};
|
};
|
||||||
|
|
||||||
// 获取数据
|
// 获取数据
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const res = await useMaterialsQueryList({
|
const res = await useMaterialsQueryList({
|
||||||
projectId: currentProject.value?.id,
|
projectId: currentProject.value?.id,
|
||||||
findType: 1
|
findType: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
tableData.value = res.rows;
|
tableData.value = res.rows;
|
||||||
total.value = res.total;
|
total.value = res.total;
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ElMessage.error('获取数据失败:' + error.message);
|
ElMessage.error('获取数据失败:' + error.message);
|
||||||
console.error(error);
|
console.error(error);
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 搜索
|
// 搜索
|
||||||
const handleSearch = () => {
|
const handleSearch = () => {
|
||||||
currentPage.value = 1; // 重置到第一页
|
currentPage.value = 1; // 重置到第一页
|
||||||
fetchData();
|
fetchData();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 刷新数据
|
// 刷新数据
|
||||||
const refreshData = () => {
|
const refreshData = () => {
|
||||||
fetchData();
|
fetchData();
|
||||||
ElMessage.success('数据已刷新');
|
ElMessage.success('数据已刷新');
|
||||||
};
|
};
|
||||||
|
|
||||||
// 分页大小改变
|
// 分页大小改变
|
||||||
const handleSizeChange = (val) => {
|
const handleSizeChange = (val) => {
|
||||||
pageSize.value = val;
|
pageSize.value = val;
|
||||||
currentPage.value = 1;
|
currentPage.value = 1;
|
||||||
fetchData();
|
fetchData();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 当前页改变
|
// 当前页改变
|
||||||
const handleCurrentChange = (val) => {
|
const handleCurrentChange = (val) => {
|
||||||
currentPage.value = val;
|
currentPage.value = val;
|
||||||
fetchData();
|
fetchData();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 新增
|
// 新增
|
||||||
const handleAdd = () => {
|
const handleAdd = () => {
|
||||||
dialogType.value = 'add';
|
dialogType.value = 'add';
|
||||||
resetForm();
|
resetForm();
|
||||||
dialogVisible.value = true;
|
dialogVisible.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 编辑
|
// 编辑
|
||||||
const handleEdit = (row) => {
|
const handleEdit = (row) => {
|
||||||
dialogType.value = 'edit';
|
dialogType.value = 'edit';
|
||||||
currentRow.value = row;
|
currentRow.value = row;
|
||||||
resetForm();
|
resetForm();
|
||||||
|
|
||||||
// 填充表单数据
|
// 填充表单数据
|
||||||
Object.keys(formData).forEach(key => {
|
Object.keys(formData).forEach((key) => {
|
||||||
if (row.hasOwnProperty(key)) {
|
if (row.hasOwnProperty(key)) {
|
||||||
formData[key] = row[key];
|
formData[key] = row[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dialogVisible.value = true;
|
dialogVisible.value = true;
|
||||||
};
|
};
|
||||||
const handleAddSon = (row) => {
|
const handleAddSon = (row) => {
|
||||||
ElMessageBox.confirm(
|
ElMessageBox.confirm('确认提交', '提示', {
|
||||||
'确认提交',
|
confirmButtonText: '确认',
|
||||||
'提示',
|
cancelButtonText: '取消',
|
||||||
{
|
type: 'warning'
|
||||||
confirmButtonText: '确认',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning',
|
|
||||||
}
|
|
||||||
).then(() => {
|
|
||||||
materialsEdit({id:row.id,purchaseSubmission:'1'}).then(res=>{
|
|
||||||
let { code } = res
|
|
||||||
if (code === 200) {
|
|
||||||
ElMessage({
|
|
||||||
type: 'success',
|
|
||||||
message: '提交成功',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}).catch(() => {
|
|
||||||
ElMessage({
|
|
||||||
type: 'info',
|
|
||||||
message: '已取消提交',
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
.then(() => {
|
||||||
|
materialsEdit({ id: row.id, purchaseSubmission: '1' }).then((res) => {
|
||||||
|
let { code } = res;
|
||||||
|
if (code === 200) {
|
||||||
|
ElMessage({
|
||||||
|
type: 'success',
|
||||||
|
message: '提交成功'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
ElMessage({
|
||||||
|
type: 'info',
|
||||||
|
message: '已取消提交'
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
const handleDelete = (row) => {
|
const handleDelete = (row) => {
|
||||||
currentRow.value = row;
|
currentRow.value = row;
|
||||||
deleteDialogVisible.value = true;
|
deleteDialogVisible.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 确认删除
|
// 确认删除
|
||||||
const confirmDelete = async () => {
|
const confirmDelete = async () => {
|
||||||
if (!currentRow.value) return;
|
if (!currentRow.value) return;
|
||||||
|
|
||||||
deleteLoading.value = true;
|
deleteLoading.value = true;
|
||||||
try {
|
try {
|
||||||
// 模拟API请求
|
// 模拟API请求
|
||||||
const res = await materialsDel(currentRow.value.id)
|
const res = await materialsDel(currentRow.value.id);
|
||||||
const { code } = res;
|
const { code } = res;
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
ElMessage.success('删除成功');
|
ElMessage.success('删除成功');
|
||||||
deleteDialogVisible.value = false;
|
deleteDialogVisible.value = false;
|
||||||
fetchData();
|
fetchData();
|
||||||
} else {
|
} else {
|
||||||
ElMessage.error('删除失败');
|
ElMessage.error('删除失败');
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
ElMessage.error('删除失败:' + error.message);
|
|
||||||
console.error(error);
|
|
||||||
} finally {
|
|
||||||
deleteLoading.value = false;
|
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error('删除失败:' + error.message);
|
||||||
|
console.error(error);
|
||||||
|
} finally {
|
||||||
|
deleteLoading.value = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 保存
|
// 保存
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
// 表单验证
|
// 表单验证
|
||||||
if (!formRef.value) return;
|
if (!formRef.value) return;
|
||||||
const valid = await formRef.value.validate();
|
const valid = await formRef.value.validate();
|
||||||
if (!valid) return;
|
if (!valid) return;
|
||||||
|
|
||||||
saveLoading.value = true;
|
saveLoading.value = true;
|
||||||
try {
|
try {
|
||||||
// 模拟API请求
|
// 模拟API请求
|
||||||
const form = toRaw(formData);
|
const form = toRaw(formData);
|
||||||
|
|
||||||
if (dialogType.value === 'add') {
|
if (dialogType.value === 'add') {
|
||||||
// 新增
|
// 新增
|
||||||
formData.projectId = currentProject.value?.id;
|
formData.projectId = currentProject.value?.id;
|
||||||
const res = await newMaterialsAdd(formData)
|
const res = await newMaterialsAdd(formData);
|
||||||
let { code } = res
|
let { code } = res;
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
ElMessage.success('新增成功');
|
ElMessage.success('新增成功');
|
||||||
fetchData();
|
fetchData();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 编辑
|
// 编辑
|
||||||
const res = await materialsEdit(formData)
|
const res = await materialsEdit(formData);
|
||||||
let { code } = res
|
let { code } = res;
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
ElMessage.success('保存成功');
|
ElMessage.success('保存成功');
|
||||||
fetchData();
|
fetchData();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
dialogVisible.value = false;
|
|
||||||
} catch (error) {
|
|
||||||
ElMessage.error('保存失败:' + error.message);
|
|
||||||
console.error(error);
|
|
||||||
} finally {
|
|
||||||
saveLoading.value = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dialogVisible.value = false;
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error('保存失败:' + error.message);
|
||||||
|
console.error(error);
|
||||||
|
} finally {
|
||||||
|
saveLoading.value = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 重置表单
|
// 重置表单
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
if (formRef.value) {
|
if (formRef.value) {
|
||||||
formRef.value.resetFields();
|
formRef.value.resetFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重置表单数据
|
// 重置表单数据
|
||||||
Object.keys(formData).forEach(key => {
|
Object.keys(formData).forEach((key) => {
|
||||||
formData[key] = '';
|
formData[key] = '';
|
||||||
});
|
});
|
||||||
|
|
||||||
// 设置默认值
|
// 设置默认值
|
||||||
formData.findType = 1;
|
formData.findType = 1;
|
||||||
formData.id = '';
|
formData.id = '';
|
||||||
};
|
};
|
||||||
// 重置表单
|
// 重置表单
|
||||||
const resetForm2 = () => {
|
const resetForm2 = () => {
|
||||||
if (formRef.value) {
|
if (formRef.value) {
|
||||||
formRef.value.resetFields();
|
formRef.value.resetFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重置表单数据
|
// 重置表单数据
|
||||||
Object.keys(form).forEach(key => {
|
Object.keys(form).forEach((key) => {
|
||||||
form[key] = '';
|
form[key] = '';
|
||||||
});
|
});
|
||||||
|
|
||||||
// 设置默认值
|
// 设置默认值
|
||||||
form.findType = 1;
|
form.findType = 1;
|
||||||
form.id = '';
|
form.id = '';
|
||||||
};
|
};
|
||||||
// 提交表单
|
// 提交表单
|
||||||
|
|
||||||
|
|
||||||
// 关闭对话框
|
// 关闭对话框
|
||||||
const handleDialogClose = () => {
|
const handleDialogClose = () => {
|
||||||
resetForm();
|
resetForm();
|
||||||
dialogVisible.value = false;
|
dialogVisible.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 跳转
|
// 跳转
|
||||||
const jumpRouter = (row) => {
|
const jumpRouter = (row) => {
|
||||||
router.push({
|
router.push({
|
||||||
path: `/materials/usageMaterials/purchaseSon`,
|
path: `/materials/purchaseSon`,
|
||||||
query: {
|
query: {
|
||||||
id: row.id,
|
id: row.id,
|
||||||
type: 'update'
|
type: 'update'
|
||||||
@ -501,33 +510,32 @@ const jumpRouter = (row) => {
|
|||||||
};
|
};
|
||||||
// 初始化页面
|
// 初始化页面
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
fetchData();
|
fetchData();
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
/* 自定义表格行悬停样式 */
|
/* 自定义表格行悬停样式 */
|
||||||
::v-deep .el-table__row:hover>td {
|
::v-deep .el-table__row:hover > td {
|
||||||
background-color: #f0f7ff !important;
|
background-color: #f0f7ff !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 表单间距优化 */
|
/* 表单间距优化 */
|
||||||
::v-deep .el-form-item {
|
::v-deep .el-form-item {
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 对话框动画 */
|
/* 对话框动画 */
|
||||||
::v-deep .el-dialog__wrapper {
|
::v-deep .el-dialog__wrapper {
|
||||||
backdrop-filter: blur(2px);
|
backdrop-filter: blur(2px);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 按钮样式优化 */
|
/* 按钮样式优化 */
|
||||||
::v-deep .el-button--primary {
|
::v-deep .el-button--primary {
|
||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
::v-deep .el-button--primary:hover {
|
::v-deep .el-button--primary:hover {
|
||||||
transform: translateY(-2px);
|
transform: translateY(-2px);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@ -217,6 +217,7 @@ const handleUpdate = async (row?: ConfigVO) => {
|
|||||||
const _id = row?.id || ids.value[0];
|
const _id = row?.id || ids.value[0];
|
||||||
const res = await getConfig(_id);
|
const res = await getConfig(_id);
|
||||||
Object.assign(form.value, res.data);
|
Object.assign(form.value, res.data);
|
||||||
|
form.value.deptId = res.data.projectId ? res.data.projectId : '';
|
||||||
dialog.visible = true;
|
dialog.visible = true;
|
||||||
dialog.title = '修改消息配置';
|
dialog.title = '修改消息配置';
|
||||||
};
|
};
|
||||||
@ -226,6 +227,8 @@ const submitForm = () => {
|
|||||||
configFormRef.value?.validate(async (valid: boolean) => {
|
configFormRef.value?.validate(async (valid: boolean) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
// buttonLoading.value = true;
|
// buttonLoading.value = true;
|
||||||
|
console.log(form.value);
|
||||||
|
|
||||||
if (form.value.id) {
|
if (form.value.id) {
|
||||||
form.value.userId = form.value.userId ? form.value.userId?.join(',') : '';
|
form.value.userId = form.value.userId ? form.value.userId?.join(',') : '';
|
||||||
await updateConfig(form.value).finally(() => (buttonLoading.value = false));
|
await updateConfig(form.value).finally(() => (buttonLoading.value = false));
|
||||||
|
Reference in New Issue
Block a user