| | |
| | | <div class="right"> |
| | | <div style="margin-bottom: 10px" v-if="isShowButton"> |
| | | <el-button type="primary" @click="openModelDia('add')"> |
| | | 新增规格型号 |
| | | 新增产品高度 |
| | | </el-button> |
| | | <ImportExcel @uploadSuccess="getModelList" /> |
| | | <el-button |
| | |
| | | </el-dialog> |
| | | <el-dialog |
| | | v-model="modelDia" |
| | | title="规格型号" |
| | | title="产品高度" |
| | | width="400px" |
| | | @close="closeModelDia" |
| | | @keydown.enter.prevent |
| | |
| | | > |
| | | <el-row> |
| | | <el-col :span="24"> |
| | | <el-form-item label="规格型号:" prop="model"> |
| | | <el-form-item label="产品高度:" prop="model"> |
| | | <el-input |
| | | v-model="modelForm.model" |
| | | placeholder="请输入规格型号" |
| | | placeholder="请输入产品高度" |
| | | clearable |
| | | @keydown.enter.prevent |
| | | /> |
| | |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="24"> |
| | | <el-form-item label="单位:" prop="unit"> |
| | | <el-form-item label="高度单位:" prop="unit"> |
| | | <el-input |
| | | v-model="modelForm.unit" |
| | | placeholder="请输入单位" |
| | | placeholder="请输入高度单位" |
| | | clearable |
| | | @keydown.enter.prevent |
| | | /> |
| | |
| | | const expandedKeys = ref([]); |
| | | const tableColumn = ref([ |
| | | { |
| | | label: "规格型号", |
| | | label: "产品高度", |
| | | prop: "model", |
| | | }, |
| | | { |
| | | label: "单位", |
| | | label: "高度单位", |
| | | prop: "unit", |
| | | }, |
| | | { |
| | |
| | | form.value.productName = data.productName; |
| | | } |
| | | }; |
| | | // 打开规格型号弹框 |
| | | // 打开产品高度弹框 |
| | | const openModelDia = (type, data) => { |
| | | modelOperationType.value = type; |
| | | modelDia.value = true; |
| | |
| | | proxy.$refs.formRef.resetFields(); |
| | | productDia.value = false; |
| | | }; |
| | | // 封装一个安全的确认框,彻底阻止Enter键触发 |
| | | const safeConfirm = (message, title) => { |
| | | // 标记是否是鼠标点击(点击按钮会触发focus事件) |
| | | let isMouseClick = false; |
| | | |
| | | return new Promise((resolve, reject) => { |
| | | const box = ElMessageBox.confirm(message, title, { |
| | | confirmButtonText: "确认", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | beforeClose: (action, instance, done) => { |
| | | if (action === "confirm") { |
| | | // 只有鼠标点击时才允许确认 |
| | | if (isMouseClick) { |
| | | done(); |
| | | resolve(); |
| | | } else { |
| | | // Enter键触发时阻止 |
| | | done(false); |
| | | } |
| | | } else { |
| | | // 取消操作直接允许 |
| | | done(); |
| | | reject(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | // 监听确认按钮的focus事件(鼠标点击会触发,Enter键不会) |
| | | setTimeout(() => { |
| | | const confirmBtn = document.querySelector('.el-message-box__btns .el-button--primary'); |
| | | if (confirmBtn) { |
| | | confirmBtn.addEventListener('focus', () => { |
| | | isMouseClick = true; |
| | | }); |
| | | } |
| | | }, 0); // 延迟获取,确保DOM已渲染 |
| | | }); |
| | | }; |
| | | // 删除产品 |
| | | // 删除产品 |
| | | const remove = (node, data) => { |
| | | let ids = [data.id]; |
| | | // 使用封装的safeConfirm |
| | | safeConfirm("选中的内容将被删除,是否确认删除?", "删除提示") |
| | | let ids = []; |
| | | ids.push(data.id); |
| | | ElMessageBox.confirm("选中的内容将被删除,是否确认删除?", "删除提示", { |
| | | confirmButtonText: "确认", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | // 确认删除逻辑 |
| | | tableLoading.value = true; |
| | | delProduct(ids) |
| | | .then((res) => { |
| | |
| | | proxy.$modal.msgWarning("请选择数据"); |
| | | return; |
| | | } |
| | | safeConfirm("选中的内容将被删除,是否确认删除?", "删除提示") |
| | | ElMessageBox.confirm("选中的内容将被删除,是否确认删除?", "删除提示", { |
| | | confirmButtonText: "确认", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | tableLoading.value = true; |
| | | delProductModel(ids) |