| | |
| | | </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.inspector" placeholder="请输入质检员姓名" /> |
| | | </el-form-item> |
| | | |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="创建时间"> |
| | | <el-date-picker v-model="formCreateTimeDate" |
| | | type="date" |
| | | placeholder="选择日期" |
| | | value-format="YYYY-MM-DD" |
| | | style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | |
| | | <el-form-item label="备注"> |
| | | <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 { ref, reactive } from 'vue' |
| | | import FormDialog from '@/components/Dialog/FormDialog.vue'; |
| | | import { ref, reactive, computed } from 'vue' |
| | | import dayjs from 'dayjs' |
| | | import { ElMessage, ElMessageBox } from 'element-plus' |
| | | |
| | | const loading = ref(false) |
| | |
| | | supplierName: '', |
| | | products: [], |
| | | inspector: '', |
| | | remark: '' |
| | | remark: '', |
| | | createTime: '' |
| | | }) |
| | | const formCreateTimeDate = computed({ |
| | | get: () => (formData.createTime ? String(formData.createTime).split(' ')[0] : ''), |
| | | set: (value) => { |
| | | formData.createTime = value ? `${value} ${dayjs().format('HH:mm:ss')}` : '' |
| | | } |
| | | }) |
| | | |
| | | const mockData = [ |
| | |
| | | arrivalNo: row.arrivalNo, |
| | | supplierName: row.supplierName, |
| | | inspector: row.inspector, |
| | | remark: row.remark |
| | | remark: row.remark, |
| | | createTime: row.createTime || '' |
| | | }) |
| | | } else { |
| | | Object.assign(formData, { |
| | | arrivalNo: '', |
| | | supplierName: '', |
| | | Object.assign(formData, { |
| | | arrivalNo: '', |
| | | supplierName: '', |
| | | products: [], |
| | | inspector: '', |
| | | remark: '' |
| | | inspector: '', |
| | | remark: '', |
| | | createTime: dayjs().format('YYYY-MM-DD HH:mm:ss') |
| | | }) |
| | | } |
| | | dialogVisible.value = true |
| | | } |
| | | |
| | | 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(), |
| | | inspectionNo: `QI${Date.now()}`, |
| | | inspectionNo: '', |
| | | arrivalNo: formData.arrivalNo, |
| | | supplierName: formData.supplierName, |
| | | status: 'pending', |
| | | qualifiedQuantity: 0, |
| | | unqualifiedQuantity: 0, |
| | | inspectionTime: new Date().toLocaleString(), |
| | | qualifiedQuantity: totalQualified, |
| | | unqualifiedQuantity: totalUnqualified, |
| | | inspectionTime: formData.createTime, |
| | | inspector: formData.inspector, |
| | | remark: formData.remark |
| | | } |