Commit 9802d88b authored by mengwenhao's avatar mengwenhao

feature goods_list already

parent 3687101c
const GOODS_URI = require("../config.js").GOODS_URI; const GOODS_URI = require("../config.js").GOODS_URI;
const req = require("../utils/request").httpReq; const req = require("../utils/request").httpReq;
/** /**
* 示例 * 示例
* exports.方法名 = async ctx => { * exports.方法名 = async ctx => {
* const url = `${设置好的域名}/向服务端发送的请求地址`; * const url = `${设置好的域名}/向服务端发送的请求地址`;
...@@ -18,9 +18,19 @@ const req = require("../utils/request").httpReq; ...@@ -18,9 +18,19 @@ const req = require("../utils/request").httpReq;
exports.getCategoryList = async ctx => { exports.getCategoryList = async ctx => {
const url = `${GOODS_URI}/goods/background/get_goods_category_list`; const url = `${GOODS_URI}/goods/background/get_goods_category_list`;
const opts = {
url,
method: "GET"
};
ctx.body = await req(ctx, opts);
};
exports.getList = async ctx => {
const url = `${GOODS_URI}/goods/background/get_goods_list`;
const opts = { const opts = {
url, url,
method: "GET", method: "GET",
qs: ctx.request.query
}; };
ctx.body = await req(ctx, opts); ctx.body = await req(ctx, opts);
}; };
...@@ -38,7 +38,8 @@ router.post(`${API_VERSION}/op_commit`, enterprise.opCommit); ...@@ -38,7 +38,8 @@ router.post(`${API_VERSION}/op_commit`, enterprise.opCommit);
router.post(`${API_VERSION}/op_business_update`, enterprise.opBusinessUpdate); router.post(`${API_VERSION}/op_business_update`, enterprise.opBusinessUpdate);
/* 商品管理 */ /* 商品管理 */
router.get(`${API_VERSION}/get_goods_category_list`, goods.getCategoryList) router.get(`${API_VERSION}/get_goods_category_list`, goods.getCategoryList);
router.get(`${API_VERSION}/getGoodsList`, goods.getList);
//生活号 //生活号
router.post(`${API_VERSION}/merchant/lifeinner/life_info`, life.get_life_info) router.post(`${API_VERSION}/merchant/lifeinner/life_info`, life.get_life_info)
......
.list {
margin-top: 30px;
}
.list .goods {
margin-top: 30px;
padding: 0 30px;
}
.list .goods .search_condition {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
align-items: center;
}
.list .goods .search_condition .search_button {
display: flex;
align-items: center;
justify-self: flex-end;
}
.list .goods .search_condition .search_button .el-form-item__content {
display: flex;
justify-content: space-around;
}
.list .goods .commodity_list {
margin-top: 30px;
}
.list .goods .pagination {
margin-top: 30px;
}
.list { .list {
margin-top: 30px; margin-top: 30px;
.commodity { .goods {
margin-top: 30px; margin-top: 30px;
padding: 0 30px; padding: 0 30px;
.search_condition { .search_condition {
display: flex; display: flex;
justify-content: flex-start; justify-content: space-between;
flex-wrap: wrap; flex-wrap: wrap;
align-items: center; align-items: center;
.search_button { .search_button {
display: flex; display: flex;
align-items: center; align-items: center;
justify-self: flex-end;
.el-form-item__content { .el-form-item__content {
display: flex; display: flex;
justify-content: space-around; justify-content: space-around;
......
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
> >
<!-- 商品id --> <!-- 商品id -->
<el-form-item label="商品id"> <el-form-item label="商品id">
<el-input></el-input> <el-input v-model="searchProps.goods_spu_id"></el-input>
</el-form-item> </el-form-item>
<!-- 商品名称 --> <!-- 商品名称 -->
<el-form-item label="商品名称"> <el-form-item label="商品名称">
<el-input></el-input> <el-input v-model="searchProps.name"></el-input>
</el-form-item> </el-form-item>
<!-- 所属分类 --> <!-- 所属分类 -->
<el-form-item label="所属分类"> <el-form-item label="所属分类">
...@@ -26,21 +26,37 @@ ...@@ -26,21 +26,37 @@
</el-form-item> </el-form-item>
<!-- 生活号ID --> <!-- 生活号ID -->
<el-form-item label="生活号id"> <el-form-item label="生活号id">
<el-input></el-input> <el-input v-model="searchProps.life_account_id"></el-input>
</el-form-item> </el-form-item>
<!-- 生活号名称 --> <!-- 生活号名称 -->
<el-form-item label="生活号名称"> <el-form-item label="生活号名称">
<el-input></el-input> <el-input v-model="searchProps.life_account_name"></el-input>
</el-form-item> </el-form-item>
<!-- 商品状态 --> <!-- 商品状态 -->
<el-form-item label="商品状态"> <el-form-item label="商品状态">
<el-select <el-select
v-model="stateValue" v-model="status"
multiple multiple
collapse-tags collapse-tags
@change="handleStatusChange"
> >
<el-option <el-option
v-for="item in option" v-for="item in stateOption"
:key="item.value"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="上架状态">
<el-select
v-model="onlineStatus"
multiple
collapse-tags
@change="handleOnlineStatusChange"
>
<el-option
v-for="item in onlineStateOptions"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:value="item.value" :value="item.value"
...@@ -48,7 +64,7 @@ ...@@ -48,7 +64,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- 按钮操作 --> <!-- 按钮操作 -->
<el-form-item class="search_button"> <el-form-item style="justify-self: flex-end;">
<el-button type="primary">搜索</el-button> <el-button type="primary">搜索</el-button>
<el-button>重置</el-button> <el-button>重置</el-button>
</el-form-item> </el-form-item>
...@@ -174,8 +190,8 @@ ...@@ -174,8 +190,8 @@
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
v-model:currentPage="currentPage" v-model:currentPage="currentPage"
:page-size="100" :page-size="100"
layout="prev, pager, next, jumper" layout="total,prev, pager, next, jumper"
:total="1000" :total="totalCount"
> >
</el-pagination> </el-pagination>
</el-card> </el-card>
...@@ -185,95 +201,60 @@ ...@@ -185,95 +201,60 @@
<style lang="less" src="./index.less" scope></style> <style lang="less" src="./index.less" scope></style>
<script> <script>
import { getGoodsList } from "@/service/Goods/goods"; import { getGoodsList, getList } from "@/service/Goods/goods";
export default { export default {
name: "GoodsList", name: "GoodsList",
created () { created () {
// 获取级联选择 // 获取级联选择
this.getOptionList(); this.getOptionList();
// 获取商品列表
this.getCommodityList();
}, },
data () { data () {
return { return {
// 级联选择器参数
cascaderProps: { cascaderProps: {
multiple: true, multiple: true, // 是否支持多选
value: "category_id", value: "category_id", // 每一项选择的值
label: "name", label: "name", // 每一项的名称
children: "sub_list" children: "sub_list" // 每一项子集的对应节点
}, },
// 查询参数 // 查询参数
searchProps: { searchProps: {
page: 1, // 页码
page_size: 20, // 页数大小
goods_spu_id: "", // 后台商品id
name: "", // 商品名称
category_1_id: "", // 一级分类id category_1_id: "", // 一级分类id
category_2_id: "" // 二级分类id category_2_id: "", // 二级分类id
life_account_id: 0,
life_account_name: "",
status: "", // 商品状态
online_status: "" // 上架状态
}, },
// 级联选择器 // 级联选择器
labelOptions: [ labelOptions: [],
{
value: 1, // 商品状态
label: "东南", stateOption: [
children: [ { value: 0, label: "待审核" },
{ { value: 1, label: "审核通过" },
value: 2, { value: 2, label: "审核驳回" }
label: "上海",
children: [
{ value: 3, label: "普陀" },
{ value: 4, label: "黄埔" },
{ value: 5, label: "徐汇" }
]
},
{
value: 7,
label: "江苏",
children: [
{ value: 8, label: "南京" },
{ value: 9, label: "苏州" },
{ value: 10, label: "无锡" }
]
},
{
value: 12,
label: "浙江",
children: [
{ value: 13, label: "杭州" },
{ value: 14, label: "宁波" },
{ value: 15, label: "嘉兴" }
]
}
]
},
{
value: 17,
label: "西北",
children: [
{
value: 18,
label: "陕西",
children: [
{ value: 19, label: "西安" },
{ value: 20, label: "延安" }
]
},
{
value: 21,
label: "新疆维吾尔族自治区",
children: [
{ value: 22, label: "乌鲁木齐" },
{ value: 23, label: "克拉玛依" }
]
}
]
}
], ],
option: [ // 上下架状态
{ value: 1, label: "待审核" }, onlineStateOptions: [
{ value: 2, label: "审核通过" }, { value: 0, label: "未上架" },
{ value: 3, label: "审核驳回" }, { value: 1, label: "已上架" },
{ value: 4, label: "已上架" }, { value: 2, label: "已下架" }
{ value: 5, label: "已下架" }
], ],
// 商品状态
stateValue: [], status: [],
onlineStatus: [],
// 商品列表 // 商品列表
goodsList: [ goodsList: [
{ {
...@@ -294,38 +275,64 @@ export default { ...@@ -294,38 +275,64 @@ export default {
goods_create_time: "2021-06-17" goods_create_time: "2021-06-17"
} }
], ],
currentPage: 1 // 当前页码
currentPage: 1, // 当前页码
totalCount: 0 // 总条数
}; };
}, },
methods: { methods: {
handleChange (val) {
const every1Val = val.map(item => {
return item[0];
});
const every2Val = val.map(item => {
return item[1];
});
this.searchProps.category_1_id = every1Val.join();
this.searchProps.category_2_id = every2Val.join();
},
// 获取级联选择 // 获取级联选择
async getOptionList () { async getOptionList () {
try { try {
const res = await getGoodsList(); const res = await getGoodsList();
if (res.code !== 0) { if (res.code !== 0) return this.$message.error(res.reason);
return this.$message.error(res.reason); this.labelOptions = res.result;
} else {
this.labelOptions = res.result;
}
console.log(res); console.log(res);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }
}, },
// 获取列表信息
getList () { // 获取列表
console.log("我是准备获取信息的!!!"); async getCommodityList () {
try {
const res = await getList(this.searchProps);
if (res.code !== 0) return this.$message.error(res.reason);
this.goodsList = res.result.list;
this.totalCount = res.result.count
} catch (error) {
console.error(error);
}
},
getVal (value, index = 0) {
const valueArray = value.map(item => {
return item[index];
});
return valueArray.join();
},
getValue (value) {
const values = value.map(item => {
return item;
});
return values.join();
},
// 所属分类赋值
handleChange (val) {
this.searchProps.category_1_id = this.getVal(val, 0);
this.searchProps.category_2_id = this.getVal(val, 1);
},
// 商品状态赋值
handleStatusChange (val) {
this.searchProps.status = this.getValue(val);
},
// 上架状态赋值
handleOnlineStatusChange (val) {
this.searchProps.online_status = this.getValue(val);
}, },
// 上架/下架操作 // 上架/下架操作
...@@ -337,7 +344,7 @@ export default { ...@@ -337,7 +344,7 @@ export default {
handleCurrentChange (e) { handleCurrentChange (e) {
this.currentPage = e; this.currentPage = e;
// 获取信息 // 获取信息
this.getList(); this.getCommodityList();
}, },
// 去往详情页 // 去往详情页
......
import axios from "@/utils/request"; import axios from "@/utils/request";
// 获取商品分类列表 // 获取商品分类
export async function getGoodsList () { export async function getGoodsList () {
const res = await axios.get("/api/v1/get_goods_category_list"); const res = await axios.get("/api/v1/get_goods_category_list");
return res; return res;
} }
// 获取商品列表
export async function getList (params) {
const res = await axios.get("/api/v1/getGoodsList", params);
return res;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment