From e00905e53ee5d91d9e488ecf5ece3e25b9889436 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 20 一月 2026 16:14:44 +0800
Subject: [PATCH] 湟水峡 1.采购模块不要项目名称 2.加一个有待回款登记的提示 3.回款登记、付款登记改成和销售订单价格关联,并且可以多个一起回款或付款 4.合同管理不要下载合同了,跟合同相关的字段可以去掉了 5.重构生产模块 6.测试流程并修改bug
---
src/views/salesManagement/salesLedger/index.vue | 481 ++++++++++++++++++++++++++++++++---------------------
1 files changed, 290 insertions(+), 191 deletions(-)
diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index f1fb9a2..aedfb98 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -6,21 +6,17 @@
<el-input v-model="searchForm.customerName" placeholder="璇疯緭鍏�" clearable prefix-icon="Search"
@change="handleQuery" />
</el-form-item>
- <el-form-item label="瀹㈡埛鍚堝悓鍙凤細">
- <el-input v-model="searchForm.customerContractNo" placeholder="璇疯緭鍏�" clearable prefix-icon="Search"
- @change="handleQuery" />
- </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 label="褰曞叆鏃ユ湡锛�">
<el-date-picker v-model="searchForm.entryDate" value-format="YYYY-MM-DD" format="YYYY-MM-DD" type="daterange"
placeholder="璇烽�夋嫨" clearable @change="changeDaterange" />
+ </el-form-item>
+ <el-form-item label="浜у搧澶х被锛�">
+ <el-input v-model="searchForm.productCategory" placeholder="璇疯緭鍏�" clearable prefix-icon="Search"
+ @change="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleQuery"> 鎼滅储 </el-button>
@@ -50,40 +46,75 @@
<el-table-column label="浜у搧澶х被" prop="productCategory" />
<el-table-column label="瑙勬牸鍨嬪彿" prop="specificationModel" />
<el-table-column label="鍗曚綅" prop="unit" />
+ <el-table-column label="浜у搧鐘舵��" width="100px" align="center">
+ <template #default="scope">
+ <el-tag v-if="scope.row.approveStatus === 0" type="info">鏈嚭搴�</el-tag>
+ <el-tag v-if="scope.row.approveStatus === 1" type="success">宸插嚭搴�</el-tag>
+ <el-tag v-if="scope.row.approveStatus === 2" type="warning">瀹℃牳涓�</el-tag>
+ <el-tag v-if="scope.row.approveStatus === 3" type="success">瀹℃牳鎴愬姛</el-tag>
+ <el-tag v-if="scope.row.approveStatus === 4" type="danger">瀹℃牳澶辫触</el-tag>
+ </template>
+ </el-table-column>
+ <el-table-column label="鍙戣揣杞︾墝" minWidth="100px" align="center">
+ <template #default="scope">
+ <div>
+ <el-tag type="success" v-if="scope.row.shippingCarNumber">{{ scope.row.shippingCarNumber }}</el-tag>
+ <el-tag v-else type="info">鏈彂璐�</el-tag>
+ </div>
+ </template>
+ </el-table-column>
+ <el-table-column label="鍙戣揣鏃ユ湡" minWidth="100px" align="center">
+ <template #default="scope">
+ <div>
+ <div v-if="scope.row.shippingDate">{{ scope.row.shippingDate }}</div>
+ <el-tag v-else type="info">鏈彂璐�</el-tag>
+ </div>
+ </template>
+ </el-table-column>
<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-column Width="60px" label="鎿嶄綔" align="center">
+ <template #default="scope">
+ <el-button :disabled="scope.row.approveStatus!==2 || scope.row.approveStatus!==5" link type="primary" size="small" @click="openDeliveryForm(scope.row)">鍙戣揣</el-button>
+ </template>
+ </el-table-column>
</el-table>
</template>
</el-table-column>
<el-table-column align="center" label="搴忓彿" type="index" width="60" />
<el-table-column label="閿�鍞悎鍚屽彿" prop="salesContractNo" width="180" show-overflow-tooltip />
- <el-table-column label="瀹㈡埛鍚堝悓鍙�" prop="customerContractNo" width="180" show-overflow-tooltip />
<el-table-column label="瀹㈡埛鍚嶇О" prop="customerName" width="300" show-overflow-tooltip />
<el-table-column label="涓氬姟鍛�" prop="salesman" width="100" show-overflow-tooltip />
- <el-table-column label="椤圭洰鍚嶇О" prop="projectName" width="180" show-overflow-tooltip />
<el-table-column label="浠樻鏂瑰紡" prop="paymentMethod" show-overflow-tooltip />
<el-table-column label="鍚堝悓閲戦(鍏�)" prop="contractAmount" width="220" show-overflow-tooltip
:formatter="formattedNumber" />
<el-table-column label="褰曞叆浜�" prop="entryPersonName" width="100" show-overflow-tooltip />
<el-table-column label="褰曞叆鏃ユ湡" prop="entryDate" width="120" show-overflow-tooltip />
<el-table-column label="绛捐鏃ユ湡" prop="executionDate" width="120" show-overflow-tooltip />
- <el-table-column fixed="right" label="鎿嶄綔" min-width="200" align="center">
+ <el-table-column fixed="right" label="鎿嶄綔" min-width="100" align="center">
<template #default="scope">
- <el-button link type="primary" size="small" :disabled="scope.row.invoiceTotal>0 || scope.row.entryPersonName !== userStore.nickName" @click="openForm('edit', scope.row)">缂栬緫</el-button>
+ <el-button link type="primary" size="small" @click="openForm('edit', scope.row)">缂栬緫</el-button>
<!-- <el-button link type="primary" size="small" @click="openForm('view', scope.row)">璇︽儏</el-button>-->
<el-button link type="primary" size="small" @click="downLoadFile(scope.row)">闄勪欢</el-button>
- <el-button link type="primary" size="small" @click="openDeliveryForm(scope.row)">鍙戣揣</el-button>
+<!-- <el-button link type="primary" size="small" @click="openDeliveryForm(scope.row)">鍙戣揣</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>
- <el-dialog v-model="dialogFormVisible" :title="operationType === 'add' ? '鏂板閿�鍞彴璐﹂〉闈�' : '缂栬緫閿�鍞彴璐﹂〉闈�'" width="70%"
- @close="closeDia">
+ <FormDialog
+ v-model="dialogFormVisible"
+ :title="operationType === 'add' ? '鏂板閿�鍞彴璐﹂〉闈�' : '缂栬緫閿�鍞彴璐﹂〉闈�'"
+ :width="'70%'"
+ :operation-type="operationType"
+ @close="closeDia"
+ @confirm="submitForm"
+ @cancel="closeDia">
<el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
<el-row :gutter="30">
<el-col :span="12">
@@ -93,7 +124,9 @@
</el-col>
<el-col :span="12">
<el-form-item label="涓氬姟鍛橈細" prop="salesman">
- <el-select v-model="form.salesman" placeholder="璇烽�夋嫨" clearable :disabled="operationType === 'view'">
+ <el-select v-model="form.salesman"
+ filterable
+ :reserve-keyword="false" placeholder="璇烽�夋嫨" clearable :disabled="operationType === 'view'">
<el-option v-for="item in userList" :key="item.nickName" :label="item.nickName"
:value="item.nickName" />
</el-select>
@@ -102,26 +135,14 @@
</el-row>
<el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="瀹㈡埛鍚堝悓鍙凤細" prop="customerContractNo">
- <el-input v-model="form.customerContractNo" placeholder="璇疯緭鍏�" clearable :disabled="operationType === 'view'"/>
- </el-form-item>
- </el-col>
- <el-col :span="12">
<el-form-item label="瀹㈡埛鍚嶇О锛�" prop="customerId">
- <el-select v-model="form.customerId" placeholder="璇烽�夋嫨" clearable :disabled="operationType === 'view'">
+ <el-select v-model="form.customerId" placeholder="璇烽�夋嫨" clearable :disabled="operationType === 'view'" filterable>
<el-option v-for="item in customerOption" :key="item.id" :label="item.customerName" :value="item.id">
{{
- item.customerName + "鈥斺��" + item.taxpayerIdentificationNumber
+ item.customerName+'-'+item.customerType
}}
</el-option>
</el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="椤圭洰鍚嶇О锛�" prop="projectName">
- <el-input v-model="form.projectName" placeholder="璇疯緭鍏�" clearable :disabled="operationType === 'view'" />
</el-form-item>
</el-col>
<el-col :span="12">
@@ -134,7 +155,10 @@
<el-row :gutter="30">
<el-col :span="12">
<el-form-item label="褰曞叆浜猴細" prop="entryPerson">
- <el-select v-model="form.entryPerson" placeholder="璇烽�夋嫨" clearable @change="changs" disabled>
+ <el-select v-model="form.entryPerson"
+ filterable
+ default-first-option
+ :reserve-keyword="false" placeholder="璇烽�夋嫨" clearable @change="changs">
<el-option v-for="item in userList" :key="item.userId" :label="item.nickName" :value="item.userId" />
</el-select>
</el-form-item>
@@ -142,7 +166,7 @@
<el-col :span="12">
<el-form-item label="褰曞叆鏃ユ湡锛�" prop="entryDate">
<el-date-picker style="width: 100%" v-model="form.entryDate" value-format="YYYY-MM-DD" format="YYYY-MM-DD"
- type="date" placeholder="璇烽�夋嫨" clearable disabled />
+ type="date" placeholder="璇烽�夋嫨" clearable />
</el-form-item>
</el-col>
</el-row>
@@ -208,7 +232,7 @@
<el-button @click="closeDia">鍙栨秷</el-button>
</div>
</template>
- </el-dialog>
+ </FormDialog>
<el-dialog v-model="productFormVisible" :title="productOperationType === 'add' ? '鏂板浜у搧' : '缂栬緫浜у搧'" width="40%"
@close="closeProductDia">
<el-form :model="productForm" label-width="140px" label-position="top" :rules="productRules" ref="productFormRef">
@@ -240,17 +264,19 @@
</el-col>
<el-col :span="12">
<el-form-item label="绋庣巼(%)锛�" prop="taxRate">
- <el-select v-model="productForm.taxRate" placeholder="璇烽�夋嫨" clearable @change="calculateFromTaxRate">
- <el-option label="1" value="1" />
- <el-option label="6" value="6" />
- <el-option label="13" value="13" />
- </el-select>
+<!-- <el-select v-model="productForm.taxRate" placeholder="璇烽�夋嫨" clearable @change="calculateFromTaxRate">-->
+<!-- <el-option label="1" value="1" />-->
+<!-- <el-option label="6" value="6" />-->
+<!-- <el-option label="13" value="13" />-->
+<!-- </el-select>-->
+ <el-input-number :step="1" :min="0" v-model="productForm.taxRate" style="width: 100%"
+ placeholder="璇疯緭鍏�" clearable @change="calculateFromTaxRate" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="鍚◣鍗曚环(鍏�)锛�" prop="taxInclusiveUnitPrice">
+ <el-form-item label="鍚◣/涓嶅惈绋庡崟浠�(鍏�)锛�" prop="taxInclusiveUnitPrice">
<el-input-number :step="0.01" :min="0" v-model="productForm.taxInclusiveUnitPrice" style="width: 100%"
:precision="2"
placeholder="璇疯緭鍏�" clearable @change="calculateFromUnitPrice" />
@@ -317,10 +343,10 @@
<div v-for="(item, index) in printData" :key="index" class="print-page">
<div class="delivery-note">
<div class="header">
- <div class="company-name">榧庤瘹鐟炲疄涓氭湁闄愯矗浠诲叕鍙�</div>
+ <div class="company-name">闈掓捣婀熸按宄″啘涓氬彂灞曟湁闄愬叕鍙�</div>
<div class="document-title">闆跺敭鍙戣揣鍗�</div>
</div>
-
+
<div class="info-section">
<div class="info-row">
<div>
@@ -328,12 +354,15 @@
<span class="value">{{ formatDate(item.createTime) }}</span>
</div>
<div>
-
- <span class="label">瀹㈡埛鍚嶇О锛�</span>
- <span class="value">{{ item.customerName || '寮犵埍鏈�' }}</span>
+ <span class="label">鍙戣揣杞︾墝鍙凤細</span>
+ <span class="value">{{ item.shippingCarNumber }}</span>
</div>
</div>
<div class="info-row">
+ <div>
+ <span class="label">瀹㈡埛鍚嶇О锛�</span>
+ <span class="value">{{ item.customerName || '寮犵埍鏈�' }}</span>
+ </div>
<span class="label">鍗曞彿锛�</span>
<span class="value">{{ item.salesContractNo }}</span>
</div>
@@ -457,26 +486,31 @@
<script setup>
import { getToken } from "@/utils/auth";
import pagination from "@/components/PIMTable/Pagination.vue";
-import {onMounted, ref} from "vue";
+import {onMounted, ref, getCurrentInstance} from "vue";
import { addShippingInfo } from "@/api/salesManagement/deliveryLedger.js";
-import { ElMessageBox } from "element-plus";
+import { ElMessageBox, ElMessage } from "element-plus";
+import { UploadFilled } from "@element-plus/icons-vue";
import useUserStore from "@/store/modules/user";
import { userListNoPage } from "@/api/system/user.js";
-import FileList from "./fileList.vue";
+import FileListDialog from '@/components/Dialog/FileListDialog.vue';
+import FormDialog from '@/components/Dialog/FormDialog.vue';
+import { getQuotationList } from "@/api/salesManagement/salesQuotation.js";
import {
- ledgerListPage,
- productList,
- customerList,
- addOrUpdateSalesLedger,
- getSalesLedgerWithProducts,
- delLedger,
- addOrUpdateSalesLedgerProduct,
- delProduct,
- delLedgerFile,
+ ledgerListPage,
+ productList,
+ customerList,
+ addOrUpdateSalesLedger,
+ getSalesLedgerWithProducts,
+ delLedger,
+ addOrUpdateSalesLedgerProduct,
+ delProduct,
+ delLedgerFile, getProductInventory,
} from "@/api/salesManagement/salesLedger.js";
+import { getQuotationDetail } from "@/api/salesManagement/salesQuotation.js";
import { modelList, productTreeList } from "@/api/basicData/product.js";
import useFormData from "@/hooks/useFormData.js";
import dayjs from "dayjs";
+import { getCurrentDate } from "@/utils/index.js";
const userStore = useUserStore();
const { proxy } = getCurrentInstance();
@@ -502,22 +536,16 @@
const data = reactive({
searchForm: {
customerName: "", // 瀹㈡埛鍚嶇О
- customerContractNo: "", // 瀹㈡埛鍚堝悓缂栧彿
salesContractNo: "", // 閿�鍞悎鍚岀紪鍙�
- projectName: "", // 椤圭洰鍚嶇О
- entryDate: [
- dayjs().format("YYYY-MM-DD"),
- dayjs().add(1, "day").format("YYYY-MM-DD"),
- ], // 褰曞叆鏃ユ湡
- entryDateStart: dayjs().format("YYYY-MM-DD"),
- entryDateEnd: dayjs().add(1, "day").format("YYYY-MM-DD"),
+ productCategory: "", // 浜у搧澶х被
+ entryDate: null, // 褰曞叆鏃ユ湡
+ entryDateStart: undefined,
+ entryDateEnd: undefined,
},
form: {
salesContractNo: "",
salesman: "",
- customerContractNo: "",
customerId: "",
- projectName: "",
entryPerson: "",
entryDate: "",
maintenanceTime: "",
@@ -527,15 +555,11 @@
},
rules: {
salesman: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
- customerContractNo: [
- { required: true, message: "璇疯緭鍏�", trigger: "blur" },
- ],
customerId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
- projectName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
entryPerson: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
entryDate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
executionDate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
- },
+ },
});
const { form, rules } = toRefs(data);
const { form: searchForm } = useFormData(data.searchForm);
@@ -566,14 +590,14 @@
taxInclusiveUnitPrice: [
{ required: true, message: "璇疯緭鍏�", trigger: "blur" },
],
- taxRate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+ // taxRate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
taxInclusiveTotalPrice: [
{ required: true, message: "璇疯緭鍏�", trigger: "blur" },
],
taxExclusiveTotalPrice: [
{ required: true, message: "璇疯緭鍏�", trigger: "blur" },
],
- invoiceType: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+ // invoiceType: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
},
});
const { productForm, productRules } = toRefs(productFormData);
@@ -622,7 +646,11 @@
// 鏌ヨ鍒楄〃
/** 鎼滅储鎸夐挳鎿嶄綔 */
const handleQuery = () => {
- page.current = 1;
+ // 鍙湁鍦ㄧ偣鍑绘悳绱㈡寜閽椂鎵嶉噸缃〉鐮佸埌绗竴椤�
+ // 閬垮厤琛ㄥ崟瀛楁change浜嬩欢骞叉壈鍒嗛〉
+ if (arguments.length === 0) {
+ page.current = 1;
+ }
expandedRowKeys.value = [];
getList();
};
@@ -649,8 +677,12 @@
};
// 鑾峰彇浜у搧澶х被tree鏁版嵁
const getProductOptions = () => {
- productTreeList().then((res) => {
- productOptions.value = convertIdToValue(res);
+ // 杩斿洖 Promise锛屼究浜庡湪缂栬緫浜у搧鏃剁瓑寰呭姞杞藉畬鎴�
+ return productTreeList().then((res) => {
+ // 鍏煎鎺ュ彛杩斿洖 { data: [] } 鎴栫洿鎺ヨ繑鍥炴暟缁�
+ const list = Array.isArray(res) ? res : (res?.data ?? []);
+ productOptions.value = convertIdToValue(list);
+ return productOptions.value;
});
};
const formattedNumber = (row, column, cellValue) => {
@@ -669,6 +701,7 @@
if (index !== -1) {
productForm.value.specificationModel = modelOptions.value[index].model;
productForm.value.unit = modelOptions.value[index].unit;
+ fetchQuotationPrice();
} else {
productForm.value.specificationModel = null;
productForm.value.unit = null;
@@ -688,6 +721,29 @@
}
return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull
};
+// 鏍规嵁鎶ヤ环鎺ュ彛鍥炲~鍗曚环
+const fetchQuotationPrice = async () => {
+ // 闇�瑕佸鎴风被鍨嬨�佷骇鍝佸悕绉般�佽鏍�
+ const customer = customerOption.value.find((c) => c.id === form.value.customerId);
+ const customerType = customer?.customerType || customer?.type;
+ const productName = productForm.value.productCategory;
+ const specification = productForm.value.specificationModel;
+
+ try {
+ const { data } = await getQuotationDetail({
+ type: customerType,
+ productName,
+ specification,
+ });
+ const price = data;
+ if (price !== null && price !== undefined) {
+ productForm.value.taxInclusiveUnitPrice = Number(price);
+ mathNum(); // 閲嶆柊璁$畻鎬讳环
+ }
+ } catch (error) {
+ console.error("鑾峰彇鎶ヤ环鍗曚环澶辫触", error);
+ }
+};
function convertIdToValue(data) {
return data.map((item) => {
const { id, children, ...rest } = item;
@@ -701,6 +757,19 @@
return newItem;
});
+}
+// 鏍规嵁鍚嶇О鍙嶆煡浜у搧澶х被 id锛屼究浜庝粎瀛樺悕绉版椂鐨勫弽鏄�
+function findNodeIdByLabel(nodes, label) {
+ if (!label) return null;
+ for (let i = 0; i < nodes.length; i++) {
+ const node = nodes[i];
+ if (node.label === label) return node.value;
+ if (node.children && node.children.length > 0) {
+ const found = findNodeIdByLabel(node.children, label);
+ if (found !== null && found !== undefined) return found;
+ }
+ }
+ return null;
}
// 琛ㄦ牸閫夋嫨鏁版嵁
const handleSelectionChange = (selection) => {
@@ -758,7 +827,12 @@
customerOption.value = res;
});
form.value.entryPerson = userStore.id;
- if (type !== "add") {
+ if (type === "add") {
+ // 鏂板鏃惰缃綍鍏ユ棩鏈熶负褰撳ぉ
+ form.value.entryDate = getCurrentDate();
+ // 绛捐鏃ユ湡榛樿涓哄綋澶�
+ form.value.executionDate = getCurrentDate();
+ } else {
currentId.value = row.id;
getSalesLedgerWithProducts({ id: row.id, type: 1 }).then((res) => {
form.value = { ...res };
@@ -848,13 +922,40 @@
const productIndex = ref(0);
// 鎵撳紑浜у搧寮规
-const openProductForm = (type, row,index) => {
+const openProductForm = async (type, row, index) => {
productOperationType.value = type;
productForm.value = {};
proxy.resetForm("productFormRef");
+ // 鏂板銆佺紪杈戦兘闇�鍏堝姞杞戒骇鍝佹爲锛屽惁鍒� el-tree-select 鏃犳暟鎹�
+ try {
+ await getProductOptions();
+ } catch (e) {
+ console.error("鍔犺浇浜у搧鏍戝け璐�", e);
+ }
if (type === "edit") {
productForm.value = { ...row };
productIndex.value = index;
+ // 缂栬緫鏃舵牴鎹骇鍝佸ぇ绫诲悕绉板弽鏌� tree 鑺傜偣 id锛屽苟鍔犺浇瑙勬牸鍨嬪彿鍒楄〃
+ try {
+ const options = productOptions.value && productOptions.value.length > 0
+ ? productOptions.value
+ : await getProductOptions();
+ const categoryId = findNodeIdByLabel(options, productForm.value.productCategory);
+ if (categoryId) {
+ const models = await modelList({ id: categoryId });
+ modelOptions.value = models || [];
+ // 鏍规嵁褰撳墠瑙勬牸鍨嬪彿鍚嶇О鍙嶆煡骞惰缃� productModelId锛屼究浜庝笅鎷夋鏄剧ず宸查�夊��
+ const currentModel = (modelOptions.value || []).find(
+ (m) => m.model === productForm.value.specificationModel
+ );
+ if (currentModel) {
+ productForm.value.productModelId = currentModel.id;
+ }
+ }
+ } catch (e) {
+ // 鍔犺浇澶辫触鏃朵繚鎸佸彲缂栬緫锛屼笉涓柇寮圭獥
+ console.error("鍔犺浇浜у搧瑙勬牸鍨嬪彿澶辫触", e);
+ }
}
productFormVisible.value = true;
getProductOptions();
@@ -978,25 +1079,25 @@
proxy.$modal.msgWarning("璇烽�夋嫨瑕佹墦鍗扮殑鏁版嵁");
return;
}
-
+
// 鏄剧ず鍔犺浇鐘舵��
proxy.$modal.loading("姝e湪鑾峰彇浜у搧鏁版嵁锛岃绋嶅��...");
-
+
try {
// 涓烘瘡涓�変腑鐨勯攢鍞彴璐﹁褰曟煡璇㈠搴旂殑浜у搧鏁版嵁
const printDataWithProducts = [];
-
+
for (const row of selectedRows.value) {
try {
// 璋冪敤productList鎺ュ彛鏌ヨ浜у搧鏁版嵁
const productRes = await productList({ salesLedgerId: row.id, type: 1 });
-
+
// 灏嗕骇鍝佹暟鎹暣鍚堝埌閿�鍞彴璐﹁褰曚腑
const rowWithProducts = {
...row,
products: productRes.data || []
};
-
+
printDataWithProducts.push(rowWithProducts);
} catch (error) {
console.error(`鑾峰彇閿�鍞彴璐� ${row.id} 鐨勪骇鍝佹暟鎹け璐�:`, error);
@@ -1007,11 +1108,11 @@
});
}
}
-
+
printData.value = printDataWithProducts;
console.log('鎵撳嵃鏁版嵁锛堝寘鍚骇鍝侊級:', printData.value);
printPreviewVisible.value = true;
-
+
} catch (error) {
console.error('鑾峰彇浜у搧鏁版嵁澶辫触:', error);
proxy.$modal.msgError("鑾峰彇浜у搧鏁版嵁澶辫触锛岃閲嶈瘯");
@@ -1023,10 +1124,10 @@
const executePrint = () => {
console.log('寮�濮嬫墽琛屾墦鍗帮紝鏁版嵁鏉℃暟:', printData.value.length);
console.log('鎵撳嵃鏁版嵁:', printData.value);
-
+
// 鍒涘缓涓�涓柊鐨勬墦鍗扮獥鍙�
const printWindow = window.open('', '_blank', 'width=800,height=600');
-
+
// 鏋勫缓鎵撳嵃鍐呭
let printContent = `
<!DOCTYPE html>
@@ -1162,17 +1263,17 @@
</head>
<body>
`;
-
+
// 涓烘瘡鏉℃暟鎹敓鎴愭墦鍗伴〉闈�
printData.value.forEach((item, index) => {
printContent += `
<div class="print-page">
<div class="delivery-note">
<div class="header">
- <div class="company-name">榧庤瘹鐟炲疄涓氭湁闄愯矗浠诲叕鍙�</div>
+ <div class="company-name">闈掓捣婀熸按宄″啘涓氬彂灞曟湁闄愬叕鍙�</div>
<div class="document-title">闆跺敭鍙戣揣鍗�</div>
</div>
-
+
<div class="info-section">
<div class="info-row">
<div>
@@ -1203,7 +1304,7 @@
</tr>
</thead>
<tbody>
- ${item.products && item.products.length > 0 ?
+ ${item.products && item.products.length > 0 ?
item.products.map(product => `
<tr>
<td>${product.productCategory || ''}</td>
@@ -1213,7 +1314,7 @@
<td>${product.quantity || '0'}</td>
<td>${product.taxInclusiveTotalPrice || '0'}</td>
</tr>
- `).join('') :
+ `).join('') :
'<tr><td colspan="6" style="text-align: center; color: #999;">鏆傛棤浜у搧鏁版嵁</td></tr>'
}
</tbody>
@@ -1260,16 +1361,16 @@
</div>
`;
});
-
+
printContent += `
</body>
</html>
`;
-
+
// 鍐欏叆鍐呭鍒版柊绐楀彛
printWindow.document.write(printContent);
printWindow.document.close();
-
+
// 绛夊緟鍐呭鍔犺浇瀹屾垚鍚庢墦鍗�
printWindow.onload = () => {
setTimeout(() => {
@@ -1298,15 +1399,6 @@
const seconds = String(date.getSeconds()).padStart(2, "0");
return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
};
-// 鑾峰彇褰撳墠鏃ユ湡骞舵牸寮忓寲涓� 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 getTotalQuantity = (products) => {
if (!products || products.length === 0) return '0';
@@ -1369,148 +1461,151 @@
// 鏍规嵁鍚◣鎬讳环璁$畻鍚◣鍗曚环鍜屾暟閲�
const calculateFromTotalPrice = () => {
if (isCalculating.value) return;
-
+
const totalPrice = parseFloat(productForm.value.taxInclusiveTotalPrice);
const quantity = parseFloat(productForm.value.quantity);
-
+ const taxRate = Number(productForm.value.taxRate) || 0;
+
if (!totalPrice || !quantity || quantity <= 0) {
return;
}
-
+
isCalculating.value = true;
-
+
// 璁$畻鍚◣鍗曚环 = 鍚◣鎬讳环 / 鏁伴噺
productForm.value.taxInclusiveUnitPrice = (totalPrice / quantity).toFixed(2);
-
+
// 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
- if (productForm.value.taxRate) {
- productForm.value.taxExclusiveTotalPrice =
+ productForm.value.taxExclusiveTotalPrice =
proxy.calculateTaxExclusiveTotalPrice(
- totalPrice,
- productForm.value.taxRate
+ totalPrice,
+ taxRate
);
- }
-
+
isCalculating.value = false;
};
// 鏍规嵁涓嶅惈绋庢�讳环璁$畻鍚◣鍗曚环鍜屾暟閲�
const calculateFromExclusiveTotalPrice = () => {
- if (!productForm.value.taxRate) {
- proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
- return;
- }
+ // if (!productForm.value.taxRate) {
+ // proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
+ // return;
+ // }
if (isCalculating.value) return;
-
+
const exclusiveTotalPrice = parseFloat(productForm.value.taxExclusiveTotalPrice);
const quantity = parseFloat(productForm.value.quantity);
- const taxRate = parseFloat(productForm.value.taxRate);
-
- if (!exclusiveTotalPrice || !quantity || quantity <= 0 || !taxRate) {
+ const taxRate = Number(productForm.value.taxRate) || 0;
+
+ // if (!exclusiveTotalPrice || !quantity || quantity <= 0 || !taxRate) {
+ // return;
+ // }
+ if (!exclusiveTotalPrice || !quantity || quantity <= 0) {
return;
}
-
+
isCalculating.value = true;
-
+
// 鍏堣绠楀惈绋庢�讳环 = 涓嶅惈绋庢�讳环 / (1 - 绋庣巼/100)
const taxRateDecimal = taxRate / 100;
const inclusiveTotalPrice = exclusiveTotalPrice / (1 - taxRateDecimal);
productForm.value.taxInclusiveTotalPrice = inclusiveTotalPrice.toFixed(2);
-
+
// 璁$畻鍚◣鍗曚环 = 鍚◣鎬讳环 / 鏁伴噺
productForm.value.taxInclusiveUnitPrice = (inclusiveTotalPrice / quantity).toFixed(2);
-
+
isCalculating.value = false;
};
// 鏍规嵁鏁伴噺鍙樺寲璁$畻鎬讳环
const calculateFromQuantity = () => {
- if (!productForm.value.taxRate) {
- proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
- return;
- }
+ // if (!productForm.value.taxRate) {
+ // proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
+ // return;
+ // }
if (isCalculating.value) return;
-
+
const quantity = parseFloat(productForm.value.quantity);
const unitPrice = parseFloat(productForm.value.taxInclusiveUnitPrice);
-
+ const taxRate = Number(productForm.value.taxRate) || 0;
+
if (!quantity || quantity <= 0 || !unitPrice) {
return;
}
-
+
isCalculating.value = true;
-
+
// 璁$畻鍚◣鎬讳环
productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
-
+
// 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
- if (productForm.value.taxRate) {
- productForm.value.taxExclusiveTotalPrice =
+ productForm.value.taxExclusiveTotalPrice =
proxy.calculateTaxExclusiveTotalPrice(
- productForm.value.taxInclusiveTotalPrice,
- productForm.value.taxRate
+ productForm.value.taxInclusiveTotalPrice,
+ taxRate
);
- }
-
+
isCalculating.value = false;
};
// 鏍规嵁鍚◣鍗曚环鍙樺寲璁$畻鎬讳环
const calculateFromUnitPrice = () => {
- if (!productForm.value.taxRate) {
- proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
- return;
- }
+ // if (!productForm.value.taxRate) {
+ // proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
+ // return;
+ // }
if (isCalculating.value) return;
-
+
const quantity = parseFloat(productForm.value.quantity);
const unitPrice = parseFloat(productForm.value.taxInclusiveUnitPrice);
-
+ const taxRate = Number(productForm.value.taxRate) || 0;
+
if (!quantity || quantity <= 0 || !unitPrice) {
return;
}
-
+
isCalculating.value = true;
-
+
// 璁$畻鍚◣鎬讳环
productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
-
+
// 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
- if (productForm.value.taxRate) {
- productForm.value.taxExclusiveTotalPrice =
+ productForm.value.taxExclusiveTotalPrice =
proxy.calculateTaxExclusiveTotalPrice(
- productForm.value.taxInclusiveTotalPrice,
- productForm.value.taxRate
+ productForm.value.taxInclusiveTotalPrice,
+ taxRate
);
- }
-
+
isCalculating.value = false;
};
// 鏍规嵁绋庣巼鍙樺寲璁$畻涓嶅惈绋庢�讳环
const calculateFromTaxRate = () => {
- if (!productForm.value.taxRate) {
- proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
- return;
- }
+ // if (!productForm.value.taxRate) {
+ // proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
+ // return;
+ // }
if (isCalculating.value) return;
-
+
const inclusiveTotalPrice = parseFloat(productForm.value.taxInclusiveTotalPrice);
- const taxRate = parseFloat(productForm.value.taxRate);
-
- if (!inclusiveTotalPrice || !taxRate) {
+ const taxRate = Number(productForm.value.taxRate) || 0;
+
+ // if (!inclusiveTotalPrice || !taxRate) {
+ // return;
+ // }
+ if (!inclusiveTotalPrice) {
return;
}
-
+
isCalculating.value = true;
-
+
// 璁$畻涓嶅惈绋庢�讳环
productForm.value.taxExclusiveTotalPrice =
proxy.calculateTaxExclusiveTotalPrice(
inclusiveTotalPrice,
taxRate
);
-
+
isCalculating.value = false;
};
/**
@@ -1527,12 +1622,16 @@
// 鎵撳紑鍙戣揣寮规
const openDeliveryForm = (row) => {
- currentDeliveryRow.value = row;
- deliveryForm.value = {
- shippingDate: getCurrentDate(),
- shippingCarNumber: "",
- };
- deliveryFormVisible.value = true;
+ getProductInventory({ salesLedgerId: row.id, type:1 }).then((res) => {
+ currentDeliveryRow.value = row;
+ deliveryForm.value = {
+ shippingDate: getCurrentDate(),
+ shippingCarNumber: "",
+ };
+ deliveryFormVisible.value = true;
+ }).catch(err => {
+ ElMessage.error(err.msg);
+ });
};
// 鎻愪氦鍙戣揣琛ㄥ崟
@@ -1595,12 +1694,12 @@
padding: 15px;
border-bottom: 1px solid #e4e7ed;
text-align: center;
-
+
.el-button {
margin: 0 10px;
}
}
-
+
.print-preview-content {
padding: 20px;
background-color: #f5f5f5;
@@ -1632,13 +1731,13 @@
.header {
text-align: center;
margin-bottom: 8px;
-
+
.company-name {
font-size: 18px;
font-weight: bold;
margin-bottom: 4px;
}
-
+
.document-title {
font-size: 16px;
font-weight: bold;
@@ -1650,16 +1749,16 @@
display: flex;
justify-content: space-between;
align-items: center;
-
+
.info-row {
line-height: 20px;
-
+
.label {
font-weight: bold;
width: 60px;
font-size: 14px;
}
-
+
.value {
margin-right: 20px;
min-width: 80px;
@@ -1671,12 +1770,12 @@
.table-section {
margin-bottom: 4px;
flex: 1;
-
+
.product-table {
width: 100%;
border-collapse: collapse;
border: 1px solid #000;
-
+
th, td {
border: 1px solid #000;
padding: 6px;
@@ -1684,16 +1783,16 @@
font-size: 14px;
line-height: 1.4;
}
-
+
th {
font-weight: bold;
}
-
+
.total-label {
text-align: right;
font-weight: bold;
}
-
+
.total-value {
font-weight: bold;
}
@@ -1706,22 +1805,22 @@
margin-bottom: 3px;
line-height: 20px;
justify-content: space-between;
-
+
.footer-item {
display: flex;
margin-right: 20px;
-
+
.label {
font-weight: bold;
width: 80px;
font-size: 14px;
}
-
+
.value {
min-width: 80px;
font-size: 14px;
}
-
+
&.address-item {
.address-value {
min-width: 200px;
@@ -1735,7 +1834,7 @@
.app-container {
display: none;
}
-
+
.print-page {
box-shadow: none;
margin: 0;
--
Gitblit v1.9.3