From 202557aeadba147a25ae72a8992fd184d13252d9 Mon Sep 17 00:00:00 2001
From: 张诺 <zhang_12370@163.com>
Date: 星期三, 11 六月 2025 18:02:41 +0800
Subject: [PATCH] 新增文档管理 优化其他页面
---
src/views/procureMent/components/ProductionDialog.vue | 372 ++++++++++++++++++++++++++++++----------------------
1 files changed, 215 insertions(+), 157 deletions(-)
diff --git a/src/views/procureMent/components/ProductionDialog.vue b/src/views/procureMent/components/ProductionDialog.vue
index 3da88f5..5a0f8a9 100644
--- a/src/views/procureMent/components/ProductionDialog.vue
+++ b/src/views/procureMent/components/ProductionDialog.vue
@@ -1,7 +1,7 @@
<template>
<div>
<el-dialog
- v-model="dialogVisible"
+ v-model="dialogFormVisible"
:title="title"
width="600"
:close-on-click-modal="false"
@@ -19,29 +19,87 @@
<el-form-item label="渚涘簲鍟嗗悕绉�" prop="supplierName">
<el-input v-model="form.supplierName" placeholder="璇疯緭鍏�" />
</el-form-item>
- <el-form-item label="鐓ょ" prop="category">
- <el-input v-model="form.category" placeholder="璇疯緭鍏�" />
- </el-form-item>
+ <el-form-item label="鐓ょ" prop="coal">
+ <el-select v-model="form.coal" placeholder="璇烽�夋嫨鐓ょ" clearable style="width: 100%">
+ <el-option label="鐦︾叅" value="鐦︾叅" />
+ <el-option label="姘旂叅" value="姘旂叅" />
+ <el-option label="鏃犵儫鐓�" value="鏃犵儫鐓�" />
+ <el-option label="闀跨劙鐓�" value="闀跨劙鐓�" />
+ <el-option label="璐叅" value="璐叅" />
+ </el-select>
+ </el-form-item>
<el-form-item label="鍗曚綅" prop="unit">
- <el-input v-model="form.unit" placeholder="璇疯緭鍏�" />
+ <el-select v-model="form.unit" placeholder="璇烽�夋嫨鍗曚綅" clearable style="width: 100%">
+ <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="璇疯緭鍏�"
+ @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="purchaseAmount">
- <el-input v-model="form.purchaseAmount" placeholder="璇疯緭鍏�" />
+ <el-form-item label="鍗曚环(涓嶅惈绋�)" prop="priceExcludingTax">
+ <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="priceBeforeTax">
- <el-input v-model="form.priceBeforeTax" placeholder="璇疯緭鍏�" />
+ <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="totalBeforeTax">
- <el-input v-model="form.totalBeforeTax" placeholder="璇疯緭鍏�" />
+ <el-form-item label="鎬讳环(鍚◣)" prop="totalPriceIncludingTax">
+ <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="calorificValue">
- <el-input v-model="form.calorificValue" placeholder="璇疯緭鍏�" />
- </el-form-item>
- <el-form-item label="鐧昏浜�" prop="registrant">
- <el-input v-model="form.registrant" placeholder="璇疯緭鍏�" />
+ <el-form-item label="鐧昏浜�" prop="registrantId">
+ <el-input v-model="form.registrantId" disabled placeholder="璇疯緭鍏�" />
</el-form-item>
<el-form-item label="鐧昏鏃ユ湡" prop="registrationDate">
<el-date-picker
+ disabled
v-model="form.registrationDate"
type="date"
placeholder="YYYY-MM-DD"
@@ -52,20 +110,18 @@
</el-form>
<template #footer>
<div class="dialog-footer">
- <el-button type="primary" @click="handleSubmit">淇濆瓨</el-button>
<!-- 閲嶇疆鍜屽彇娑� -->
<el-button
- type="primary"
@click="handleClose"
v-if="title.includes('鏂板')"
>鍙栨秷</el-button
>
<el-button
- type="primary"
@click="handleReset"
v-if="title.includes('缂栬緫')"
>閲嶇疆</el-button
>
+ <el-button type="primary" @click="handleSubmit">纭</el-button>
</div>
</template>
</el-dialog>
@@ -73,16 +129,18 @@
</template>
<script setup name="ProductionDialog">
-import { ref, defineProps, watch } 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";
const props = defineProps({
title: {
type: String,
default: "",
},
});
-const emit = defineEmits(["update:visible", "success"]);
-const dialogVisible = defineModel("dialogFormVisible", {
+const emit = defineEmits(["update:dialogFormVisible", "success"]);
+const dialogFormVisible = defineModel("dialogFormVisible", {
required: true,
type: Boolean,
});
@@ -90,164 +148,164 @@
required: true,
type: Object,
});
+const copyForm = defineModel("copyForm", {
+ 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;
+})
const rules = {
supplierName: [
{ required: true, message: "璇疯緭鍏ヤ緵搴斿晢鍚嶇О", trigger: "blur" },
],
- category: [{ required: true, message: "璇疯緭鍏ョ叅绉�", trigger: "blur" }],
+ coal: [{ required: true, message: "璇疯緭鍏ョ叅绉�", trigger: "blur" }],
unit: [{ required: true, message: "璇疯緭鍏ュ崟浣�", trigger: "blur" }],
- purchaseAmount: [
+ purchaseQuantity: [
{ required: true, message: "璇疯緭鍏ラ噰璐暟閲�", trigger: "blur" },
+ { type: "number", message: "閲囪喘鏁伴噺蹇呴』涓烘暟瀛�", trigger: "blur" },
],
- priceBeforeTax: [{ required: true, message: "璇疯緭鍏ュ崟浠�", trigger: "blur" }],
- totalBeforeTax: [{ required: true, message: "璇疯緭鍏ユ�讳环", trigger: "blur" }],
- calorificValue: [{ required: true, message: "璇疯緭鍏ョ儹鍊�", trigger: "blur" }],
- registrant: [{ required: true, message: "璇疯緭鍏ョ櫥璁颁汉", trigger: "blur" }],
+ priceExcludingTax: [{ required: true, message: "璇疯緭鍏ュ崟浠�", trigger: "blur" }],
+ totalPriceExcludingTax: [{ required: true, message: "璇疯緭鍏ユ�讳环", trigger: "blur" }],
+ priceIncludingTax: [{ required: true, message: "璇疯緭鍏ュ惈绋庡崟浠�", trigger: "blur" }],
+ totalPriceIncludingTax: [{ required: true, message: "璇疯緭鍏ュ惈绋庢�讳环", trigger: "blur" }],
+ taxRate: [{ required: true, message: "璇疯緭鍏ョ◣鐜�", trigger: "blur" }],
+ registrantId: [{ required: true, message: "璇疯緭鍏ョ櫥璁颁汉", trigger: "blur" }],
registrationDate: [
{ required: true, message: "璇烽�夋嫨鐧昏鏃ユ湡", trigger: "change" },
],
};
// 鍏抽棴寮圭獥
const handleClose = () => {
- dialogVisible.value = false;
- console.log(form.value);
- // formRef.value?.resetFields()
- // Object.assign(form, {
- // })
+ dialogFormVisible.value = false;
};
-const handleReset = () => {
- if (!formRef.value) return;
- formRef.value.resetFields();
- ElMessage.success("琛ㄥ崟宸查噸缃�");
-};
-// 鎸佺画鐩戝惉form.value鐨勫彉鍖�
-watch(
- () => form.value,
- (val) => {
- console.log(val);
+const handleReset = async () => {
+ // 閲嶇疆琛ㄥ崟鏁版嵁
+ form.value = JSON.parse(JSON.stringify(copyForm.value));
+ // 绛夊緟DOM鏇存柊瀹屾垚鍚庢竻闄よ〃鍗曢獙璇佺姸鎬�
+ await nextTick();
+ if (formRef.value) {
+ formRef.value.clearValidate();
}
-);
+};
const formRef = ref(null);
// 鎻愪氦琛ㄥ崟
const handleSubmit = async () => {
+ console.log("鎻愪氦琛ㄥ崟", form.value);
if (!formRef.value) return;
- await formRef.value.validate((valid) => {
+ await formRef.value.validate(async (valid) => {
if (valid) {
- try {
- emit("success", { ...form.value });
- handleClose();
- ElMessage.success("淇濆瓨鎴愬姛");
- } catch (error) {
- console.error("淇濆瓨澶辫触:", error);
- ElMessage.error("淇濆瓨澶辫触");
+ const obj = ref({});
+ if (props.title.includes('鏂板')) {
+ let result = await addOrEditPR({
+ ...form.value,
+ })
+ obj.value = {
+ title: "鏂板",
+ ...form.value,
+ result
+ };
+ } else {
+ delete form.value.updateTime
+ delete form.value.createTime
+ let result = await addOrEditPR({
+ ...form.value,
+ })
+ obj.value = {
+ title: "缂栬緫",
+ ...form.value,
+ result
+ };
}
+ emit("submit", obj.value);
}
});
};
</script>
-<style lang="less" scoped>
-</style>
-
-<!-- <template>
- <el-dialog
- v-model="dialogFormVisible"
- title="閲囪喘鐧昏鏂板"
- width="500px"
- :close-on-click-modal="false"
- @close="handleClose"
- >
-
- </el-dialog>
-</template>
-
-<script setup>
-import { ref, reactive, defineProps, defineEmits } from 'vue'
-import { ElMessage } from 'element-plus'
-
-const props = defineProps({
- visible: {
- type: Boolean,
- default: false
- }
-})
-
-const emit = defineEmits(['update:visible', 'success'])
-
-const dialogFormVisible = ref(false)
-const formRef = ref(null)
-
-// 琛ㄥ崟鏁版嵁
-const form = reactive({
- supplierName: '',
- category: '',
- unit: '',
- purchaseAmount: '',
- priceBeforeTax: '',
- totalBeforeTax: '',
- calorificValue: '',
- registrant: '',
- registrationDate: ''
-})
-
-// 琛ㄥ崟楠岃瘉瑙勫垯
-
-
-// 鐩戝惉visible鍙樺寲
-watch(() => props.visible, (val) => {
- dialogFormVisible.value = val
-})
-
-// 鐩戝惉dialogFormVisible鍙樺寲
-watch(() => dialogFormVisible.value, (val) => {
- emit('update:visible', val)
-})
-
-// 鎻愪氦琛ㄥ崟
-const handleSubmit = async () => {
- if (!formRef.value) return
-
- await formRef.value.validate((valid) => {
- if (valid) {
- try {
- emit('success', { ...form })
- handleClose()
- ElMessage.success('淇濆瓨鎴愬姛')
- } catch (error) {
- console.error('淇濆瓨澶辫触:', error)
- ElMessage.error('淇濆瓨澶辫触')
- }
- }
- })
-}
-
-// 鍙栨秷
-const handleCancel = () => {
- handleClose()
-}
-</script>
-
-<style scoped>
-.production-form {
- padding: 20px;
-}
-
-.dialog-footer {
- display: flex;
- justify-content: center;
- gap: 20px;
-}
-
-:deep(.el-form-item__label) {
- font-weight: normal;
-}
-
-:deep(.el-input),
-:deep(.el-date-picker) {
- width: 100%;
-}
-
-:deep(.el-dialog__body) {
- padding-top: 10px;
-}
-</style> -->
\ No newline at end of file
+<style lang="sass" scoped>
+</style>
\ No newline at end of file
--
Gitblit v1.9.3