| | |
| | | <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-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 }"> |
| | |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!-- 分页 --> |
| | | <pagination |
| | | :total="total" |
| | | layout="total, sizes, prev, pager, next, jumper" |
| | | :page="pagination.current" |
| | | :limit="pagination.size" |
| | | @pagination="handleCurrentChange" |
| | | /> |
| | | </el-card> |
| | | |
| | | <el-dialog v-model="dialogVisible" :title="dialogType === 'add' ? '新增退货单' : '编辑退货单'" width="600px"> |
| | |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="关联单号"> |
| | | <el-input v-model="formData.relatedNo" placeholder="请输入关联单号" /> |
| | | <el-select v-model="formData.relatedNo" placeholder="请选择关联单号" style="width: 100%"> |
| | | <el-option v-for="item in onList" :key="item.arrivalNo" :label="item.arrivalNo" :value="item.arrivalNo" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="供应商名称"> |
| | | <el-input v-model="formData.supplierName" placeholder="请输入供应商名称" /> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, reactive } from 'vue' |
| | | import { ref, reactive,onMounted } from 'vue' |
| | | import { ElMessage, ElMessageBox } from 'element-plus' |
| | | import Pagination from '@/components/PIMTable/Pagination.vue' |
| | | import {listPage,add,update,del} from "@/api/procurementManagement/returnManagement.js" |
| | | import {listPageCopy} from "@/api/procurementManagement/arrivalManagement.js" |
| | | |
| | | onMounted(() => { |
| | | getList() |
| | | list() |
| | | }) |
| | | const onList = ref([]) |
| | | const list = () =>{ |
| | | listPageCopy({current:-1}).then(res=>{ |
| | | if(res.code === 200){ |
| | | onList.value = res.data.records |
| | | } |
| | | }) |
| | | } |
| | | const tableData = ref([]) |
| | | const getList = () => { |
| | | loading.value = true |
| | | listPage({...searchForm,...pagination}).then(res =>{ |
| | | if(res.code === 200){ |
| | | tableData.value = res.data.records |
| | | console.log(tableData.value) |
| | | total.value = res.data.total |
| | | loading.value = false |
| | | } |
| | | }) |
| | | } |
| | | |
| | | const loading = ref(false) |
| | | const dialogVisible = ref(false) |
| | | const dialogType = ref('add') |
| | | const selectedRows = ref([]) |
| | | |
| | | |
| | | const pagination = reactive({ |
| | | current: 1, |
| | | size: 10 |
| | | }) |
| | | |
| | | const total = ref(0) |
| | | |
| | | const searchForm = reactive({ |
| | | returnNo: '', |
| | |
| | | relatedNo: '', |
| | | supplierName: '', |
| | | returnReason: '', |
| | | remark: '' |
| | | remark: '', |
| | | status: '' |
| | | }) |
| | | |
| | | 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: '质检退货' } |
| | |
| | | |
| | | const handleSearch = () => { |
| | | loading.value = true |
| | | setTimeout(() => { loading.value = false }, 500) |
| | | getList() |
| | | } |
| | | |
| | | const resetSearch = () => { |
| | |
| | | |
| | | const openDialog = (type, row = {}) => { |
| | | dialogType.value = type |
| | | obj.id = row.id |
| | | if (type === 'edit' && row.id) { |
| | | Object.assign(formData, { |
| | | returnType: row.returnType, |
| | | relatedNo: row.relatedNo, |
| | | supplierName: row.supplierName, |
| | | returnReason: row.returnReason, |
| | | remark: row.remark |
| | | remark: row.remark, |
| | | status: row.status |
| | | }) |
| | | } else { |
| | | Object.assign(formData, { |
| | |
| | | relatedNo: '', |
| | | supplierName: '', |
| | | returnReason: '', |
| | | remark: '' |
| | | remark: '', |
| | | status: 'pending' |
| | | }) |
| | | } |
| | | dialogVisible.value = true |
| | | } |
| | | |
| | | const obj = reactive({ |
| | | id: '' |
| | | }) |
| | | 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 |
| | | formData.status = 'pending' |
| | | add(formData).then(res => { |
| | | if(res.code === 200){ |
| | | ElMessage.success('新增成功') |
| | | getList() |
| | | } |
| | | tableData.value.unshift(newReturn) |
| | | ElMessage.success('新增成功') |
| | | }) |
| | | }else{ |
| | | update({...formData,...obj}).then(res => { |
| | | if(res.code === 200){ |
| | | ElMessage.success('修改成功') |
| | | getList() |
| | | } |
| | | }) |
| | | } |
| | | dialogVisible.value = false |
| | | } |
| | | |
| | | const handleApprove = (row) => { |
| | | row.status = 'approved' |
| | | ElMessage.success('审核通过') |
| | | update(row).then(res => { |
| | | if(res.code === 200){ |
| | | ElMessage.success('审核成功') |
| | | getList() |
| | | } |
| | | }) |
| | | } |
| | | |
| | | const handleDelete = (row) => { |
| | |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | }).then(() => { |
| | | const index = tableData.value.findIndex(item => item.id === row.id) |
| | | if (index !== -1) { |
| | | tableData.value.splice(index, 1) |
| | | ElMessage.success('删除成功') |
| | | } |
| | | let ids = [row.id] |
| | | del(ids).then(res => { |
| | | if(res.code === 200){ |
| | | ElMessage.success('删除成功') |
| | | getList() |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | const handleBatchApprove = () => { |
| | | ElMessage.success('批量审核成功') |
| | | } |
| | | |
| | | const handleBatchDelete = () => { |
| | | ElMessage.success('批量删除成功') |
| | | let ids = selectedRows.value.map(item => item.id) |
| | | del(ids).then(res => { |
| | | if(res.code === 200){ |
| | | ElMessage.success('批量删除成功') |
| | | getList() |
| | | } |
| | | }) |
| | | } |
| | | |
| | | const handleSelectionChange = (rows) => { |