From 624faa46fb237709a40db1567e3b708ec24c4222 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 12 六月 2025 17:30:41 +0800
Subject: [PATCH] 1.巡检管理页面开发
---
src/views/procureMent/components/ProductionDialog.vue | 142 ++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 121 insertions(+), 21 deletions(-)
diff --git a/src/views/procureMent/components/ProductionDialog.vue b/src/views/procureMent/components/ProductionDialog.vue
index 3216d1f..5a0f8a9 100644
--- a/src/views/procureMent/components/ProductionDialog.vue
+++ b/src/views/procureMent/components/ProductionDialog.vue
@@ -33,48 +33,66 @@
<el-option label="鍚�" value="鍚�" />
<el-option label="鍗冨厠" value="鍗冨厠" />
</el-select>
- </el-form-item>
- <el-form-item label="閲囪喘鏁伴噺" prop="purchaseQuantity">
- <el-input v-model.number="form.purchaseQuantity" placeholder="璇疯緭鍏�" >
+ </el-form-item> <el-form-item label="閲囪喘鏁伴噺" prop="purchaseQuantity">
+ <el-input
+ v-model.number="form.purchaseQuantity"
+ placeholder="璇疯緭鍏�"
+ @blur="handleQuantityBlur"
+ >
<template v-slot:suffix>
<i style="font-style:normal;">{{form.unit?form.unit:''}}</i>
</template>
</el-input>
+ </el-form-item><el-form-item label="绋庣巼" prop="taxRate">
+ <el-input
+ v-model.number="form.taxRate"
+ placeholder="璇疯緭鍏ョ◣鐜�"
+ @blur="handleTaxRateBlur"
+ >
+ <template v-slot:suffix>
+ <i style="font-style:normal;">%</i>
+ </template>
+ </el-input>
</el-form-item>
<el-form-item label="鍗曚环(涓嶅惈绋�)" prop="priceExcludingTax">
- <el-input v-model.number="form.priceExcludingTax" placeholder="璇疯緭鍏�" >
+ <el-input
+ v-model.number="form.priceExcludingTax"
+ placeholder="璇疯緭鍏�"
+ @blur="handlePriceBlur"
+ >
+ <template v-slot:suffix>
+ <i style="font-style:normal;">鍏�</i>
+ </template>
+ </el-input>
+ </el-form-item> <el-form-item label="鍗曚环(鍚◣)" prop="priceIncludingTax">
+ <el-input
+ v-model.number="form.priceIncludingTax"
+ placeholder="鑷姩璁$畻"
+ >
<template v-slot:suffix>
<i style="font-style:normal;">鍏�</i>
</template>
</el-input>
</el-form-item>
<el-form-item label="鎬讳环(涓嶅惈绋�)" prop="totalPriceExcludingTax">
- <el-input v-model.number="form.totalPriceExcludingTax" placeholder="璇疯緭鍏�" >
- <template v-slot:suffix>
- <i style="font-style:normal;">鍏�</i>
- </template>
- </el-input>
- </el-form-item>
- <el-form-item label="鍗曚环(鍚◣)" prop="priceIncludingTax">
- <el-input v-model.number="form.priceIncludingTax" placeholder="璇疯緭鍏�" >
+ <el-input
+ v-model.number="form.totalPriceExcludingTax"
+ placeholder="鑷姩璁$畻"
+ >
<template v-slot:suffix>
<i style="font-style:normal;">鍏�</i>
</template>
</el-input>
</el-form-item>
<el-form-item label="鎬讳环(鍚◣)" prop="totalPriceIncludingTax">
- <el-input v-model.number="form.totalPriceIncludingTax" placeholder="璇疯緭鍏�" >
+ <el-input
+ v-model.number="form.totalPriceIncludingTax"
+ placeholder="鑷姩璁$畻"
+ >
<template v-slot:suffix>
<i style="font-style:normal;">鍏�</i>
</template>
</el-input>
- </el-form-item>
- <el-form-item label="绋庣巼" prop="taxRate">
- <el-input v-model="form.taxRate" placeholder="璇疯緭鍏ョ◣鐜�" >
- <template v-slot:suffix>
- <i style="font-style:normal;">%</i>
- </template>
- </el-input>
</el-form-item>
<el-form-item label="鐧昏浜�" prop="registrantId">
<el-input v-model="form.registrantId" disabled placeholder="璇疯緭鍏�" />
@@ -111,7 +129,7 @@
</template>
<script setup name="ProductionDialog">
-import { ref, defineProps, watch, onMounted, nextTick } from "vue";
+import { ref, defineProps, watch, onMounted, nextTick, computed } from "vue";
import { ElMessage } from "element-plus";
import useUserStore from '@/store/modules/user'
import {addOrEditPR} from "@/api/procureMent";
@@ -134,8 +152,89 @@
required: true,
type: Object,
});
+
+const toFixed = (num, precision = 2) => {
+ if (isNaN(num) || num === null || num === undefined || num === '') {
+ return 0;
+ }
+ return Math.floor(parseFloat(num) * Math.pow(10, precision)) / Math.pow(10, precision);
+};
+// 鍚◣鍗曚环璁$畻
+const unitPriceWithTax = computed(() => {
+ const priceExcludingTax = parseFloat(form.value.priceExcludingTax) || 0;
+ const taxRate = parseFloat(form.value.taxRate) || 0;
+ if (!priceExcludingTax || !taxRate) {
+ return 0;
+ }
+ const result = priceExcludingTax * (1 + taxRate / 100);
+ return toFixed(result, 2);
+});
+
+// 鍚◣鎬讳环璁$畻
+const totalUnitPriceWithTax = computed(() => {
+ const priceExcludingTax = parseFloat(form.value.priceExcludingTax) || 0;
+ const taxRate = parseFloat(form.value.taxRate) || 0;
+ const purchaseQuantity = parseFloat(form.value.purchaseQuantity) || 0;
+
+ if (!priceExcludingTax || !taxRate || !purchaseQuantity) {
+ return 0;
+ }
+
+ const unitPriceWithTaxValue = priceExcludingTax * (1 + taxRate / 100);
+ const result = unitPriceWithTaxValue * purchaseQuantity;
+ return toFixed(result, 2);
+});
+
+// 涓嶅惈绋庢�讳环璁$畻
+const taxExclusiveTotalPrice = computed(() => {
+ const purchaseQuantity = parseFloat(form.value.purchaseQuantity) || 0;
+ const priceExcludingTax = parseFloat(form.value.priceExcludingTax) || 0;
+
+ if (!purchaseQuantity || !priceExcludingTax) {
+ return 0;
+ }
+
+ const result = purchaseQuantity * priceExcludingTax;
+ return toFixed(result, 2);
+});
+
+// 鐩戝惉璁$畻鍊煎彉鍖栵紝鍚屾鍒� form 瀵硅薄涓�
+watch(unitPriceWithTax, (newValue) => {
+ form.value.priceIncludingTax = newValue;
+});
+
+watch(totalUnitPriceWithTax, (newValue) => {
+ form.value.totalPriceIncludingTax = newValue;
+});
+
+watch(taxExclusiveTotalPrice, (newValue) => {
+ form.value.totalPriceExcludingTax = newValue;
+});
+
const userStore = useUserStore()
const userInfo = ref({});
+
+// 澶勭悊绋庣巼杈撳叆妗嗗け鐒︼紝纭繚绮惧害
+const handleTaxRateBlur = () => {
+ if (form.value.taxRate !== null && form.value.taxRate !== undefined && form.value.taxRate !== '') {
+ form.value.taxRate = toFixed(parseFloat(form.value.taxRate), 2);
+ }
+};
+
+// 澶勭悊涓嶅惈绋庡崟浠疯緭鍏ユ澶辩劍锛岀‘淇濈簿搴�
+const handlePriceBlur = () => {
+ if (form.value.priceExcludingTax !== null && form.value.priceExcludingTax !== undefined && form.value.priceExcludingTax !== '') {
+ form.value.priceExcludingTax = toFixed(parseFloat(form.value.priceExcludingTax), 2);
+ }
+};
+
+// 澶勭悊閲囪喘鏁伴噺杈撳叆妗嗗け鐒︼紝纭繚绮惧害
+const handleQuantityBlur = () => {
+ if (form.value.purchaseQuantity !== null && form.value.purchaseQuantity !== undefined && form.value.purchaseQuantity !== '') {
+ form.value.purchaseQuantity = toFixed(parseFloat(form.value.purchaseQuantity), 3); // 鏁伴噺淇濈暀3浣嶅皬鏁�
+ }
+};
+
onMounted(async () => {
let res = await userStore.getInfo()
userInfo.value = res;
@@ -176,6 +275,7 @@
const formRef = ref(null);
// 鎻愪氦琛ㄥ崟
const handleSubmit = async () => {
+ console.log("鎻愪氦琛ㄥ崟", form.value);
if (!formRef.value) return;
await formRef.value.validate(async (valid) => {
if (valid) {
--
Gitblit v1.9.3