优化问题、更换接口

This commit is contained in:
gyq
2024-09-27 13:44:17 +08:00
parent dc758120c4
commit f0bca6e0d1
12 changed files with 642 additions and 92 deletions

View File

@@ -23,13 +23,72 @@
</el-row>
</div>
<div class="head-container">
<el-row>
<el-col>
<router-link :to="{ name: 'add_shop' }">
<el-button type="primary" icon="el-icon-plus">添加商品</el-button>
</router-link>
</el-col>
</el-row>
<div class="header_wrap">
<router-link :to="{ name: 'add_shop' }">
<el-button type="primary" icon="el-icon-plus">添加商品</el-button>
</router-link>
<el-select v-model="tableData.sort" placeholder="排序" @change="getTableData">
<el-option value="createdAt,desc" label="创建时间"></el-option>
<el-option value="stockNumber,asc" label="数量由低到高"></el-option>
</el-select>
</div>
</div>
<div class="head-container">
<div class="data_wrap">
<div class="item">
<div class="icon">
<i class="el-icon-pie-chart"></i>
</div>
<div class="info">
<div class="row">
<span>现有数量</span>
<span @click="showStockHistory('stockNumber')">{{ countInfo.stockNumber || 0 }}</span>
</div>
</div>
</div>
<div class="item">
<div class="icon">
<i class="el-icon-sort-up"></i>
</div>
<div class="info">
<div class="row">
<span>增加数量</span>
<span class="link" @click="showStockHistory('addCountNumber')">{{ countInfo.addCountNumber || 0 }}</span>
</div>
<div class="row">
<span>手动增加</span>
<span class="link" @click="showStockHistory('addNumber')">{{ countInfo.addNumber || 0 }}</span>
</div>
</div>
</div>
<div class="item">
<div class="icon">
<i class="el-icon-sort-down"></i>
</div>
<div class="info">
<div class="row">
<span>减少数量</span>
<span class="link" @click="showStockHistory('subCountNumber')">{{ countInfo.subCountNumber || 0 }}</span>
</div>
<div class="row">
<div class="row">
<span>手动减少</span>
<span class="link" @click="showStockHistory('subNumber')">{{ countInfo.subNumber || 0 }}</span>
</div>
<div class="line"></div>
<div class="row">
<span>销售量</span>
<span class="link" @click="showStockHistory('saleNumber')">{{ countInfo.saleNumber || 0 }}</span>
</div>
<div class="line"></div>
<div class="row">
<span>报损</span>
<span class="link" @click="showStockHistory('lossNumber')">{{ countInfo.lossNumber || 0 }}</span>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="head-container" id="table_drag">
<el-table ref="table" :data="tableData.data" v-loading="tableData.loading" row-key="id"
@@ -73,7 +132,7 @@
</el-table-column>
<el-table-column label="耗材信息" width="200">
<template v-slot="scope">
<div class="cons_wrap">
<div class="cons_wrap" v-if="scope.row.typeEnum">
<div v-if="scope.row.conInfos && scope.row.conInfos.length">
<span v-for="item in scope.row.conInfos" :key="item.id">{{ item.conName }}</span>
</div>
@@ -91,15 +150,25 @@
<el-button type="text" icon="el-icon-edit"
v-if="!scope.row.isShowCash && !scope.row.isShowMall">未上架</el-button> -->
<el-switch v-model="scope.row.isGrounding" :active-value="1" :inactive-value="0"
@change="changeGrounding($event, scope.row)"></el-switch>
@change="changeGrounding($event, scope.row, 'grounding')"></el-switch>
</template>
</el-table-column>
<el-table-column label="排序" prop="sort" sortable />
<el-table-column label="售罄">
<template v-slot="scope">
<!-- <el-button type="text" icon="el-icon-edit" v-if="scope.row.isShowCash">收银端</el-button>
<el-button type="text" icon="el-icon-edit" v-if="scope.row.isShowMall">小程序</el-button>
<el-button type="text" icon="el-icon-edit"
v-if="!scope.row.isShowCash && !scope.row.isShowMall">未上架</el-button> -->
<el-switch v-model="scope.row.isPauseSale" :active-value="1" :inactive-value="0"
@change="changeGrounding($event, scope.row, 'pauseSale')"></el-switch>
</template>
</el-table-column>
<!-- <el-table-column label="排序" prop="sort" sortable />
<el-table-column label="更新时间" prop="createdAt" width="150">
<template v-slot="scope">
{{ dayjs(scope.row.createdAt).format('YYYY-MM-DD HH:mm:ss') }}
</template>
</el-table-column>
</el-table-column> -->
<!-- <el-table-column label="设为热门" prop="createdAt">
<template v-slot="scope">
<el-switch v-model="scope.row.isHot" :active-value="1" :inactive-value="0"
@@ -130,7 +199,9 @@
layout="total, sizes, prev, pager, next, jumper"></el-pagination>
</div>
<!-- 绑定耗材 -->
<BindCons ref="bindCons" />
<BindCons ref="bindCons" @refundChange="refundChange" />
<!-- 商品库存记录 -->
<StockHistory ref="stockHistory" />
<!-- 编辑售价库存 -->
<el-dialog :title="editorEumn[editorForm.key]" :visible.sync="editorVisable" :show-close="false" width="300px">
<el-form :model="editorForm">
@@ -151,10 +222,12 @@ import Sortable from 'sortablejs'
import dayjs from 'dayjs'
import settings from '@/settings'
import BindCons from './components/bindCons.vue'
import { tbProductListV2, tbShopCategoryGet, tbProductDelete, tbProductIsHot, upProSort, updateProductData } from '@/api/shop'
import StockHistory from './components/stockHistory.vue'
import { tbProductListV2, tbShopCategoryGet, tbProductDelete, tbProductIsHot, upProSort, updateProductData, tbProductStockDetailStockCount } from '@/api/shop'
export default {
components: {
BindCons
BindCons,
StockHistory
},
data() {
return {
@@ -168,6 +241,7 @@ export default {
categorys: [],
typeEnums: settings.typeEnum,
tableData: {
sort: 'createdAt,desc',
data: [],
page: 0,
size: 30,
@@ -188,7 +262,8 @@ export default {
id: '',
key: '',
value: ''
}
},
countInfo: {}
}
},
async mounted() {
@@ -205,10 +280,40 @@ export default {
this.tableDrag()
})
}
this.tbProductStockDetailStockCount()
},
methods: {
changeGrounding(event, row) {
this.editorForm.key = 'grounding'
// 显示库存记录
showStockHistory(key) {
this.$refs.stockHistory.show(key)
},
// 库存统计列表 统计
async tbProductStockDetailStockCount() {
try {
const res = await tbProductStockDetailStockCount({
shopId: localStorage.getItem('shopId')
})
this.countInfo = res
} catch (error) {
console.log(error);
}
},
// 编辑退款是否退回库存
refundChange(e) {
let row = this.tableData.data.find(item => item.id == e.id)
if (row.isRefundStock != e.isRefundStock) {
this.editorForm.key = 'refundStock'
this.editorForm.id = e.id
this.editorForm.isSku = !e.typeEnum
this.editorForm.value = e.isRefundStock
this.editorConfirmChange()
}
},
changeGrounding(event, row, key) {
this.editorForm.key = key
this.editorForm.id = row.id
this.editorForm.isSku = !row.typeEnum
this.editorForm.value = event
@@ -221,7 +326,7 @@ export default {
this.editorFormLoading = true
const res = await updateProductData([this.editorForm])
this.editorFormLoading = false
this.$message.success('修改成功')
// this.$message.success('修改成功')
this.editorVisable = false
this.getTableData()
} catch (error) {
@@ -320,7 +425,7 @@ export default {
}
this.tableData.loading = true
console.log(this.query, '调试2')
// console.log(this.query, '调试2')
const res = await tbProductListV2({
page: this.tableData.page,
size: this.tableData.size,
@@ -328,7 +433,8 @@ export default {
categoryId: this.query.categoryId,
id: this.query.productId,
type: this.query.typeEnum,
shopId: localStorage.getItem('shopId')
shopId: localStorage.getItem('shopId'),
sort: this.tableData.sort
})
this.tableData.loading = false
this.tableData.data = res.content
@@ -369,6 +475,73 @@ export default {
</script>
<style scoped lang="scss">
.header_wrap {
display: flex;
align-items: center;
justify-content: space-between;
}
.data_wrap {
display: flex;
justify-content: space-between;
.item {
display: flex;
align-items: center;
background-color: #F4F9FF;
height: 80px;
padding: 20px;
.icon {
width: 37px;
height: 37px;
border-radius: 50%;
background-color: #D4E9FE;
display: flex;
align-items: center;
justify-content: center;
color: #3F9EFF;
font-size: 20px;
}
.info {
flex: 1;
display: flex;
gap: 14px;
flex-direction: column;
padding-left: 14px;
.row {
display: flex;
align-items: center;
gap: 10px;
font-size: 14px;
.line {
margin: 0 14px;
height: 20px;
border-left: 1px solid #DDDFE6;
}
span {
&.link {
color: #3F9EFF;
cursor: pointer;
&:hover {
text-decoration: underline;
}
}
&:first-child {
color: #666;
}
}
}
}
}
}
.cons_wrap {
display: flex;
flex-wrap: wrap;