This commit is contained in:
魏啾
2024-06-27 10:50:07 +08:00
11 changed files with 439 additions and 193 deletions

View File

@@ -0,0 +1,194 @@
<template>
<el-dialog title="选择商品" :visible.sync="dialogVisible" @open="resetHandle()">
<el-form :model="searhForm" inline>
<el-form-item>
<el-input v-model="searhForm.name" placeholder="商品名称"></el-input>
</el-form-item>
<el-form-item>
<el-select v-model="searhForm.category" placeholder="商品分类">
<el-option :label="item.name" :value="item.id" v-for="item in categoryList"
:key="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="getTableData">查询</el-button>
<el-button @click="resetHandle">重置</el-button>
</el-form-item>
</el-form>
<div class="head-container">
<el-table ref="table" :data="tableData.list" v-loading="tableData.loading">
<el-table-column type="selection" width="55" align="center"></el-table-column>
<el-table-column label="商品信息">
<template v-slot="scope">
<div class="shop_info">
<el-image :src="scope.row.coverImg" style="width: 30px;height: 30px;">
<div class="img_error" slot="error">
<i class="icon el-icon-document-delete"></i>
</div>
</el-image>
<span>{{ scope.row.name }}</span>
</div>
</template>
</el-table-column>
<el-table-column label="规格">
<template v-slot="scope">
{{ scope.row.typeEnum }}
</template>
</el-table-column> <el-table-column label="是否售罄">
<template v-slot="scope">
{{ scope.row.isPauseSale == 1?'':'' }}
</template>
</el-table-column> <el-table-column label="是否分销">
<template v-slot="scope">
{{ scope.row.isDistribute == 1?'':'' }}
</template>
</el-table-column>
<el-table-column label="售价">
<template v-slot="scope">
{{ scope.row.lowPrice }}
</template>
</el-table-column>
<el-table-column label="销量/库存">
<template v-slot="scope">
{{ scope.row.realSalesNumber }}/{{ scope.row.stockNumber }}
</template>
</el-table-column>
<el-table-column label="分类名称" prop="categoryName"></el-table-column>
</el-table>
</div>
<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>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="confirmHandle"> </el-button>
</span>
</el-dialog>
</template>
<script>
import { tbShopCategoryGet, tbProductlist } from "@/api/invoicing";
export default {
data() {
return {
dialogVisible: false,
searhForm: {
name: '',
category: ''
},
categoryList: [],
tableData: {
page: 0,
size: 10,
total: 0,
loading: false,
list: []
},
goods: []
}
},
methods: {
// 确定选商品
confirmHandle() {
let res = this.$refs.table.selection
this.$emit('success', res)
this.close()
},
// 重置查询
resetHandle() {
this.searhForm.name = ''
this.searhForm.category = ''
this.tableData.page = 0
this.tableData.size = 10
this.tableData.list = []
this.getTableData()
},
// 分页大小改变
sizeChange(e) {
this.tableData.size = e
this.getTableData()
},
// 分页回调
paginationChange(e) {
this.tableData.page = e - 1
this.getTableData()
},
// 商品列表
async getTableData() {
this.tableData.loading = true
try {
const res = await tbProductlist({
page: this.tableData.page,
size: this.tableData.size,
name: this.searhForm.name,
categoryId: this.searhForm.category,
shopId: localStorage.getItem('shopId'),
sort: 'id',
})
this.tableData.list = res.content
this.tableData.total = res.totalElements
if (this.goods.length) {
this.$nextTick(() => {
this.selection()
})
}
setTimeout(() => {
this.tableData.loading = false
}, 500);
} catch (error) {
console.log(error)
}
},
// 商品分类
async tbShopCategoryGet() {
try {
const res = await tbShopCategoryGet({
page: 0,
size: 100,
sort: 'id',
shopId: localStorage.getItem('shopId')
})
this.categoryList = res.content
} catch (error) {
console.log(error)
}
},
show(goods) {
this.dialogVisible = true
if (goods && goods.length) {
this.goods = goods
} else {
this.goods = []
}
this.resetHandle()
this.tbShopCategoryGet()
this.getTableData()
},
close() {
this.dialogVisible = false
},
selection() {
this.goods.forEach(row => {
this.tableData.list.forEach((item, index) => {
if (row.id == item.id) {
this.$refs.table.toggleRowSelection(this.tableData.list[index]);
}
})
});
}
}
}
</script>
<style scoped lang="scss">
.shop_info {
display: flex;
align-items: center;
span {
margin-left: 10px;
}
}
</style>

