| | |
| | | <StructureEdit v-if="showEdit" v-model:show-model="showEdit" :record="currentRow" /> |
| | | |
| | | <!-- 新增/编辑弹窗 --> |
| | | <el-dialog v-model="dialogVisible" :title="operationType === 'add' ? '新增BOM' : '编辑BOM'" width="600px" |
| | | <el-dialog v-model="dialogVisible" :title="dialogTitle" width="600px" |
| | | @close="closeDialog"> |
| | | <el-form ref="formRef" :model="form" :rules="rules" label-width="120px"> |
| | | <el-form-item label="产品名称" prop="productModelId"> |
| | | <el-button type="primary" @click="showProductSelectDialog = true"> |
| | | {{ form.productName || '选择产品' }} |
| | | {{ form.productName || form.productModelName || '选择产品' }} |
| | | </el-button> |
| | | </el-form-item> |
| | | <el-form-item label="版本号" prop="version"> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, reactive, toRefs, onMounted, getCurrentInstance, defineAsyncComponent } from "vue"; |
| | | import { ref, reactive, toRefs, computed, onMounted, getCurrentInstance, defineAsyncComponent } from "vue"; |
| | | import { getToken } from "@/utils/auth"; |
| | | import { listPage, add, update, batchDelete, exportBom, downloadTemplate } from "@/api/productionManagement/productBom.js"; |
| | | import { listPage, add, update, copyBom, batchDelete, exportBom, downloadTemplate } from "@/api/productionManagement/productBom.js"; |
| | | import { useRouter } from 'vue-router' |
| | | import { ElMessageBox } from 'element-plus' |
| | | import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue"; |
| | |
| | | label: "操作", |
| | | align: "center", |
| | | fixed: "right", |
| | | width: 150, |
| | | width: 220, |
| | | operation: [ |
| | | { |
| | | name: "编辑", |
| | | type: "text", |
| | | clickFun: (row) => { |
| | | handleEdit(row) |
| | | } |
| | | }, |
| | | { |
| | | name: "复制", |
| | | type: "text", |
| | | clickFun: (row) => { |
| | | handleCopy(row) |
| | | } |
| | | }, |
| | | { |
| | |
| | | const selectedRows = ref([]); |
| | | const currentRow = ref({}); |
| | | const dialogVisible = ref(false); |
| | | const operationType = ref('add'); // add | edit |
| | | const operationType = ref('add'); // add | edit | copy |
| | | const copySourceId = ref(undefined); |
| | | const formRef = ref(null); |
| | | const showProductSelectDialog = ref(false); |
| | | const dialogTitle = computed(() => { |
| | | const titleMap = { |
| | | add: "新增BOM", |
| | | edit: "编辑BOM", |
| | | copy: "复制BOM" |
| | | }; |
| | | return titleMap[operationType.value] || "BOM"; |
| | | }); |
| | | |
| | | // BOM导入参数 |
| | | const upload = reactive({ |
| | |
| | | // 新增 |
| | | const handleAdd = () => { |
| | | operationType.value = 'add'; |
| | | copySourceId.value = undefined; |
| | | Object.assign(form.value, { |
| | | id: undefined, |
| | | productName: "", |
| | |
| | | // 编辑 |
| | | const handleEdit = (row) => { |
| | | operationType.value = 'edit'; |
| | | copySourceId.value = undefined; |
| | | Object.assign(form.value, { |
| | | id: row.id, |
| | | productName: row.productName || "", |
| | |
| | | productModelId: row.productModelId || "", |
| | | remark: row.remark || "", |
| | | version: row.version || "" |
| | | }); |
| | | dialogVisible.value = true; |
| | | }; |
| | | |
| | | // 复制 |
| | | const handleCopy = (row) => { |
| | | operationType.value = 'copy'; |
| | | copySourceId.value = row.id; |
| | | Object.assign(form.value, { |
| | | id: undefined, |
| | | productName: "", |
| | | productModelName: "", |
| | | productModelId: "", |
| | | remark: "", |
| | | version: "" |
| | | }); |
| | | dialogVisible.value = true; |
| | | }; |
| | |
| | | .catch(() => { |
| | | proxy.$modal.msgError('新增失败'); |
| | | }); |
| | | } else { |
| | | } else if (operationType.value === 'edit') { |
| | | update(payload) |
| | | .then(() => { |
| | | proxy.$modal.msgSuccess('修改成功'); |
| | |
| | | .catch(() => { |
| | | proxy.$modal.msgError('修改失败'); |
| | | }); |
| | | } else { |
| | | copyBom({ |
| | | ...payload, |
| | | copyId: copySourceId.value |
| | | }) |
| | | .then(() => { |
| | | proxy.$modal.msgSuccess('复制成功'); |
| | | closeDialog(); |
| | | getList(); |
| | | }) |
| | | .catch(() => { |
| | | proxy.$modal.msgError('复制失败'); |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | |
| | | // 关闭弹窗 |
| | | const closeDialog = () => { |
| | | dialogVisible.value = false; |
| | | copySourceId.value = undefined; |
| | | formRef.value?.resetFields(); |
| | | }; |
| | | |