| | |
| | | disabled /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="批号:" |
| | | prop="batchNo"> |
| | | <el-input v-model="productForm.batchNo" |
| | | clearable |
| | | placeholder="选填,可输入批号;留空将自动生成" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | |
| | | productModelId: "", |
| | | specificationModel: "", |
| | | materialCode: "", |
| | | batchNo: "", |
| | | unit: "", |
| | | quantity: "", |
| | | taxInclusiveUnitPrice: "", |
| | |
| | | return newItem; |
| | | }); |
| | | } |
| | | |
| | | /** 与库存新增一致:未填批号时前端生成(PH + 时间戳 + 随机数) */ |
| | | const generateProductBatchNo = () => { |
| | | const d = new Date(); |
| | | const pad = (n) => String(n).padStart(2, "0"); |
| | | const ts = `${d.getFullYear()}${pad(d.getMonth() + 1)}${pad(d.getDate())}${pad(d.getHours())}${pad(d.getMinutes())}${pad(d.getSeconds())}`; |
| | | const r = Math.floor(Math.random() * 10000) |
| | | .toString() |
| | | .padStart(4, "0"); |
| | | return `PH${ts}${r}`; |
| | | }; |
| | | |
| | | const ensureProductBatchNo = () => { |
| | | const v = (productForm.value.batchNo ?? "").toString().trim(); |
| | | productForm.value.batchNo = v || generateProductBatchNo(); |
| | | }; |
| | | |
| | | // 提交产品表单 |
| | | const submitProduct = () => { |
| | | proxy.$refs["productFormRef"].validate(valid => { |
| | | if (valid) { |
| | | ensureProductBatchNo(); |
| | | if (operationType.value === "edit") { |
| | | submitProductEdit(); |
| | | } else { |