From 6570b36a352edd87532dcf13a124181d4d815a39 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期二, 30 六月 2026 13:23:26 +0800
Subject: [PATCH] 销项发票页面新增录入发票功能

---
 src/views/financialManagement/receivable/outputInvoice.vue |  119 +++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 99 insertions(+), 20 deletions(-)

diff --git a/src/views/financialManagement/receivable/outputInvoice.vue b/src/views/financialManagement/receivable/outputInvoice.vue
index 22cc202..e5c8bf8 100644
--- a/src/views/financialManagement/receivable/outputInvoice.vue
+++ b/src/views/financialManagement/receivable/outputInvoice.vue
@@ -37,7 +37,7 @@
       <div class="actions">
         <div></div>
         <div>
-          <!-- <el-button type="primary" @click="add" icon="Plus">褰曞叆鍙戠エ</el-button> -->
+          <el-button type="primary" @click="add" icon="Plus">褰曞叆鍙戠エ</el-button>
           <el-button type="success" @click="handleExport" icon="Download">瀵煎嚭</el-button>
         </div>
       </div>
@@ -111,13 +111,25 @@
           </el-col>
           <el-col :span="12">
             <el-form-item label="瀹㈡埛" prop="customerId">
-              <el-select v-model="form.customerId" placeholder="璇烽�夋嫨瀹㈡埛" style="width: 100%;" :disabled="isView">
+              <el-select @change="checkCustomer" v-model="form.customerId" placeholder="璇烽�夋嫨瀹㈡埛" style="width: 100%;" :disabled="isView">
                 <el-option v-for="item in customerList" :key="item.id" :label="item.customerName" :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="accountInvoiceApplicationId">
+              <el-select v-model="form.accountInvoiceApplicationId"
+                        placeholder="璇峰厛閫夋嫨瀹㈡埛"
+                        readonly
+                         @change="selectionApply"
+                        :disabled="!form.customerId || isView"
+                        class="outbound-batch-select">
+                <el-option v-for="(item,index) in applyList" :key="index" :label="item.invoiceApplicationNo" :value="item.id"></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
           <el-col :span="12">
             <el-form-item label="寮�绁ㄦ棩鏈�" prop="invoiceDate">
               <el-date-picker
@@ -130,14 +142,15 @@
               />
             </el-form-item>
           </el-col>
+        </el-row>
+        <el-row :gutter="20">
           <el-col :span="12">
             <el-form-item label="鍙戠エ绫诲瀷" prop="invoiceType">
               <el-select
-                v-model="form.invoiceType"
-                placeholder="璇烽�夋嫨鍙戠エ绫诲瀷"
-                style="width: 100%;"
-                :disabled="isView"
-                @change="handleInvoiceTypeChange"
+                  v-model="form.invoiceType"
+                  placeholder="璇烽�夋嫨鍙戠エ绫诲瀷"
+                  style="width: 100%;"
+                  :disabled="isView"
               >
                 <el-option label="澧炲�肩◣涓撶敤鍙戠エ" value="澧炲�肩◣涓撶敤鍙戠エ" />
                 <el-option label="澧炲�肩◣鏅�氬彂绁�" value="澧炲�肩◣鏅�氬彂绁�" />
@@ -145,8 +158,6 @@
               </el-select>
             </el-form-item>
           </el-col>
-        </el-row>
-        <el-row :gutter="20">
           <el-col :span="12">
             <el-form-item label="绋庣巼" prop="taxRate">
               <el-select
@@ -154,7 +165,7 @@
                 placeholder="璇烽�夋嫨绋庣巼"
                 style="width: 100%;"
                 :disabled="isView"
-                @change="calculateTax"
+                @change="handleTaxRateChange"
               >
                 <el-option
                   v-for="dict in tax_rate"
@@ -175,7 +186,7 @@
                 :precision="2"
                 style="width: 100%;"
                 :disabled="isView"
-                @change="calculateTax"
+                @change="handleTaxRateChange"
               />
             </el-form-item>
           </el-col>
@@ -224,6 +235,7 @@
   cancelAccountSalesInvoice,
   deleteAccountSalesInvoice,
 } from "@/api/financialManagement/accountSalesInvoice.js";
+import {getAccountInvoiceApplicationList} from "@/api/financialManagement/invoiceApply.js";
 
 const FileList = defineAsyncComponent(() => import("@/components/Dialog/FileList.vue"));
 
@@ -271,6 +283,9 @@
 const fileDialogVisible = ref(false);
 const currentRecordId = ref(0);
 
