From 89f06c79bf5f16b3a0a4d464efb790645c1c011f Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期三, 17 九月 2025 11:26:01 +0800
Subject: [PATCH] yys  退货管理

---
 src/views/procurementManagement/returnManagement/index.vue |  144 ++++++++++++++++++++++++++++++-----------------
 1 files changed, 92 insertions(+), 52 deletions(-)

diff --git a/src/views/procurementManagement/returnManagement/index.vue b/src/views/procurementManagement/returnManagement/index.vue
index d86e524..2a54083 100644
--- a/src/views/procurementManagement/returnManagement/index.vue
+++ b/src/views/procurementManagement/returnManagement/index.vue
@@ -21,7 +21,6 @@
     <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>
 
@@ -42,9 +41,6 @@
             <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 }">
@@ -54,6 +50,14 @@
           </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">
@@ -65,7 +69,9 @@
           </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="璇疯緭鍏ヤ緵搴斿晢鍚嶇О" />
@@ -90,13 +96,49 @@
 </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: '',
@@ -108,25 +150,9 @@
   relatedNo: '',
   supplierName: '',
   returnReason: '',
-  remark: ''
+  remark: '',
+  status: ''
 })
-
-const mockData = [
-  {
-    id: 1,
-    returnNo: 'RT20241201001',
-    relatedNo: 'PO20241201001',
-    returnType: 'purchase',
-    supplierName: '渚涘簲鍟咥',
-    status: 'approved',
-    returnAmount: 500.00,
-    createTime: '2025-12-01 17:30:00',
-    returnReason: '璐ㄩ噺闂',
-    remark: '鍟嗗搧瀛樺湪璐ㄩ噺闂'
-  }
-]
-
-const tableData = ref([...mockData])
 
 const getReturnTypeText = (type) => {
   const typeMap = { purchase: '閲囪喘閫�璐�', quality: '璐ㄦ閫�璐�' }
@@ -145,7 +171,7 @@
 
 const handleSearch = () => {
   loading.value = true
-  setTimeout(() => { loading.value = false }, 500)
+  getList()
 }
 
 const resetSearch = () => {
@@ -154,13 +180,15 @@
 
 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, {
@@ -168,35 +196,43 @@
       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) => {
@@ -205,20 +241,24 @@
     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) => {

--
Gitblit v1.9.3