提交 16c93ed7 authored 作者: lidongxu's avatar lidongxu

refactor(sale): 简单过了下商品明细

同上
上级 26fe3e2a
...@@ -2,11 +2,10 @@ ...@@ -2,11 +2,10 @@
<div class="app-container"> <div class="app-container">
<!-- 套表 Item --> <!-- 套表 Item -->
<div class="excel_charts_item" <div class="excel_charts_item"
v-for="item, index in platformSalesList" v-for="item, index in platformSalesList">
:key="index">
<!-- 查询表单 --> <!-- 查询表单 -->
<el-form :model="item.queryParams" <el-form :model="item.queryParams"
:inline="true" inline
label-width="68px" label-width="68px"
v-show="item.showSearch"> v-show="item.showSearch">
<el-form-item label="商品标签"> <el-form-item label="商品标签">
...@@ -54,7 +53,7 @@ ...@@ -54,7 +53,7 @@
<el-form-item class="del_excel_charts" <el-form-item class="del_excel_charts"
v-if="index !== 0"> v-if="index !== 0">
<el-button type="danger" <el-button type="danger"
icon="el-icon-delete" icon="Delete"
@click="platformSalesList.splice(index, 1)">删除表</el-button> @click="platformSalesList.splice(index, 1)">删除表</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
...@@ -262,7 +261,7 @@ ...@@ -262,7 +261,7 @@
@click="createTableAndECharts">新增套表</div> @click="createTableAndECharts">新增套表</div>
<!-- 上传货需弹框 --> <!-- 上传货需弹框 -->
<el-dialog title="上传货需" <el-dialog title="上传货需"
v-model:visible="uploadDemandImportVisible"> v-model="uploadDemandImportVisible">
<el-form :model="uploadDemand" <el-form :model="uploadDemand"
label-width="150px"> label-width="150px">
<el-form-item label="年份"> <el-form-item label="年份">
...@@ -277,7 +276,7 @@ ...@@ -277,7 +276,7 @@
action="#" action="#"
:http-request="uploadDemandImportFn"> :http-request="uploadDemandImportFn">
<i class="el-icon-upload"></i> <i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> <div class="el-upload__text">货需表格模板,拖到此处,或<em>点击上传</em></div>
<div class="el-upload__tip">只能上传 excel 文件</div> <div class="el-upload__tip">只能上传 excel 文件</div>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
...@@ -291,8 +290,8 @@ ...@@ -291,8 +290,8 @@
<levitated-sphere> <levitated-sphere>
<el-button type="primary" <el-button type="primary"
@click="createTableAndECharts">新增套表</el-button> @click="createTableAndECharts">新增套表</el-button>
<el-button type="warning" <!-- <el-button type="warning"
@click="uploadDemandImportVisible = true">上传货需</el-button> @click="uploadDemandImportVisible = true">上传货需</el-button> -->
<el-button type="danger" <el-button type="danger"
@click="reset">重置本页</el-button> @click="reset">重置本页</el-button>
</levitated-sphere> </levitated-sphere>
...@@ -353,12 +352,36 @@ const platformSalesObj = reactive({ // 平台销售数据对象(一套表图 ...@@ -353,12 +352,36 @@ const platformSalesObj = reactive({ // 平台销售数据对象(一套表图
}) })
const { pickerOptions } = useDatePickerOptions() const { pickerOptions } = useDatePickerOptions()
const uploadDemandImportVisible = ref(false) const uploadDemandImportVisible = ref(false)
const uploadDemand = ref({ // 上传货需数据对象 const uploadDemand = reactive({ // 上传货需数据对象
year: '', // 默认设置当前年份
year: new Date(),
file: '' file: ''
}) })
/** 获取销售数据列表 */
// 商品标签列表
const getSeriesGoodsTagList = async () => {
const { data: { total } } = await getSeriesGoodsTagListAPI()
const { data: { rows } } = await getSeriesGoodsTagListAPI({
pageSize: total
})
prdTagList.value = rows
}
// 系列列表
const getSeriesList = async () => {
const res = await getSeriesListAPI()
allSeriesList.value = res.data
}
// 商品列表
const getProductList = async (item) => {
const { data: { total } } = await getProductListAPI({ seriesId: item.queryParams.seriesId })
const res = await getProductListAPI({ seriesId: item.queryParams.seriesId, pageSize: total })
item.prdList = res.data.rows
}
// 销售表格数据
const getSaleList = async (item) => { const getSaleList = async (item) => {
item.loading = true item.loading = true
const res = await getSaleListAPI({ const res = await getSaleListAPI({
...@@ -426,35 +449,15 @@ const getSaleList = async (item) => { ...@@ -426,35 +449,15 @@ const getSaleList = async (item) => {
// 默认先显示销售量数据 // 默认先显示销售量数据
item.chartData.data = item.chartData.saleCount item.chartData.data = item.chartData.saleCount
item.loading = false item.loading = false
} }
// 商品标签列表
const getSeriesGoodsTagList = async () => {
const { data: { total } } = await getSeriesGoodsTagListAPI()
const { data: { rows } } = await getSeriesGoodsTagListAPI({
pageSize: total
})
prdTagList.value = rows
}
// 获取所有系列列表
const getSeriesList = async () => {
const res = await getSeriesListAPI()
allSeriesList.value = res.data
}
// 平台 id 值换平台中文名字
const getProductList = async (item) => {
const { data: { total } } = await getProductListAPI({ seriesId: item.queryParams.seriesId })
const res = await getProductListAPI({ seriesId: item.queryParams.seriesId, pageSize: total })
item.prdList = res.data.rows
return res.data.rows
}
// 格式化平台名字 // 格式化平台名字
const formatterPlatForm = (row, cell, cellValue) => { const formatterPlatForm = (row, cell, cellValue) => {
return dict.sale_platform.value.find(o => o.value == cellValue)?.label return dict.sale_platform.value.find(o => o.value == cellValue)?.label
} }
// 商品标签改变时
// 表格合计
const getSummaries = (param) => { const getSummaries = (param) => {
const { columns, data } = param; const { columns, data } = param;
const sums = []; const sums = [];
...@@ -513,6 +516,7 @@ const getSummaries = (param) => { ...@@ -513,6 +516,7 @@ const getSummaries = (param) => {
return sums; return sums;
} }
// 商品标签改变
const prdTagChange = async (item) => { const prdTagChange = async (item) => {
// 获取标签对应下属的商品 code 集合 // 获取标签对应下属的商品 code 集合
const response = await getPrdTagDetailAPI({ const response = await getPrdTagDetailAPI({
...@@ -521,18 +525,14 @@ const prdTagChange = async (item) => { ...@@ -521,18 +525,14 @@ const prdTagChange = async (item) => {
const prdCodes = response.data.map(o => o.prdCode) const prdCodes = response.data.map(o => o.prdCode)
item.queryParams.prdCodes = prdCodes item.queryParams.prdCodes = prdCodes
// 查询对应销售数据 // 查询销售数据
getSaleList(item) getSaleList(item)
} }
// 系列改变时 // 系列改变时
const seriesChange = async (item) => { const seriesChange = async (item) => {
// 对应商品列表改变 // 对应商品列表改变
const res = await getProductList(item) await getProductList(item)
// 商品列表里是否有刚才选择的数据,有就不清空,否则清空刚才选中的选项
if (!res.find(o => o.prdCode === item.queryParams.prdCode)) {
item.queryParams.prdCode = ''
}
// 对应销售数据改变 // 对应销售数据改变
getSaleList(item) getSaleList(item)
} }
...@@ -542,12 +542,13 @@ const prdChange = async (item) => { ...@@ -542,12 +542,13 @@ const prdChange = async (item) => {
// 对应销售数据改变 // 对应销售数据改变
getSaleList(item) getSaleList(item)
} }
// 创建查询某个系列/商品的套表
// 创建套表
const createTableAndECharts = () => { const createTableAndECharts = () => {
let item = reactive(deepClone(toRaw(platformSalesObj))) let item = reactive(deepClone(toRaw(platformSalesObj)))
// 如果是第一套套表,默认填写日期 // 第一套表,默认填写日期
if (platformSalesList.value.length === 0) { if (platformSalesList.value.length === 0) {
item.queryParams.date = [new Date().setDate(1), new Date().setDate((new Date().getDate() - 1))] // 默认查询和显示的是当月 1 号到 T-1 日期 item.queryParams.date = [new Date().setDate(1), new Date().setDate((new Date().getDate() - 1))]
} else { } else {
// 非第一套图表,滚动到底 // 非第一套图表,滚动到底
nextTick(() => { nextTick(() => {
...@@ -578,14 +579,14 @@ const uploadDemandImportFn = (obj) => { ...@@ -578,14 +579,14 @@ const uploadDemandImportFn = (obj) => {
// 确认上传货需 // 确认上传货需
const submitUploadDemandFn = async () => { const submitUploadDemandFn = async () => {
const fd = new FormData() const fd = new FormData()
console.log(uploadDemand.year)
fd.append('file', uploadDemand.file) fd.append('file', uploadDemand.file)
fd.append('year', uploadDemand?.year.getFullYear()) fd.append('year', uploadDemand.year.getFullYear())
const res = await uploadDemandImportAPI(fd) const res = await uploadDemandImportAPI(fd)
$message.success(res.msg) $message.success(res.msg)
uploadDemandImportVisible.value = false uploadDemandImportVisible.value = false
} }
const init = async () => { const init = async () => {
// 默认创建第一个表格 // 默认创建第一个表格
const item = createTableAndECharts() const item = createTableAndECharts()
...@@ -667,7 +668,7 @@ init() ...@@ -667,7 +668,7 @@ init()
} }
} }
/* 网页刚加载时表格最右侧的竖线去掉 */ /* 网页刚加载时表格最右侧的竖线去掉 */
.el-table--group::after, .el-table--group::after,
.el-table--border::after { .el-table--border::after {
...@@ -683,5 +684,5 @@ init() ...@@ -683,5 +684,5 @@ init()
} }
</style> </style>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论