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/api/procurementManagement/returnManagement.js           |   35 +++++
 src/api/procurementManagement/arrivalManagement.js          |   43 ++++++
 src/views/procurementManagement/arrivalManagement/index.vue |  149 ++++++++++++++-------
 src/views/salesManagement/paymentShipping/index.vue         |    8 
 src/views/procurementManagement/returnManagement/index.vue  |  144 +++++++++++++-------
 5 files changed, 274 insertions(+), 105 deletions(-)

diff --git a/src/api/procurementManagement/arrivalManagement.js b/src/api/procurementManagement/arrivalManagement.js
new file mode 100644
index 0000000..107fc3c
--- /dev/null
+++ b/src/api/procurementManagement/arrivalManagement.js
@@ -0,0 +1,43 @@
+// 閿�鍞彴璐﹂〉闈㈡帴鍙�
+import request from "@/utils/request";
+
+// 鍒嗛〉鏌ヨ
+export function listPage(query) {
+    return request({
+        url: "/inboundManagement/listPage",
+        method: "get",
+        params: query,
+    });
+}
+
+export function listPageCopy(query) {
+    return request({
+        url: "/inboundManagement/listPage",
+        method: "get",
+        params: query,
+    });
+}
+// 鏂板
+export function add(data) {
+    return request({
+        url: "/inboundManagement/add",
+        method: "post",
+        data
+    });
+}
+// 淇敼
+export function update(data) {
+    return request({
+        url: "/inboundManagement/update",
+        method: "post",
+        data
+    });
+}
+// 鍒犻櫎閿�鍞彴璐�
+export function del(data) {
+    return request({
+        url: "/inboundManagement/del",
+        method: "delete",
+        data
+    });
+}
\ No newline at end of file
diff --git a/src/api/procurementManagement/returnManagement.js b/src/api/procurementManagement/returnManagement.js
new file mode 100644
index 0000000..e765701
--- /dev/null
+++ b/src/api/procurementManagement/returnManagement.js
@@ -0,0 +1,35 @@
+// 閿�鍞彴璐﹂〉闈㈡帴鍙�
+import request from "@/utils/request";
+
+// 鍒嗛〉鏌ヨ
+export function listPage(query) {
+    return request({
+        url: "/returnManagement/listPage",
+        method: "get",
+        params: query,
+    });
+}
+// 鏂板
+export function add(data) {
+    return request({
+        url: "/returnManagement/add",
+        method: "post",
+        data
+    });
+}
+// 淇敼
+export function update(data) {
+    return request({
+        url: "/returnManagement/update",
+        method: "post",
+        data
+    });
+}
+// 鍒犻櫎閿�鍞彴璐�
+export function del(data) {
+    return request({
+        url: "/returnManagement/del",
+        method: "delete",
+        data
+    });
+}
\ No newline at end of file
diff --git a/src/views/procurementManagement/arrivalManagement/index.vue b/src/views/procurementManagement/arrivalManagement/index.vue
index d2c89b1..060d2f1 100644
--- a/src/views/procurementManagement/arrivalManagement/index.vue
+++ b/src/views/procurementManagement/arrivalManagement/index.vue
@@ -18,7 +18,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="handleBatchReceive">鎵归噺鏀惰揣</el-button>
         <el-button type="danger" @click="handleBatchDelete">鎵归噺鍒犻櫎</el-button>
       </div>
 
@@ -37,23 +36,34 @@
         <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="handleReceive(row)">鏀惰揣</el-button>
+            <el-button type="success" v-if="row.status === 'pending'" link @click="handleReceive(row)">鏀惰揣</el-button>
             <el-button type="danger" link @click="handleDelete(row)">鍒犻櫎</el-button>
           </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-form :model="formData" label-width="120px">
+        <el-form-item label="鍒拌揣鍗曞彿">
+          <el-input v-model="formData.arrivalNo" placeholder="鍒拌揣鍗曞彿" />
+        </el-form-item>
         <el-form-item label="閲囪喘璁㈠崟鍙�">
-          <el-select v-model="formData.orderNo" placeholder="璇烽�夋嫨閲囪喘璁㈠崟" style="width: 100%">
-            <el-option label="PO20241201001" value="PO20241201001" />
-            <el-option label="PO20241201002" value="PO20241201002" />
-          </el-select>
+          <el-input v-model="formData.orderNo" placeholder="閲囪喘璁㈠崟鍙�" />
         </el-form-item>
         <el-form-item label="渚涘簲鍟嗗悕绉�">
           <el-input v-model="formData.supplierName" placeholder="渚涘簲鍟嗗悕绉�" />
+        </el-form-item>
+        <el-form-item label="鍒拌揣鏁伴噺">
+          <el-input-number  :min="0" v-model="formData.arrivalQuantity" placeholder="鍒拌揣鏁伴噺" />
         </el-form-item>
         <el-form-item label="澶囨敞">
           <el-input v-model="formData.remark" type="textarea" :rows="3" placeholder="璇疯緭鍏ュ娉ㄤ俊鎭�" />
@@ -68,8 +78,40 @@
 </template>
 
 <script setup>
-import { ref, reactive } from 'vue'
+import { ref, reactive,onMounted } from 'vue'
 import { ElMessage, ElMessageBox } from 'element-plus'
