提交 9af68ad0 authored 作者: lidongxu's avatar lidongxu

feat(finance): 新增直播间分类展开行内嵌表格的功能

同上
上级 19b17451
...@@ -51,11 +51,18 @@ export const getFinanceListAPI = (data) => { ...@@ -51,11 +51,18 @@ export const getFinanceListAPI = (data) => {
series: data.seriesPrdMap.map(o => o[0]), series: data.seriesPrdMap.map(o => o[0]),
goodsName: data.seriesPrdMap.map(o => o[1]), goodsName: data.seriesPrdMap.map(o => o[1]),
startDate: parseTime(data.date[0], `{y}-{m}-{d}`), startDate: parseTime(data.date[0], `{y}-{m}-{d}`),
endDate: parseTime(data.date[1], `{y}-{m}-{d}`) endDate: parseTime(data.date[1], `{y}-{m}-{d}`),
pageNum: data.pageNum,
pageSize: data.pageSize
} }
}) })
} }
/**
* 获取订单详情
* @param {*} data
* @returns
*/
export const getFinanceDetailAPI = (data) => { export const getFinanceDetailAPI = (data) => {
return request({ return request({
url: '/bi/finance/cost/detail/list', url: '/bi/finance/cost/detail/list',
...@@ -75,4 +82,32 @@ export const getFinanceDetailAPI = (data) => { ...@@ -75,4 +82,32 @@ export const getFinanceDetailAPI = (data) => {
pageSize: data.pageSize pageSize: data.pageSize
} }
}) })
}
/**
* 直播间子数据列表
* @param {*} data
* @returns
*/
export const getFinanceSubListAPI = (data) => {
return request({
url: '/bi/finance/cost/subList',
method: 'POST',
data: {
subType: 0, // 直播间的
zbjQdType: data.zbjQdType,
flavor: data.flavorErp,
specName: data.specNameErp,
zbjQdTypeAll: data.zbjQdTypeAll,
flavorErpAll: data.flavorErpAll,
specNameErpAll: data.specNameErpAll,
series: data.seriesPrdMap.map(o => o[0]),
goodsName: data.seriesPrdMap.map(o => o[1]),
startDate: parseTime(data.date[0], `{y}-{m}-{d}`),
endDate: parseTime(data.date[1], `{y}-{m}-{d}`),
pageNum: data.pageNum,
pageSize: data.pageSize
}
})
} }
\ No newline at end of file
...@@ -114,20 +114,53 @@ ...@@ -114,20 +114,53 @@
<!-- 数据 --> <!-- 数据 -->
<el-table :data="tableList" <el-table :data="tableList"
border border
row-key="zbjQdType" @expand-change="expandChangeFn"
lazy @mousedown="handleMouseDown">
:load="load" <el-table-column type="expand">
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"> <template #default="props">
<div class="expand-div">
<el-table :data="expandTableList"
show-overflow-tooltip
class="expand-table">
<el-table-column v-for="item in columns"
:key="item.prop"
:label="item.label"
:prop="item.prop"
:min-width="item.width"
:formatter="formatter"
:sortable="item.sortable">
</el-table-column>
<el-table-column label="操作"
width="120">
<template v-slot="scope">
<el-button type="primary"
link
@click="rowClick(scope.row)">订单详情</el-button>
</template>
</el-table-column>
</el-table>
<pagination :total="expandTotal"
v-model:page="expandQuery.pageNum"
v-model:limit="expandQuery.pageSize"
@pagination="expandChangeFn"></pagination>
</div>
</template>
</el-table-column>
<template v-for="item in columns"> <template v-for="item in columns">
<el-table-column v-if="item.visible" <el-table-column v-if="item.visible"
:key="item.prop" :key="item.prop"
:label="item.label" :label="item.label"
:prop="item.prop" :prop="item.prop"
:min-width="item.width" :min-width="item.width"
:formatter="formatter"> :formatter="formatter"
:sortable="item.sortable">
</el-table-column> </el-table-column>
</template> </template>
<el-table-column label="操作" width="120">
<el-table-column label="操作"
width="120">
<template v-slot="scope"> <template v-slot="scope">
<el-button type="primary" <el-button type="primary"
link link
...@@ -135,6 +168,10 @@ ...@@ -135,6 +168,10 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination :total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="getList"></pagination>
<!-- 订单详情 --> <!-- 订单详情 -->
<el-dialog v-model="detailVisible" <el-dialog v-model="detailVisible"
title="订单详情" title="订单详情"
...@@ -174,7 +211,7 @@ ...@@ -174,7 +211,7 @@
</template> </template>
<script setup> <script setup>
import { getBrandListAPI, getTasteListAPI, getSpecListAPI, getSeriesListAPI, getProductListAPI, getFinanceListAPI, getFinanceDetailAPI } from '@/api' import { getBrandListAPI, getTasteListAPI, getSpecListAPI, getSeriesListAPI, getProductListAPI, getFinanceListAPI, getFinanceDetailAPI, getFinanceSubListAPI } from '@/api'
import { useDatePickerOptions } from '@/hooks' import { useDatePickerOptions } from '@/hooks'
import { formatNumberWithUnit, parseTime } from '@/utils' import { formatNumberWithUnit, parseTime } from '@/utils'
...@@ -188,15 +225,21 @@ const data = reactive({ ...@@ -188,15 +225,21 @@ const data = reactive({
flavorErp: [], // 口味 flavorErp: [], // 口味
specNameErp: [], // 规格 specNameErp: [], // 规格
date: lastDate, // 日期 date: lastDate, // 日期
seriesPrdMap: [] // 系列商品 seriesPrdMap: [], // 系列商品
pageNum: 1,
pageSize: 10
}, },
detailQueryParams: { // 详情查询 detailQueryParams: { // 详情查询
pageNum: 1, pageNum: 1,
pageSize: 10 pageSize: 10
}, },
expandQuery: { // 展开查询
pageNum: 1,
pageSize: 10
}
}) })
const { queryParams, detailQueryParams } = toRefs(data) const { queryParams, detailQueryParams, expandQuery } = toRefs(data)
const reset = () => { const reset = () => {
queryParams.value = { queryParams.value = {
...@@ -204,7 +247,9 @@ const reset = () => { ...@@ -204,7 +247,9 @@ const reset = () => {
flavorErp: [], // 口味 flavorErp: [], // 口味
specNameErp: [], // 规格 specNameErp: [], // 规格
date: lastDate, // 日期 date: lastDate, // 日期
seriesPrdMap: [] // 系列商品 seriesPrdMap: [], // 系列商品
pageNum: 1,
pageSize: 10
} }
getList() getList()
} }
...@@ -292,88 +337,101 @@ const columns = ref([ ...@@ -292,88 +337,101 @@ const columns = ref([
prop: 'zbjQdType', prop: 'zbjQdType',
visible: true, visible: true,
width: 140, width: 140,
check: true // 根据查询条件有无,判断当前列实/隐 check: true, // 根据查询条件有无,判断当前列实/隐
sortable: false
}, },
{ {
label: '口味', label: '口味',
prop: 'flavorErp', prop: 'flavorErp',
visible: true, visible: true,
width: 120, width: 120,
check: true check: true,
sortable: false
}, },
{ {
label: '规格', label: '规格',
prop: 'specNameErp', prop: 'specNameErp',
visible: true, visible: true,
width: 140, width: 140,
check: true check: true,
sortable: false
}, },
{ {
label: '系列', label: '系列',
prop: 'series', prop: 'series',
visible: true, visible: true,
width: 140, width: 140,
check: true check: true,
sortable: false
}, },
{ {
label: '商品', label: '商品',
prop: 'goodsName', prop: 'goodsName',
visible: true, visible: true,
width: 140, width: 140,
check: true check: true,
sortable: false
}, },
{ {
label: '分销商 id', label: '分销商 id',
prop: 'fenxiaoId', prop: 'fenxiaoId',
visible: true, visible: true,
width: 100, width: 100,
check: true check: true,
sortable: false
}, },
{ {
label: '分销商名称', label: '分销商名称',
prop: 'fenxiaoName', prop: 'fenxiaoName',
visible: true, visible: true,
width: 200, width: 200,
check: true check: true,
sortable: false
}, },
{ {
label: '分摊后总价', label: '分摊后总价',
prop: 'shareAmountSum', prop: 'shareAmountSum',
visible: true, visible: true,
width: 120, width: 120,
check: false check: false,
sortable: true
}, },
{ {
label: '实际成本', label: '实际成本',
prop: 'actualCostSum', prop: 'actualCostSum',
visible: true, visible: true,
width: 120, width: 120,
check: false check: false,
sortable: true
}, },
{ {
label: '实际成本毛利', label: '实际成本毛利',
prop: 'actualCostGrossProfitSum', prop: 'actualCostGrossProfitSum',
visible: true, visible: true,
width: 120, width: 160,
check: false check: false,
sortable: true
}, },
{ {
label: '标准成本', label: '标准成本',
prop: 'standardCostSum', prop: 'standardCostSum',
visible: true, visible: true,
width: 120, width: 120,
check: false check: false,
sortable: true
}, },
{ {
label: '标准成本毛利', label: '标准成本毛利',
prop: 'standardCostGrossProfitSum', prop: 'standardCostGrossProfitSum',
visible: true, visible: true,
width: 120, width: 160,
check: false check: false,
sortable: true
} }
]) ])
const tableList = ref([ const tableList = ref([
]) ])
const total = ref(0)
const getList = async () => { const getList = async () => {
// 直播间分类全选时,单独增加字段给后台 // 直播间分类全选时,单独增加字段给后台
queryParams.value.zbjQdTypeAll = (queryParams.value.zbjQdType.length === brandList.value.length) queryParams.value.zbjQdTypeAll = (queryParams.value.zbjQdType.length === brandList.value.length)
...@@ -383,10 +441,8 @@ const getList = async () => { ...@@ -383,10 +441,8 @@ const getList = async () => {
queryParams.value.specNameErpAll = (queryParams.value.specNameErp.length === specList.value.length) queryParams.value.specNameErpAll = (queryParams.value.specNameErp.length === specList.value.length)
const res = await getFinanceListAPI(queryParams.value) const res = await getFinanceListAPI(queryParams.value)
tableList.value = res.data.list.map(o => { total.value = res.data.total
o.hasChildren = true tableList.value = res.data.list
return o
})
} }
getList() getList()
...@@ -398,6 +454,27 @@ const formatter = (row, column, value) => { ...@@ -398,6 +454,27 @@ const formatter = (row, column, value) => {
} }
} }
// 展开行
const expandTableList = ref([])
const expandTotal = ref(0)
let nowExpandRow = ref(null)
const expandChangeFn = async (row) => {
if (row) nowExpandRow = row
const res = await getFinanceSubListAPI({
...nowExpandRow,
...queryParams.value,
...expandQuery.value
})
expandTableList.value = res.data.list
expandTotal.value = res.data.total
}
const handleMouseDown = (event) => {
if (event.button === 1) { // 1 表示鼠标中键
event.preventDefault(); // 阻止默认的滚动行为
}
}
// 观察查询表单选择字段,则显示 // 观察查询表单选择字段,则显示
// watch(queryParams, (val) => { // watch(queryParams, (val) => {
// // 日期无需决定列显示与否 // // 日期无需决定列显示与否
...@@ -438,14 +515,7 @@ const formatter = (row, column, value) => { ...@@ -438,14 +515,7 @@ const formatter = (row, column, value) => {
// }) // })
// 展开行 // 展开行
const load = (options) => {
// 请求某个展开行下属的数据
console.log(options)
// const { page, limit } = options
// queryParams.value.pageNum = page
// queryParams.value.pageSize = limit
// getList()
}
// 详情数据 // 详情数据
const detailList = ref([]) const detailList = ref([])
...@@ -605,7 +675,8 @@ const rowClick = (row) => { ...@@ -605,7 +675,8 @@ const rowClick = (row) => {
zbjQdType: row.zbjQdType && [row.zbjQdType], // 直播间 zbjQdType: row.zbjQdType && [row.zbjQdType], // 直播间
flavorErp: row.flavorErp && [row.flavorErp], // 口味 flavorErp: row.flavorErp && [row.flavorErp], // 口味
specNameErp: row.specNameErp && [row.specNameErp], // 规格 specNameErp: row.specNameErp && [row.specNameErp], // 规格
seriesPrdMap: row.seriesId && [{ value: row.seriesId, label: row.seriesName }], // TODO:行里没有系列字段等会看下 // seriesPrdMap: row.seriesId && [{ value: row.seriesId, label: row.seriesName }], // TODO:行里没有系列字段等会看下,现在格式应该是 [[系列id],[商品id]]
seriesPrdMap: [],
date: queryParams.value.date, // 日期 date: queryParams.value.date, // 日期
pageNum: 1, pageNum: 1,
pageSize: 10 pageSize: 10
...@@ -633,6 +704,7 @@ const detailFormatter = (row, column, value) => { ...@@ -633,6 +704,7 @@ const detailFormatter = (row, column, value) => {
const changeShowOver = () => { const changeShowOver = () => {
showOverFlowToolTip.value = !showOverFlowToolTip.value showOverFlowToolTip.value = !showOverFlowToolTip.value
} }
</script> </script>
<style scoped <style scoped
...@@ -670,4 +742,15 @@ const changeShowOver = () => { ...@@ -670,4 +742,15 @@ const changeShowOver = () => {
} }
} }
} }
/* 展开行表格 */
.expand-div {
background-color: rgb(240, 240, 240);
padding: 20px !important;
}
.el-scrollbar__bar {
height: 0;
}
</style> </style>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论