From bfff831304d65d948613e3774364bb29bebaeb0c Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 15 六月 2026 09:20:18 +0800
Subject: [PATCH] pro 1.数据模拟前端页面

---
 src/views/financialManagement/receivable/salesOut.vue |  394 +++++++++++++++++++++++---------------------------------
 1 files changed, 163 insertions(+), 231 deletions(-)

diff --git a/src/views/financialManagement/receivable/salesOut.vue b/src/views/financialManagement/receivable/salesOut.vue
index 034f2b9..f6205d8 100644
--- a/src/views/financialManagement/receivable/salesOut.vue
+++ b/src/views/financialManagement/receivable/salesOut.vue
@@ -1,19 +1,33 @@
 <template>
+  <!-- 閿�鍞嚭搴� -->
   <div class="app-container">
-    <el-form :model="filters" :inline="true">
+    <el-form :model="filters"
+             :inline="true">
       <el-form-item label="鍑哄簱鍗曞彿:">
-        <el-input v-model="filters.outCode" placeholder="璇疯緭鍏ュ嚭搴撳崟鍙�" clearable style="width: 200px;" />
+        <el-input v-model="filters.outboundBatches"
+                  placeholder="璇疯緭鍏ュ嚭搴撳崟鍙�"
+                  clearable
+                  style="width: 200px;" />
       </el-form-item>
-      <el-form-item label="瀹㈡埛:">
-        <el-select v-model="filters.customerId" placeholder="璇烽�夋嫨瀹㈡埛" clearable style="width: 200px;">
-          <el-option v-for="item in customerList" :key="item.id" :label="item.name" :value="item.id" />
-        </el-select>
+      <el-form-item label="瀹㈡埛鍚嶇О:">
+        <el-input v-model="filters.customerName"
+                  placeholder="璇疯緭鍏ュ鎴峰悕绉�"
+                  clearable
+                  style="width: 200px;" />
       </el-form-item>
       <el-form-item label="鍑哄簱鏃ユ湡:">
-        <el-date-picker v-model="filters.dateRange" value-format="YYYY-MM-DD" format="YYYY-MM-DD" type="daterange" range-separator="鑷�" start-placeholder="寮�濮嬫棩鏈�" end-placeholder="缁撴潫鏃ユ湡" clearable />
+        <el-date-picker v-model="filters.dateRange"
+                        value-format="YYYY-MM-DD"
+                        format="YYYY-MM-DD"
+                        type="daterange"
+                        range-separator="鑷�"
+                        start-placeholder="寮�濮嬫棩鏈�"
+                        end-placeholder="缁撴潫鏃ユ湡"
+                        clearable />
       </el-form-item>
       <el-form-item>
-        <el-button type="primary" @click="getTableData">鎼滅储</el-button>
+        <el-button type="primary"
+                   @click="onSearch">鎼滅储</el-button>
         <el-button @click="resetFilters">閲嶇疆</el-button>
       </el-form-item>
     </el-form>
@@ -21,250 +35,168 @@
       <div class="actions">
         <div></div>
         <div>
-          <el-button @click="handleOut" icon="Download">瀵煎嚭</el-button>
+          <el-button @click="handleOut"
+                     icon="Download">瀵煎嚭</el-button>
         </div>
       </div>
-      <PIMTable
-        rowKey="id"
-        :column="columns"
-        :tableData="dataList"
-        :page="{
+      <PIMTable rowKey="id"
+                :column="columns"
+                :tableData="dataList"
+                :tableLoading="tableLoading"
+                isShowSummary
+                :summaryMethod="getSummaries"
+                :page="{
           current: pagination.currentPage,
           size: pagination.pageSize,
           total: pagination.total,
         }"
-        @pagination="changePage"
-      >
-        <template #status="{ row }">
-          <el-tag :type="getStatusType(row.status)">{{ getStatusLabel(row.status) }}</el-tag>
-        </template>
-        <template #operation="{ row }">
-          <el-button type="primary" link @click="view(row)">鏌ョ湅</el-button>
-          <el-button type="primary" link @click="edit(row)" v-if="row.status === 'pending'">缂栬緫</el-button>
-          <el-button type="danger" link @click="handleDelete(row)" v-if="row.status === 'pending'">鍒犻櫎</el-button>
-        </template>
-      </PIMTable>
+                @pagination="changePage" />
     </div>
