From 6472e7cb3babd991e0e10e8de6bafee4dafdf76e Mon Sep 17 00:00:00 2001 From: gaoluyang <2820782392@qq.com> Date: 星期四, 12 六月 2025 15:52:00 +0800 Subject: [PATCH] 1.销售出库页面联调 --- src/views/salesOutbound/components/formDia.vue | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 100 insertions(+), 17 deletions(-) diff --git a/src/views/salesOutbound/components/formDia.vue b/src/views/salesOutbound/components/formDia.vue index d9d8059..8607196 100644 --- a/src/views/salesOutbound/components/formDia.vue +++ b/src/views/salesOutbound/components/formDia.vue @@ -1,6 +1,6 @@ <template> <div> - <el-dialog :title="operationType === 'add' ? '鏂板鍑哄簱' : '缂栬緫鍑哄簱'" + <el-dialog :title="operationType === 'add' ? '鏂板閿�鍞嚭搴�' : '缂栬緫閿�鍞嚭搴�'" v-model="dialogVisitable" width="800px" @close="cancel"> <el-form :model="form" :rules="rules" ref="formRef" label-width="120px"> <el-row> @@ -22,9 +22,9 @@ <el-select v-model="form.customerId" placeholder="璇烽�夋嫨瀹㈡埛"> <el-option v-for="item in customerOptions" - :key="item.value" - :label="item.label" - :value="item.value" + :key="item.id" + :label="item.customerName" + :value="item.id" /> </el-select> </el-form-item> @@ -33,12 +33,12 @@ <el-row> <el-col :span="12"> <el-form-item label="鐓ょ" prop="coalId"> - <el-select v-model="form.coalId" placeholder="璇烽�夋嫨鐓ょ"> + <el-select v-model="form.coalId" placeholder="璇烽�夋嫨鐓ょ" @change="setInfo"> <el-option - v-for="item in typeOptions" - :key="item.value" - :label="item.label" - :value="item.value" + v-for="item in coalOptions" + :key="item.id" + :label="item.coal" + :value="item.id" /> </el-select> </el-form-item> @@ -68,8 +68,20 @@ </el-form-item> </el-col> <el-col :span="12"> - <el-form-item label="閿�鍞崟浠�(鍚◣)" prop="salePrice"> + <el-form-item label="閿�鍞崟浠�(鍚◣)" prop="salePrice" @change="mathProfit"> <el-input v-model="form.salePrice" placeholder="璇疯緭鍏ラ攢鍞崟浠�(鍚◣)" maxlength="30" type="number" /> + </el-form-item> + </el-col> + </el-row> + <el-row> + <el-col :span="12"> + <el-form-item label="閿�鍞�讳环(鍚◣)" prop="totalAmount"> + <el-input v-model="form.totalAmount" placeholder="璇疯緭鍏ラ攢鍞�讳环(鍚◣)" maxlength="30" type="number" /> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="杩愯垂" prop="freight"> + <el-input v-model="form.freight" placeholder="璇疯緭鍏ラ攢鍞�讳环(鍚◣)" maxlength="30" type="number" /> </el-form-item> </el-col> </el-row> @@ -109,15 +121,17 @@ </template> <script setup> -import {ref, reactive} from "vue"; -import {addOrEditSalesRecord, customerList} from "../../../api/salesOutbound/index.js"; +import {reactive, ref} from "vue"; +import {addOrEditSalesRecord, customerList, officialList} from "../../../api/salesOutbound/index.js"; +import useUserStore from '@/store/modules/user' + const { proxy } = getCurrentInstance() const emit = defineEmits() - +const userStore = useUserStore() const dialogVisitable = ref(false); const operationType = ref('add'); const customerOptions = ref([]) // 瀹㈡埛涓嬫媺妗� -const typeOptions = ref([]) // 鐓ょ涓嬫媺妗� +const coalOptions = ref([]) // 鐓ょ涓嬫媺妗� const data = reactive({ form: { saleDate: '', @@ -127,6 +141,7 @@ saleQuantity: '', salePrice: '', totalAmount: '', + freight: '', taxCoal: '', taxTrans: '', grossProfit: '', @@ -142,13 +157,81 @@ const { form, rules } = toRefs(data) // 鎵撳紑寮规 -const openDialog = (type, row) => { - console.log('openDialog', type, row) +const openDialog = async (type, row) => { dialogVisitable.value = true form.value.saleDate = proxy.getCurrentDate() customerList().then((res) => { - console.log(res) + customerOptions.value = res.data }) + officialList().then((res) => { + coalOptions.value = res.data + }) + let res = await userStore.getInfo() + form.value.registrantId = res.user.userId + form.value.taxCoal = 13 + form.value.taxTrans = 9 + form.value.freight = 20 + if (type === 'edit') { + form.value = {...row} + } +} +// 澶嶅埗鐓ょ鐩稿叧淇℃伅 +const setInfo = (val) => { + const index = coalOptions.value.findIndex(item => item.id === val) + if (index > -1) { + form.value.inventoryQuantity = coalOptions.value[index].inventoryQuantity + form.value.priceIncludingTax = coalOptions.value[index].priceIncludingTax + form.value.unit = coalOptions.value[index].unit + } + if (!val) { + form.value.inventoryQuantity = '' + form.value.priceIncludingTax = '' + form.value.unit = '' + } +} +// 璁$畻 +const mathProfit = () => { + form.value.totalAmount = form.value.saleQuantity * form.value.salePrice + // 杈撳叆鏁版嵁 + const purchaseTons = form.value.inventoryQuantity; // 搴撳瓨鏁伴噺 + const saleTons = form.value.saleQuantity; // 閿�鍞暟閲� + const purchasePricePerTon = form.value.priceIncludingTax; // 鍚◣鍗曚环 + const transportPricePerTon = form.value.freight; // 杩愯垂 + const salePricePerTon = form.value.salePrice; // 閿�鍞崟浠凤紙鍏�/鍚級 + const coalTaxRate = form.value.taxCoal / 100; // 璐攢鐓ょ◣鐜囷紙13%锛� + const transportTaxRate = form.value.taxTrans / 100; // 杩愯緭绋庣巼锛�9%锛� + const surchargeRate = 0.12; // 澧炲�肩◣闄勫姞绋庣巼锛�12%锛� + const stampDutyRate = 3 / 10000; // 鍗拌姳绋庣◣鐜囷紙0.03%锛� + const waterFundRate = 5 / 10000; // 姘村埄鍩洪噾璐圭巼锛�0.05%锛� + +// 璁$畻涓嶅惈绋庝环鏍煎強杩涢」/閿�椤圭◣棰� + const A = purchasePricePerTon / (1 + coalTaxRate); // 璐叅涓嶅惈绋庡崟浠� + const B = A * coalTaxRate * purchaseTons; // 璐叅杩涢」绋庨 + const C = transportPricePerTon / (1 + transportTaxRate); // 杩愯垂涓嶅惈绋庡崟浠� + const D = C * transportTaxRate * purchaseTons; // 杩愯垂杩涢」绋庨 + const E = salePricePerTon / (1 + coalTaxRate); // 閿�鍞笉鍚◣鍗曚环 + const F = E * coalTaxRate * saleTons; // 閿�椤圭◣棰� + +// 姣涘埄娑� = 閿�鍞敹鍏� - 鎴愭湰鎴愭湰锛堣喘鐓�+杩愯垂锛夌殑鎴愭湰閮ㄥ垎 + const G = E * saleTons - A * saleTons - C * saleTons; + form.value.grossProfit = G.toFixed(2); + +// 搴旂即绾冲鍊肩◣ = 閿�椤圭◣ - 鍙姷鎵h繘椤圭◣锛堟寜閿�鍞噺姣斾緥璁$畻锛� + const H = F - (A * coalTaxRate * saleTons) - (C * transportTaxRate * saleTons); + +// 澧炲�肩◣闄勫姞绋� + const K = H * surchargeRate; + +// 鍗拌姳绋庯細璐�佽繍銆侀攢涓夋柟閲戦鍚堣 脳 绋庣巼 + const M = (purchasePricePerTon * saleTons + + transportPricePerTon * saleTons + + salePricePerTon * saleTons) * stampDutyRate; + +// 姘村埄寤鸿鍩洪噾锛氶攢鍞敹鍏� 脳 璐圭巼 + const P = E * saleTons * waterFundRate; + +// 鍑�鍒╂鼎 = 姣涘埄娑� - 鍚勭被绋庤垂锛堥檮鍔犵◣銆佸嵃鑺辩◣銆佹按鍒╁熀閲戯級 + form.value.netProfit = (G - K - M - P).toFixed(2); } // 鎻愪氦鍚堝苟琛ㄥ崟 const submitForm = () => { -- Gitblit v1.9.3