<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.returnNo" placeholder="请输入退货单号" clearable />
|
</el-form-item>
|
<el-form-item label="退货类型:" style="width: 300px;">
|
<el-select v-model="searchForm.returnType" placeholder="请选择类型" clearable>
|
<el-option label="采购退货" value="purchase" />
|
<el-option label="质检退货" value="quality" />
|
</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="handleBatchApprove">批量审核</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="returnNo" width="180" />
|
<el-table-column label="关联单号" prop="relatedNo" width="180" />
|
<el-table-column label="退货类型" prop="returnType" width="100">
|
<template #default="{ row }">
|
<el-tag :type="row.returnType === 'purchase' ? 'danger' : 'warning'">
|
{{ getReturnTypeText(row.returnType) }}
|
</el-tag>
|
</template>
|
</el-table-column>
|
<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="returnAmount" width="120">
|
<template #default="{ row }">¥{{ row.returnAmount.toFixed(2) }}</template>
|
</el-table-column>
|
<el-table-column label="创建时间" prop="createTime" 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="handleApprove(row)" v-if="row.status === 'pending'">审核</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="600px">
|
<el-form :model="formData" label-width="120px">
|
<el-form-item label="退货类型">
|
<el-select v-model="formData.returnType" placeholder="请选择退货类型" style="width: 100%">
|
<el-option label="采购退货" value="purchase" />
|
<el-option label="质检退货" value="quality" />
|
</el-select>
|
</el-form-item>
|
<el-form-item label="关联单号">
|
<el-input v-model="formData.relatedNo" placeholder="请输入关联单号" />
|
</el-form-item>
|
<el-form-item label="供应商名称">
|
<el-input v-model="formData.supplierName" placeholder="请输入供应商名称" />
|
</el-form-item>
|
<el-form-item label="退货原因">
|
<el-select v-model="formData.returnReason" placeholder="请选择退货原因" style="width: 100%">
|
<el-option label="质量问题" value="quality" />
|
<el-option label="规格不符" value="specification" />
|
<el-option label="数量错误" value="quantity" />
|
</el-select>
|
</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({
|
returnNo: '',
|
returnType: ''
|
})
|
|
const formData = reactive({
|
returnType: '',
|
relatedNo: '',
|
supplierName: '',
|
returnReason: '',
|
remark: ''
|
})
|
|
const mockData = [
|
{
|
id: 1,
|
returnNo: 'RT20241201001',
|
relatedNo: 'PO20241201001',
|
returnType: 'purchase',
|
supplierName: '供应商A',
|
status: 'approved',
|
returnAmount: 500.00,
|
createTime: '2024-12-01 17:30:00',
|
returnReason: '质量问题',
|
remark: '商品存在质量问题'
|
}
|
]
|
|
const tableData = ref([...mockData])
|
|
const getReturnTypeText = (type) => {
|
const typeMap = { purchase: '采购退货', quality: '质检退货' }
|
return typeMap[type] || '未知'
|
}
|
|
const getStatusType = (status) => {
|
const statusMap = { pending: 'warning', approved: 'success', returned: 'info' }
|
return statusMap[status] || 'info'
|
}
|
|
const getStatusText = (status) => {
|
const statusMap = { pending: '待审核', approved: '已审核', returned: '已退货' }
|
return statusMap[status] || '未知'
|
}
|
|
const handleSearch = () => {
|
loading.value = true
|
setTimeout(() => { loading.value = false }, 500)
|
}
|
|
const resetSearch = () => {
|
Object.assign(searchForm, { returnNo: '', returnType: '' })
|
}
|
|
const openDialog = (type, row = {}) => {
|
dialogType.value = type
|
if (type === 'edit' && row.id) {
|
Object.assign(formData, {
|
returnType: row.returnType,
|
relatedNo: row.relatedNo,
|
supplierName: row.supplierName,
|
returnReason: row.returnReason,
|
remark: row.remark
|
})
|
} else {
|
Object.assign(formData, {
|
returnType: '',
|
relatedNo: '',
|
supplierName: '',
|
returnReason: '',
|
remark: ''
|
})
|
}
|
dialogVisible.value = true
|
}
|
|
const handleSubmit = () => {
|
if (dialogType.value === 'add') {
|
const newReturn = {
|
id: Date.now(),
|
returnNo: `RT${Date.now()}`,
|
relatedNo: formData.relatedNo,
|
returnType: formData.returnType,
|
supplierName: formData.supplierName,
|
status: 'pending',
|
returnAmount: 0,
|
createTime: new Date().toLocaleString(),
|
returnReason: formData.returnReason,
|
remark: formData.remark
|
}
|
tableData.value.unshift(newReturn)
|
ElMessage.success('新增成功')
|
}
|
dialogVisible.value = false
|
}
|
|
const handleApprove = (row) => {
|
row.status = 'approved'
|
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 handleBatchApprove = () => {
|
ElMessage.success('批量审核成功')
|
}
|
|
const handleBatchDelete = () => {
|
ElMessage.success('批量删除成功')
|
}
|
|
const handleSelectionChange = (rows) => {
|
selectedRows.value = rows
|
}
|
</script>
|
|
<style scoped>
|
.app-container { padding: 20px; }
|
.search-card { margin-bottom: 20px; }
|
.table-card { margin-bottom: 20px; }
|
.table-header { margin-bottom: 20px; }
|
</style>
|