src/api/tool/publicInterface.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/components/Table/ETable.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/basicInformation/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/basicInformation/mould/coal.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/procureMent/components/ProductionDialog.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/procureMent/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/production/components/ProductionDialog.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/production/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/api/tool/publicInterface.js
@@ -3,7 +3,7 @@ // 获取路由 export const testUserList = () => { return request({ url: '/test/user/list', url: '/system/user/listAll', method: 'get' }) } src/components/Table/ETable.vue
@@ -17,8 +17,8 @@ :row-key="rowKey" style="width: 100%;" > <el-table-column v-if="showSelection" type="selection" width="55" align="center" /> <el-table-column v-if="showIndex" label="序号" width="60" align="center" fixed="left"> <el-table-column v-if="showSelection" type="selection" width="55" align="center" :show-overflow-tooltip="false" /> <el-table-column v-if="showIndex" label="序号" width="60" align="center" fixed="left" :show-overflow-tooltip="false"> <template #default="scope"> {{ getRowIndex(scope.$index) }} </template> src/views/basicInformation/index.vue
@@ -310,10 +310,12 @@ const getUserList = async () => { try { const res = await testUserList(); console.log("获取用户列表数据:", res); console.log("userMap:", userMap.value); if (res && res.data) { userList.value = res.data; userList.value.forEach((user) => { userMap.value[user.userId] = user.username; userMap.value[user.userId] = user.nickName; }); } } catch (error) { src/views/basicInformation/mould/coal.vue
@@ -23,7 +23,7 @@ </el-form-item> <el-form-item label="维护人姓名" prop="maintainerId"> <el-input :value="userStore.name || ''" :value="userStore.nickName || ''" placeholder="维护人姓名" disabled /> @@ -79,26 +79,6 @@ required: true, type: Object, }); // 在组件挂载时获取用户信息 onMounted(async () => { // 如果store中没有用户信息,则获取用户信息 if (!userStore.name) { try { await userStore.getInfo() // 自动填充维护人ID if (props.addOrEdit === 'add') { formData.value.maintainerId = userStore.id } } catch (error) { console.error('获取用户信息失败:', error) } } else { // 自动填充维护人ID if (props.addOrEdit === 'add') { formData.value.maintainerId = userStore.id } } }) const emit = defineEmits(['submit', 'handleBeforeClose', 'update:coalDialogFormVisible']) // 表单引用 @@ -127,7 +107,6 @@ if (!formRef.value) return await formRef.value.validate(async (valid, fields) => { if (valid) { delete formData.value.maintainerName // 删除显示用的字段,只保留ID // 确保maintainerId有值 if (!formData.value.maintainerId) { @@ -166,12 +145,8 @@ emit('update:coalDialogFormVisible', false) } const rules = reactive({ supplierName: [ {required: true, message: "请输入供货商名称", trigger: "blur"}, ], identifyNumber: [ {required: true, message: "请正确输入纳税人识别号", trigger: "blur"}, {min: 17, max: 20, message: "请输入17-20位纳税人识别号", trigger: "blur"}, coal: [ {required: true, message: "请输入煤种名称", trigger: "blur"}, ], }); src/views/procureMent/components/ProductionDialog.vue
@@ -50,10 +50,10 @@ </template> </el-input> </el-form-item> <el-form-item label="单价(不含税)" prop="priceExcludingTax"> <el-form-item label="单价(含税)" prop="priceIncludingTax"> <el-input v-model.number="form.priceExcludingTax" placeholder="请输入" v-model.number="form.priceIncludingTax" placeholder="请输入含税单价" @blur="handlePriceBlur" :disabled="isViewMode" > @@ -62,9 +62,9 @@ </template> </el-input> </el-form-item> <el-form-item label="单价(含税)" prop="priceIncludingTax"> <el-form-item label="单价(不含税)" prop="priceExcludingTax"> <el-input v-model.number="form.priceIncludingTax" v-model.number="form.priceExcludingTax" placeholder="自动计算" disabled > @@ -180,116 +180,95 @@ defineExpose({ getDropdownData, }); // 数值格式化工具函数 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) ); return Number((Math.floor(parseFloat(num) * Math.pow(10, precision)) / Math.pow(10, precision)).toFixed(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; // 安全获取数值 const safeNumber = (value) => { const num = parseFloat(value); return isNaN(num) ? 0 : num; }; if (!priceExcludingTax || !taxRate || !purchaseQuantity) { return 0; } // 计算逻辑 - 基于含税单价计算不含税价格 const calculatePrices = () => { const priceIncludingTax = safeNumber(form.value.priceIncludingTax); // 含税单价 const taxRate = safeNumber(form.value.taxRate); // 税率 const quantity = safeNumber(form.value.purchaseQuantity); // 采购数量 const unitPriceWithTaxValue = priceExcludingTax * (1 + taxRate / 100); const result = unitPriceWithTaxValue * purchaseQuantity; return toFixed(result, 2); }); // 1. 根据含税单价和税率计算不含税单价 // 不含税单价 = 含税单价 / (1 + 税率/100) const priceExcludingTax = priceIncludingTax && taxRate ? toFixed(priceIncludingTax / (1 + taxRate / 100), 2) : 0; // 不含税总价计算 const taxExclusiveTotalPrice = computed(() => { const purchaseQuantity = parseFloat(form.value.purchaseQuantity) || 0; const priceExcludingTax = parseFloat(form.value.priceExcludingTax) || 0; // 2. 计算不含税总价 = 不含税单价 × 数量 const totalPriceExcludingTax = priceExcludingTax && quantity ? toFixed(priceExcludingTax * quantity, 2) : 0; if (!purchaseQuantity || !priceExcludingTax) { return 0; } // 3. 计算含税总价 = 含税单价 × 数量 const totalPriceIncludingTax = priceIncludingTax && quantity ? toFixed(priceIncludingTax * quantity, 2) : 0; const result = purchaseQuantity * priceExcludingTax; return toFixed(result, 2); }); // 更新表单数据 form.value.priceExcludingTax = priceExcludingTax; form.value.totalPriceExcludingTax = totalPriceExcludingTax; form.value.totalPriceIncludingTax = totalPriceIncludingTax; }; // 监听计算值变化,同步到 form 对象中 watch(unitPriceWithTax, (newValue) => { form.value.priceIncludingTax = newValue; }); watch(totalUnitPriceWithTax, (newValue) => { form.value.totalPriceIncludingTax = newValue; }); watch(taxExclusiveTotalPrice, (newValue) => { form.value.totalPriceExcludingTax = newValue; }); // 监听表单对象变化,用于处理编辑模式下的数据加载和实时计算 watch( () => [form.value.priceIncludingTax, form.value.taxRate, form.value.purchaseQuantity], () => { // 防抖处理,避免频繁计算 nextTick(() => { calculatePrices(); }); }, { deep: true } ); const userStore = useUserStore(); const userInfo = ref({}); const match = () => { return userInfo.value.nickName || "未知用户"; }; // 处理税率输入框失焦,确保精度 // 处理税率输入框失焦事件 const handleTaxRateBlur = () => { if ( form.value.taxRate !== null && form.value.taxRate !== undefined && form.value.taxRate !== "" ) { if (form.value.taxRate !== null && form.value.taxRate !== undefined && form.value.taxRate !== "") { form.value.taxRate = toFixed(parseFloat(form.value.taxRate), 2); // watch 会自动触发 calculatePrices,不需要手动调用 } }; // 处理不含税单价输入框失焦,确保精度 // 处理含税单价输入框失焦事件 const handlePriceBlur = () => { if ( form.value.priceExcludingTax !== null && form.value.priceExcludingTax !== undefined && form.value.priceExcludingTax !== "" ) { form.value.priceExcludingTax = toFixed( parseFloat(form.value.priceExcludingTax), 2 ); if (form.value.priceIncludingTax !== null && form.value.priceIncludingTax !== undefined && form.value.priceIncludingTax !== "") { form.value.priceIncludingTax = toFixed(parseFloat(form.value.priceIncludingTax), 2); // watch 会自动触发 calculatePrices,不需要手动调用 } }; // 处理采购数量输入框失焦,确保精度 // 处理采购数量输入框失焦事件 const handleQuantityBlur = () => { if ( form.value.purchaseQuantity !== null && form.value.purchaseQuantity !== undefined && form.value.purchaseQuantity !== "" ) { form.value.purchaseQuantity = toFixed( parseFloat(form.value.purchaseQuantity), 3 ); // 数量保留3位小数 if (form.value.purchaseQuantity !== null && form.value.purchaseQuantity !== undefined && form.value.purchaseQuantity !== "") { form.value.purchaseQuantity = toFixed(parseFloat(form.value.purchaseQuantity), 3); // 数量保留3位小数 // watch 会自动触发 calculatePrices,不需要手动调用 } }; onMounted(async () => { let res = await userStore.getInfo(); userInfo.value = res.user; getDropdownData() await getDropdownData(); // 组件加载完成后触发一次计算 calculatePrices(); }); const rules = { supplierName: [ src/views/procureMent/index.vue
@@ -201,7 +201,7 @@ form.value = { supplierName: "", coal: "", unit: "t", unit: "吨", purchaseQuantity: "", priceExcludingTax: "", totalPriceExcludingTax: "", src/views/production/components/ProductionDialog.vue
@@ -165,6 +165,7 @@ getCoalInfoList, deleteProductionInventory, } from "@/api/production/index.js"; import { getSupplyList } from "@/api/procureMent/index.js" import {validateFormData, validateNumber, deepClone, createDefaultProductionRow} from "@/utils/production"; import {useCoalData} from "./useCoalData"; import useUserStore from "@/store/modules/user"; @@ -218,15 +219,13 @@ ]; const formalDatabaseColumns = ref([ {prop: "supplierName", label: "供应商名称", minwidth: 150 // ,formatter: (row) => { // console.log(row); // return supplierList.value[row.supplierId] || "--"; // } {prop: "supplierId", label: "供应商名称", minwidth: 150 ,formatter: (row) => { return supplierList.value.find(supplier => supplier.id === row.supplierId)?.supplierName || "--"; } }, {prop: "coalId", label: "煤种", minwidth: 60, formatter: (row) => { // return coalList.value[row.coalId].coal || "--"; return coalList.value.find(coal => coal.id === row.coalId)?.coal || "--"; } }, @@ -251,12 +250,13 @@ // 获取配置数据 const handlData = async () => { innerVisible.value = true; let getSupplier = await getOfficialAll(); let OfficialAll = await getOfficialAll(); let getSupplierList = await getSupplyList(); let getCoalName = await getCoalInfoList(); coalList.value = getCoalName.data || []; supplierList.value = getSupplier.data || []; if (getSupplier.code === 200) { formalDatabaseData.value = getSupplier.data; supplierList.value = getSupplierList.data || []; if (OfficialAll.code === 200) { formalDatabaseData.value = OfficialAll.data; const existingOfficialIds = tableData.value .map((item) => item.officialId) .filter((id) => id); src/views/production/index.vue
@@ -1,5 +1,5 @@ <template> <div> <div class="app-container"> <!-- 搜索表单 --> <el-form :inline="true" :model="queryParams" class="search-form"> <el-form-item label="搜索">