View File

@@ -140,7 +140,7 @@
<script>
import dayjs from 'dayjs'
import shopList from '@/components/shopList'
import shopList from './components/shopList'
import { tbShopPurveyorGet, tbProductStockOperateOutAndOn } from '@/api/invoicing'
export default {
components: {

View File

@@ -140,7 +140,7 @@
<script>
import dayjs from 'dayjs'
import shopList from '@/components/shopList'
import shopList from './components/shopList'
import { tbShopPurveyorGet, tbProductStockOperateOutAndOn } from '@/api/invoicing'
export default {
components: {

View File

@@ -18,7 +18,7 @@
</el-table-column>
<el-table-column label="操作" width="240">
<template v-slot="scope">
<el-button type="text" icon="el-icon-rank">排序</el-button>
<el-button type="text" icon="el-icon-rank" v-if="isPcBowser">排序</el-button>
<el-button type="text" size="mini" round icon="el-icon-edit" @click="$refs.addGroupRef.show(scope.row)"
style="margin-left: 20px !important;">编辑</el-button>
<el-popconfirm title="确定删除吗?" @confirm="delHandle([scope.row.id])">
@@ -56,9 +56,11 @@ export default {
},
mounted() {
this.getTableData()
this.$nextTick(() => {
this.tableDrag()
})
if (this.isPcBowser) {
this.$nextTick(() => {
this.tableDrag()
})
}
},
methods: {
//表格拖拽

View File

@@ -17,7 +17,7 @@
</el-select>
</el-col>
<el-col :span="6">
<el-button type="primary" @click="getTableData">查询</el-button>
<el-button type="primary" @click="queryHandle">查询</el-button>
<el-button @click="resetHandle">重置</el-button>
</el-col>
</el-row>
@@ -80,7 +80,7 @@
</el-table-column>
<el-table-column label="操作" width="200">
<template v-slot="scope">
<el-button type="text" icon="el-icon-rank">排序</el-button>
<el-button type="text" icon="el-icon-rank" v-if="isPcBowser">排序</el-button>
<router-link :to="{ path: '/product/add_shop', query: { goods_id: scope.row.id } }"
style="margin-left: 20px !important;">
<el-button type="text" icon="el-icon-edit">编辑</el-button>
@@ -125,14 +125,21 @@ export default {
}
}
},
mounted() {
this.getTableData()
this.tbShopCategoryGet()
this.$nextTick(() => {
this.tableDrag()
})
async mounted() {
await this.tbShopCategoryGet()
await this.getTableData()
if (this.isPcBowser) {
this.$nextTick(() => {
this.tableDrag()
})
}
},
methods: {
// 选择分类
queryHandle() {
localStorage.setItem('shopIndexQuery', JSON.stringify(this.query))
this.getTableData()
},
//表格拖拽
tableDrag() {
const el = document.querySelector('#table_drag .el-table__body-wrapper tbody')
@@ -177,6 +184,7 @@ export default {
this.query.categoryId = ''
this.query.typeEnum = ''
this.tableData.page = 0
localStorage.setItem('shopIndexQuery', JSON.stringify(this.query))
this.getTableData()
},
// 分页回调
@@ -186,8 +194,13 @@ export default {
},
// 获取商品列表
async getTableData() {
this.tableData.loading = true
try {
let localQuery = JSON.parse(localStorage.getItem('shopIndexQuery'))
if (localQuery != null) {
this.query = localQuery
}
this.tableData.loading = true
const res = await tbProduct({
page: this.tableData.page,
size: this.tableData.size,