优化商品查询方法
This commit is contained in:
@@ -81,3 +81,10 @@ export function getInfo(id) {
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function getStoreProductAndCart() {
|
||||
return request({
|
||||
url: '/bxg/api/yxStoreProductAndCart',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
<el-table-column prop="useMinPrice" label="优惠券最低消费" />
|
||||
<el-table-column label="优惠券开始时间">
|
||||
<template slot-scope="scope">
|
||||
{{ formatTimeTwo(scope.row.addTime) }}
|
||||
{{ formatTimeTwo(scope.row.useStartTime) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="优惠券结束时间">
|
||||
<template slot-scope="scope">
|
||||
{{ formatTimeTwo(scope.row.endTime) }}
|
||||
{{ formatTimeTwo(scope.row.useEndTime) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="获取方式">
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
@change="change"
|
||||
placeholder="选择商品"
|
||||
:options="cateList"
|
||||
:props="props"
|
||||
filterable>
|
||||
</el-cascader>
|
||||
</el-form-item>
|
||||
@@ -154,7 +155,7 @@ import pagination from '@crud/Pagination'
|
||||
import MaterialList from "@/components/material";
|
||||
import crudOperation from "@crud/CRUD.operation";
|
||||
import {initData} from "@/api/bxg/data";
|
||||
import {getInfo} from "@/api/bxg/yxStoreProduct";
|
||||
import {getInfo, getStoreProductAndCart} from "@/api/bxg/yxStoreProduct";
|
||||
|
||||
// crud交由presenter持有
|
||||
const defaultCrud = CRUD({ title: '榜单记录', url: 'bxg/api/yxStoreHotListRecord', sort: 'id,desc', crudMethod: { ...crudYxStoreHotListRecord }})
|
||||
@@ -179,7 +180,12 @@ export default {
|
||||
price: [{ required: true, message: "商品价格不能为空", trigger: "blur" }],
|
||||
hotSales: [{ required: true, message: "商品销量不能为空", trigger: "blur" }],
|
||||
mouth: [{ required: true, message: "参与月份不能为空", trigger: "blur" }],
|
||||
}
|
||||
},
|
||||
props:{
|
||||
value: 'id',
|
||||
label: 'storeName',
|
||||
children:'children',
|
||||
},
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
@@ -218,29 +224,10 @@ export default {
|
||||
that.hotList=data.content
|
||||
//若为编辑,应初始化一下品牌
|
||||
}),
|
||||
await getInfo(0).then( res => {
|
||||
//商品分类
|
||||
that.cateList = res.cateList
|
||||
})
|
||||
for (const item of that.cateList) {
|
||||
await initData('/bxg/api/yxStoreProduct', {
|
||||
page: 0,
|
||||
size: 999,
|
||||
sort: 'id,desc',
|
||||
cateId:item.value,
|
||||
}).then(data=>{
|
||||
data.content.forEach(ele=>{
|
||||
//不能直接使用ele,会有浅拷贝问题
|
||||
// let ele1=JSON.parse(JSON.stringify(ele))
|
||||
// that.$set(ele,'value',ele1)
|
||||
that.$set(ele,'value',ele.id)
|
||||
that.$set(ele,'label',ele.storeName)
|
||||
}
|
||||
)
|
||||
that.$set(item,'children',data.content)
|
||||
await getStoreProductAndCart().then(res=>{
|
||||
that.cateList=res;
|
||||
})
|
||||
}
|
||||
console.log(that.cateList,'that.cateList')
|
||||
// console.log(that.cateList,'that.cateList')
|
||||
},
|
||||
dataFilter(val){
|
||||
this.value=val
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="250px">
|
||||
<el-form-item label="关联商品:" prop="product">
|
||||
<el-cascader
|
||||
style="width:370px"
|
||||
ref="cascader"
|
||||
v-model="product"
|
||||
@change="change"
|
||||
:props="props"
|
||||
placeholder="试试搜索:眼镜"
|
||||
:options="cateList"
|
||||
filterable></el-cascader>
|
||||
@@ -125,6 +127,7 @@ import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import MaterialList from "@/components/material";
|
||||
import {getInfo} from "@/api/bxg/yxStoreProduct";
|
||||
import {getStoreProductAndCart} from "@/api/bxg/yxStoreProduct";
|
||||
import {initData} from "@/api/bxg/data";
|
||||
import FileUpload from "@comp/FileUpload";
|
||||
import VideoUpload from "@comp/VideoUpload";
|
||||
@@ -158,39 +161,11 @@ export default {
|
||||
product:[],
|
||||
//分类列表
|
||||
cateList:[],
|
||||
//懒加载暂无法回显,弃用
|
||||
// props:{
|
||||
// // emitPath:false,
|
||||
// lazy: true,
|
||||
// value: 'value',
|
||||
// label: 'label',
|
||||
// lazyLoad (node, resolve) {
|
||||
// console.log('node, resolve',node, resolve)
|
||||
// const { level,value } = node;
|
||||
// setTimeout(arrayLike => {
|
||||
// let productList=[]
|
||||
// initData('/bxg/api/yxStoreProduct', {
|
||||
// page: 0,
|
||||
// size: 999,
|
||||
// sort: 'id,desc',
|
||||
// cateId:value,
|
||||
// }).then(data => {
|
||||
// console.log('data', data);
|
||||
// //获取当前分类下的商品列表
|
||||
// productList = data.content
|
||||
// const nodes = Array.from(productList,item=>({
|
||||
// value:item,
|
||||
// label: item.storeName,
|
||||
// //判断是不是子节点
|
||||
// leaf: level >=1
|
||||
// }), {length: level + 1})
|
||||
// console.log('node, resolve',nodes)
|
||||
// // 通过调用resolve将子节点数据返回,通知组件数据加载完成
|
||||
// resolve(nodes);
|
||||
// })
|
||||
// }, 1000);
|
||||
// }
|
||||
// },
|
||||
props:{
|
||||
value: 'id',
|
||||
label: 'storeName',
|
||||
children:'children',
|
||||
},
|
||||
video:[],
|
||||
picArr:[],
|
||||
permission: {
|
||||
@@ -313,18 +288,6 @@ export default {
|
||||
handleClick(tab, event) {
|
||||
console.log(tab, event);
|
||||
},
|
||||
// // 根据id获取商品名,因为异步同步无法实现
|
||||
// getProductName(value){
|
||||
// console.log(value,'value')
|
||||
// //这里需要一个同步请求,才能获取商品名字
|
||||
// let product=''
|
||||
// initData('/bxg/api/yxStoreProduct/info/'+value).then((data)=>{
|
||||
// product= data.productInfo.store_name
|
||||
// }
|
||||
// )
|
||||
// console.log(product,product)
|
||||
// return product
|
||||
// },
|
||||
videoInput(uploadList){
|
||||
// console.log(uploadList,'uploadList');
|
||||
// this.video =[]
|
||||
@@ -336,31 +299,11 @@ export default {
|
||||
// })
|
||||
},
|
||||
async getInfo(){
|
||||
//查询商品分类
|
||||
//查询商品分类及商品
|
||||
let that = this;
|
||||
await getInfo(0).then( res => {
|
||||
//商品分类
|
||||
that.cateList = res.cateList
|
||||
await getStoreProductAndCart().then(res=>{
|
||||
that.cateList=res;
|
||||
})
|
||||
for (const item of that.cateList) {
|
||||
await initData('/bxg/api/yxStoreProduct', {
|
||||
page: 0,
|
||||
size: 999,
|
||||
sort: 'id,desc',
|
||||
cateId:item.value,
|
||||
}).then(data=>{
|
||||
data.content.forEach(ele=>{
|
||||
//不能直接使用ele,会有浅拷贝问题
|
||||
// let ele1=JSON.parse(JSON.stringify(ele))
|
||||
// that.$set(ele,'value',ele1)
|
||||
that.$set(ele,'value',ele.id)
|
||||
that.$set(ele,'label',ele.storeName)
|
||||
}
|
||||
)
|
||||
that.$set(item,'children',data.content)
|
||||
})
|
||||
}
|
||||
console.log(that.cateList,'that.cateList')
|
||||
},
|
||||
// 获取数据前设置好接口地址
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
|
||||
Reference in New Issue
Block a user