基础信息页:编辑弹窗新增另存为新项功能(清主键+切标题+清脏检查基准,复用 addMaterialBase 接口)
This commit is contained in:
@ -370,15 +370,26 @@
|
|||||||
<template #header>
|
<template #header>
|
||||||
<div style="display: flex; align-items: center; justify-content: space-between; padding-right: 20px;">
|
<div style="display: flex; align-items: center; justify-content: space-between; padding-right: 20px;">
|
||||||
<span style="font-size: 18px; font-weight: 500;">{{ dialog.title }}</span>
|
<span style="font-size: 18px; font-weight: 500;">{{ dialog.title }}</span>
|
||||||
<el-link
|
<div style="display: flex; align-items: center; gap: 16px;">
|
||||||
v-if="form.id"
|
<el-link
|
||||||
type="success"
|
v-if="form.id"
|
||||||
:underline="false"
|
type="primary"
|
||||||
style="font-size: 14px;"
|
:underline="false"
|
||||||
@click="createBomForMaterial"
|
style="font-size: 14px;"
|
||||||
>
|
@click="handleSaveAs"
|
||||||
<el-icon style="margin-right: 4px"><Plus /></el-icon>加入或查看BOM
|
>
|
||||||
</el-link>
|
<el-icon style="margin-right: 4px"><DocumentCopy /></el-icon>另存为新项
|
||||||
|
</el-link>
|
||||||
|
<el-link
|
||||||
|
v-if="form.id"
|
||||||
|
type="success"
|
||||||
|
:underline="false"
|
||||||
|
style="font-size: 14px;"
|
||||||
|
@click="createBomForMaterial"
|
||||||
|
>
|
||||||
|
<el-icon style="margin-right: 4px"><Plus /></el-icon>加入或查看BOM
|
||||||
|
</el-link>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="110px">
|
<el-form ref="formRef" :model="form" :rules="rules" label-width="110px">
|
||||||
@ -659,7 +670,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted, nextTick, computed, watch } from 'vue';
|
import { ref, reactive, onMounted, nextTick, computed, watch } from 'vue';
|
||||||
import { Plus, Document, Refresh, Setting, Rank, Camera, Link, Download, Bell, CircleCheck, Files, ZoomIn, Delete, Picture } from '@element-plus/icons-vue';
|
import { Plus, Document, DocumentCopy, Refresh, Setting, Rank, Camera, Link, Download, Bell, CircleCheck, Files, ZoomIn, Delete, Picture } from '@element-plus/icons-vue';
|
||||||
import { ElMessage, ElMessageBox, ElLoading } from 'element-plus';
|
import { ElMessage, ElMessageBox, ElLoading } from 'element-plus';
|
||||||
import type { FormInstance, FormRules } from 'element-plus';
|
import type { FormInstance, FormRules } from 'element-plus';
|
||||||
import { useUserStore } from '@/stores/user';
|
import { useUserStore } from '@/stores/user';
|
||||||
@ -1357,6 +1368,23 @@ const handleEdit = (row: MaterialBaseVO) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 另存为新项:把当前编辑项的数据复制一份,转为"新增"模式提交
|
||||||
|
const handleSaveAs = () => {
|
||||||
|
if (!form.value.id) return; // 防御:新增模式下不该看到此按钮
|
||||||
|
|
||||||
|
// 1. 清除主键:submitForm 用 form.value.id 判空决定走 add / update 接口
|
||||||
|
delete form.value.id;
|
||||||
|
|
||||||
|
// 2. 切换弹窗标题(项目沿用 dialog.title 命名,无 dialogType / isEdit 变量)
|
||||||
|
dialog.title = '新增基础信息';
|
||||||
|
|
||||||
|
// 3. 清空脏检查基准:让 submitForm 走"完整 payload"分支(新增模式)
|
||||||
|
originalForm.value = null;
|
||||||
|
|
||||||
|
// 4. 提示用户
|
||||||
|
ElMessage.success('已成功复制当前数据,已切换至【新增】模式。请修改特定信息(如规格型号)后点击确定保存。');
|
||||||
|
};
|
||||||
|
|
||||||
const checkDuplicate = async (name: string, spec: string): Promise<boolean> => {
|
const checkDuplicate = async (name: string, spec: string): Promise<boolean> => {
|
||||||
try {
|
try {
|
||||||
const nameRes: any = await listMaterialBase({ pageNum: 1, pageSize: 100, keyword: name, category: '', type: '', company: '' });
|
const nameRes: any = await listMaterialBase({ pageNum: 1, pageSize: 100, keyword: name, category: '', type: '', company: '' });
|
||||||
|
|||||||
Reference in New Issue
Block a user