商品管理系统 - 库存管理
<div id="app" @mousemove="handleMouseMove">
<el-form :inline="true" :model="formInline" class="demo-form-inline">
<el-form-item label="查询分店">
<el-select v-model="formInline.branchname" placeholder="请选择分店">
<el-option :key="get.branchname" :label="get.branchname" :value="get.branchname" v-for="get in getname">
{{get.branchname}}
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit(row)">查询</el-button>
</el-form-item>
</el-form>
<pre><code><template>
<el-button type="primary" @click="refresh">刷新</el-button>
<el-table
:data="tableData"
border
style="width: 100%">
<el-table-column
prop="goodsid"
label="商品编号"
width="50">
</el-table-column>
<el-table-column
label="图片"
width="100">
<template slot-scope="scope">
<img :src="scope.row.url" alt="商品图片" style="width: 100px; height: 50px;"
@click="showImage(scope.row.url)">
</template>
</el-table-column>
<el-table-column
prop="goodsname"
label="商品名称"
width="130">
</el-table-column>
<el-table-column
prop="layout"
label="键盘布局"
width="80">
</el-table-column>
<el-table-column
prop="keycapname"
label="键帽材质"
width="110">
</el-table-column>
<el-table-column
prop="keyboardcolorname"
label="键盘颜色"
width="80">
</el-table-column>
<el-table-column
prop="shaftchoose"
label="轴体颜色"
width="80">
</el-table-column>
<el-table-column
prop="interfacetype"
label="接口信息"
width="100">
</el-table-column>
<el-table-column
prop="cprice"
label="商品进价"
width="80">
</el-table-column>
<el-table-column
prop="sprice"
label="商品出价"
width="80">
</el-table-column>
<el-table-column
prop="branchname"
label="所属分店"
width="150">
</el-table-column>
<el-table-column
prop="branchid"
label="分店编号"
width="100"
v-if="false">
</el-table-column>
<el-table-column
prop="counts"
label="商品数量"
width="100">
</el-table-column>
<el-table-column
label="出库数量"
width="100px">
<input type="text" style="width: 70px;height: 30px;margin: 0;border: 0px"
v-model="input">
</el-table-column>
<el-table-column label="操作" width="200px">
<template slot-scope="scope">
<el-button
:disabled="!isValidInput"
size="mini"
@click="handleEdit(scope.$index, scope.row)">零售
</el-button>
<el-button
size="mini"
@click="pingdiao(scope.$index, scope.row)">平调
</el-button>
</template>
</el-table-column>
</el-table>
</template>
<div class="block">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page.sync="pagenum"
:page-sizes="[5,10,20,50]"
:page-size="5"
layout="total, sizes, prev, pager, next, jumper"
:total="k">
</el-pagination>
</div>
<el-dialog title="平调" :visible.sync="dialogFormVisible">
<el-form :model="form">
<el-form-item label="选择平调仓库" :label-width="formLabelWidth">
<el-select v-model="from1.branchname" placeholder="请选择活动区域">
<el-option :label="name.branchname" :value="name.branchname" v-for="name in getname">
{{name.branchname}}
</el-option>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">取 消</el-button>
<el-button type="primary" @click="pingdia">确 定</el-button>
</div>
</el-dialog>
<!--图片放大-->
<el-dialog :visible.sync="dialogVisible" width="80%">
<img :src="selectedImageUrl" alt="放大图片" style="width: 100%;">
</el-dialog>
</code></pre>
</div>
<script type="module">
const instance = axios.create({
baseURL: 'http://localhost:8080',
timeout: 1000,
})
<pre><code>new Vue({
el: '#app',
dataType: 'json',
data: {
isValidInput: false,
name: '',
dialogVisible: false,
selectedImageUrl: '',
from1: {
branchname: ''
},
dialogFormVisible: false,
num: '',
total: '',
pagenum: 1,
index: 1,
size: 5,
yc: true,
input: '',
getname: [],
formInline: {
branchname: ''
},
coun: '',
k: 0,
from: [],
branchname: '',
tableData: [],
dialogFormVisible: false,
title: '添加部门',
show: false,
form: {
branchname: ''
},
formLabelWidth: '120px'
},
methods: {
handleMouseMove(){
if (this.input!=''){
this.isValidInput = true
}else {
this.isValidInput=false
}
},
showImage(url) {
this.selectedImageUrl = url;
this.dialogVisible = true;
},
/*点击平调获取参数*/
pingdiao(index, row) {
if (this.input==''||this.input.length==0){
this.$message({
showClose: true,
message: '格式错误',
type: 'warning'
});
return;
}else {
if (row.counts >= this.input & this.input != 0) {
console.log(row.branchname)
if (this.name != row.branchname) {
this.$message({
showClose: true,
message: '您不是本店员工,无法进行操作',
type: 'warning'
});
return;
}
if (this.input <= 5) {
this.$message({
showClose: true,
message: '平调数量不能小于5',
type: 'warning'
});
return
}
this.dialogFormVisible = true
this.coun = row.counts
this.num = this.input
this.total = row.sprice * this.input
row.counts = row.counts - this.input;
var a = row.counts;
this.from = {
count: a,
goodsid: row.goodsid,
branchid: row.branchid,
num: this.num,
total: this.total,
branchname: '',
coun: this.coun
}
this.input = ''
}
}
},
/*点击平调确认向后端传参*/
pingdia() {
this.from.branchname = this.from1.branchname
instance.put(`/goods?count=${this.from.count}&goodsid=${this.from.goodsid}&branchid=${this.from.branchid}`).then(res => {
if (res.data.code == 0) {
instance.get("/goods")
.then(function (res) {
this.tableData = res.data.data.list;
this.k = res.data.data.total
})
this.input = ''
instance.post(`/goods/post2`, this.from).then(res => {
})
instance.put(`/outfers/shu?coun=${this.from.coun}&goodsid=${this.from.goodsid}&branchid=${this.from.branchid}`).then(res => {
})
this.input = ''
this.dialogFormVisible = false
this.handleCurrentChange(this.index)
}
})
},
/*刷新到第一页*/
refresh() {
this.handleCurrentChange(1)
},
/*零售*/
handleEdit: function (index, row) {
if (this.input==''||this.input.length==0){
this.$message({
showClose: true,
message: '格式错误',
type: 'warning'
});
return;
}else {
if (row.counts >= this.input & this.input != 0) {
if (this.name != row.branchname) {
this.$message({
showClose: true,
message: '您不是本店员工,无法进行操作',
type: 'warning'
});
return;
}
if (this.input > 5) {
this.$message({
showClose: true,
message: '零售数量不能大于5',
type: 'warning'
});
return
}
this.coun = row.counts
this.num = this.input
this.total = row.sprice * this.input
row.counts = row.counts - this.input;
var a = row.counts;
instance.put(`/goods?count=${a}&goodsid=${row.goodsid}&branchid=${row.branchid}`).then(res => {
if (res.data.code == 0) {
instance.get("/goods")
.then(function (res) {
this.tableData = res.data.data.list;
this.k = res.data.data.total
})
this.input = ''
instance.post(`/goods/post?branchid=${row.branchid}&goodsid=${row.goodsid}&num=${this.num}&total=${this.total}`).then(res => {
})
instance.put(`/outfers/shu?coun=${this.coun}&goodsid=${row.goodsid}&branchid=${row.branchid}`).then(res => {
})
}
})
this.handleCurrentChange(this.index)
this.input = ''
}
}
},
/*查询*/
onSubmit(row) {
this.handleCurrentChange(1)
},
/*分页*/
handleSizeChange(val) {
this.size = val
this.pages()
/* instance.get(`/goods?size=${this.size}&index=${this.index}`, {params: this.formInline}).then(res => {
this.tableData = res.data.data.list;
this.pagenum = res.data.data.pageNum
this.k = res.data.data.total
})*/
},
/*分页*/
handleCurrentChange(val) {
this.index = val
this.pages()
/* instance.get(`/goods?index=${val}`, {params: this.formInline}).then(res => {
this.tableData = res.data.data.list;
this.pagenum = res.data.data.pageNum
this.k = res.data.data.total
})*/
},
pages() {
instance.get(`/goods?size=${this.size}&index=${this.index}`, {params: this.formInline}).then(res => {
this.tableData = res.data.data.list;
this.pagenum = res.data.data.pageNum
this.k = res.data.data.total
})
}
},
created() {
var jl = this;
instance.get("/logincontroller/getStaff")
.then(res => {
console.log(res.data.data)
jl.name = res.data.data.branchname; // 将获取到的员工姓名赋值给name变量
});
instance.get("/goods")
.then(function (res) {
jl.tableData = res.data.data.list;
jl.k = res.data.data.total
})
.catch(function (res) {
console.log(res);
});
/*获取店铺名称*/
instance.get("/goods/getname")
.then(function (res) {
jl.getname = res.data.data;
})
},
watch: {
input: function (newVal) {
this.isValidInput = newVal !== null;
}
}
});
</code></pre>
</script>
原文地址: https://www.cveoy.top/t/topic/pe31 著作权归作者所有。请勿转载和采集!