From ea6ad9ddc3d5b33897e93276282245f7023836ff Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期四, 28 八月 2025 17:45:28 +0800
Subject: [PATCH] 大数据市场分析

---
 src/views/sales/purchaseReturn.vue |  462 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 462 insertions(+), 0 deletions(-)

diff --git a/src/views/sales/purchaseReturn.vue b/src/views/sales/purchaseReturn.vue
new file mode 100644
index 0000000..b84cc10
--- /dev/null
+++ b/src/views/sales/purchaseReturn.vue
@@ -0,0 +1,462 @@
+<template>
+  <div class="app-container">
+    <el-form :inline="true" :model="queryParams" class="search-form">
+      <el-form-item label="閫�璐у崟鍙�">
+        <el-input
+          v-model="queryParams.returnNo"
+          placeholder="璇疯緭鍏ラ��璐у崟鍙�"
+          clearable
+          :style="{ width: '200px' }"
+        />
+      </el-form-item>
+      <el-form-item label="渚涘簲鍟�">
+        <el-select
+          v-model="queryParams.supplierId"
+          placeholder="璇烽�夋嫨渚涘簲鍟�"
+          clearable
+          :style="{ width: '200px' }"
+        >
+          <el-option
+            :label="item.label"
+            v-for="item in supplierList"
+            :key="item.value"
+            :value="item.value"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="鐘舵��">
+        <el-select
+          v-model="queryParams.status"
+          placeholder="璇烽�夋嫨鐘舵��"
+          clearable
+          :style="{ width: '150px' }"
+        >
+          <el-option
+            :label="item.label"
+            v-for="item in statusList"
+            :key="item.value"
+            :value="item.value"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="鍗曟嵁鏃ユ湡">
+        <el-date-picker
+          v-model="queryParams.dateRange"
+          type="daterange"
+          range-separator="鑷�"
+          start-placeholder="寮�濮嬫棩鏈�"
+          end-placeholder="缁撴潫鏃ユ湡"
+          format="YYYY-MM-DD"
+          value-format="YYYY-MM-DD"
+          :style="{ width: '240px' }"
+        />
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" @click="handleQuery">鏌ヨ</el-button>
+        <el-button @click="resetQuery">閲嶇疆</el-button>
+      </el-form-item>
+    </el-form>
+
+    <el-card>
+      <!-- 鎿嶄綔鎸夐挳鍖� -->
+      <el-row :gutter="24" class="table-toolbar" justify="space-between">
+        <el-button type="primary" :icon="Plus" @click="handleAdd">
+          鏂板閫�璐у崟
+        </el-button>
+        <el-button type="success" :icon="Refresh" @click="handleGenerateReturn">
+          涓�閿敓鎴愰��璐у崟
+        </el-button>
+        <el-button type="danger" :icon="Delete" @click="handleBatchDelete" :disabled="selectedIds.length === 0">
+          鎵归噺鍒犻櫎
+        </el-button>
+      </el-row>
+
+      <!-- 琛ㄦ牸缁勪欢 -->
+      <el-table
+        v-loading="loading"
+        :data="tableData"
+        @selection-change="handleSelectionChange"
+        border
+        style="width: 100%"
+      >
+        <el-table-column type="selection" width="55" />
+        <el-table-column label="閫�璐у崟鍙�" prop="returnNo" width="180" />
+        <el-table-column label="渚涘簲鍟�" prop="supplierName" width="200" />
+        <el-table-column label="鍗曟嵁鏃ユ湡" prop="returnDate" width="120" />
+        <el-table-column label="鎿嶄綔鍛�" prop="operatorName" width="120" />
+        <el-table-column label="閫�璐у師鍥�" prop="returnReason" width="200" show-overflow-tooltip />
+        <el-table-column label="閫�璐ф暟閲�" prop="returnQuantity" width="120">
+          <template #default="scope">
+            {{ scope.row.returnQuantity }} 鍚�
+          </template>
+        </el-table-column>
+        <el-table-column label="鐘舵��" prop="status" width="100">
+          <template #default="scope">
+            <el-tag :type="getStatusType(scope.row.status)">
+              {{ getStatusText(scope.row.status) }}
+            </el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column label="鍒涘缓鏃堕棿" prop="createTime" width="160" />
+        <el-table-column label="鎿嶄綔" width="200" fixed="right">
+          <template #default="scope">
+            <el-button
+              size="small"
+              type="primary"
+              @click="handleView(scope.row)"
+            >
+              鏌ョ湅
+            </el-button>
+            <el-button
+              size="small"
+              type="warning"
+              @click="handleEdit(scope.row)"
+              v-if="scope.row.status === 'draft'"
+            >
+              缂栬緫
+            </el-button>
+            <el-button
+              size="small"
+              type="danger"
+              @click="handleDelete(scope.row)"
+              v-if="scope.row.status === 'draft'"
+            >
+              鍒犻櫎
+            </el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+
+      <!-- 鍒嗛〉缁勪欢 -->
+      <pagination
+        v-if="total > 0"
+        :page="current"
+        :limit="pageSize"
+        :total="total"
+        @pagination="handlePagination"
+        :layout="'total, prev, pager, next, jumper'"
+      />
+    </el-card>
+
+    <!-- 鏂板/缂栬緫瀵硅瘽妗� -->
+    <PurchaseReturnDialog
+      v-model:dialogFormVisible="dialogFormVisible"
+      v-model:form="form"
+      :title="title"
+      :is-edit="isEdit"
+      @submit="handleSubmit"
+      @success="handleSuccess"
+      ref="purchaseReturnDialog"
+    />
+
+    <!-- 鏌ョ湅璇︽儏瀵硅瘽妗� -->
+    <PurchaseReturnViewDialog
+      v-model:dialogViewVisible="dialogViewVisible"
+      :form="viewForm"
+      title="閫�璐у崟璇︽儏"
+    />
+
+    <!-- 涓�閿敓鎴愰��璐у崟瀵硅瘽妗� -->
+    <GenerateReturnDialog
+      v-model:dialogGenerateVisible="dialogGenerateVisible"
+      @success="handleGenerateSuccess"
+    />
+  </div>
+</template>
+
+<script setup>
+import { ref, reactive, onMounted, getCurrentInstance } from "vue";
+import { ElMessage, ElMessageBox } from "element-plus";
+import { Plus, Edit, Delete, Refresh, View } from "@element-plus/icons-vue";
+import Pagination from "@/components/Pagination";
+import PurchaseReturnDialog from "./components/PurchaseReturnDialog.vue";
+import PurchaseReturnViewDialog from "./components/PurchaseReturnViewDialog.vue";
+import GenerateReturnDialog from "./components/GenerateReturnDialog.vue";
+
+// 鍝嶅簲寮忔暟鎹�
+const loading = ref(false);
+const tableData = ref([]);
+const selectedIds = ref([]);
+const current = ref(1);
+const pageSize = ref(10);
+const total = ref(0);
+const dialogFormVisible = ref(false);
+const dialogViewVisible = ref(false);
+const dialogGenerateVisible = ref(false);
+const isEdit = ref(false);
+const title = ref("");
+const form = ref({});
+const viewForm = ref({});
+
+// 鏌ヨ鍙傛暟
+const queryParams = reactive({
+  returnNo: "",
+  supplierId: "",
+  status: "",
+  dateRange: []
+});
+
+// 渚涘簲鍟嗗垪琛�
+const supplierList = ref([
+  { value: "1", label: "渚涘簲鍟咥" },
+  { value: "2", label: "渚涘簲鍟咮" },
+  { value: "3", label: "渚涘簲鍟咰" }
+]);
+
+// 鐘舵�佸垪琛�
+const statusList = ref([
+  { value: "draft", label: "鑽夌" },
+  { value: "pending", label: "寰呭鏍�" },
+  { value: "approved", label: "宸插鏍�" },
+  { value: "rejected", label: "宸叉嫆缁�" },
+  { value: "completed", label: "宸插畬鎴�" }
+]);
+
+// 妯℃嫙鏁版嵁
+const mockData = [
+  {
+    id: "1",
+    returnNo: "TH20241201001",
+    supplierName: "渚涘簲鍟咥",
+    returnDate: "2024-12-01",
+    operatorName: "闄堝織寮�",
+    returnReason: "璐ㄩ噺涓嶅悎鏍硷紝鐓よ川涓嶇鍚堣姹�",
+    returnQuantity: 50,
+    status: "pending",
+    createTime: "2024-12-01 10:00:00"
+  },
+  {
+    id: "2",
+    returnNo: "TH20241201002",
+    supplierName: "渚涘簲鍟咮",
+    returnDate: "2024-12-01",
+    operatorName: "鍒樼編鐜�",
+    returnReason: "浜よ揣婊炲悗锛屽奖鍝嶇敓浜ц鍒�",
+    returnQuantity: 30,
+    status: "approved",
+    createTime: "2024-12-01 14:30:00"
+  }
+];
+
+// 鑾峰彇鐘舵�佺被鍨�
+const getStatusType = (status) => {
+  const statusMap = {
+    draft: "",
+    pending: "warning",
+    approved: "success",
+    rejected: "danger",
+    completed: "info"
+  };
+  return statusMap[status] || "";
+};
+
+// 鑾峰彇鐘舵�佹枃鏈�
+const getStatusText = (status) => {
+  const statusMap = {
+    draft: "鑽夌",
+    pending: "寰呭鏍�",
+    approved: "宸插鏍�",
+    rejected: "宸叉嫆缁�",
+    completed: "宸插畬鎴�"
+  };
+  return statusMap[status] || status;
+};
+
+// 鏌ヨ
+const handleQuery = () => {
+  current.value = 1;
+  loadData();
+};
+
+// 閲嶇疆鏌ヨ
+const resetQuery = () => {
+  Object.assign(queryParams, {
+    returnNo: "",
+    supplierId: "",
+    status: "",
+    dateRange: []
+  });
+  handleQuery();
+};
+
+// 鍔犺浇鏁版嵁
+const loadData = () => {
+  loading.value = true;
+  // 妯℃嫙API璋冪敤
+  setTimeout(() => {
+    tableData.value = mockData;
+    total.value = mockData.length;
+    loading.value = false;
+  }, 500);
+};
+
+// 鍒嗛〉澶勭悊
+const handlePagination = (pagination) => {
+  current.value = pagination.page;
+  pageSize.value = pagination.limit;
+  loadData();
+};
+
+// 閫夋嫨鍙樺寲
+const handleSelectionChange = (selection) => {
+  selectedIds.value = selection.map(item => item.id);
+};
+
+// 鏂板
+const handleAdd = () => {
+  isEdit.value = false;
+  title.value = "鏂板閫�璐у崟";
+  form.value = {
+    supplierId: "",
+    returnDate: "",
+    operatorId: "",
+    returnReason: "",
+    returnQuantity: "",
+    returnAmount: "",
+    returnItems: [],
+    remark: ""
+  };
+  dialogFormVisible.value = true;
+};
+
+// 缂栬緫
+const handleEdit = (row) => {
+  isEdit.value = true;
+  title.value = "缂栬緫閫�璐у崟";
+  form.value = { ...row };
+  dialogFormVisible.value = true;
+};
+
+// 鏌ョ湅
+const handleView = (row) => {
+  viewForm.value = { ...row };
+  dialogViewVisible.value = true;
+};
+
+// 鍒犻櫎
+const handleDelete = (row) => {
+  ElMessageBox.confirm(
+    `纭畾瑕佸垹闄ら��璐у崟 ${row.returnNo} 鍚楋紵`,
+    "鎻愮ず",
+    {
+      confirmButtonText: "纭畾",
+      cancelButtonText: "鍙栨秷",
+      type: "warning"
+    }
+  ).then(() => {
+    // 妯℃嫙鍒犻櫎
+    const index = tableData.value.findIndex(item => item.id === row.id);
+    if (index > -1) {
+      tableData.value.splice(index, 1);
+      total.value--;
+      ElMessage.success("鍒犻櫎鎴愬姛");
+    }
+  });
+};
+
+// 鎵归噺鍒犻櫎
+const handleBatchDelete = () => {
+  if (selectedIds.value.length === 0) {
+    ElMessage.warning("璇烽�夋嫨瑕佸垹闄ょ殑璁板綍");
+    return;
+  }
+  
+  ElMessageBox.confirm(
+    `纭畾瑕佸垹闄ら�変腑鐨� ${selectedIds.value.length} 鏉¤褰曞悧锛焋,
+    "鎻愮ず",
+    {
+      confirmButtonText: "纭畾",
+      cancelButtonText: "鍙栨秷",
+      type: "warning"
+    }
+  ).then(() => {
+    // 妯℃嫙鎵归噺鍒犻櫎
+    tableData.value = tableData.value.filter(item => !selectedIds.value.includes(item.id));
+    total.value = tableData.value.length;
+    selectedIds.value = [];
+    ElMessage.success("鎵归噺鍒犻櫎鎴愬姛");
+  });
+};
+
+// 涓�閿敓鎴愰��璐у崟
+const handleGenerateReturn = () => {
+  dialogGenerateVisible.value = true;
+};
+
+// 鎻愪氦琛ㄥ崟
+const handleSubmit = (formData) => {
+  if (isEdit.value) {
+    // 缂栬緫
+    const index = tableData.value.findIndex(item => item.id === formData.id);
+    if (index > -1) {
+      tableData.value[index] = { ...formData };
+      ElMessage.success("缂栬緫鎴愬姛");
+    }
+  } else {
+    // 鏂板
+    const newItem = {
+      id: Date.now().toString(),
+      returnNo: `TH${Date.now()}`,
+      supplierName: supplierList.value.find(item => item.value === formData.supplierId)?.label || "",
+      returnDate: formData.returnDate,
+      operatorName: "褰撳墠鐢ㄦ埛",
+      returnReason: formData.returnReason,
+      returnQuantity: formData.returnQuantity,
+      status: "draft",
+      createTime: new Date().toLocaleString()
+    };
+    tableData.value.unshift(newItem);
+    total.value++;
+    ElMessage.success("鏂板鎴愬姛");
+  }
+  dialogFormVisible.value = false;
+};
+
+// 琛ㄥ崟鎴愬姛鍥炶皟
+const handleSuccess = () => {
+  loadData();
+};
+
+// 鐢熸垚閫�璐у崟鎴愬姛鍥炶皟
+const handleGenerateSuccess = (returnOrder) => {
+  dialogGenerateVisible.value = false;
+  // 灏嗙敓鎴愮殑閫�璐у崟娣诲姞鍒板垪琛ㄤ腑
+  if (returnOrder) {
+    const newItem = {
+      id: Date.now().toString(),
+      returnNo: returnOrder.returnNo,
+      supplierName: returnOrder.supplierName,
+      returnDate: returnOrder.returnDate,
+      operatorName: returnOrder.operatorName,
+      returnReason: returnOrder.returnReason,
+      returnQuantity: returnOrder.returnQuantity,
+      status: returnOrder.status,
+      createTime: returnOrder.createTime,
+      returnItems: returnOrder.returnItems
+    };
+    tableData.value.unshift(newItem);
+    total.value++;
+  }
+  loadData();
+  ElMessage.success("閫�璐у崟鐢熸垚鎴愬姛");
+};
+
+// 椤甸潰鍔犺浇
+onMounted(() => {
+  loadData();
+});
+</script>
+
+<style scoped>
+.search-form {
+  margin-bottom: 20px;
+}
+
+.table-toolbar {
+  margin-bottom: 20px;
+}
+
+.el-card {
+  margin-bottom: 20px;
+}
+</style>

--
Gitblit v1.9.3