¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <el-card class="search-card" shadow="never"> |
| | | <el-form :model="searchForm" :inline="true"> |
| | | <el-form-item label="è´¨æ£åå·ï¼" style="width: 300px;"> |
| | | <el-input v-model="searchForm.inspectionNo" placeholder="请è¾å
¥è´¨æ£åå·" clearable /> |
| | | </el-form-item> |
| | | <el-form-item label="è´¨æ£ç¶æï¼" style="width: 300px;"> |
| | | <el-select v-model="searchForm.status" placeholder="è¯·éæ©ç¶æ" clearable> |
| | | <el-option label="å¾
è´¨æ£" value="pending" /> |
| | | <el-option label="è´¨æ£ä¸" value="inspecting" /> |
| | | <el-option label="已宿" value="completed" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="handleSearch">æç´¢</el-button> |
| | | <el-button @click="resetSearch">éç½®</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </el-card> |
| | | |
| | | <el-card class="table-card" shadow="never"> |
| | | <div class="table-header"> |
| | | <el-button type="primary" @click="openDialog('add')">æ°å¢è´¨æ£å</el-button> |
| | | <el-button type="success" @click="handleBatchComplete">æ¹é宿</el-button> |
| | | <el-button type="danger" @click="handleBatchDelete">æ¹éå é¤</el-button> |
| | | </div> |
| | | |
| | | <el-table :data="tableData" border v-loading="loading" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column label="è´¨æ£åå·" prop="inspectionNo" width="180" /> |
| | | <el-table-column label="å°è´§åå·" prop="arrivalNo" width="180" /> |
| | | <el-table-column label="ä¾åºååç§°" prop="supplierName" /> |
| | | <el-table-column label="è´¨æ£ç¶æ" prop="status" width="100"> |
| | | <template #default="{ row }"> |
| | | <el-tag :type="getStatusType(row.status)">{{ getStatusText(row.status) }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="åæ ¼æ°é" prop="qualifiedQuantity" width="100" /> |
| | | <el-table-column label="ä¸åæ ¼æ°é" prop="unqualifiedQuantity" width="100" /> |
| | | <el-table-column label="è´¨æ£æ¶é´" prop="inspectionTime" width="180" /> |
| | | <el-table-column label="æä½" width="200" align="center"> |
| | | <template #default="{ row }"> |
| | | <el-button type="primary" link @click="openDialog('edit', row)">ç¼è¾</el-button> |
| | | <el-button type="success" link @click="handleComplete(row)" v-if="row.status !== 'completed'">宿</el-button> |
| | | <el-button type="danger" link @click="handleDelete(row)">å é¤</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </el-card> |
| | | |
| | | <el-dialog v-model="dialogVisible" :title="dialogType === 'add' ? 'æ°å¢è´¨æ£å' : 'ç¼è¾è´¨æ£å'" width="1000px"> |
| | | <el-form :model="formData" label-width="120px"> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="å°è´§åå·"> |
| | | <el-select v-model="formData.arrivalNo" placeholder="è¯·éæ©å°è´§å" style="width: 100%"> |
| | | <el-option label="AR20241201001" value="AR20241201001" /> |
| | | <el-option label="AR20241201002" value="AR20241201002" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="ä¾åºååç§°"> |
| | | <el-input v-model="formData.supplierName" placeholder="ä¾åºååç§°" readonly /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | |
| | | <el-form-item label="è´¨æ£åå"> |
| | | <div class="product-list" style="width: 100%;"> |
| | | <el-table :data="formData.products" border width="100%"> |
| | | <el-table-column label="åååç§°" width="150"> |
| | | <template #default="{ row }"> |
| | | <el-input v-model="row.productName" placeholder="请è¾å
¥åååç§°" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="è§æ ¼åå·" width="150"> |
| | | <template #default="{ row }"> |
| | | <el-input v-model="row.specification" placeholder="请è¾å
¥è§æ ¼åå·" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="å°è´§æ°é" width="150"> |
| | | <template #default="{ row }"> |
| | | <el-input-number v-model="row.arrivalQuantity" :min="0" placeholder="æ°é" style="width: 100%;"/> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="åæ ¼æ°é" width="150"> |
| | | <template #default="{ row }"> |
| | | <el-input-number v-model="row.qualifiedQuantity" :min="0" placeholder="æ°é" style="width: 100%;"/> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="ä¸åæ ¼æ°é" width="150"> |
| | | <template #default="{ row }"> |
| | | <el-input-number v-model="row.unqualifiedQuantity" :min="0" placeholder="æ°é" style="width: 100%;"/> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="ä¸åæ ¼åå " width="200"> |
| | | <template #default="{ row }"> |
| | | <el-input v-model="row.unqualifiedReason" placeholder="请è¾å
¥ä¸åæ ¼åå " /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="æä½" width="100"> |
| | | <template #default="{ $index }"> |
| | | <el-button type="danger" link @click="removeProduct($index)">å é¤</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <div class="add-product-btn"> |
| | | <el-button type="primary" @click="addProduct">æ·»å åå</el-button> |
| | | </div> |
| | | </div> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="è´¨æ£å"> |
| | | <el-input v-model="formData.inspector" placeholder="请è¾å
¥è´¨æ£åå§å" /> |
| | | </el-form-item> |
| | | |
| | | <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> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, reactive } from 'vue' |
| | | import { ElMessage, ElMessageBox } from 'element-plus' |
| | | |
| | | const loading = ref(false) |
| | | const dialogVisible = ref(false) |
| | | const dialogType = ref('add') |
| | | const selectedRows = ref([]) |
| | | |
| | | const searchForm = reactive({ |
| | | inspectionNo: '', |
| | | status: '' |
| | | }) |
| | | |
| | | const formData = reactive({ |
| | | arrivalNo: '', |
| | | supplierName: '', |
| | | products: [], |
| | | inspector: '', |
| | | remark: '' |
| | | }) |
| | | |
| | | const mockData = [ |
| | | { |
| | | id: 1, |
| | | inspectionNo: 'QI20241201001', |
| | | arrivalNo: 'AR20241201001', |
| | | supplierName: 'ä¾åºåA', |
| | | status: 'completed', |
| | | qualifiedQuantity: 240, |
| | | unqualifiedQuantity: 10, |
| | | inspectionTime: '2025-12-01 16:30:00', |
| | | inspector: 'éå¿å¼º', |
| | | remark: 'è´¨æ£å®æ' |
| | | } |
| | | ] |
| | | |
| | | const tableData = ref([...mockData]) |
| | | |
| | | const getStatusType = (status) => { |
| | | const statusMap = { pending: 'info', inspecting: 'warning', completed: 'success' } |
| | | return statusMap[status] || 'info' |
| | | } |
| | | |
| | | const getStatusText = (status) => { |
| | | const statusMap = { pending: 'å¾
è´¨æ£', inspecting: 'è´¨æ£ä¸', completed: '已宿' } |
| | | return statusMap[status] || 'æªç¥' |
| | | } |
| | | |
| | | const handleSearch = () => { |
| | | loading.value = true |
| | | setTimeout(() => { loading.value = false }, 500) |
| | | } |
| | | |
| | | const resetSearch = () => { |
| | | Object.assign(searchForm, { inspectionNo: '', status: '' }) |
| | | } |
| | | |
| | | const openDialog = (type, row = {}) => { |
| | | dialogType.value = type |
| | | if (type === 'edit' && row.id) { |
| | | Object.assign(formData, { |
| | | arrivalNo: row.arrivalNo, |
| | | supplierName: row.supplierName, |
| | | inspector: row.inspector, |
| | | remark: row.remark |
| | | }) |
| | | } else { |
| | | Object.assign(formData, { |
| | | arrivalNo: '', |
| | | supplierName: '', |
| | | products: [], |
| | | inspector: '', |
| | | remark: '' |
| | | }) |
| | | } |
| | | dialogVisible.value = true |
| | | } |
| | | |
| | | const handleSubmit = () => { |
| | | if (dialogType.value === 'add') { |
| | | const newInspection = { |
| | | id: Date.now(), |
| | | inspectionNo: `QI${Date.now()}`, |
| | | arrivalNo: formData.arrivalNo, |
| | | supplierName: formData.supplierName, |
| | | status: 'pending', |
| | | qualifiedQuantity: 0, |
| | | unqualifiedQuantity: 0, |
| | | inspectionTime: new Date().toLocaleString(), |
| | | inspector: formData.inspector, |
| | | remark: formData.remark |
| | | } |
| | | tableData.value.unshift(newInspection) |
| | | ElMessage.success('æ°å¢æå') |
| | | } |
| | | dialogVisible.value = false |
| | | } |
| | | |
| | | const handleComplete = (row) => { |
| | | row.status = 'completed' |
| | | ElMessage.success('è´¨æ£å®æ') |
| | | } |
| | | |
| | | const handleDelete = (row) => { |
| | | ElMessageBox.confirm('ç¡®å®è¦å é¤è¿æ¡è®°å½åï¼', 'æç¤º', { |
| | | confirmButtonText: 'ç¡®å®', |
| | | cancelButtonText: 'åæ¶', |
| | | type: 'warning' |
| | | }).then(() => { |
| | | const index = tableData.value.findIndex(item => item.id === row.id) |
| | | if (index !== -1) { |
| | | tableData.value.splice(index, 1) |
| | | ElMessage.success('å 餿å') |
| | | } |
| | | }) |
| | | } |
| | | |
| | | const handleBatchComplete = () => { |
| | | ElMessage.success('æ¹é宿æå') |
| | | } |
| | | |
| | | const handleBatchDelete = () => { |
| | | ElMessage.success('æ¹éå 餿å') |
| | | } |
| | | |
| | | const handleSelectionChange = (rows) => { |
| | | selectedRows.value = rows |
| | | } |
| | | |
| | | const addProduct = () => { |
| | | formData.products.push({ |
| | | productName: '', |
| | | specification: '', |
| | | arrivalQuantity: 0, |
| | | qualifiedQuantity: 0, |
| | | unqualifiedQuantity: 0, |
| | | unqualifiedReason: '' |
| | | }) |
| | | } |
| | | |
| | | const removeProduct = (index) => { |
| | | formData.products.splice(index, 1) |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .app-container { padding: 20px; } |
| | | .search-card { margin-bottom: 20px; } |
| | | .table-card { margin-bottom: 20px; } |
| | | .table-header { margin-bottom: 20px; } |
| | | .product-list { border: 1px solid #dcdfe6; border-radius: 4px; padding: 15px; } |
| | | .product-item { margin-bottom: 15px; padding: 10px; background-color: #f5f7fa; border-radius: 4px; } |
| | | .add-product-btn { margin-top: 15px; text-align: center; } |
| | | </style> |