-
-    <el-dialog :title="dialogTitle" v-model="dialogVisible" width="800px" append-to-body>
-      <el-form :model="form" :rules="rules" ref="formRef" label-width="100px">
-        <el-row :gutter="20">
-          <el-col :span="12">
-            <el-form-item label="鍑哄簱鍗曞彿" prop="outCode">
-              <el-input v-model="form.outCode" placeholder="璇疯緭鍏ュ嚭搴撳崟鍙�" :disabled="isEdit" />
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="瀹㈡埛" prop="customerId">
-              <el-select v-model="form.customerId" placeholder="璇烽�夋嫨瀹㈡埛" style="width: 100%;" :disabled="isEdit">
-                <el-option v-for="item in customerList" :key="item.id" :label="item.name" :value="item.id" />
-              </el-select>
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-row :gutter="20">
-          <el-col :span="12">
-            <el-form-item label="鍑哄簱鏃ユ湡" prop="outDate">
-              <el-date-picker v-model="form.outDate" type="date" placeholder="閫夋嫨鏃ユ湡" value-format="YYYY-MM-DD" style="width: 100%;" />
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="閲戦" prop="amount">
-              <el-input-number v-model="form.amount" :min="0" :precision="2" style="width: 100%;" />
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-form-item label="澶囨敞" prop="remark">
-          <el-input v-model="form.remark" type="textarea" :rows="3" placeholder="璇疯緭鍏ュ娉�" />
-        </el-form-item>
-      </el-form>
-      <template #footer>
-        <el-button @click="dialogVisible = false">鍙栨秷</el-button>
-        <el-button type="primary" @click="submitForm">纭畾</el-button>
-      </template>
-    </el-dialog>
   </div>
 </template>
 
 <script setup>
-import { ref, reactive, onMounted } from "vue";
-import { ElMessage, ElMessageBox } from "element-plus";
+  import { ref, reactive, onMounted, getCurrentInstance } from "vue";
+  import { ElMessage } from "element-plus";
+  import { listPageAccountSales } from "@/api/financialManagement/accountSales";
 
