| | |
| | | <template> |
| | | <view class="report-manage-page"> |
| | | <view class="pt-2"> |
| | | <wd-card class="card_bg"> |
| | | <view class="pt-2 fixed-header-card"> |
| | | <wd-card class="card_bg header-card"> |
| | | <template #title> |
| | | <view class="flex justify-between w-full"> |
| | | <text class="font-medium text-[#252525]">报工管理</text> |
| | |
| | | </wd-row> |
| | | <template #footer> |
| | | <view class="flex gap-2"> |
| | | <wd-button plain size="small" @click="toAttachment(child)">附件</wd-button> |
| | | <wd-button plain size="small" @click="toAttachment(child)" style="margin-right: 10px"> |
| | | 附件 |
| | | </wd-button> |
| | | <wd-button plain type="error" size="small" @click="handleDeleteSingle(child)"> |
| | | 删除 |
| | | </wd-button> |
| | |
| | | </wd-cell-group> |
| | | </view> |
| | | <view class="dialog-footer"> |
| | | <wd-button plain @click="closeAddDialog">取消</wd-button> |
| | | <wd-button plain @click="closeAddDialog" style="margin-right: 10px">取消</wd-button> |
| | | <wd-button type="primary" class="ml-2" @click="handleSaveNewChild">保存</wd-button> |
| | | </view> |
| | | </view> |
| | |
| | | const oneLength = ref(); |
| | | const allChildDataList = ref<any[]>([]); |
| | | const wireDetail = ref<any>(null); |
| | | const isMonofil = ref(); |
| | | const meterWeight = ref(); |
| | | const totalWeight = ref(); |
| | | |
| | | // 新增弹框相关 |
| | | const addDialogVisible = ref(false); |
| | |
| | | const handleAdd = () => { |
| | | const lastChild = childList.value[childList.value.length - 1]; |
| | | |
| | | // 从详情数据中获取米重 |
| | | const meterWeight = |
| | | // 从详情数据中获取米重,优先使用传入的参数 |
| | | const meterWeightValue = |
| | | Number(meterWeight.value) || |
| | | Number(wireDetail.value?.meterWeight) || |
| | | Number(wireDetail.value?.weight) || |
| | | Number(wireDetail.value?.theoryWeight) || |
| | | 0; |
| | | |
| | | // 如果是成品单丝,根据公式自动计算盘长:(totalWeight/meterWeight)*1000 |
| | | let calculatedLength = ""; |
| | | if ( |
| | | isMonofil.value && |
| | | (isMonofil.value === 1 || isMonofil.value === "1" || isMonofil.value === true) |
| | | ) { |
| | | const totalWeightValue = Number(totalWeight.value) || 0; |
| | | if (totalWeightValue > 0 && meterWeightValue > 0) { |
| | | calculatedLength = ((totalWeightValue / meterWeightValue) * 1000).toFixed(2); |
| | | } |
| | | } |
| | | |
| | | // 初始化新数据,如果有最后一条数据,使用其值作为默认值 |
| | | newChildData.value = { |
| | | dishModel: lastChild?.dishModel || "", |
| | | actuallyLength: lastChild?.actuallyLength || "", |
| | | actuallyLength: calculatedLength || lastChild?.actuallyLength || "", |
| | | actuallyWeight: lastChild?.actuallyWeight || "", |
| | | isJoint: lastChild?.isJoint || 0, |
| | | meterWeight: meterWeight, |
| | | meterWeight: meterWeightValue, |
| | | }; |
| | | |
| | | addDialogVisible.value = true; |
| | |
| | | } |
| | | }; |
| | | |
| | | // 自动计算实际重量 |
| | | // 自动计算实际重量(根据长度) |
| | | const handleCalculateWeight = (row: any) => { |
| | | // 从 newChildData 对象中获取米重 |
| | | const meterWeight = Number(row.meterWeight) || 0; |
| | | const meterWeightValue = Number(row.meterWeight) || 0; |
| | | const actuallyLength = Number(row.actuallyLength); |
| | | |
| | | if (meterWeight > 0 && actuallyLength > 0) { |
| | | const calculatedWeight = (meterWeight * actuallyLength) / 1000; |
| | | if (meterWeightValue > 0 && actuallyLength > 0) { |
| | | const calculatedWeight = (meterWeightValue * actuallyLength) / 1000; |
| | | row.actuallyWeight = Number(calculatedWeight.toFixed(3)); |
| | | } |
| | | console.log("row", meterWeight, actuallyLength); |
| | | console.log("row", meterWeightValue, actuallyLength); |
| | | }; |
| | | |
| | | // 监听实际长度变化,自动计算重量 |
| | | // 自动计算实际长度(根据重量,仅成品单丝) |
| | | const handleCalculateLength = (row: any) => { |
| | | // 如果是成品单丝,根据重量计算长度 |
| | | if ( |
| | | isMonofil.value && |
| | | (isMonofil.value === 1 || isMonofil.value === "1" || isMonofil.value === true) |
| | | ) { |
| | | const meterWeightValue = Number(meterWeight.value) || Number(row.meterWeight) || 0; |
| | | const actuallyWeight = Number(row.actuallyWeight); |
| | | |
| | | if (meterWeightValue > 0 && actuallyWeight > 0) { |
| | | const calculatedLength = (actuallyWeight / meterWeightValue) * 1000; |
| | | row.actuallyLength = Number(calculatedLength.toFixed(2)); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | // 监听实际长度变化,自动计算重量(非成品单丝时) |
| | | watch( |
| | | () => newChildData.value.actuallyLength, |
| | | (newValue, oldValue) => { |
| | | console.log("实际长度变化:", { newValue, oldValue, newChildData: newChildData.value }); |
| | | if (newValue && String(newValue).trim() !== "") { |
| | | console.log("实际长度变化:", { newValue, oldValue, isMonofil: isMonofil.value }); |
| | | // 如果不是成品单丝,才根据长度计算重量 |
| | | if ( |
| | | newValue && |
| | | String(newValue).trim() !== "" && |
| | | !( |
| | | isMonofil.value && |
| | | (isMonofil.value === 1 || isMonofil.value === "1" || isMonofil.value === true) |
| | | ) |
| | | ) { |
| | | // 使用 nextTick 确保 v-model 已经更新 |
| | | nextTick(() => { |
| | | handleCalculateWeight(newChildData.value); |
| | | }); |
| | | } |
| | | }, |
| | | { immediate: false, deep: true } |
| | | ); |
| | | |
| | | // 监听实际重量变化,自动计算长度(仅成品单丝) |
| | | watch( |
| | | () => newChildData.value.actuallyWeight, |
| | | (newValue, oldValue) => { |
| | | console.log("实际重量变化:", { newValue, oldValue, isMonofil: isMonofil.value }); |
| | | if (newValue && String(newValue).trim() !== "") { |
| | | // 使用 nextTick 确保 v-model 已经更新 |
| | | nextTick(() => { |
| | | handleCalculateLength(newChildData.value); |
| | | }); |
| | | } |
| | | }, |
| | |
| | | supplier: options.supplier, |
| | | }; |
| | | |
| | | // 接收传递的参数 |
| | | isMonofil.value = options.isMonofil; |
| | | meterWeight.value = options.meterWeight; |
| | | totalWeight.value = options.totalWeight; |
| | | |
| | | await getDetailData(options.wireId); |
| | | await getData(); |
| | | }); |
| | |
| | | .report-manage-page { |
| | | min-height: 100vh; |
| | | background: #f3f9f8; |
| | | padding-bottom: 20px; |
| | | padding: 0 4px 20px 4px; |
| | | } |
| | | |
| | | .card_bg { |
| | | box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.05); |
| | | padding-bottom: 10px; |
| | | } |
| | | |
| | | .fixed-header-card { |
| | | position: sticky; |
| | | top: 0; |
| | | z-index: 100; |
| | | background: #f3f9f8; |
| | | padding: 8px 0; |
| | | } |
| | | |
| | | .header-card { |
| | | border: none; |
| | | margin: 0; |
| | | border-radius: 0; |
| | | box-shadow: none; |
| | | } |
| | | |
| | | .icon_box { |
| | |
| | | } |
| | | |
| | | .page-content { |
| | | padding: 12px; |
| | | padding: 12px 4px; |
| | | margin-top: 12px; |
| | | } |
| | | |
| | | // 弹框 z-index 需要高于固定头部卡片 |
| | | :deep(.yl-popup) { |
| | | z-index: 400 !important; |
| | | } |
| | | |
| | | // 弹框遮罩层 z-index 也需要高于固定头部卡片(使用更高的值确保在固定头部之上) |
| | | :deep(.wd-popup__mask), |
| | | :deep(.wd-popup-mask), |
| | | :deep([class*="popup"][class*="mask"]), |
| | | :deep(.wd-overlay), |
| | | :deep([class*="overlay"]) { |
| | | z-index: 300 !important; |
| | | } |
| | | .wd-card { |
| | | margin-left: 5px; |
| | | margin-right: 5px; |
| | | margin-top: 0px; |
| | | } |
| | | </style> |
| | | |
| | | <style lang="scss"> |
| | | // 全局样式:确保弹框遮罩层 z-index 高于固定头部卡片 |
| | | .wd-popup__mask, |
| | | .wd-popup-mask, |
| | | [class*="popup"][class*="mask"], |
| | | .wd-overlay, |
| | | [class*="overlay"] { |
| | | z-index: 300 !important; |
| | | } |
| | | </style> |