From 5747cef7e826014682a02cd00da8769e1fa1e65a Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期二, 30 十二月 2025 14:45:52 +0800
Subject: [PATCH] 添加采购审批页面,显示台账审批状态

---
 src/views/procurementManagement/procurementLedger/index.vue |   23 +
 src/views/collaborativeApproval/purchaseApproval/index.vue  | 1071 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/api/procurementManagement/procurementLedger.js          |    7 
 3 files changed, 1,100 insertions(+), 1 deletions(-)

diff --git a/src/api/procurementManagement/procurementLedger.js b/src/api/procurementManagement/procurementLedger.js
index c3b5d86..b9f09ca 100644
--- a/src/api/procurementManagement/procurementLedger.js
+++ b/src/api/procurementManagement/procurementLedger.js
@@ -72,3 +72,10 @@
     method: "get",
   });
 }
+export function updateApprovalStatus(query) {
+    return request({
+        url: "/purchase/ledger/updateApprovalStatus",
+        method: "post",
+        data: query,
+    });
+}
\ No newline at end of file
diff --git a/src/views/collaborativeApproval/purchaseApproval/index.vue b/src/views/collaborativeApproval/purchaseApproval/index.vue
new file mode 100644
index 0000000..aeb931e
--- /dev/null
+++ b/src/views/collaborativeApproval/purchaseApproval/index.vue
@@ -0,0 +1,1071 @@
+<template>
+  <div class="app-container">
+    <div class="search_form">
+      <div>
+        <el-form :model="searchForm" :inline="true">
+          <el-form-item label="渚涘簲鍟嗗悕绉帮細">
+            <el-input v-model="searchForm.supplierName" placeholder="璇疯緭鍏�" clearable prefix-icon="Search"
+                      @change="handleQuery" />
+          </el-form-item>
+          <el-form-item label="閲囪喘鍚堝悓鍙凤細">
+            <el-input
+                v-model="searchForm.purchaseContractNumber"
+                style="width: 240px"
+                placeholder="璇疯緭鍏�"
+                @change="handleQuery"
+                clearable
+                :prefix-icon="Search"
+            />
+          </el-form-item>
+          <el-form-item label="閿�鍞悎鍚屽彿锛�">
+            <el-input v-model="searchForm.salesContractNo" placeholder="璇疯緭鍏�" clearable prefix-icon="Search"
+                      @change="handleQuery" />
+          </el-form-item>
+          <el-form-item label="椤圭洰鍚嶇О锛�">
+            <el-input v-model="searchForm.projectName" placeholder="璇疯緭鍏�" clearable prefix-icon="Search"
+                      @change="handleQuery" />
+          </el-form-item>
+          <el-form-item>
+            <el-button type="primary" @click="handleQuery"> 鎼滅储 </el-button>
+          </el-form-item>
+        </el-form>
+      </div>
+
+    </div>
+    <div class="table_list">
+      <div style="display: flex;justify-content: flex-end;margin-bottom: 20px;">
+        <el-button @click="handleOut">瀵煎嚭</el-button>
+        <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
+      </div>
+      <el-table
+        :data="tableData"
+        border
+        v-loading="tableLoading"
+        @selection-change="handleSelectionChange"
+        :expand-row-keys="expandedRowKeys"
+        :row-key="(row) => row.id"
+        show-summary
+        :summary-method="summarizeMainTable"
+        @expand-change="expandChange"
+        height="calc(100vh - 18.5em)"
+        :row-class-name="tableRowClassName"
+      >
+        <el-table-column align="center" type="selection" width="55" />
+        <el-table-column type="expand">
+          <template #default="props">
+            <el-table
+              :data="props.row.children"
+              border
+              show-summary
+              :summary-method="summarizeChildrenTable"
+            >
+              <el-table-column
+                align="center"
+                label="搴忓彿"
+                type="index"
+                width="60"
+              />
+              <el-table-column label="浜у搧澶х被" prop="productCategory" />
+              <el-table-column label="瑙勬牸鍨嬪彿" prop="specificationModel" />
+              <el-table-column label="鍗曚綅" prop="unit" />
+              <el-table-column label="鏁伴噺" prop="quantity" />
+              <el-table-column label="绋庣巼(%)" prop="taxRate" />
+              <el-table-column
+                label="鍚◣鍗曚环(鍏�)"
+                prop="taxInclusiveUnitPrice"
+                :formatter="formattedNumber"
+              />
+              <el-table-column
+                label="鍚◣鎬讳环(鍏�)"
+                prop="taxInclusiveTotalPrice"
+                :formatter="formattedNumber"
+              />
+              <el-table-column
+                label="涓嶅惈绋庢�讳环(鍏�)"
+                prop="taxExclusiveTotalPrice"
+                :formatter="formattedNumber"
+              />
+            </el-table>
+          </template>
+        </el-table-column>
+        <el-table-column align="center" label="搴忓彿" type="index" width="60" />
+        <el-table-column
+          label="閲囪喘鍚堝悓鍙�"
+          prop="purchaseContractNumber"
+          width="200"
+          show-overflow-tooltip
+        />
+        <el-table-column
+          label="閿�鍞悎鍚屽彿"
+          prop="salesContractNo"
+          width="200"
+          show-overflow-tooltip
+        />
+        <el-table-column
+          label="渚涘簲鍟嗗悕绉�"
+          width="240"
+          prop="supplierName"
+          show-overflow-tooltip
+        />
+        <el-table-column label="璁㈠崟鐘舵��" width="100" align="center">
+          <template #default="scope">
+            <el-tag v-if="scope.row.isInvalid" type="danger" size="small">澶辨晥</el-tag>
+            <el-tag v-else type="success" size="small">姝e父</el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column
+          label="椤圭洰鍚嶇О"
+          prop="projectName"
+          width="420"
+          show-overflow-tooltip
+        />
+        <el-table-column
+            label="瀹℃壒鐘舵��"
+            prop="approvalStatus"
+            width="200"
+            show-overflow-tooltip
+        >
+          <template #default="scope">
+            <el-tag
+                size="small"
+            >
+              {{ approvalStatusText[scope.row.approvalStatus] || '鏈煡鐘舵��' }}
+            </el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column
+          label="浠樻鏂瑰紡"
+          width="100"
+          prop="paymentMethod"
+          show-overflow-tooltip
+        />
+        <el-table-column
+          label="鍚堝悓閲戦(鍏�)"
+          prop="contractAmount"
+           width="200"
+          show-overflow-tooltip
+          :formatter="formattedNumber"
+        />
+        <el-table-column
+          label="褰曞叆浜�"
+          prop="recorderName"
+           width="100"
+          show-overflow-tooltip
+        />
+        <el-table-column
+          label="褰曞叆鏃ユ湡"
+          prop="entryDate"
+           width="100"
+          show-overflow-tooltip
+        />
+        <el-table-column
+          fixed="right"
+          label="鎿嶄綔"
+          min-width="150"
+          align="center"
+        >
+          <template #default="scope">
+            <el-button
+              link
+              type="primary"
+              size="small"
+              @click="approvePurchase(scope.row)"
+              :disabled="scope.row.approvalStatus !== 0"
+              >瀹℃壒</el-button
+            >
+            <el-button
+                link
+                type="primary"
+                size="small"
+                @click="rejectPurchase(scope.row)"
+                :disabled="scope.row.approvalStatus !== 0"
+            >鎷掔粷瀹℃壒</el-button
+            >
+          </template>
+        </el-table-column>
+      </el-table>
+      <pagination
+        v-show="total > 0"
+        :total="total"
+        layout="total, sizes, prev, pager, next, jumper"
+        :page="page.current"
+        :limit="page.size"
+        @pagination="paginationChange"
+      />
+    </div>
+  </div>
+</template>
+
+<script setup>
+import { getToken } from "@/utils/auth";
+import pagination from "@/components/PIMTable/Pagination.vue";
+import { ref, onMounted, reactive, toRefs, getCurrentInstance, nextTick } from "vue";
+import { Search } from "@element-plus/icons-vue";
+import { ElMessageBox } from "element-plus";
+import { userListNoPage } from "@/api/system/user.js";
+import {
+  getSalesLedgerWithProducts,
+  addOrUpdateSalesLedgerProduct,
+  delProduct,
+  delLedgerFile,
+  getProductInfoByContractNo,
+} from "@/api/salesManagement/salesLedger.js";
+import {
+  addOrEditPurchase,
+  delPurchase,
+  getSalesNo,
+  purchaseListPage,
+  productList,
+  getPurchaseById,
+  getOptions,
+  createPurchaseNo, updateApprovalStatus,
+} from "@/api/procurementManagement/procurementLedger.js";
+import useFormData from "@/hooks/useFormData.js";
+import QRCode from "qrcode";
+
+
+const { proxy } = getCurrentInstance();
+const tableData = ref([]);
+const productData = ref([]);
+const selectedRows = ref([]);
+const productSelectedRows = ref([]);
+const modelOptions = ref([]);
+const userList = ref([]);
+const productOptions = ref([]);
+const salesContractList = ref([]);
+const supplierList = ref([]);
+const tableLoading = ref(false);
+const page = reactive({
+  current: 1,
+  size: 100,
+});
+const total = ref(0);
+const fileList = ref([]);
+import useUserStore from "@/store/modules/user";
+import { modelList, productTreeList } from "@/api/basicData/product.js";
+import dayjs from "dayjs";
+
+const userStore = useUserStore();
+
+// 浜岀淮鐮佺浉鍏冲彉閲�
+const qrCodeDialogVisible = ref(false);
+const qrCodeUrl = ref("");
+
+// 璁㈠崟瀹℃壒鐘舵�佹樉绀烘枃鏈�
+const approvalStatusText = {
+  0: '寰呭鎵�',
+  1: '瀹℃壒閫氳繃',
+  2: '瀹℃壒澶辫触'
+};
+
+// 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁
+const operationType = ref("");
+const dialogFormVisible = ref(false);
+const data = reactive({
+  searchForm: {
+    supplierName: "", // 渚涘簲鍟嗗悕绉�
+    purchaseContractNumber: "", // 閲囪喘鍚堝悓缂栧彿
+    salesContractNo: "", // 閿�鍞悎鍚岀紪鍙�
+    projectName: "", // 椤圭洰鍚嶇О
+    entryDate: null, // 褰曞叆鏃ユ湡
+    entryDateStart: undefined,
+    entryDateEnd: undefined,
+  },
+  form: {
+    purchaseContractNumber: "",
+    salesLedgerId: "",
+    projectName: "",
+    recorderId: "",
+    entryDate: "",
+    productData: [],
+    supplierName: "",
+    supplierId: "",
+    paymentMethod: "",
+		executionDate: "",
+    approvalStatus: "0",
+  },
+  rules: {
+    purchaseContractNumber: [
+      { required: true, message: "璇疯緭鍏�", trigger: "blur" },
+    ],
+    projectName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+    supplierId: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+		entryDate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+		executionDate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+  },
+});
+const {  form, rules } = toRefs(data);
+const { form: searchForm } = useFormData(data.searchForm);
+
+// 浜у搧琛ㄥ崟寮规鏁版嵁
+const productFormVisible = ref(false);
+const productOperationType = ref("");
+const productOperationIndex = ref("");
+const currentId = ref("");
+const productFormData = reactive({
+  productForm: {
+    productId: "",
+    productCategory: "",
+    productModelId: "",
+    specificationModel: "",
+    unit: "",
+    quantity: "",
+    taxInclusiveUnitPrice: "",
+    taxRate: "",
+    taxInclusiveTotalPrice: "",
+    taxExclusiveTotalPrice: "",
+    invoiceType: "",
+		warnNum: "",
+  },
+  productRules: {
+    productId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+    productModelId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+    unit: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+    quantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+    taxInclusiveUnitPrice: [
+      { required: true, message: "璇疯緭鍏�", trigger: "blur" },
+    ],
+    taxRate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+		warnNum: [{ required: false, message: "璇烽�夋嫨", trigger: "change" }],
+    taxInclusiveTotalPrice: [
+      { required: true, message: "璇疯緭鍏�", trigger: "blur" },
+    ],
+    taxExclusiveTotalPrice: [
+      { required: true, message: "璇疯緭鍏�", trigger: "blur" },
+    ],
+    invoiceType: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+  },
+});
+const { productForm, productRules } = toRefs(productFormData);
+const upload = reactive({
+  // 涓婁紶鐨勫湴鍧�
+  url: import.meta.env.VITE_APP_BASE_API + "/file/upload",
+  // 璁剧疆涓婁紶鐨勮姹傚ご閮�
+  headers: { Authorization: "Bearer " + getToken() },
+});
+
+const changeDaterange = (value) => {
+  if (value) {
+    searchForm.entryDateStart = dayjs(value[0]).format("YYYY-MM-DD");
+    searchForm.entryDateEnd = dayjs(value[1]).format("YYYY-MM-DD");
+  } else {
+    searchForm.entryDateStart = undefined;
+    searchForm.entryDateEnd = undefined;
+  }
+  handleQuery();
+};
+
+const formattedNumber = (row, column, cellValue) => {
+  return parseFloat(cellValue).toFixed(2);
+};
+// 鏌ヨ鍒楄〃
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+  page.current = 1;
+  getList();
+};
+// 瀛愯〃鍚堣鏂规硶
+const summarizeChildrenTable = (param) => {
+  return proxy.summarizeTable(
+    param,
+    [
+      "taxInclusiveUnitPrice",
+      "taxInclusiveTotalPrice",
+      "taxExclusiveTotalPrice",
+      "ticketsNum",
+      "ticketsAmount",
+      "futureTickets",
+      "futureTicketsAmount",
+    ],
+    {
+      ticketsNum: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
+      futureTickets: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
+    }
+  );
+};
+const paginationChange = (obj) => {
+  page.current = obj.page;
+  page.size = obj.limit;
+  getList();
+};
+const getList = () => {
+  tableLoading.value = true;
+  const { entryDate, ...rest } = searchForm;
+  purchaseListPage({ ...rest, ...page })
+    .then((res) => {
+      tableLoading.value = false;
+      // tableData.value = res.data.records;
+      // 澶勭悊鏁版嵁锛屾坊鍔犲け鏁堢姸鎬佹爣璁�
+      tableData.value = res.data.records.map(record => ({
+        ...record,
+        isInvalid: record.isWhite === 1
+      }));
+      tableData.value.map((item) => {
+        item.children = [];
+      });
+      total.value = res.data.total;
+      expandedRowKeys.value = [];
+    })
+    .catch(() => {
+      tableLoading.value = false;
+    });
+};
+// 琛ㄦ牸閫夋嫨鏁版嵁
+const handleSelectionChange = (selection) => {
+  selectedRows.value = selection;
+};
+const productSelected = (selectedRows) => {
+  productSelectedRows.value = selectedRows;
+};
+const expandedRowKeys = ref([]);
+// 灞曞紑琛�
+const expandChange = (row, expandedRows) => {
+  if (expandedRows.length > 0) {
+    expandedRowKeys.value = [];
+    try {
+      productList({ salesLedgerId: row.id, type: 2 }).then((res) => {
+        const index = tableData.value.findIndex((item) => item.id === row.id);
+        if (index > -1) {
+          tableData.value[index].children = res.data;
+        }
+        expandedRowKeys.value.push(row.id);
+      });
+    } catch (error) {
+      console.log(error);
+    }
+  } else {
+    expandedRowKeys.value = [];
+  }
+};
+// 涓昏〃鍚堣鏂规硶
+const summarizeMainTable = (param) => {
+  return proxy.summarizeTable(param, ["contractAmount"]);
+};
+// 瀛愯〃鍚堣鏂规硶
+const summarizeProTable = (param) => {
+  return proxy.summarizeTable(param, [
+    "taxInclusiveUnitPrice",
+    "taxInclusiveTotalPrice",
+    "taxExclusiveTotalPrice",
+  ]);
+};
+// 鎵撳紑寮规
+const openForm = (type, row) => {
+  operationType.value = type;
+  form.value = {};
+  productData.value = [];
+  fileList.value = [];
+  if (operationType.value == "add") {
+    createPurchaseNo().then((res) => {
+      form.value.purchaseContractNumber = res.data;
+    });
+  }
+  userListNoPage().then((res) => {
+    userList.value = res.data;
+  });
+  getSalesNo().then((res) => {
+    salesContractList.value = res;
+  });
+  getOptions().then((res) => {
+    // 渚涘簲鍟嗚繃婊ゅ嚭isWhite=0 鐨勬暟鎹�
+    supplierList.value = res.data.filter((item) => item.isWhite == 0);
+  });
+  form.value.recorderId = userStore.id;
+  form.value.entryDate = getCurrentDate();
+  if (type === "edit") {
+    currentId.value = row.id;
+    getPurchaseById({ id: row.id, type: 2 }).then((res) => {
+      form.value = { ...res };
+      productData.value = form.value.productData;
+      if (form.value.salesLedgerFiles) {
+        fileList.value = form.value.salesLedgerFiles;
+      } else {
+        fileList.value = [];
+      }
+    });
+  }
+  dialogFormVisible.value = true;
+};
+// 涓婁紶鍓嶆牎妫�
+function handleBeforeUpload(file) {
+  // 鏍℃鏂囦欢澶у皬
+  if (file.size > 1024 * 1024 * 10) {
+    proxy.$modal.msgError("涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃10MB!");
+    return false;
+  }
+  proxy.$modal.loading("姝e湪涓婁紶鏂囦欢锛岃绋嶅��...");
+  return true;
+}
+// 涓婁紶澶辫触
+function handleUploadError(err) {
+  proxy.$modal.msgError("涓婁紶鏂囦欢澶辫触");
+  proxy.$modal.closeLoading();
+}
+// 涓婁紶鎴愬姛鍥炶皟
+function handleUploadSuccess(res, file, uploadFiles) {
+  proxy.$modal.closeLoading();
+  if (res.code === 200) {
+    file.tempId = res.data.tempId;
+    proxy.$modal.msgSuccess("涓婁紶鎴愬姛");
+  } else {
+    proxy.$modal.msgError(res.msg);
+    proxy.$refs.fileUpload.handleRemove(file);
+  }
+}
+// 绉婚櫎鏂囦欢
+function handleRemove(file) {
+  console.log("handleRemove", file.id);
+  if (file.size > 1024 * 1024 * 10) { 
+    // 浠呭墠绔竻鐞嗭紝涓嶈皟鐢ㄥ垹闄ゆ帴鍙e拰鎻愮ず
+    return; 
+  }
+  if (operationType.value === "edit") {
+    let ids = [];
+    ids.push(file.id);
+    delLedgerFile(ids).then((res) => {
+      proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+    });
+  }
+}
+// 鎻愪氦琛ㄥ崟
+const submitForm = (n) => {
+  proxy.$refs["formRef"].validate((valid) => {
+    if (valid) {
+      if (productData.value.length > 0) {
+        form.value.productData = proxy.HaveJson(productData.value);
+      } else {
+        proxy.$modal.msgWarning("璇锋坊鍔犱骇鍝佷俊鎭�");
+        return;
+      }
+      let tempFileIds = [];
+      if (fileList.value.length > 0) {
+        tempFileIds = fileList.value.map((item) => item.tempId);
+      }
+      form.value.tempFileIds = tempFileIds;
+      form.value.type = 2;
+      form.value.approvalStatus = n;
+      addOrEditPurchase(form.value).then((res) => {
+        proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+        closeDia();
+        getList();
+      });
+    }
+  });
+};
+// 鍏抽棴寮规
+const closeDia = () => {
+  proxy.resetForm("formRef");
+  dialogFormVisible.value = false;
+};
+// 鎵撳紑浜у搧寮规
+const openProductForm = (type, row, index) => {
+  productOperationType.value = type;
+  productOperationIndex.value = index;
+  productForm.value = {};
+  proxy.resetForm("productFormRef");
+  if (type === "edit") {
+    productForm.value = { ...row };
+  }
+  productFormVisible.value = true;
+  getProductOptions();
+};
+const getProductOptions = () => {
+  productTreeList().then((res) => {
+    productOptions.value = convertIdToValue(res);
+  });
+};
+const getModels = (value) => {
+  if (value) {
+    productForm.value.productCategory = findNodeById(productOptions.value, value) || "";
+    modelList({ id: value }).then((res) => {
+      modelOptions.value = res;
+    });
+  } else {
+    productForm.value.productCategory = "";
+    modelOptions.value = [];
+  }
+};
+const getProductModel = (value) => {
+  const index = modelOptions.value.findIndex((item) => item.id === value);
+  if (index !== -1) {
+    productForm.value.specificationModel = modelOptions.value[index].model;
+    productForm.value.unit = modelOptions.value[index].unit;
+  } else {
+    productForm.value.specificationModel = null;
+    productForm.value.unit = null;
+  }
+};
+const findNodeById = (nodes, productId) => {
+  for (let i = 0; i < nodes.length; i++) {
+    if (nodes[i].value === productId) {
+      return nodes[i].label; // 鎵惧埌鑺傜偣锛岃繑鍥炶鑺傜偣鐨刲abel
+    }
+    if (nodes[i].children && nodes[i].children.length > 0) {
+      const foundNode = findNodeById(nodes[i].children, productId);
+      if (foundNode) {
+        return foundNode; // 鍦ㄥ瓙鑺傜偣涓壘鍒帮紝鐩存帴杩斿洖锛堝凡缁忔槸label瀛楃涓诧級
+      }
+    }
+  }
+  return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull
+};
+function convertIdToValue(data) {
+  return data.map((item) => {
+    const { id, children, ...rest } = item;
+    const newItem = {
+      ...rest,
+      value: id, // 灏� id 鏀逛负 value
+    };
+    if (children && children.length > 0) {
+      newItem.children = convertIdToValue(children);
+    }
+
+    return newItem;
+  });
+}
+// 鎻愪氦浜у搧琛ㄥ崟
+const submitProduct = () => {
+  proxy.$refs["productFormRef"].validate((valid) => {
+    if (valid) {
+      if (operationType.value === "edit") {
+        submitProductEdit();
+      } else {
+        if (productOperationType.value === "add") {
+          productData.value.push({ ...productForm.value });
+          console.log("productData.value---", productData.value);
+        } else {
+          productData.value[productOperationIndex.value] = {
+            ...productForm.value,
+          };
+        }
+        closeProductDia();
+      }
+    }
+  });
+};
+const submitProductEdit = () => {
+  productForm.value.salesLedgerId = currentId.value;
+  productForm.value.type = 2;
+  addOrUpdateSalesLedgerProduct(productForm.value).then((res) => {
+    proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+    closeProductDia();
+    getPurchaseById({ id: currentId.value, type: 2 }).then((res) => {
+      productData.value = res.productData;
+    });
+  });
+};
+// 鍒犻櫎浜у搧
+const deleteProduct = () => {
+  if (productSelectedRows.value.length === 0) {
+    proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+    return;
+  }
+  if (operationType.value === "add") {
+    productSelectedRows.value.forEach((selectedRow) => {
+      const index = productData.value.findIndex(
+        (product) => product.id === selectedRow.id
+      );
+      if (index !== -1) {
+        productData.value.splice(index, 1);
+      }
+    });
+  } else {
+    let ids = [];
+    if (productSelectedRows.value.length > 0) {
+      ids = productSelectedRows.value.map((item) => item.id);
+    }
+    ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "瀵煎嚭", {
+      confirmButtonText: "纭",
+      cancelButtonText: "鍙栨秷",
+      type: "warning",
+    })
+      .then(() => {
+        delProduct(ids).then((res) => {
+          proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+          closeProductDia();
+          getSalesLedgerWithProducts({ id: currentId.value, type: 2 }).then(
+            (res) => {
+              productData.value = res.productData;
+            }
+          );
+        });
+      })
+      .catch(() => {
+        proxy.$modal.msg("宸插彇娑�");
+      });
+  }
+};
+// 鍏抽棴浜у搧寮规
+const closeProductDia = () => {
+  proxy.resetForm("productFormRef");
+  productFormVisible.value = false;
+};
+// 瀹℃壒閫氳繃鏂规硶
+const approvePurchase = (row) => {
+  ElMessageBox.confirm(`纭閫氳繃閲囪喘鍚堝悓鍙蜂负 ${row.purchaseContractNumber} 鐨勫鎵癸紵`, '瀹℃壒纭', {
+    confirmButtonText: '纭',
+    cancelButtonText: '鍙栨秷',
+    type: 'warning',
+  }).then(() => {
+    updateApprovalStatus({ id: row.id, approvalStatus: 1}).then((res)=>{
+      proxy.$modal.msgSuccess('瀹℃壒鎴愬姛');
+      getList();
+    })
+  }).catch(() => {
+    proxy.$modal.msg('宸插彇娑堝鎵�');
+  });
+};
+
+// 瀹℃壒鎷掔粷鏂规硶
+const rejectPurchase = (row) => {
+  ElMessageBox.confirm(`纭鎷掔粷閲囪喘鍚堝悓鍙蜂负 ${row.purchaseContractNumber} 鐨勫鎵癸紵`, '瀹℃壒纭', {
+    confirmButtonText: '纭',
+    cancelButtonText: '鍙栨秷',
+    type: 'warning',
+  }).then(() => {
+    updateApprovalStatus({ id: row.id, approvalStatus: 2}).then((res)=>{
+      proxy.$modal.msgSuccess('瀹℃壒鎴愬姛');
+      getList();
+    })
+  }).catch(() => {
+    proxy.$modal.msg('宸插彇娑堝鎵�');
+  });
+};
+
+// 瀵煎嚭
+const handleOut = () => {
+  ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
+    confirmButtonText: "纭",
+    cancelButtonText: "鍙栨秷",
+    type: "warning",
+  })
+    .then(() => {
+      proxy.download("/purchase/ledger/export", {}, "閲囪喘鍙拌处.xlsx");
+    })
+    .catch(() => {
+      proxy.$modal.msg("宸插彇娑�");
+    });
+};
+// 鍒犻櫎
+const handleDelete = () => {
+  let ids = [];
+  if (selectedRows.value.length > 0) {
+		// 妫�鏌ユ槸鍚︽湁浠栦汉缁存姢鐨勬暟鎹�
+		const unauthorizedData = selectedRows.value.filter(item => item.recorderName !== userStore.nickName);
+		if (unauthorizedData.length > 0) {
+			proxy.$modal.msgWarning("涓嶅彲鍒犻櫎浠栦汉缁存姢鐨勬暟鎹�");
+			return;
+		}
+    ids = selectedRows.value.map((item) => item.id);
+  } else {
+    proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+    return;
+  }
+  ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "瀵煎嚭", {
+    confirmButtonText: "纭",
+    cancelButtonText: "鍙栨秷",
+    type: "warning",
+  })
+    .then(() => {
+      delPurchase(ids).then((res) => {
+        proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+        getList();
+      });
+    })
+    .catch(() => {
+      proxy.$modal.msg("宸插彇娑�");
+    });
+};
+// 鑾峰彇褰撳墠鏃ユ湡骞舵牸寮忓寲涓� YYYY-MM-DD
+function getCurrentDate() {
+  const today = new Date();
+  const year = today.getFullYear();
+  const month = String(today.getMonth() + 1).padStart(2, "0"); // 鏈堜唤浠�0寮�濮�
+  const day = String(today.getDate()).padStart(2, "0");
+  return `${year}-${month}-${day}`;
+}
+const mathNum = () => {
+	if (!productForm.value.taxRate) {
+		proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
+		return;
+	}
+  if (!productForm.value.taxInclusiveUnitPrice) {
+    return;
+  }
+  if (!productForm.value.quantity) {
+    return;
+  }
+  // 鍚◣鎬讳环璁$畻
+  productForm.value.taxInclusiveTotalPrice =
+    proxy.calculateTaxIncludeTotalPrice(
+      productForm.value.taxInclusiveUnitPrice,
+      productForm.value.quantity
+    );
+  if (productForm.value.taxRate) {
+    // 涓嶅惈绋庢�讳环璁$畻
+    productForm.value.taxExclusiveTotalPrice =
+      proxy.calculateTaxExclusiveTotalPrice(
+        productForm.value.taxInclusiveTotalPrice,
+        productForm.value.taxRate
+      );
+  }
+};
+const reverseMathNum = (field) => {
+	if (!productForm.value.taxRate) {
+		proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
+		return;
+	}
+  const taxRate = Number(productForm.value.taxRate);
+  if (!taxRate) return;
+  if (field === 'taxInclusiveTotalPrice') {
+    // 宸茬煡鍚◣鎬讳环鍜屾暟閲忥紝鍙嶇畻鍚◣鍗曚环
+    if (productForm.value.quantity) {
+      productForm.value.taxInclusiveUnitPrice = 
+        (Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.quantity)).toFixed(2);
+    }
+    // 宸茬煡鍚◣鎬讳环鍜屽惈绋庡崟浠凤紝鍙嶇畻鏁伴噺
+    else if (productForm.value.taxInclusiveUnitPrice) {
+      productForm.value.quantity = 
+        (Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.taxInclusiveUnitPrice)).toFixed(2);
+    }
+    // 鍙嶇畻涓嶅惈绋庢�讳环
+    productForm.value.taxExclusiveTotalPrice = 
+      (Number(productForm.value.taxInclusiveTotalPrice) / (1 + taxRate / 100)).toFixed(2);
+  } else if (field === 'taxExclusiveTotalPrice') {
+    // 鍙嶇畻鍚◣鎬讳环
+    productForm.value.taxInclusiveTotalPrice = 
+      (Number(productForm.value.taxExclusiveTotalPrice) * (1 + taxRate / 100)).toFixed(2);
+    // 宸茬煡鏁伴噺锛屽弽绠楀惈绋庡崟浠�
+    if (productForm.value.quantity) {
+      productForm.value.taxInclusiveUnitPrice = 
+        (Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.quantity)).toFixed(2);
+    }
+    // 宸茬煡鍚◣鍗曚环锛屽弽绠楁暟閲�
+    else if (productForm.value.taxInclusiveUnitPrice) {
+      productForm.value.quantity = 
+        (Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.taxInclusiveUnitPrice)).toFixed(2);
+    }
+  }
+};
+// 閿�鍞悎鍚岄�夋嫨鏀瑰彉鏂规硶
+const salesLedgerChange = async (row) => {
+  console.log("row", row);
+  var index = salesContractList.value.findIndex((item) => item.id == row);
+  console.log("index", index);
+  if (index > -1) {
+    form.value.projectName = salesContractList.value[index].projectName;
+    await querygProductInfoByContractNo();
+  }
+};
+
+const querygProductInfoByContractNo = async () => {
+  const { code, data } = await getProductInfoByContractNo({
+    contractNo: form.value.salesLedgerId,
+  });
+  if (code == 200) {
+    productData.value = data;
+  }
+};
+
+// 鏄剧ず浜岀淮鐮�
+const showQRCode = async (row) => {
+  try {
+    // 鏋勫缓浜岀淮鐮佸唴瀹癸紝鍙寘鍚噰璐悎鍚屽彿锛堢函鏂囨湰锛�
+    const qrContent = row.purchaseContractNumber || '';
+    // 妫�鏌ュ唴瀹规槸鍚︿负绌�
+    if (!qrContent || qrContent.trim() === '') {
+      proxy.$modal.msgWarning("璇ヨ娌℃湁閲囪喘鍚堝悓鍙凤紝鏃犳硶鐢熸垚浜岀淮鐮�");
+      return;
+    }
+    qrCodeUrl.value = await QRCode.toDataURL(qrContent, {
+      width: 200,
+      margin: 2,
+      color: {
+        dark: '#000000',
+        light: '#FFFFFF'
+      }
+    });
+    qrCodeDialogVisible.value = true;
+  } catch (error) {
+    console.error('鐢熸垚浜岀淮鐮佸け璐�:', error);
+    proxy.$modal.msgError("鐢熸垚浜岀淮鐮佸け璐ワ細" + error.message);
+  }
+};
+
+// 涓嬭浇浜岀淮鐮�
+const downloadQRCode = () => {
+  if (!qrCodeUrl.value) {
+    proxy.$modal.msgWarning("浜岀淮鐮佹湭鐢熸垚");
+    return;
+  }
+  
+  const a = document.createElement('a');
+  a.href = qrCodeUrl.value;
+  a.download = `閲囪喘鍚堝悓鍙蜂簩缁寸爜_${new Date().getTime()}.png`;
+  document.body.appendChild(a);
+  a.click();
+  document.body.removeChild(a);
+  proxy.$modal.msgSuccess("涓嬭浇鎴愬姛");
+};
+
+// 鎵爜鏂板瀵硅瘽妗嗙浉鍏冲彉閲�
+const scanAddDialogVisible = ref(false);
+const scanAddForm = reactive({
+  scanContent: "",
+  purchaseContractNumber: "",
+  supplierName: "",
+  projectName: "",
+  contractAmount: "",
+  paymentMethod: "",
+  recorderName: "",
+  scanRemark: "",
+});
+const scanAddRules = {
+  purchaseContractNumber: [{ required: true, message: "璇疯緭鍏ラ噰璐悎鍚屽彿", trigger: "blur" }],
+  supplierName: [{ required: true, message: "璇疯緭鍏ヤ緵搴斿晢鍚嶇О", trigger: "blur" }],
+  projectName: [{ required: true, message: "璇疯緭鍏ラ」鐩悕绉�", trigger: "blur" }],
+};
+
+// 鎵爜鐧昏瀵硅瘽妗嗙浉鍏冲彉閲�
+const scanDialogVisible = ref(false);
+const scanForm = reactive({
+  purchaseContractNumber: "",
+  supplierName: "",
+  projectName: "",
+  scanTime: "",
+  scannerName: "",
+  scanStatus: "鏈壂鐮�",
+  scanRemark: "",
+});
+const scanRules = {
+  scanRemark: [{ required: true, message: "璇疯緭鍏ユ壂鐮佸娉�", trigger: "blur" }],
+};
+const scanRecords = ref([]);
+
+// 鎵撳紑鎵爜鏂板瀵硅瘽妗�
+const openScanAddDialog = () => {
+  scanAddForm.scanContent = "";
+  scanAddForm.purchaseContractNumber = "";
+  scanAddForm.supplierName = "";
+  scanAddForm.projectName = "";
+  scanAddForm.contractAmount = "";
+  scanAddForm.paymentMethod = "";
+  scanAddForm.recorderName = userStore.nickName;
+  scanAddForm.scanRemark = "";
+  scanAddDialogVisible.value = true;
+};
+
+// 瑙f瀽鎵爜鍐呭锛堟ā鎷熻В鏋愪簩缁寸爜鏁版嵁锛�
+const parseScanContent = (content) => {
+  if (!content) return;
+  
+  // 妯℃嫙瑙f瀽浜岀淮鐮佸唴瀹癸紝杩欓噷鍙互鏍规嵁瀹為檯闇�姹傝皟鏁磋В鏋愰�昏緫
+  // 鍋囪鎵爜鍐呭鏍煎紡涓猴細鍚堝悓鍙穦渚涘簲鍟唡椤圭洰|閲戦|浠樻鏂瑰紡
+  const parts = content.split('|');
+  if (parts.length >= 3) {
+    scanAddForm.purchaseContractNumber = parts[0] || "";
+    scanAddForm.supplierName = parts[1] || "";
+    scanAddForm.projectName = parts[2] || "";
+    scanAddForm.contractAmount = parts[3] || "";
+    scanAddForm.paymentMethod = parts[4] || "";
+  }
+};
+
+// 鍏抽棴鎵爜鏂板瀵硅瘽妗�
+const closeScanAddDialog = () => {
+  scanAddDialogVisible.value = false;
+  proxy.resetForm("scanAddFormRef");
+};
+
+// 鎻愪氦鎵爜鏂板
+const submitScanAdd = () => {
+  proxy.$refs["scanAddFormRef"].validate((valid) => {
+    if (valid) {
+      // 鏋勫缓鏂板鏁版嵁
+      const newData = {
+        purchaseContractNumber: scanAddForm.purchaseContractNumber,
+        supplierName: scanAddForm.supplierName,
+        projectName: scanAddForm.projectName,
+        contractAmount: scanAddForm.contractAmount,
+        paymentMethod: scanAddForm.paymentMethod,
+        recorderName: scanAddForm.recorderName,
+        entryDate: getCurrentDate(),
+        remark: scanAddForm.scanRemark,
+        type: 2
+      };
+      
+      // 妯℃嫙鏂板鎴愬姛
+      proxy.$modal.msgSuccess("鎵爜鏂板鎴愬姛锛�");
+      closeScanAddDialog();
+      
+      // 鍙互閫夋嫨鏄惁鍒锋柊鍒楄〃
+      // getList();
+    }
+  });
+};
+
+// 鎵撳紑鎵爜鐧昏瀵硅瘽妗�
+const openScanDialog = (row) => {
+  scanForm.purchaseContractNumber = row.purchaseContractNumber;
+  scanForm.supplierName = row.supplierName;
+  scanForm.projectName = row.projectName;
+  scanForm.scanTime = getCurrentDateTime();
+  scanForm.scannerName = userStore.nickName;
+  scanForm.scanStatus = "鏈壂鐮�";
+  scanForm.scanRemark = "";
+  scanRecords.value = [];
+  scanDialogVisible.value = true;
+};
+
+// 鍏抽棴鎵爜鐧昏瀵硅瘽妗�
+const closeScanDialog = () => {
+  scanDialogVisible.value = false;
+  proxy.resetForm("scanFormRef");
+};
+
+// 鎻愪氦鎵爜鐧昏
+const submitScan = () => {
+  proxy.$refs["scanFormRef"].validate((valid) => {
+    if (valid) {
+      // 娣诲姞鎵爜璁板綍
+      scanRecords.value.push({
+        ...scanForm,
+        id: Date.now(), // 妯℃嫙ID
+        scanTime: getCurrentDateTime(),
+      });
+      scanForm.scanStatus = "宸叉壂鐮�";
+      scanForm.scanRemark = scanForm.scanRemark || "鏃�";
+      proxy.$modal.msgSuccess("鎵爜鐧昏鎴愬姛锛�");
+      closeScanDialog();
+    }
+  });
+};
+
+// 鑾峰彇褰撳墠鏃ユ湡鏃堕棿
+function getCurrentDateTime() {
+  const now = new Date();
+  const year = now.getFullYear();
+  const month = String(now.getMonth() + 1).padStart(2, "0");
+  const day = String(now.getDate()).padStart(2, "0");
+  const hours = String(now.getHours()).padStart(2, "0");
+  const minutes = String(now.getMinutes()).padStart(2, "0");
+  const seconds = String(now.getSeconds()).padStart(2, "0");
+  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+}
+
+// 娣诲姞琛岀被鍚嶆柟娉�
+const tableRowClassName = ({ row }) => {
+  return row.isInvalid ? 'invalid-row' : '';
+};
+
+onMounted(() => {
+  getList();
+});
+</script>
+
+<style scoped lang="scss">
+.invalid-row {
+  opacity: 0.6;
+  background-color: #f5f7fa;
+}
+</style>
diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue
index f6f2fce..4475f30 100644
--- a/src/views/procurementManagement/procurementLedger/index.vue
+++ b/src/views/procurementManagement/procurementLedger/index.vue
@@ -113,7 +113,7 @@
           prop="supplierName"
           show-overflow-tooltip
         />
