优化商品查询方法
This commit is contained in:
@@ -81,3 +81,10 @@ export function getInfo(id) {
|
|||||||
method: 'get'
|
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 prop="useMinPrice" label="优惠券最低消费" />
|
||||||
<el-table-column label="优惠券开始时间">
|
<el-table-column label="优惠券开始时间">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
{{ formatTimeTwo(scope.row.addTime) }}
|
{{ formatTimeTwo(scope.row.useStartTime) }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="优惠券结束时间">
|
<el-table-column label="优惠券结束时间">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
{{ formatTimeTwo(scope.row.endTime) }}
|
{{ formatTimeTwo(scope.row.useEndTime) }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="获取方式">
|
<el-table-column label="获取方式">
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
@change="change"
|
@change="change"
|
||||||
placeholder="选择商品"
|
placeholder="选择商品"
|
||||||
:options="cateList"
|
:options="cateList"
|
||||||
|
:props="props"
|
||||||
filterable>
|
filterable>
|
||||||
</el-cascader>
|
</el-cascader>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -154,7 +155,7 @@ import pagination from '@crud/Pagination'
|
|||||||
import MaterialList from "@/components/material";
|
import MaterialList from "@/components/material";
|
||||||
import crudOperation from "@crud/CRUD.operation";
|
import crudOperation from "@crud/CRUD.operation";
|
||||||
import {initData} from "@/api/bxg/data";
|
import {initData} from "@/api/bxg/data";
|
||||||
import {getInfo} from "@/api/bxg/yxStoreProduct";
|
import {getInfo, getStoreProductAndCart} from "@/api/bxg/yxStoreProduct";
|
||||||
|
|
||||||
// crud交由presenter持有
|
// crud交由presenter持有
|
||||||
const defaultCrud = CRUD({ title: '榜单记录', url: 'bxg/api/yxStoreHotListRecord', sort: 'id,desc', crudMethod: { ...crudYxStoreHotListRecord }})
|
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" }],
|
price: [{ required: true, message: "商品价格不能为空", trigger: "blur" }],
|
||||||
hotSales: [{ required: true, message: "商品销量不能为空", trigger: "blur" }],
|
hotSales: [{ required: true, message: "商品销量不能为空", trigger: "blur" }],
|
||||||
mouth: [{ required: true, message: "参与月份不能为空", trigger: "blur" }],
|
mouth: [{ required: true, message: "参与月份不能为空", trigger: "blur" }],
|
||||||
}
|
},
|
||||||
|
props:{
|
||||||
|
value: 'id',
|
||||||
|
label: 'storeName',
|
||||||
|
children:'children',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
@@ -218,29 +224,10 @@ export default {
|
|||||||
that.hotList=data.content
|
that.hotList=data.content
|
||||||
//若为编辑,应初始化一下品牌
|
//若为编辑,应初始化一下品牌
|
||||||
}),
|
}),
|
||||||
await getInfo(0).then( res => {
|
await getStoreProductAndCart().then(res=>{
|
||||||
//商品分类
|
that.cateList=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)
|
|
||||||
})
|
})
|
||||||
}
|
// console.log(that.cateList,'that.cateList')
|
||||||
console.log(that.cateList,'that.cateList')
|
|
||||||
},
|
},
|
||||||
dataFilter(val){
|
dataFilter(val){
|
||||||
this.value=val
|
this.value=val
|
||||||
|
|||||||
@@ -15,9 +15,11 @@
|
|||||||
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="250px">
|
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="250px">
|
||||||
<el-form-item label="关联商品:" prop="product">
|
<el-form-item label="关联商品:" prop="product">
|
||||||
<el-cascader
|
<el-cascader
|
||||||
|
style="width:370px"
|
||||||
ref="cascader"
|
ref="cascader"
|
||||||
v-model="product"
|
v-model="product"
|
||||||
@change="change"
|
@change="change"
|
||||||
|
:props="props"
|
||||||
placeholder="试试搜索:眼镜"
|
placeholder="试试搜索:眼镜"
|
||||||
:options="cateList"
|
:options="cateList"
|
||||||
filterable></el-cascader>
|
filterable></el-cascader>
|
||||||
@@ -125,6 +127,7 @@ import udOperation from '@crud/UD.operation'
|
|||||||
import pagination from '@crud/Pagination'
|
import pagination from '@crud/Pagination'
|
||||||
import MaterialList from "@/components/material";
|
import MaterialList from "@/components/material";
|
||||||
import {getInfo} from "@/api/bxg/yxStoreProduct";
|
import {getInfo} from "@/api/bxg/yxStoreProduct";
|
||||||
|
import {getStoreProductAndCart} from "@/api/bxg/yxStoreProduct";
|
||||||
import {initData} from "@/api/bxg/data";
|
import {initData} from "@/api/bxg/data";
|
||||||
import FileUpload from "@comp/FileUpload";
|
import FileUpload from "@comp/FileUpload";
|
||||||
import VideoUpload from "@comp/VideoUpload";
|
import VideoUpload from "@comp/VideoUpload";
|
||||||
@@ -158,39 +161,11 @@ export default {
|
|||||||
product:[],
|
product:[],
|
||||||
//分类列表
|
//分类列表
|
||||||
cateList:[],
|
cateList:[],
|
||||||
//懒加载暂无法回显,弃用
|
props:{
|
||||||
// props:{
|
value: 'id',
|
||||||
// // emitPath:false,
|
label: 'storeName',
|
||||||
// lazy: true,
|
children:'children',
|
||||||
// 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);
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
video:[],
|
video:[],
|
||||||
picArr:[],
|
picArr:[],
|
||||||
permission: {
|
permission: {
|
||||||
@@ -313,18 +288,6 @@ export default {
|
|||||||
handleClick(tab, event) {
|
handleClick(tab, event) {
|
||||||
console.log(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){
|
videoInput(uploadList){
|
||||||
// console.log(uploadList,'uploadList');
|
// console.log(uploadList,'uploadList');
|
||||||
// this.video =[]
|
// this.video =[]
|
||||||
@@ -336,31 +299,11 @@ export default {
|
|||||||
// })
|
// })
|
||||||
},
|
},
|
||||||
async getInfo(){
|
async getInfo(){
|
||||||
//查询商品分类
|
//查询商品分类及商品
|
||||||
let that = this;
|
let that = this;
|
||||||
await getInfo(0).then( res => {
|
await getStoreProductAndCart().then(res=>{
|
||||||
//商品分类
|
that.cateList=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)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
console.log(that.cateList,'that.cateList')
|
|
||||||
},
|
},
|
||||||
// 获取数据前设置好接口地址
|
// 获取数据前设置好接口地址
|
||||||
[CRUD.HOOK.beforeRefresh]() {
|
[CRUD.HOOK.beforeRefresh]() {
|
||||||
|
|||||||
Reference in New Issue
Block a user