优化进销存库存上传下载

This commit is contained in:
gyq
2024-06-20 09:06:35 +08:00
parent 2026193f0f
commit 7605011b63
13 changed files with 372 additions and 191 deletions

View File

@@ -5,7 +5,17 @@
<el-tab-pane label="销量" name="2"></el-tab-pane>
</el-tabs>
<div class="head-container">
<el-form :model="query" label-position="left">
<el-form :model="query" inline label-position="left">
<template v-if="orderType == 2">
<el-form-item>
<el-input placeholder="商品名称" v-model="query.proName" />
</el-form-item>
<el-form-item>
<el-select v-model="query.cateId" placeholder="商品分类" style="width: 140px;">
<el-option :label="item.name" :value="item.id" v-for="item in categorys" :key="item.id"></el-option>
</el-select>
</el-form-item>
</template>
<el-form-item>
<el-radio-group v-model="timeValue" @change="timeChange">
<el-radio-button label="">全部</el-radio-button>
@@ -17,24 +27,15 @@
<el-radio-button label="month">本月</el-radio-button>
<el-radio-button label="custom">自定义</el-radio-button>
</el-radio-group>
<el-date-picker
v-model="query.createdAt"
type="daterange"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"
value-format="yyyy-MM-dd HH:mm:ss"
v-if="timeValue == 'custom'"
>
</el-date-picker
><el-button type="primary" @click="getTableData">查询</el-button>
<el-date-picker v-model="query.createdAt" type="daterange" range-separator="至" start-placeholder="开始日期"
end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" value-format="yyyy-MM-dd HH:mm:ss"
v-if="timeValue == 'custom'">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="getTableData">查询</el-button>
<el-button @click="resetHandle">重置</el-button>
<el-button
icon="el-icon-download"
v-loading="downloadLoading"
@click="downloadHandle"
>
<el-button icon="el-icon-download" v-loading="downloadLoading" @click="downloadHandle">
<span v-if="!downloadLoading">导出Excel</span>
<span v-else>下载中...</span>
</el-button>
@@ -48,54 +49,68 @@
<i class="icon" :class="item.icon"></i>
</div>
<div class="info">
<div class="m">{{ item.payAmount }}</div>
<div class="m">
<template v-if="item.isAmount == 1"></template>
{{ item.payAmount }}
</div>
<div class="t">{{ item.payType }}</div>
</div>
</div>
</div>
</div>
<div class="head-container">
<el-table
:data="tableData.data"
v-loading="tableData.loading"
v-if="orderType == 1"
>
<el-table :data="tableData.data" v-loading="tableData.loading" v-if="orderType == 1">
<el-table-column label="日期" prop="tradeDay"></el-table-column>
<el-table-column label="总金额" prop="total"></el-table-column>
<el-table-column label="微信小程序支付" prop="wxLite"></el-table-column>
<el-table-column label="扫码支付金额" prop="scanCode"></el-table-column>
<el-table-column label="现金支付金额" prop="cash"></el-table-column>
<el-table-column label="总金额" prop="total">
<template v-slot="scope">
{{ scope.row.total }}
</template>
</el-table-column>
<el-table-column label="微信小程序支付" prop="wxLite">
<template v-slot="scope">
{{ scope.row.wxLite }}
</template>
</el-table-column>
<el-table-column label="扫码支付金额" prop="scanCode">
<template v-slot="scope">
{{ scope.row.scanCode }}
</template>
</el-table-column>
<el-table-column label="现金支付金额" prop="cash">
<template v-slot="scope">
{{ scope.row.cash }}
</template>
</el-table-column>
</el-table>
<el-table
:data="tableData.data"
v-loading="tableData.loading"
v-if="orderType == 2"
>
<el-table :data="tableData.data" v-loading="tableData.loading" v-if="orderType == 2">
<el-table-column label="商品名称" prop="productName"></el-table-column>
<el-table-column
label="商品描述"
prop="productSkuName"
></el-table-column>
<el-table-column label="商品分类" prop="cateName"></el-table-column>
<el-table-column label="商品描述" prop="productSkuName"></el-table-column>
<el-table-column label="销量" prop="salesNum"></el-table-column>
<el-table-column label="退单量" prop="refNum"></el-table-column>
<el-table-column label="总量" prop="num"></el-table-column>
<el-table-column label="销售金额" prop="salesAmount">
<template v-slot="scope">
{{ scope.row.salesAmount }}
</template>
</el-table-column>
<el-table-column label="退款金额" prop="refAmount">
<template v-slot="scope">
{{ scope.row.refAmount }}
</template>
</el-table-column>
</el-table>
</div>
<div class="head-container">
<el-pagination
:total="tableData.total"
:current-page="tableData.page + 1"
:page-size="tableData.size"
@current-change="paginationChange"
@size-change="sizeChange"
layout="total, sizes, prev, pager, next, jumper"
></el-pagination>
<el-pagination :total="tableData.total" :current-page="tableData.page + 1" :page-size="tableData.size"
@current-change="paginationChange" @size-change="sizeChange"
layout="total, sizes, prev, pager, next, jumper"></el-pagination>
</div>
</div>
</template>
<script>
import { daydownload, daycount, summaryday } from "@/api/home";
import { tbShopCategoryGet } from '@/api/shop'
import dayjs from "dayjs";
import { downloadFile } from "@/utils/index";
@@ -105,8 +120,11 @@ export default {
timeValue: "",
resetQuery: null,
orderType: "1",
categorys: [],
query: {
createdAt: []
createdAt: [],
proName: '',
cateId: ''
},
tableData: {
data: [],
@@ -128,8 +146,38 @@ export default {
mounted() {
this.resetQuery = { ...this.query };
this.getTableData();
this.tbShopCategoryGet()
},
methods: {
// 获取商品分类
async tbShopCategoryGet() {
try {
const res = await tbShopCategoryGet({
page: 0,
size: 200,
sort: 'id,desc',
shopId: localStorage.getItem('shopId')
})
let categorys = []
for (let item of res.content) {
categorys.push({
name: `|----${item.name}`,
id: item.id
})
if (item.childrenList.length) {
for (let val of item.childrenList) {
categorys.push({
name: `|----|----${val.name}`,
id: val.id
})
}
}
}
this.categorys = categorys
} catch (error) {
console.log(error);
}
},
// 获取订单汇总
async daycount() {
try {
@@ -149,7 +197,9 @@ export default {
const file = await daydownload({
type: this.orderType,
startTime: this.query.createdAt[0],
endTime: this.query.createdAt[1]
endTime: this.query.createdAt[1],
cateId: this.query.cateId,
proName: this.query.proName
});
downloadFile(file, "数据", "xlsx");
this.downloadLoading = false;
@@ -184,7 +234,9 @@ export default {
size: this.tableData.size,
type: this.orderType,
startTime: this.query.createdAt[0],
endTime: this.query.createdAt[1]
endTime: this.query.createdAt[1],
proName: this.query.proName,
cateId: this.query.cateId
});
this.tableData.loading = false;
this.tableData.data = res.content;