-defineOptions({
-  name: "閿�鍞嚭搴�",
-});
-
-const filters = reactive({
-  outCode: "",
-  customerId: "",
-  dateRange: [],
-});
-
-const pagination = reactive({
-  currentPage: 1,
-  pageSize: 10,
-  total: 0,
-});
-
-const columns = [
-  { label: "鍑哄簱鍗曞彿", prop: "outCode", width: "150" },
-  { label: "瀹㈡埛鍚嶇О", prop: "customerName", width: "180" },
-  { label: "鍑哄簱鏃ユ湡", prop: "outDate", width: "120" },
-  { label: "閲戦", prop: "amount", width: "120" },
-  { label: "鐘舵��", prop: "status", slot: "status" },
-  { label: "澶囨敞", prop: "remark", showOverflowTooltip: true },
-  { label: "鎿嶄綔", prop: "operation", slot: "operation", width: "200", fixed: "right" },
-];
-
-const dataList = ref([]);
-const dialogVisible = ref(false);
-const dialogTitle = ref("");
-const formRef = ref(null);
-const isEdit = ref(false);
-const currentId = ref(null);
-
-const customerList = [
-  { id: 1, name: "鍖椾含绉戞妧鏈夐檺鍏徃" },
-  { id: 2, name: "涓婃捣璐告槗鍏徃" },
-  { id: 3, name: "骞垮窞瀹炰笟鏈夐檺鍏徃" },
-  { id: 4, name: "娣卞湷鐢靛瓙鍏徃" },
-];
-
-const form = reactive({
-  outCode: "",
-  customerId: "",
-  outDate: "",
-  amount: 0,
-  remark: "",
-});
-
-const rules = {
-  outCode: [{ required: true, message: "璇疯緭鍏ュ嚭搴撳崟鍙�", trigger: "blur" }],
-  customerId: [{ required: true, message: "璇烽�夋嫨瀹㈡埛", trigger: "change" }],
-  outDate: [{ required: true, message: "璇烽�夋嫨鍑哄簱鏃ユ湡", trigger: "change" }],
-  amount: [{ required: true, message: "璇疯緭鍏ラ噾棰�", trigger: "blur" }],
-};
-
-const mockData = [
-  { id: 1, outCode: "CK2024001", customerId: 1, customerName: "鍖椾含绉戞妧鏈夐檺鍏徃", outDate: "2024-01-15", amount: 5000, status: "approved", remark: "" },
-  { id: 2, outCode: "CK2024002", customerId: 2, customerName: "涓婃捣璐告槗鍏徃", outDate: "2024-01-16", amount: 8000, status: "pending", remark: "" },
-  { id: 3, outCode: "CK2024003", customerId: 3, customerName: "骞垮窞瀹炰笟鏈夐檺鍏徃", outDate: "2024-01-18", amount: 12000, status: "approved", remark: "" },
-  { id: 4, outCode: "CK2024004", customerId: 4, customerName: "娣卞湷鐢靛瓙鍏徃", outDate: "2024-01-20", amount: 3500, status: "pending", remark: "" },
-];
-
-const getStatusLabel = (status) => {
-  const map = { pending: "寰呭鏍�", approved: "宸插鏍�", rejected: "宸查┏鍥�" };
-  return map[status] || status;
-};
-
-const getStatusType = (status) => {
-  const map = { pending: "warning", approved: "success", rejected: "danger" };
-  return map[status] || "";
-};
-
-const getTableData = () => {
-  let result = [...mockData];
-  if (filters.outCode) {
-    result = result.filter(item => item.outCode.includes(filters.outCode));
-  }
-  if (filters.customerId) {
-    result = result.filter(item => item.customerId === filters.customerId);
-  }
-  if (filters.dateRange && filters.dateRange.length === 2) {
-    result = result.filter(item => item.outDate >= filters.dateRange[0] && item.outDate <= filters.dateRange[1]);
-  }
-  pagination.total = result.length;
-  dataList.value = result.slice((pagination.currentPage - 1) * pagination.pageSize, pagination.currentPage * pagination.pageSize);
-};
-
-const resetFilters = () => {
-  filters.outCode = "";
-  filters.customerId = "";
-  filters.dateRange = [];
-  pagination.currentPage = 1;
-  getTableData();
-};
-
-const changePage = ({ current, size }) => {
-  pagination.currentPage = current;
-  pagination.pageSize = size;
-  getTableData();
-};
-
-const add = () => {
-  isEdit.value = false;
-  dialogTitle.value = "鏂板鍑哄簱";
-  Object.assign(form, {
-    outCode: "CK" + Date.now(),
-    customerId: "",
-    outDate: "",
-    amount: 0,
-    remark: "",
+  defineOptions({
+    name: "閿�鍞嚭搴�",
   });
-  dialogVisible.value = true;
-};
 
-const edit = (row) => {
-  isEdit.value = true;
-  currentId.value = row.id;
-  dialogTitle.value = "缂栬緫鍑哄簱";
-  Object.assign(form, row);
-  dialogVisible.value = true;
-};
+  const { proxy } = getCurrentInstance();
 
-const view = (row) => {
-  ElMessage.info(`鏌ョ湅鍑哄簱鍗�: ${row.outCode}`);
-};
+  const filters = reactive({
+    outboundBatches: "",
+    customerName: "",
+    dateRange: [],
+  });
 
-const submitForm = () => {
-  formRef.value.validate((valid) => {
-    if (valid) {
-      const customer = customerList.find(item => item.id === form.customerId);
-      if (isEdit.value) {
-        const index = mockData.findIndex(item => item.id === currentId.value);
-        if (index !== -1) {
-          mockData[index] = { ...mockData[index], ...form, customerName: customer?.name };
+  const pagination = reactive({
+    currentPage: 1,
+    pageSize: 10,
+    total: 0,
+  });
+
+  const columns = [
+    { label: "鍑哄簱鍗曞彿", prop: "outboundBatches", minWidth: "150" },
+    { label: "瀹㈡埛鍚嶇О", prop: "customerName", minWidth: "180" },
+    { label: "鍑哄簱鏃ユ湡", prop: "shippingDate", width: "170" },
+    { label: "浜у搧鍚嶇О", prop: "productName", minWidth: "140" },
+    { label: "瑙勬牸鍨嬪彿", prop: "specificationModel", minWidth: "140" },
+    {
+      label: "閲戦",
+      prop: "outboundAmount",
+      minWidth: "120",
+      formatData: val =>
+        val === null || val === undefined || val === ""
+          ? ""
+          : Number(val).toLocaleString("zh-CN", {
+              minimumFractionDigits: 2,
+              maximumFractionDigits: 2,
+            }),
+    },
+    { label: "鍙戣揣缂栧彿", prop: "shippingNo", minWidth: "140" },
+    { label: "閿�鍞鍗曞彿", prop: "salesContractNo", minWidth: "150" },
+  ];
+
+  const dataList = ref([]);
+  const tableLoading = ref(false);
+
+  function buildFilterParams() {
+    const params = {
+      outboundBatches: filters.outboundBatches || undefined,
+      customerName: filters.customerName || undefined,
+    };
+    if (filters.dateRange && filters.dateRange.length === 2) {
+      params.startDate = filters.dateRange[0];
+      params.endDate = filters.dateRange[1];
+    }
+    return params;
+  }
+
+  const onSearch = () => {
+    pagination.currentPage = 1;
+    getTableData();
+  };
+
+  const getTableData = () => {
+    tableLoading.value = true;
+    listPageAccountSales({
+      ...buildFilterParams(),
+      current: pagination.currentPage,
+      size: pagination.pageSize,
+    })
+      .then(res => {
+        const ok = res.code === 200 || res.code === 0;
+        if (ok && res.data) {
+          pagination.total = res.data.total ?? 0;
+          dataList.value = res.data.records ?? [];
+        } else {
+          ElMessage.error(res.msg || "鏌ヨ澶辫触");
+          dataList.value = [];
         }
-        ElMessage.success("缂栬緫鎴愬姛");
-      } else {
-        const newId = mockData.length > 0 ? Math.max(...mockData.map(item => item.id)) + 1 : 1;
-        mockData.push({ id: newId, ...form, customerName: customer?.name, status: "pending" });
-        ElMessage.success("鏂板鎴愬姛");
-      }
-      dialogVisible.value = false;
-      getTableData();
-    }
-  });
-};
+      })
+      .catch(() => {
+        dataList.value = [];
+      })
+      .finally(() => {
+        tableLoading.value = false;
+      });
+  };
 
-const handleDelete = (row) => {
-  ElMessageBox.confirm("纭鍒犻櫎璇ュ嚭搴撳崟鍚楋紵", "鎻愮ず", {
-    confirmButtonText: "纭畾",
-    cancelButtonText: "鍙栨秷",
-    type: "warning",
-  }).then(() => {
-    const index = mockData.findIndex(item => item.id === row.id);
-    if (index !== -1) {
-      mockData.splice(index, 1);
-    }
-    ElMessage.success("鍒犻櫎鎴愬姛");
+  const resetFilters = () => {
+    filters.outboundBatches = "";
+    filters.customerName = "";
+    filters.dateRange = [];
+    pagination.currentPage = 1;
+    getTableData();
+  };
+
+  const changePage = ({ page, limit }) => {
+    pagination.currentPage = page;
+    pagination.pageSize = limit;
+    getTableData();
+  };
+
+  const getSummaries = ({ columns, data }) => {
+    const sums = [];
+    columns.forEach((col, index) => {
+      if (index === 0) {
+        sums[index] = "鍚堣";
+      } else if (col.property === "outboundAmount") {
+        const total = data.reduce((prev, cur) => {
+          const v = Number(cur.outboundAmount);
+          return prev + (isNaN(v) ? 0 : v);
+        }, 0);
+        sums[index] = total.toLocaleString("zh-CN", {
+          minimumFractionDigits: 2,
+          maximumFractionDigits: 2,
+        });
+      } else {
+        sums[index] = "";
+      }
+    });
+    return sums;
+  };
+
+  const handleOut = () => {
+    proxy.download(
+      "/accountSales/exportAccountSalesOutbound",
+      buildFilterParams(),
+      `閿�鍞嚭搴揰${new Date().getTime()}.xlsx`
+    );
+  };
+
+  onMounted(() => {
     getTableData();
   });
-};
-
-const handleOut = () => {
-  ElMessage.success("瀵煎嚭鎴愬姛");
-};
-
-onMounted(() => {
-  getTableData();
-});
 </script>
 
 <style lang="scss" scoped>
-.actions {
-  display: flex;
-  justify-content: space-between;
-  margin-bottom: 15px;
-}
+  .actions {
+    display: flex;
+    justify-content: space-between;
+    margin-bottom: 15px;
+  }
 </style>

--
Gitblit v1.9.3