+import {listPage,add,update,del} from "@/api/procurementManagement/arrivalManagement.js"
+import Pagination from '@/components/PIMTable/Pagination.vue'
+
+onMounted(() => {
+    getList()
+})
+
+const tableData = ref([])
+
+const getList = () => {
+  loading.value = true
+  listPage({...searchForm,...pagination}).then(res =>{
+    if(res.code === 200){
+      tableData.value = res.data.records
+      total.value = res.data.total
+      loading.value = false
+    }
+  })
+}
+
+const pagination = reactive({
+  current: 1,
+  size: 10
+})
+
+const total = ref(0)
+
+const handleCurrentChange = (val) => {
+  pagination.current = val.page
+  pagination.size = val.limit
+  getList()
+}
 
 const loading = ref(false)
 const dialogVisible = ref(false)
@@ -82,25 +124,13 @@
 })
 
 const formData = reactive({
+  arrivalNo: '',
+  arrivalQuantity: 0,
   orderNo: '',
   supplierName: '',
-  remark: ''
+  remark: '',
+  status: 'pending'
 })
-
-const mockData = [
-  {
-    id: 1,
-    arrivalNo: 'AR20241201001',
-    orderNo: 'PO20241201001',
-    supplierName: '渚涘簲鍟咥',
-    status: 'received',
-    arrivalQuantity: 250,
-    arrivalTime: '2025-12-01 15:30:00',
-    remark: '姝e父鍒拌揣'
-  }
-]
-
-const tableData = ref([...mockData])
 
 const getStatusType = (status) => {
   const statusMap = { pending: 'warning', received: 'success', stored: 'info' }
@@ -114,7 +144,7 @@
 
 const handleSearch = () => {
   loading.value = true
-  setTimeout(() => { loading.value = false }, 500)
+  getList()
 }
 
 const resetSearch = () => {
@@ -124,34 +154,45 @@
 const openDialog = (type, row = {}) => {
   dialogType.value = type
   if (type === 'edit' && row.id) {
-    Object.assign(formData, { orderNo: row.orderNo, supplierName: row.supplierName, remark: row.remark })
+    obj.id = row.id
+    Object.assign(formData, { orderNo: row.orderNo, supplierName: row.supplierName, remark: row.remark, arrivalQuantity: row.arrivalQuantity,arrivalNo: row.arrivalNo })
   } else {
-    Object.assign(formData, { orderNo: '', supplierName: '', remark: '' })
+    Object.assign(formData, { orderNo: '', supplierName: '', remark: '',arrivalQuantity: 0,arrivalNo: '' })
   }
   dialogVisible.value = true
 }
 
+const obj = reactive({
+  id:''
+})
+
 const handleSubmit = () => {
   if (dialogType.value === 'add') {
-    const newArrival = {
-      id: Date.now(),
-      arrivalNo: `AR${Date.now()}`,
-      orderNo: formData.orderNo,
-      supplierName: formData.supplierName,
-      status: 'pending',
-      arrivalQuantity: 0,
-      arrivalTime: new Date().toLocaleString(),
-      remark: formData.remark
-    }
-    tableData.value.unshift(newArrival)
-    ElMessage.success('鏂板鎴愬姛')
+    add(formData).then(res => {
+      if(res.code === 200){
+        ElMessage.success('鏂板鎴愬姛')
+        getList()
+      }
+    })
+  }else{
+    update({...formData, ...obj}).then(res => {
+      if(res.code === 200){
+        ElMessage.success('缂栬緫鎴愬姛')
+        getList()
+      }
+    })
   }
   dialogVisible.value = false
 }
 
 const handleReceive = (row) => {
   row.status = 'received'
-  ElMessage.success('鏀惰揣鎴愬姛')
+  update(row).then(res => {
+    if(res.code === 200){
+      ElMessage.success('鏀惰揣鎴愬姛')
+      getList()
+    }
+  })
 }
 
 const handleDelete = (row) => {
@@ -160,20 +201,30 @@
     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 handleBatchReceive = () => {
-  ElMessage.success('鎵归噺鏀惰揣鎴愬姛')
-}
-
 const handleBatchDelete = () => {
-  ElMessage.success('鎵归噺鍒犻櫎鎴愬姛')
+  ElMessageBox.confirm('纭畾瑕佸垹闄ら�変腑鐨勮褰曞悧锛�', '鎻愮ず', {
+    confirmButtonText: '纭畾',
+    cancelButtonText: '鍙栨秷',
+    type: 'warning'
+  }).then(() => {
+    let ids = selectedRows.value.map(item => item.id)
+    del(ids).then(res => {
+      if(res.code === 200){
+        ElMessage.success('鍒犻櫎鎴愬姛')
+        getList()
+      }
+    })
+  })
 }
 
 const handleSelectionChange = (rows) => {
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) => {
diff --git a/src/views/salesManagement/paymentShipping/index.vue b/src/views/salesManagement/paymentShipping/index.vue
index ae59d08..0bcfd87 100644
--- a/src/views/salesManagement/paymentShipping/index.vue
+++ b/src/views/salesManagement/paymentShipping/index.vue
@@ -91,8 +91,8 @@
       <pagination
         :total="total"
         layout="total, sizes, prev, pager, next, jumper"
-        :page="pagination.currentPage"
-        :limit="pagination.pageSize"
+        :page="pagination.current"
+        :limit="pagination.size"
         @pagination="handleCurrentChange"
       />
     </el-card>
@@ -496,8 +496,8 @@
 }
 
 const handleCurrentChange = (val) => {
-  pagination.currentPage = val.page
-  pagination.pageSize = val.limit
+  pagination.current = val.page
+  pagination.size = val.limit
 }
 </script>
 

--
Gitblit v1.9.3