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/api/salesOutbound/index.js | 16 ++++ src/views/salesOutbound/index.vue | 56 +++++++------ src/views/salesOutbound/components/formDia.vue | 117 +++++++++++++++++++++++++---- 3 files changed, 147 insertions(+), 42 deletions(-) diff --git a/src/api/salesOutbound/index.js b/src/api/salesOutbound/index.js index 0d83ebe..61bae4f 100644 --- a/src/api/salesOutbound/index.js +++ b/src/api/salesOutbound/index.js @@ -24,4 +24,20 @@ method: 'get', params: query }) +} +// 鏌ヨ鐓ょ +export function officialList(query) { + return request({ + url: '/officialInventory/officialList', + method: 'get', + params: query + }) +} +// 鏌ヨ鐓ょ +export function delSalesRecord(query) { + return request({ + url: '/salesRecord/delSalesRecord', + method: 'delete', + data: query + }) } \ No newline at end of file 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 = () => { diff --git a/src/views/salesOutbound/index.vue b/src/views/salesOutbound/index.vue index fca072b..1c28393 100644 --- a/src/views/salesOutbound/index.vue +++ b/src/views/salesOutbound/index.vue @@ -1,33 +1,27 @@ <template> <div class="app-container"> <el-form :inline="true" :model="queryParams" class="search-form"> - <el-form-item label="鎼滅储"> - <el-input - v-model="queryParams.searchText" - placeholder="璇疯緭鍏ュ叧閿瘝" + <el-form-item label="閿�鍞棩鏈�"> + <el-date-picker + v-model="queryParams.saleDate" + type="date" + placeholder="璇烽�夋嫨" + value-format="YYYY-MM-DD" + format="YYYY-MM-DD" clearable - :style="{ width: '100%' }" /> </el-form-item> - <el-form-item label="渚涘簲鍟嗗悕绉�"> + <el-form-item label="瀹㈡埛"> <el-input - v-model="queryParams.supplierName" + v-model="queryParams.customer" placeholder="璇疯緭鍏�" clearable :style="{ width: '100%' }" /> </el-form-item> - <el-form-item label="缁熶竴浜鸿瘑鍒彿"> + <el-form-item label="鐓ょ"> <el-input - v-model="queryParams.identifyNumber" - placeholder="璇疯緭鍏�" - clearable - :style="{ width: '100%' }" - /> - </el-form-item> - <el-form-item label="缁忚惀鍦板潃"> - <el-input - v-model="queryParams.address" + v-model="queryParams.coal" placeholder="璇疯緭鍏�" clearable :style="{ width: '100%' }" @@ -50,7 +44,7 @@ </el-tabs> <!-- 鎿嶄綔鎸夐挳鍖� --> <el-space> - <el-button type="primary" :icon="Plus" @click="openDia('add')">鏂板缓</el-button> + <el-button type="primary" :icon="Plus" @click="openDia()">鏂板缓</el-button> <el-button type="danger" :icon="Delete" @click="handleDelete">鍒犻櫎</el-button> <el-button type="info" plain :icon="Download" @click="handleExport">瀵煎嚭</el-button> </el-space> @@ -85,7 +79,7 @@ import ETable from "@/components/Table/ETable.vue"; import Pagination from "@/components/Pagination/index.vue"; import FormDia from "@/views/salesOutbound/components/formDia.vue"; -import {salesRecordList} from "../../api/salesOutbound/index.js"; +import {delSalesRecord, salesRecordList} from "../../api/salesOutbound/index.js"; const formDia = ref() const activeTab = ref("out"); @@ -106,6 +100,7 @@ { prop: "saleQuantity", label: "閿�鍞暟閲�", minWidth: 120 }, { prop: "salePrice", label: "閿�鍞崟浠�(鍚◣)", minWidth: 150 }, { prop: "totalAmount", label: "閿�鍞�讳环(鍚◣)", minWidth: 120 }, + { prop: "freight", label: "杩愯垂", minWidth: 90 }, { prop: "taxCoal", label: "璐攢鐓ょ◣鐜�(%)", minWidth: 120 }, { prop: "taxTrans", label: "杩愯緭绋庣巼(%)", minWidth: 120 }, { prop: "grossProfit", label: "姣涘埄娑�", minWidth: 90 }, @@ -119,10 +114,9 @@ const pageSize = ref(10); // 鏌ヨ鍙傛暟 const queryParams = reactive({ - searchText: "", - supplierName: "", - identifyNumber: "", - address: "", + saleDate: "", + customer: "", + coal: "", }) onMounted(() => { handleQuery() @@ -151,14 +145,26 @@ handleQuery(); }; // 鏂板鍑哄簱 -const openDia = (type, row) => { +const openDia = (row) => { + console.log(row) + const type = row === undefined ? 'add' : 'edit' nextTick(() => { formDia.value?.openDialog(type, row) }) }; // 鍒犻櫎鍑哄簱 const handleDelete = () => { - + if (selectedRows.value.length === 0) { + proxy.$modal.msgWarning("璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁"); + return; + } + const deleteIds = selectedRows.value.map(item => item.id); + proxy.$modal.confirm('鏄惁纭鍒犻櫎鎵�閫夋暟鎹」锛�').then(function() { + return delSalesRecord(deleteIds) + }).then(() => { + handleQuery() + proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛") + }).catch(() => {}) }; // 瀵煎嚭鍑哄簱 const handleExport = () => { -- Gitblit v1.9.3