| | |
| | | </el-table-column> |
| | | <el-table-column label="快递公司" |
| | | prop="expressCompany" |
| | | v-if="false" |
| | | show-overflow-tooltip /> |
| | | <el-table-column label="快递单号" |
| | | prop="expressNumber" |
| | | v-if="false" |
| | | show-overflow-tooltip /> |
| | | <el-table-column label="发货车牌" |
| | | minWidth="100px" |
| | |
| | | width="160" |
| | | align="right"> |
| | | <template #default="scope"> |
| | | {{ Number(scope.row.totalAmount ?? 0).toFixed(2) }} |
| | | {{ formatDecimal(scope.row.totalAmount) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column fixed="right" |
| | |
| | | <el-col :span="12"> |
| | | <el-form-item label="含税单价(元):" |
| | | prop="taxInclusiveUnitPrice"> |
| | | <el-input-number :step="0.01" |
| | | <el-input-number :step="0.000001" |
| | | :min="0" |
| | | v-model="productForm.taxInclusiveUnitPrice" |
| | | style="width: 100%" |
| | | :precision="2" |
| | | :precision="6" |
| | | placeholder="请输入" |
| | | clearable |
| | | @change="calculateFromUnitPrice" /> |
| | |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <!-- <el-col :span="12"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="是否生产:" |
| | | prop="isProduction"> |
| | | <el-radio-group v-model="productForm.isProduction"> |
| | | <el-radio label="是" |
| | | :value="true" /> |
| | | <el-radio label="否" |
| | | :value="false" /> |
| | | </el-radio-group> |
| | | <div style="display: flex; align-items: center; width: 100%;"> |
| | | <el-radio-group v-model="productForm.isProduction"> |
| | | <el-radio label="是" |
| | | :value="true" /> |
| | | <el-radio label="否" |
| | | :value="false" /> |
| | | </el-radio-group> |
| | | <div |
| | | v-if="currentStock !== null" |
| | | :style="{ |
| | | marginLeft: '20px', |
| | | padding: '0 12px', |
| | | height: '28px', |
| | | lineHeight: '28px', |
| | | borderRadius: '4px', |
| | | fontSize: '13px', |
| | | fontWeight: '500', |
| | | display: 'inline-block', |
| | | whiteSpace: 'nowrap', |
| | | backgroundColor: (productForm.quantity || 0) > currentStock ? '#fff0f0' : '#f0f9eb', |
| | | border: (productForm.quantity || 0) > currentStock ? '1px solid #ffcccc' : '1px solid #e1f3d8', |
| | | color: (productForm.quantity || 0) > currentStock ? '#f56c6c' : '#67c23a' |
| | | }" |
| | | > |
| | | <span>当前库存:{{ currentStock }} {{ productForm.unit || '' }}</span> |
| | | </div> |
| | | </div> |
| | | </el-form-item> |
| | | </el-col>--> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | </FormDialog> |
| | |
| | | <el-option label="货车" |
| | | value="货车" /> |
| | | <el-option label="快递" |
| | | v-if="false" |
| | | value="快递" /> |
| | | </el-select> |
| | | </el-form-item> |
| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24" |
| | | v-else> |
| | | v-else-if="false"> |
| | | <el-form-item label="快递公司:" |
| | | prop="expressCompany"> |
| | | <el-input v-model="deliveryForm.expressCompany" |
| | |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30" |
| | | v-if="deliveryForm.type === '快递'"> |
| | | v-if="false"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="快递单号:" |
| | | prop="expressNumber"> |
| | |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" |
| | | :loading="deliveryLoading" |
| | | @click="submitDelivery">确认发货 |
| | | </el-button> |
| | | <el-button @click="closeDeliveryDia">取消</el-button> |
| | |
| | | import useFormData from "@/hooks/useFormData.js"; |
| | | import dayjs from "dayjs"; |
| | | import FileUpload from "@/components/AttachmentUpload/file/index.vue"; |
| | | import { |
| | | tableAmountFormatter, |
| | | formatDecimal, |
| | | buildAmountSummaryFormat, |
| | | } from "@/utils/numberFormat"; |
| | | import ImageUpload from "@/components/AttachmentUpload/image/index.vue"; |
| | | import { getCurrentDate } from "@/utils/index.js"; |
| | | import { listCustomer } from "@/api/basicData/customer.js"; |
| | |
| | | |
| | | // 发货相关 |
| | | const deliveryFormVisible = ref(false); |
| | | const deliveryLoading = ref(false); |
| | | const currentDeliveryRow = ref(null); |
| | | const getDeliveryBatchQuantity = item => { |
| | | const quantity = |
| | |
| | | item?.qualifiedQuantity ?? |
| | | item?.stockQuantity; |
| | | return quantity ?? 0; |
| | | }; |
| | | const currentStock = ref(null); |
| | | const fetchCurrentStock = async (productModelId) => { |
| | | if (!productModelId) { |
| | | currentStock.value = null; |
| | | return; |
| | | } |
| | | try { |
| | | const res = await getStockInventoryByModelId(productModelId); |
| | | const rawList = Array.isArray(res?.data) |
| | | ? res.data |
| | | : res?.data?.records || res?.data?.rows || []; |
| | | let total = 0; |
| | | rawList.forEach(item => { |
| | | total += Number(getDeliveryBatchQuantity(item) || 0); |
| | | }); |
| | | currentStock.value = total; |
| | | } catch (e) { |
| | | console.error(e); |
| | | currentStock.value = 0; |
| | | } |
| | | }; |
| | | const getCurrentDeliveryRowQuantity = () => { |
| | | return Number(currentDeliveryRow.value?.noQuantity || 0); |
| | |
| | | return productOptions.value; |
| | | }); |
| | | }; |
| | | const formattedNumber = (row, column, cellValue) => { |
| | | if (cellValue === undefined || cellValue === null || cellValue === "") { |
| | | return "0.00"; |
| | | } |
| | | return parseFloat(cellValue).toFixed(2); |
| | | }; |
| | | const formattedNumber = tableAmountFormatter; |
| | | const findLedgerRecordByRow = row => { |
| | | if (!row) return null; |
| | | if ( |
| | |
| | | // 获取tree子数据 |
| | | const getModels = value => { |
| | | productForm.value.productCategory = findNodeById(productOptions.value, value); |
| | | currentStock.value = null; |
| | | modelList({ id: value }).then(res => { |
| | | modelOptions.value = res; |
| | | }); |
| | |
| | | if (index !== -1) { |
| | | productForm.value.specificationModel = modelOptions.value[index].model; |
| | | productForm.value.unit = modelOptions.value[index].unit; |
| | | fetchCurrentStock(value); |
| | | } else { |
| | | productForm.value.specificationModel = null; |
| | | productForm.value.unit = null; |
| | | currentStock.value = null; |
| | | } |
| | | }; |
| | | const findNodeById = (nodes, productId) => { |
| | |
| | | }; |
| | | // 主表合计方法 |
| | | const summarizeMainTable = param => { |
| | | return proxy.summarizeTable(param, [ |
| | | "contractAmount", |
| | | "taxInclusiveTotalPrice", |
| | | "taxExclusiveTotalPrice", |
| | | ]); |
| | | return proxy.summarizeTable( |
| | | param, |
| | | ["contractAmount", "taxInclusiveTotalPrice", "taxExclusiveTotalPrice"], |
| | | buildAmountSummaryFormat([ |
| | | "contractAmount", |
| | | "taxInclusiveTotalPrice", |
| | | "taxExclusiveTotalPrice", |
| | | ]) |
| | | ); |
| | | }; |
| | | // 子表合计方法 |
| | | const summarizeChildrenTable = (param, parentRow) => { |
| | |
| | | return ""; |
| | | }); |
| | | } |
| | | return proxy.summarizeTable(param, [ |
| | | "taxInclusiveUnitPrice", |
| | | "taxInclusiveTotalPrice", |
| | | "taxExclusiveTotalPrice", |
| | | ]); |
| | | return proxy.summarizeTable( |
| | | param, |
| | | [ |
| | | "taxInclusiveUnitPrice", |
| | | "taxInclusiveTotalPrice", |
| | | "taxExclusiveTotalPrice", |
| | | ], |
| | | buildAmountSummaryFormat([ |
| | | "taxInclusiveUnitPrice", |
| | | "taxInclusiveTotalPrice", |
| | | "taxExclusiveTotalPrice", |
| | | ]) |
| | | ); |
| | | }; |
| | | // 打开弹框 |
| | | const openForm = async (type, row) => { |
| | |
| | | const quantity = Number(p.quantity ?? 0) || 0; |
| | | const unitPrice = Number(p.unitPrice ?? 0) || 0; |
| | | const taxRate = "13"; // 默认 13%,便于直接提交(如需可在产品中自行修改) |
| | | const taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2); |
| | | const taxInclusiveTotalPrice = formatDecimal(unitPrice * quantity); |
| | | const taxExclusiveTotalPrice = proxy.calculateTaxExclusiveTotalPrice( |
| | | taxInclusiveTotalPrice, |
| | | taxRate |
| | |
| | | unit: p.unit || "", |
| | | quantity: quantity, |
| | | taxRate: taxRate, |
| | | taxInclusiveUnitPrice: unitPrice.toFixed(2), |
| | | taxInclusiveUnitPrice: formatDecimal(unitPrice), |
| | | taxInclusiveTotalPrice: taxInclusiveTotalPrice, |
| | | taxExclusiveTotalPrice: taxExclusiveTotalPrice, |
| | | invoiceType: "增普票", |
| | |
| | | |
| | | productOperationType.value = type; |
| | | productForm.value = {}; |
| | | currentStock.value = null; |
| | | if (type === "add") { |
| | | productForm.value.isProduction = true; |
| | | } |
| | |
| | | ); |
| | | if (currentModel) { |
| | | productForm.value.productModelId = currentModel.id; |
| | | fetchCurrentStock(currentModel.id); |
| | | } |
| | | } |
| | | } catch (e) { |
| | |
| | | const total = products.reduce((sum, product) => { |
| | | return sum + (parseFloat(product.taxInclusiveTotalPrice) || 0); |
| | | }, 0); |
| | | return total.toFixed(2); |
| | | return formatDecimal(total); |
| | | }; |
| | | |
| | | // 用于打印的计算函数 |
| | |
| | | const total = products.reduce((sum, product) => { |
| | | return sum + (parseFloat(product.taxInclusiveTotalPrice) || 0); |
| | | }, 0); |
| | | return total.toFixed(2); |
| | | return formatDecimal(total); |
| | | }; |
| | | |
| | | const mathNum = () => { |
| | |
| | | isCalculating.value = true; |
| | | |
| | | // 计算含税单价 = 含税总价 / 数量 |
| | | productForm.value.taxInclusiveUnitPrice = (totalPrice / quantity).toFixed(2); |
| | | productForm.value.taxInclusiveUnitPrice = formatDecimal(totalPrice / quantity); |
| | | |
| | | // 如果有税率,计算不含税总价 |
| | | if (productForm.value.taxRate) { |
| | |
| | | // 先计算含税总价 = 不含税总价 / (1 - 税率/100) |
| | | const taxRateDecimal = taxRate / 100; |
| | | const inclusiveTotalPrice = exclusiveTotalPrice / (1 - taxRateDecimal); |
| | | productForm.value.taxInclusiveTotalPrice = inclusiveTotalPrice.toFixed(2); |
| | | productForm.value.taxInclusiveTotalPrice = formatDecimal(inclusiveTotalPrice); |
| | | |
| | | // 计算含税单价 = 含税总价 / 数量 |
| | | productForm.value.taxInclusiveUnitPrice = ( |
| | | productForm.value.taxInclusiveUnitPrice = formatDecimal( |
| | | inclusiveTotalPrice / quantity |
| | | ).toFixed(2); |
| | | ); |
| | | |
| | | isCalculating.value = false; |
| | | }; |
| | |
| | | isCalculating.value = true; |
| | | |
| | | // 计算含税总价 |
| | | productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2); |
| | | productForm.value.taxInclusiveTotalPrice = formatDecimal(unitPrice * quantity); |
| | | |
| | | // 如果有税率,计算不含税总价 |
| | | if (productForm.value.taxRate) { |
| | |
| | | isCalculating.value = true; |
| | | |
| | | // 计算含税总价 |
| | | productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2); |
| | | productForm.value.taxInclusiveTotalPrice = formatDecimal(unitPrice * quantity); |
| | | |
| | | // 如果有税率,计算不含税总价 |
| | | if (productForm.value.taxRate) { |
| | |
| | | const productModelId = |
| | | currentDeliveryRow.value.productModelId || |
| | | currentDeliveryRow.value.modelId; |
| | | deliveryLoading.value = true; |
| | | addShippingInfo({ |
| | | salesLedgerId: salesLedgerId, |
| | | salesLedgerProductId: currentDeliveryRow.value.id, |
| | |
| | | }); |
| | | } |
| | | }); |
| | | }).finally(() => { |
| | | deliveryLoading.value = false; |
| | | }); |
| | | } |
| | | }); |