| | |
| | | let orderBomData =ref({ |
| | | productName:[] |
| | | }) |
| | | let bomSum = ref({ |
| | | sumData:[], |
| | | sumDatilsData:[] |
| | | }) |
| | | |
| | | let orderBomDetails = ref(null) |
| | | |
| | |
| | | {field: 'quantity',width:120, title: t('order.quantity'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | // {field: 'goodsQuantity',width:120, title: t('searchOrder.inventoryNum'), sortable: true}, |
| | | {field: 'area',width:120, title: t('order.computeGrossArea'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: 'bomPrice',width:120, title: 'BOM成本',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: 'bomPrice',width:120, title: t('bom.bomPrice'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: 'money',width:120, title: t('order.money'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: 'createTime',width:120,filters:[{ data: '' }],slots: { filter: 'num1_filter' }, title: t('basicData.reportData'), sortable: true}, |
| | | {field: 'packType',width:120, title: t('order.packType'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | |
| | | selectOrderList() |
| | | } |
| | | |
| | | //总价 |
| | | const totalPriceSum = ref() |
| | | |
| | | //页面跳转更新或者删除订单 |
| | | const getTableRow = (row,type) => { |
| | | switch (type) { |
| | |
| | | request.post(`/BomData/getOrderBomData/${row.orderId}`,).then((res) => { |
| | | if (res.code == 200 ) { |
| | | orderBomData.value.productName =res.data.data |
| | | // orderBomData.value.productName = orderBomData.value.productName.map(item => { |
| | | // const parts = item.product_name.split(/[*+]/) |
| | | // parts.push("其它") |
| | | // return { |
| | | // ...item, |
| | | // product_parts: parts |
| | | // } |
| | | // }) |
| | | |
| | | bomSum.value.sumData = res.data.sumData |
| | | bomSum.value.sumDatilsData =res.data.sumDataDatils |
| | | request.post(`/BomData/getBomDataProduct`,orderBomData.value).then((res) => { |
| | | if (res.code == 200 ) { |
| | | orderBomDetails.value=res.data.data |
| | | orderBomData.value.productName.forEach((product, i) => { |
| | | const details = orderBomDetails.value[i]?.data || [] |
| | | const perimeter = Number(product.perimeter || 0) |
| | | |
| | | // hollow:重算 consume、materialPric |
| | | details.forEach(d => { |
| | | if (d.detail_type === 'hollow') { |
| | | const glueDepth = Number(d.glueDepth || 0) |
| | | const thickness = Number(d.thickness || 0) |
| | | const price = Number(d.price || 0) |
| | | |
| | | // consume 保持为数字 |
| | | const consume = (glueDepth / 100) * (thickness / 100) * perimeter |
| | | d.consume = Number(consume.toFixed(2)) // 需要保留2位就转回 number |
| | | |
| | | // materialPric 也保持为数字 |
| | | d.materialPric = Number((d.consume * price).toFixed(2)) |
| | | } |
| | | }) |
| | | |
| | | // 生成 parts |
| | | const parts = product.product_name.split(/[*+]/) |
| | | parts.push("其它") |
| | | |
| | | product.product_parts = parts.map((p, idx) => { |
| | | // 找出所有 product_layer == idx+1 的 detail |
| | | const assignedDetails = details.filter(d => d.product_layer === idx + 1) |
| | | const assignedDetails = details.filter(d => Number(d.product_layer) === idx + 1) |
| | | return { name: p, details: assignedDetails } |
| | | }) |
| | | |
| | | return { |
| | | name: p, |
| | | details: assignedDetails |
| | | // 每个 product 的总价(保证数字相加) |
| | | product.totalPrice = details.reduce( |
| | | (sum, d) => sum + Number(d.materialPric || 0), |
| | | 0 |
| | | ) |
| | | }) |
| | | |
| | | // 成品合计:从 details 汇总 |
| | | const totalMap = new Map() |
| | | |
| | | orderBomDetails.value.forEach(block => { |
| | | const details = block?.data || [] |
| | | details.forEach(d => { |
| | | const consume = Number(d.consume || 0) |
| | | const price = Number(d.price || 0) |
| | | const key = `${Number(d.material_id)}|${String(d.detail_type || '')}|${price}` |
| | | |
| | | if (!totalMap.has(key)) { |
| | | totalMap.set(key, { |
| | | material_id: d.material_id, |
| | | material: d.material, |
| | | detail_type: d.detail_type, |
| | | price, |
| | | unit: d.unit, |
| | | type: d.type, |
| | | consume: 0, |
| | | materialPrice: 0 |
| | | }) |
| | | } |
| | | |
| | | const row = totalMap.get(key) |
| | | row.consume += consume |
| | | }) |
| | | }) |
| | | |
| | | const totalSumDatilsData = Array.from(totalMap.values()).map(r => ({ |
| | | ...r, |
| | | consume: Number(r.consume.toFixed(2)), |
| | | materialPrice: Number(r.materialPrice.toFixed(2)) |
| | | })) |
| | | |
| | | bomSum.value.sumDatilsData = totalSumDatilsData |
| | | |
| | | // 汇总总金额 |
| | | totalPriceSum.value = orderBomData.value.productName.reduce( |
| | | (sum, p) => sum + Number(p.totalPrice || 0), |
| | | 0 |
| | | ) |
| | | |
| | | dialogTableVisible.value = true |
| | | } |
| | | }) |
| | | console.log(orderBomData.value.productName) |
| | | } |
| | | }) |
| | | |
| | |
| | | return row.timeOut |
| | | } |
| | | } |
| | | |
| | | |
| | | </script> |
| | | |
| | |
| | | :close-on-click-modal="false" |
| | | :close-on-press-escape="false" |
| | | > |
| | | <el-card style="max-width: 480px;margin-left: 45px"> |
| | | <el-card style="max-width: 480px;margin-left: 45px;margin-top: 20px"> |
| | | <!-- header --> |
| | | <template #header> |
| | | <div class="card-header"> |
| | | <span style="font-weight: bold">成品合计</span> |
| | |       |
| | | <span>面积:1312.48㎡</span> |
| | |       |
| | | <span>数量:200</span> |
| | |       |
| | | <span>周长:5325.7m</span> |
| | | |
| | | <span>面积:{{ bomSum.sumData[0].area.toFixed(2) }}㎡</span> |
| | | |
| | | <span>数量:{{ bomSum.sumData[0].quantity }}</span> |
| | | |
| | | <span>周长:{{ bomSum.sumData[0].perimeter.toFixed(2) }}m</span> |
| | | </div> |
| | | </template> |
| | | <el-row > |
| | | <el-col :span="8">6mm超白:</el-col> |
| | | <el-col :span="8">3149.72㎡</el-col> |
| | | |
| | | <!-- body --> |
| | | <el-row |
| | | v-for="(mat, idx) in bomSum.sumDatilsData" |
| | | :key="idx" |
| | | style="text-align: left; margin-bottom: 6px" |
| | | > |
| | | <el-col :span="8">{{ mat.material }}:</el-col> |
| | | <el-col :span="8">{{ mat.consume }}㎡</el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="8">8mm超白:</el-col> |
| | | <el-col :span="8">787.72㎡</el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="8">铝框:</el-col> |
| | | <el-col :span="8">2662.85m</el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="8">0.76PVB:</el-col> |
| | | <el-col :span="8">1706.22㎡</el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="8">其他:</el-col> |
| | | <el-col :span="8">5</el-col> |
| | | </el-row> |
| | | <template #footer>合计xxx元</template> |
| | | |
| | | <!-- footer --> |
| | | <template #footer> |
| | | 合计 ¥{{ totalPriceSum }} |
| | | </template> |
| | | </el-card> |
| | | |
| | | <el-card |
| | |
| | | |
| | | <span>数量:{{ item.quantity }}</span> |
| | | |
| | | <span>周长:{{ item.perimeter }}</span> |
| | | <span>周长:{{ Number(item.perimeter).toFixed(2) }}</span> |
| | | </div> |
| | | </template> |
| | | |
| | | <!-- body --> |
| | | <el-row v-for="(part, index) in item.product_parts" :key="index" style="text-align: left"> |
| | | <el-col :span="8">{{ part.name }}:</el-col> |
| | | <el-col :span="16"> |
| | | <div v-for="(d, j) in part.details" :key="j"> |
| | | {{ d.material }} ¥{{ d.materialPric}} |
| | | </div> |
| | | <hr> |
| | | <el-row |
| | | v-for="(part, index) in item.product_parts" |
| | | :key="index" |
| | | style="text-align: left; margin-bottom: 6px" |
| | | > |
| | | <el-col :span="24"> |
| | | |
| | | <el-row v-for="(d, j) in part.details" |
| | | :key="j" |
| | | style="text-align: left"> |
| | | <el-col :span="8">{{ d.material }}</el-col> |
| | | <el-col :span="8">{{ d.consume }}{{d.unit}}</el-col> |
| | | </el-row> |
| | | <!-- <hr v-if="part.details.length > 0" />--> |
| | | </el-col> |
| | | </el-row> |
| | | |