+const applySelectVisible = ref(false);
+const applyList = ref([]);
+
 const openFileDialog = (row) => {
   if (!row.accountInvoiceApplicationId) {
     ElMessage.warning("鏈叧鑱斿紑绁ㄧ敵璇凤紝鏃犳硶鏌ョ湅闄勪欢");
@@ -313,17 +328,88 @@
   totalAmount: 0,
   content: "",
   remark: "",
+  deptId: undefined,
   accountInvoiceApplicationId: undefined,
   storageAttachmentId: undefined,
 });
 
 const rules = {
   invoiceNo: [{ required: true, message: "璇疯緭鍏ュ彂绁ㄥ彿鐮�", trigger: "blur" }],
+  accountInvoiceApplicationId: [{ required: true, message: "璇烽�夋嫨寮�绁ㄧ敵璇�", trigger: "change" }],
   customerId: [{ required: true, message: "璇烽�夋嫨瀹㈡埛", trigger: "change" }],
   invoiceDate: [{ required: true, message: "璇烽�夋嫨寮�绁ㄦ棩鏈�", trigger: "change" }],
   invoiceType: [{ required: true, message: "璇烽�夋嫨鍙戠エ绫诲瀷", trigger: "change" }],
   taxRate: [{ required: true, message: "璇烽�夋嫨绋庣巼", trigger: "change" }],
   amount: [{ required: true, message: "璇疯緭鍏ラ噾棰�", trigger: "blur" }],
+};
+
+// 閫夋嫨瀹㈡埛
+const checkCustomer = (val) =>{
+  loadApplyList(val);
+}
+
+//鏌ヨ寮�绁ㄧ敵璇峰垪琛�
+const loadApplyList = (customerId) => {
+  if (!customerId) {
+    applyList.value = [];
+    return Promise.resolve();
+  }
+  return getAccountInvoiceApplicationList({ customerId })
+      .then(res => {
+        if (res.code === 200) {
+          const list = res.data?.records ?? res.data ?? [];
+          applyList.value = Array.isArray(list) ? list : [];
+        } else {
+          applyList.value = [];
+        }
+      })
+      .catch(() => {
+        applyList.value = [];
+      })
+};
+
+const selectionApply = (val)=>{
+  const applyObj = applyList.value.find(item=>item.id === val);
+  if(!applyObj){
+    ElMessage.warning("璇烽�夋嫨鍏宠仈鐨勫紑绁ㄧ敵璇�");
+    return;
+  }
+  form.remark = applyObj.remark;
+  form.content = applyObj.invoiceContent;
+  form.invoiceDate = applyObj.applyDate;
+  form.invoiceType = applyObj.invoiceType;
+  form.deptId = applyObj.deptId;
+  form.taxRate = applyObj.taxRate;
+  form.totalAmount = applyObj.invoiceAmount
+  handleTaxRateChange();
+}
+
+/** 浠风◣鍚堣鍙樻洿锛氭寜绋庣巼鍙嶇畻涓嶅惈绋庨噾棰濄�佺◣棰� */
+const calculateTaxFromInclusive = (inclusiveTotal) => {
+  const total = Number(inclusiveTotal ?? form.totalAmount ?? 0);
+  if (total <= 0) {
+    form.amount = 0;
+    form.taxAmount = 0;
+    form.totalAmount = 0;
+    return;
+  }
+  const rate = Number(form.taxRate) / 100;
+  form.totalAmount = Number(total.toFixed(2));
+  form.amount = Number((form.totalAmount / (1 + rate)).toFixed(2));
+  form.taxAmount = Number((form.totalAmount - form.amount).toFixed(2));
+};
+
+const calculateTaxFromExclusive = () => {
+  form.taxAmount = Number((form.amount * form.taxRate / 100).toFixed(2));
+  form.totalAmount = Number((form.amount + form.taxAmount).toFixed(2));
+};
+
+const handleTaxRateChange = () => {
+  if (form.totalAmount > 0) {
+    calculateTaxFromInclusive(form.totalAmount);
+  } else {
+    calculateTaxFromExclusive();
+  }
 };
 
 const getSummaries = ({ columns, data }) => {
@@ -350,15 +436,6 @@
 const formatMoney = (value) => {
   if (value === undefined || value === null) return "0.00";
   return Number(value).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
-};
-
-const calculateTax = () => {
-  form.taxAmount = Number((form.amount * form.taxRate / 100).toFixed(2));
-  form.totalAmount = Number((form.amount + form.taxAmount).toFixed(2));
-};
-
-const handleInvoiceTypeChange = () => {
-  calculateTax();
 };
 
 const normalizeTableRow = (row) => ({
@@ -506,6 +583,8 @@
 
 const closeDialog = () => {
   dialogVisible.value = false;
+  applySelectVisible.value = false;
+  isView.value = false;
   isView.value = false;
 };
 

--
Gitblit v1.9.3