-        <el-table-column label="鐘舵��" width="100" align="center">
+        <el-table-column label="璁㈠崟鐘舵��" width="100" align="center">
           <template #default="scope">
             <el-tag v-if="scope.row.isInvalid" type="danger" size="small">澶辨晥</el-tag>
             <el-tag v-else type="success" size="small">姝e父</el-tag>
@@ -125,6 +125,20 @@
           width="420"
           show-overflow-tooltip
         />
+        <el-table-column
+            label="瀹℃壒鐘舵��"
+            prop="approvalStatus"
+            width="200"
+            show-overflow-tooltip
+        >
+          <template #default="scope">
+            <el-tag
+                size="small"
+            >
+              {{ approvalStatusText[scope.row.approvalStatus] || '鏈煡鐘舵��' }}
+            </el-tag>
+          </template>
+        </el-table-column>
         <el-table-column
           label="浠樻鏂瑰紡"
           width="100"
@@ -851,6 +865,13 @@
 const qrCodeDialogVisible = ref(false);
 const qrCodeUrl = ref("");
 
+// 璁㈠崟瀹℃壒鐘舵�佹樉绀烘枃鏈�
+const approvalStatusText = {
+  0: '瀹℃壒涓�',
+  1: '瀹℃壒閫氳繃',
+  2: '瀹℃壒澶辫触'
+};
+
 // 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁
 const operationType = ref("");
 const dialogFormVisible = ref(false);

--
Gitblit v1.9.3