| | |
| | | </el-table> |
| | | </el-card> |
| | | |
| | | <el-dialog v-model="dialogVisible" :title="dialogType === 'add' ? '新增质检单' : '编辑质检单'" width="1000px"> |
| | | <FormDialog v-model="dialogVisible" :title="dialogType === 'add' ? '新增质检单' : '编辑质检单'" :width="'1000px'" :operation-type="dialogType" @close="dialogVisible = false" @confirm="handleSubmit" @cancel="dialogVisible = false"> |
| | | <el-form :model="formData" label-width="120px"> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="供应商名称"> |
| | | <el-input v-model="formData.supplierName" placeholder="供应商名称" readonly /> |
| | | <el-input v-model="formData.supplierName" placeholder="供应商名称" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | <el-input v-model="formData.remark" type="textarea" :rows="3" placeholder="请输入备注信息" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <el-button @click="dialogVisible = false">取消</el-button> |
| | | <el-button type="primary" @click="handleSubmit">确定</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | </FormDialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import FormDialog from '@/components/Dialog/FormDialog.vue'; |
| | | import { ref, reactive } from 'vue' |
| | | import { ElMessage, ElMessageBox } from 'element-plus' |
| | | |
| | |
| | | status: 'completed', |
| | | qualifiedQuantity: 240, |
| | | unqualifiedQuantity: 10, |
| | | inspectionTime: '2024-12-01 16:30:00', |
| | | inspector: '张三', |
| | | inspectionTime: '2025-12-01 16:30:00', |
| | | inspector: '陈志强', |
| | | remark: '质检完成' |
| | | } |
| | | ] |
| | |
| | | } |
| | | |
| | | const handleSubmit = () => { |
| | | if (!formData.products || formData.products.length === 0) { |
| | | ElMessage.error('请至少添加一条质检商品') |
| | | return |
| | | } |
| | | |
| | | for (let i = 0; i < formData.products.length; i++) { |
| | | const product = formData.products[i] |
| | | if (product.qualifiedQuantity === null || product.qualifiedQuantity === undefined) { |
| | | ElMessage.error(`第${i + 1}条商品的合格数量不能为空`) |
| | | return |
| | | } |
| | | if (product.unqualifiedQuantity === null || product.unqualifiedQuantity === undefined) { |
| | | ElMessage.error(`第${i + 1}条商品的不合格数量不能为空`) |
| | | return |
| | | } |
| | | } |
| | | |
| | | const totalQualified = formData.products.reduce((sum, p) => sum + (p.qualifiedQuantity || 0), 0) |
| | | const totalUnqualified = formData.products.reduce((sum, p) => sum + (p.unqualifiedQuantity || 0), 0) |
| | | |
| | | if (dialogType.value === 'add') { |
| | | const newInspection = { |
| | | id: Date.now(), |
| | |
| | | arrivalNo: formData.arrivalNo, |
| | | supplierName: formData.supplierName, |
| | | status: 'pending', |
| | | qualifiedQuantity: 0, |
| | | unqualifiedQuantity: 0, |
| | | qualifiedQuantity: totalQualified, |
| | | unqualifiedQuantity: totalUnqualified, |
| | | inspectionTime: new Date().toLocaleString(), |
| | | inspector: formData.inspector, |
| | | remark: formData.remark |