370 lines
11 KiB
Vue
Raw Normal View History

2022-08-02 10:16:07 +08:00
<template>
<!-- 商品管理页面 -->
<div>
2022-08-06 20:03:35 +08:00
<!-- 条件筛选板块 -->
2022-08-02 10:16:07 +08:00
<el-card class="box-card">
2022-08-06 20:03:35 +08:00
<div class="goods" style="margin: 20px">
<el-form ref="form" :inline="true" :model="form">
2022-08-02 10:16:07 +08:00
<el-form-item label="商品名称:">
2022-08-06 20:03:35 +08:00
<el-input v-model="form.goods_title" placeholder="商品名称">
2022-08-04 18:59:32 +08:00
</el-input>
2022-08-02 10:16:07 +08:00
</el-form-item>
<el-form-item label="商品种类:">
2022-08-06 20:03:35 +08:00
<el-select v-model="form.type_id" placeholder="商品种类">
<el-option
v-for="item in cate"
:key="item.id"
:label="item.name"
:value="item.id"
>
2022-08-02 10:16:07 +08:00
</el-option>
</el-select>
</el-form-item>
<el-form-item label="商品规格:">
2022-08-06 20:03:35 +08:00
<el-input v-model="form.sku_title" placeholder="商品规格">
2022-08-04 18:59:32 +08:00
</el-input>
2022-08-02 10:16:07 +08:00
</el-form-item>
<el-form-item label="商品品牌:">
2022-08-06 20:03:35 +08:00
<el-select v-model="form.brand_id" placeholder="商品品牌">
<el-option
v-for="item in brand"
:key="item.id"
:label="item.name"
:value="item.id"
>
2022-08-02 10:16:07 +08:00
</el-option>
</el-select>
</el-form-item>
2022-08-04 18:59:32 +08:00
<el-form-item label="商品库存:">
2022-08-06 20:03:35 +08:00
<el-input v-model="form.keyword_type" placeholder="商品库存">
2022-08-04 18:59:32 +08:00
</el-input>
</el-form-item>
2022-08-02 10:16:07 +08:00
<el-form-item label="商品状态:">
2022-08-06 20:03:35 +08:00
<el-select v-model="form.status" placeholder="商品状态">
<el-option
v-for="item in options"
:key="item.id"
:label="item.label"
:value="item.id"
>
2022-08-02 10:16:07 +08:00
</el-option>
</el-select>
</el-form-item>
<el-form-item label="创建时间:">
2022-08-06 20:03:35 +08:00
<el-date-picker
v-model="timer"
type="datetimerange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
align="right"
value-format="yyyy-MM-DD hh:mm:ss"
>
2022-08-02 10:16:07 +08:00
</el-date-picker>
</el-form-item>
<el-form-item>
2022-08-06 20:03:35 +08:00
<el-button type="primary" @click="handleChoose">筛选</el-button>
<el-button plain @click="handleReChoose">重置筛选</el-button>
2022-08-02 10:16:07 +08:00
</el-form-item>
</el-form>
</div>
</el-card>
2022-08-06 20:03:35 +08:00
<el-card class="box-card1" style="margin-top: 30px">
2022-08-02 10:16:07 +08:00
<div>
<!-- 表格头部操作 -->
<div>
2022-08-06 20:03:35 +08:00
<span> 全部商品({{ total }}) </span>
2022-08-02 10:16:07 +08:00
<div class="btn">
2022-08-06 20:03:35 +08:00
<el-button type="primary" plain @click="addNewgoods"
>新建商品</el-button
>
<el-button type="primary" @click="update()" plain>上新</el-button>
<el-button type="primary" plain>库存盘点</el-button>
<el-button type="primary" plain @click="handleImport"
>导入商品</el-button
>
<el-button type="primary" plain @click="handleExport"
>表格导出</el-button
>
2022-08-02 10:16:07 +08:00
</div>
</div>
2022-08-06 20:03:35 +08:00
2022-08-02 10:16:07 +08:00
<!-- 表格 -->
2022-08-06 20:03:35 +08:00
<el-table
ref="multipleTable"
:data="tableData"
class="table"
tooltip-effect="dark"
style="width: 100%"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55"> </el-table-column>
2022-08-02 10:16:07 +08:00
<el-table-column label="商品信息">
2022-08-04 18:59:32 +08:00
<template slot-scope="scope">
2022-08-06 20:03:35 +08:00
<div>{{ scope.row.goods.img_url }}</div>
<div>{{ scope.row.goods.title }}</div>
2022-08-04 18:59:32 +08:00
</template>
2022-08-02 10:16:07 +08:00
</el-table-column>
2022-08-04 18:59:32 +08:00
<el-table-column label="品类">
<template slot-scope="scope">
2022-08-06 20:03:35 +08:00
<div>
{{ scope.row.goods.type ? scope.row.goods.type.name : "" }}
</div>
2022-08-04 18:59:32 +08:00
</template>
2022-08-02 10:16:07 +08:00
</el-table-column>
2022-08-06 20:03:35 +08:00
<el-table-column label="规格" prop="title"> </el-table-column>
2022-08-04 18:59:32 +08:00
<el-table-column label="品牌">
<template slot-scope="scope">
2022-08-06 20:03:35 +08:00
<div>
{{ scope.row.goods.brand ? scope.row.goods.brand.name : "" }}
</div>
2022-08-04 18:59:32 +08:00
</template>
2022-08-02 10:16:07 +08:00
</el-table-column>
2022-08-06 20:03:35 +08:00
<el-table-column prop="two_days_ago_num" sortable label="2天前库存">
2022-08-02 10:16:07 +08:00
</el-table-column>
2022-08-06 20:03:35 +08:00
<el-table-column prop="yesterday_num" sortable label="1天前库存">
2022-08-02 10:16:07 +08:00
</el-table-column>
2022-08-06 20:03:35 +08:00
<el-table-column sortable label="今日到货">
2022-08-04 18:59:32 +08:00
<template slot-scope="scope">
<div>
<div v-if="true">
<el-input v-model="input"></el-input>
</div>
2022-08-06 20:03:35 +08:00
<div>
{{
scope.row.daily != null
? scope.row.daily.arrived_today_num
: 0
}}
</div>
2022-08-02 10:16:07 +08:00
</div>
</template>
</el-table-column>
2022-08-06 20:03:35 +08:00
<el-table-column prop="cost" sortable label="成本">
2022-08-02 10:16:07 +08:00
<template>
<div v-if="isShow">
<el-input v-model="input"></el-input>
</div>
</template>
</el-table-column>
2022-08-06 20:03:35 +08:00
<el-table-column prop="reference_price" sortable label="参考售价">
2022-08-02 10:16:07 +08:00
</el-table-column>
2022-08-06 20:03:35 +08:00
<el-table-column prop="num" sortable label="总量"> </el-table-column>
<el-table-column prop="reserve" sortable label="预留量">
2022-08-02 10:16:07 +08:00
</el-table-column>
2022-08-06 20:03:35 +08:00
<el-table-column prop="name" sortable label="店铺订单">
2022-08-02 10:16:07 +08:00
</el-table-column>
2022-08-06 20:03:35 +08:00
<el-table-column sortable label="损耗">
2022-08-04 18:59:32 +08:00
<template slot-scope="scope">
2022-08-06 20:03:35 +08:00
<el-popover width="200" placement="right" trigger="hover">
2022-08-04 18:59:32 +08:00
<div class="detail">
<span>损耗</span>
<el-input></el-input>
</div>
2022-08-02 10:16:07 +08:00
<el-radio-group v-model="radio">
2022-08-04 18:59:32 +08:00
<el-radio :label="3">48h以上</el-radio>
<el-radio :label="6">到货错误</el-radio>
<el-radio :label="9">灰霉</el-radio>
<el-radio :label="2">长度</el-radio>
<el-radio :label="4">花朵</el-radio>
<el-radio :label="5">其他</el-radio>
2022-08-02 10:16:07 +08:00
</el-radio-group>
2022-08-04 18:59:32 +08:00
<div class="list_btn">
<el-button type="primary">保存</el-button>
<el-button>取消</el-button>
</div>
2022-08-06 20:03:35 +08:00
<div class="loss" slot="reference">
{{ scope.row.daily ? scope.row.daily.arrived_loss_num : 0 }}
</div>
2022-08-04 18:59:32 +08:00
</el-popover>
2022-08-02 10:16:07 +08:00
</template>
</el-table-column>
2022-08-06 20:03:35 +08:00
<el-table-column prop="stock" sortable label="库存">
2022-08-02 10:16:07 +08:00
</el-table-column>
2022-08-06 20:03:35 +08:00
<el-table-column prop="address" sortable label="库存盘点">
2022-08-04 18:59:32 +08:00
<template slot-scope="scope">
2022-08-06 20:03:35 +08:00
<div>{{ scope.row.daily ? scope.row.daily.inventory : 0 }}</div>
2022-08-04 18:59:32 +08:00
</template>
2022-08-02 10:16:07 +08:00
</el-table-column>
2022-08-06 20:03:35 +08:00
<el-table-column prop="status" label="状态"> </el-table-column>
2022-08-02 10:16:07 +08:00
<el-table-column label="操作">
2022-08-04 18:59:32 +08:00
<template slot-scope="scope">
2022-08-02 10:16:07 +08:00
<div>
2022-08-04 18:59:32 +08:00
<el-button type="text">库存</el-button>
2022-08-02 10:16:07 +08:00
</div>
<div>
2022-08-06 20:03:35 +08:00
<el-button type="text" @click="handleEdit(scope.row.id)"
>编辑</el-button
>
2022-08-02 10:16:07 +08:00
</div>
<div>
<el-button type="text">记录</el-button>
</div>
</template>
</el-table-column>
</el-table>
</div>
<el-button type="primary">确定</el-button>
</el-card>
</div>
</template>
<script>
2022-08-06 20:03:35 +08:00
import axios from "axios";
import { goods } from "../../api/goods";
import { goods_types, Brand_goods_types } from "../../api/rankingData.js";
2022-08-02 10:16:07 +08:00
export default {
data() {
return {
2022-08-04 18:59:32 +08:00
total: 0, // 总条数
2022-08-06 20:03:35 +08:00
timer: "", // 筛选的时间
radio: "", // 损耗选择的原因
2022-08-04 18:59:32 +08:00
brand: [], // 品牌列表
cate: [], // 种类列表
2022-08-02 10:16:07 +08:00
isShow: false, // 点击上新显示输入框
2022-08-04 18:59:32 +08:00
tableData: [], // 商品列表
2022-08-02 10:16:07 +08:00
options: [
{
2022-08-06 20:03:35 +08:00
id: "1",
label: "在售",
2022-08-02 10:16:07 +08:00
},
{
2022-08-06 20:03:35 +08:00
id: "2",
label: "预警",
2022-08-02 10:16:07 +08:00
},
{
2022-08-06 20:03:35 +08:00
id: "0",
label: "下架",
2022-08-02 10:16:07 +08:00
},
2022-08-06 20:03:35 +08:00
], // 商品状态
2022-08-04 18:59:32 +08:00
// 请求商品列表的参数
2022-08-02 10:16:07 +08:00
form: {
2022-08-06 20:03:35 +08:00
goods_title: "", // 商品名称
type_id: "", // 商品种类id
brand_id: "", // 商品品牌id
sku_title: "", // 商品规格
status: "", // 商品状态
keyword_type: "", // 库存
keyword_value: "",
2022-08-04 18:59:32 +08:00
page: 1,
per_page: 5,
2022-08-02 10:16:07 +08:00
},
2022-08-06 20:03:35 +08:00
input: "",
value1: "",
};
2022-08-02 10:16:07 +08:00
},
methods: {
2022-08-06 20:03:35 +08:00
list() {
axios.get("/api/goods").then((res) => {
console.log("我是商品", res);
});
},
2022-08-04 18:59:32 +08:00
// 列表编辑
handleEdit(id) {
2022-08-06 20:03:35 +08:00
this.$router.push("/addgoods?id=" + id);
2022-08-04 18:59:32 +08:00
},
// 获取商品列表
getList() {
2022-08-06 20:03:35 +08:00
this.form.keyword_value = this.timer[0] + "-" + this.timer[1];
const forms = { ...this.form };
// console.log(forms, 'opopo')
2022-08-04 18:59:32 +08:00
goods(forms).then((res) => {
2022-08-06 20:03:35 +08:00
console.log(res);
this.tableData = res.data.data;
// console.log(res, 111)
2022-08-04 18:59:32 +08:00
// console.log(this.tableData, 'ppp')
2022-08-06 20:03:35 +08:00
});
2022-08-04 18:59:32 +08:00
},
// 筛选
handleChoose() {
2022-08-06 20:03:35 +08:00
this.getList();
2022-08-04 18:59:32 +08:00
},
// 分页-当前页改变
handleCurrentChange(e) {
2022-08-06 20:03:35 +08:00
this.form.page = e;
this.handleChoose();
2022-08-04 18:59:32 +08:00
},
// 分页
handleSizeChange(e) {
2022-08-06 20:03:35 +08:00
this.form.per_page = e;
this.getList();
2022-08-04 18:59:32 +08:00
},
// 重置筛选
handleReChoose() {
this.form = {
2022-08-06 20:03:35 +08:00
goods_title: "", // 商品名称
type_id: "", // 商品种类id
brand_id: "", // 商品品牌id
sku_title: "", // 商品规格
status: "", // 商品状态
keyword_type: "",
};
this.timer = "";
2022-08-04 18:59:32 +08:00
},
// 导入商品
handleImport() {},
// 导出商品
handleExport() {},
2022-08-06 20:03:35 +08:00
2022-08-02 10:16:07 +08:00
// 点击上新
update() {
2022-08-06 20:03:35 +08:00
this.isShow = true;
console.log(this.isShow, 8888);
2022-08-02 10:16:07 +08:00
},
// 复选框按钮
handleSelectionChange(val) {
2022-08-06 20:03:35 +08:00
console.log(val);
this.multipleSelection = val;
2022-08-02 10:16:07 +08:00
},
2022-08-06 20:03:35 +08:00
// 新增商品跳转
2022-08-02 10:16:07 +08:00
addNewgoods() {
2022-08-06 20:03:35 +08:00
this.$router.push("/index/yingyeting/addgoods");
2022-08-02 10:16:07 +08:00
},
},
2022-08-04 18:59:32 +08:00
mounted() {
// 获取商品种类
goods_types().then((res) => {
2022-08-06 20:03:35 +08:00
this.cate = res.data.data;
});
2022-08-04 18:59:32 +08:00
// 获取商品品牌
Brand_goods_types().then((res) => {
2022-08-06 20:03:35 +08:00
this.brand = res.data.data;
});
2022-08-04 18:59:32 +08:00
// 获取商品列表
2022-08-06 20:03:35 +08:00
this.getList();
2022-08-02 10:16:07 +08:00
},
2022-08-06 20:03:35 +08:00
};
2022-08-02 10:16:07 +08:00
</script>
<style lang="css" scoped>
.loss {
position: relative;
}
2022-08-04 18:59:32 +08:00
/deep/ .detail .el-button,
/deep/ .detail .el-button--primary {
width: 20px;
height: 20px;
line-height: 5px;
}
/deep/ .detail .el-input,
/deep/ .detail .el-input__inner {
width: 20px;
height: 20px;
2022-08-02 10:16:07 +08:00
}
2022-08-04 18:59:32 +08:00
2022-08-02 10:16:07 +08:00
.goods {
}
.table {
margin-top: 40px;
}
.btn {
float: right;
}
</style>