|
| 1 | +<!-- 可退款的采购退货单列表 --> |
| 2 | +<template> |
| 3 | + <Dialog |
| 4 | + title="选择采购退货(仅展示可退款)" |
| 5 | + v-model="dialogVisible" |
| 6 | + :appendToBody="true" |
| 7 | + :scroll="true" |
| 8 | + width="1080" |
| 9 | + > |
| 10 | + <ContentWrap> |
| 11 | + <!-- 搜索工作栏 --> |
| 12 | + <el-form |
| 13 | + class="-mb-15px" |
| 14 | + :model="queryParams" |
| 15 | + ref="queryFormRef" |
| 16 | + :inline="true" |
| 17 | + label-width="68px" |
| 18 | + > |
| 19 | + <el-form-item label="退货单号" prop="no"> |
| 20 | + <el-input |
| 21 | + v-model="queryParams.no" |
| 22 | + placeholder="请输入退货单号" |
| 23 | + clearable |
| 24 | + @keyup.enter="handleQuery" |
| 25 | + class="!w-160px" |
| 26 | + /> |
| 27 | + </el-form-item> |
| 28 | + <el-form-item label="产品" prop="productId"> |
| 29 | + <el-select |
| 30 | + v-model="queryParams.productId" |
| 31 | + clearable |
| 32 | + filterable |
| 33 | + placeholder="请选择产品" |
| 34 | + class="!w-160px" |
| 35 | + > |
| 36 | + <el-option |
| 37 | + v-for="item in productList" |
| 38 | + :key="item.id" |
| 39 | + :label="item.name" |
| 40 | + :value="item.id" |
| 41 | + /> |
| 42 | + </el-select> |
| 43 | + </el-form-item> |
| 44 | + <el-form-item label="退货时间" prop="orderTime"> |
| 45 | + <el-date-picker |
| 46 | + v-model="queryParams.inTime" |
| 47 | + value-format="YYYY-MM-DD HH:mm:ss" |
| 48 | + type="daterange" |
| 49 | + start-placeholder="开始日期" |
| 50 | + end-placeholder="结束日期" |
| 51 | + :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" |
| 52 | + class="!w-160px" |
| 53 | + /> |
| 54 | + </el-form-item> |
| 55 | + <el-form-item> |
| 56 | + <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> |
| 57 | + <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> |
| 58 | + </el-form-item> |
| 59 | + </el-form> |
| 60 | + </ContentWrap> |
| 61 | + |
| 62 | + <ContentWrap> |
| 63 | + <el-table |
| 64 | + v-loading="loading" |
| 65 | + :data="list" |
| 66 | + :show-overflow-tooltip="true" |
| 67 | + :stripe="true" |
| 68 | + @selection-change="handleSelectionChange" |
| 69 | + > |
| 70 | + <el-table-column width="30" label="选择" type="selection" /> |
| 71 | + <el-table-column min-width="180" label="退货单号" align="center" prop="no" /> |
| 72 | + <el-table-column label="供应商" align="center" prop="supplierName" /> |
| 73 | + <el-table-column label="产品信息" align="center" prop="productNames" min-width="200" /> |
| 74 | + <el-table-column |
| 75 | + label="退货时间" |
| 76 | + align="center" |
| 77 | + prop="returnTime" |
| 78 | + :formatter="dateFormatter2" |
| 79 | + width="120px" |
| 80 | + /> |
| 81 | + <el-table-column label="创建人" align="center" prop="creatorName" /> |
| 82 | + <el-table-column |
| 83 | + label="应退金额" |
| 84 | + align="center" |
| 85 | + prop="totalPrice" |
| 86 | + :formatter="erpPriceTableColumnFormatter" |
| 87 | + /> |
| 88 | + <el-table-column |
| 89 | + label="已退金额" |
| 90 | + align="center" |
| 91 | + prop="refundPrice" |
| 92 | + :formatter="erpPriceTableColumnFormatter" |
| 93 | + /> |
| 94 | + <el-table-column label="未退金额" align="center"> |
| 95 | + <template #default="scope"> |
| 96 | + <span v-if="scope.row.refundPrice === scope.row.totalPrice">0</span> |
| 97 | + <el-tag type="danger" v-else> |
| 98 | + {{ erpPriceInputFormatter(scope.row.totalPrice - scope.row.refundPrice) }} |
| 99 | + </el-tag> |
| 100 | + </template> |
| 101 | + </el-table-column> |
| 102 | + </el-table> |
| 103 | + <!-- 分页 --> |
| 104 | + <Pagination |
| 105 | + v-model:limit="queryParams.pageSize" |
| 106 | + v-model:page="queryParams.pageNo" |
| 107 | + :total="total" |
| 108 | + @pagination="getList" |
| 109 | + /> |
| 110 | + </ContentWrap> |
| 111 | + <template #footer> |
| 112 | + <el-button :disabled="!selectionList.length" type="primary" @click="submitForm"> |
| 113 | + 确 定 |
| 114 | + </el-button> |
| 115 | + <el-button @click="dialogVisible = false">取 消</el-button> |
| 116 | + </template> |
| 117 | + </Dialog> |
| 118 | +</template> |
| 119 | +<script lang="ts" setup> |
| 120 | +import { ElTable } from 'element-plus' |
| 121 | +import { dateFormatter2 } from '@/utils/formatTime' |
| 122 | +import { erpPriceInputFormatter, erpPriceTableColumnFormatter } from '@/utils' |
| 123 | +import { ProductApi, ProductVO } from '@/api/erp/product/product' |
| 124 | +import { PurchaseReturnApi, PurchaseReturnVO } from '@/api/erp/purchase/return' |
| 125 | +import { PurchaseInVO } from '@/api/erp/purchase/in' |
| 126 | +
|
| 127 | +defineOptions({ name: 'PurchaseInPaymentEnableList' }) |
| 128 | +
|
| 129 | +const list = ref<PurchaseReturnVO[]>([]) // 列表的数据 |
| 130 | +const total = ref(0) // 列表的总页数 |
| 131 | +const loading = ref(false) // 列表的加载中 |
| 132 | +const dialogVisible = ref(false) // 弹窗的是否展示 |
| 133 | +const queryParams = reactive({ |
| 134 | + pageNo: 1, |
| 135 | + pageSize: 10, |
| 136 | + no: undefined, |
| 137 | + productId: undefined, |
| 138 | + inTime: [], |
| 139 | + refundEnable: true, |
| 140 | + supplierId: undefined |
| 141 | +}) |
| 142 | +const queryFormRef = ref() // 搜索的表单 |
| 143 | +const productList = ref<ProductVO[]>([]) // 产品列表 |
| 144 | +
|
| 145 | +/** 选中操作 */ |
| 146 | +const selectionList = ref<PurchaseInVO[]>([]) |
| 147 | +const handleSelectionChange = (rows: PurchaseInVO[]) => { |
| 148 | + selectionList.value = rows |
| 149 | +} |
| 150 | +
|
| 151 | +/** 打开弹窗 */ |
| 152 | +const open = async (supplierId: number) => { |
| 153 | + dialogVisible.value = true |
| 154 | + await nextTick() // 等待,避免 queryFormRef 为空 |
| 155 | + // 加载列表 |
| 156 | + queryParams.supplierId = supplierId |
| 157 | + await resetQuery() |
| 158 | + // 加载产品列表 |
| 159 | + productList.value = await ProductApi.getProductSimpleList() |
| 160 | +} |
| 161 | +defineExpose({ open }) // 提供 open 方法,用于打开弹窗 |
| 162 | +
|
| 163 | +/** 提交选择 */ |
| 164 | +const emits = defineEmits<{ |
| 165 | + (e: 'success', value: PurchaseInVO[]): void |
| 166 | +}>() |
| 167 | +const submitForm = () => { |
| 168 | + try { |
| 169 | + emits('success', selectionList.value) |
| 170 | + } finally { |
| 171 | + // 关闭弹窗 |
| 172 | + dialogVisible.value = false |
| 173 | + } |
| 174 | +} |
| 175 | +
|
| 176 | +/** 加载列表 */ |
| 177 | +const getList = async () => { |
| 178 | + loading.value = true |
| 179 | + try { |
| 180 | + const data = await PurchaseReturnApi.getPurchaseReturnPage(queryParams) |
| 181 | + list.value = data.list |
| 182 | + total.value = data.total |
| 183 | + } finally { |
| 184 | + loading.value = false |
| 185 | + } |
| 186 | +} |
| 187 | +
|
| 188 | +/** 重置按钮操作 */ |
| 189 | +const resetQuery = () => { |
| 190 | + queryFormRef.value.resetFields() |
| 191 | + handleQuery() |
| 192 | +} |
| 193 | +
|
| 194 | +/** 搜索按钮操作 */ |
| 195 | +const handleQuery = () => { |
| 196 | + queryParams.pageNo = 1 |
| 197 | + selectionList.value = [] |
| 198 | + getList() |
| 199 | +} |
| 200 | +</script> |
0 commit comments