Browse Source

商品增加榜单设置

master
sj 2 years ago
parent
commit
83b2ce4e62
  1. 27
      src/api/bxg/yxStoreHotListRecord.js
  2. 46
      src/views/bxg/shop/goods/form.vue
  3. 4
      src/views/bxg/shop/set/form.vue
  4. 276
      src/views/bxg/shop/yxStoreHotList/index.vue
  5. 284
      src/views/bxg/shop/yxStoreHotListRecord/index.vue

27
src/api/bxg/yxStoreHotListRecord.js

@ -0,0 +1,27 @@
import request from '@/utils/request'
export function add(data) {
return request({
url: 'bxg/api/yxStoreHotListRecord',
method: 'post',
data
})
}
export function del(ids) {
return request({
url: 'bxg/api/yxStoreHotListRecord/',
method: 'delete',
data: ids
})
}
export function edit(data) {
return request({
url: 'bxg/api/yxStoreHotListRecord',
method: 'put',
data
})
}
export default { add, edit, del }

46
src/views/bxg/shop/goods/form.vue

@ -210,8 +210,8 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="底部栏目配置" > <el-form-item label="底部栏目配置:" >
<el-tabs v-model="editableTabsValue" type="card" editable @edit="handleTabsEdit"> <el-tabs v-model="editableTabsValue" type="card" editable @edit="handleTabsEdit" style="width: 950px">
<el-tab-pane <el-tab-pane
:key="item.name" :key="item.name"
v-for="(item, index) in editableTabs" v-for="(item, index) in editableTabs"
@ -219,7 +219,9 @@
:name="item.name" :name="item.name"
> >
<span style="display: flex;margin-bottom:10px">当前栏目标题<el-input style="width:300px" v-model="item.content"></el-input></span> <span style="display: flex;margin-bottom:10px">当前栏目标题<el-input style="width:300px" v-model="item.content"></el-input></span>
<single-pic v-model="item.configuration" type="image" :num="1" :width="150" :height="150" /> <span style="display: flex;margin-bottom:10px">当前栏目图标<single-pic v-model="item.configuration" type="image" :num="1" :width="150" :height="150" /></span>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</el-form-item> </el-form-item>
@ -403,6 +405,29 @@
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8">
<el-form-item label="参与榜单:">
<el-radio-group v-model="formValidate.is_hot_list" >
<el-radio :label="1" class="radio">开启</el-radio>
<el-radio :label="0">关闭</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12" v-if="formValidate.is_hot_list==1">
<el-form-item label="选择榜单:">
<el-select v-model="formValidate.hotListId" filterable :filter-method="dataFilter" style="width: 220px" clearable>
<el-option v-for="item in hotList"
:value="item.id"
:key="item.id"
:label="item.listName" ></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12" v-if="formValidate.is_hot_list==1">
<el-form-item label="榜单虚拟销量:">
<el-input v-model="formValidate.hotSales" type="number"></el-input>
</el-form-item>
</el-col>
</el-row> </el-row>
<el-form-item> <el-form-item>
<el-button type="primary" class="submission" @click="handleSubmit('formValidate')">保存</el-button> <el-button type="primary" class="submission" @click="handleSubmit('formValidate')">保存</el-button>
@ -427,6 +452,7 @@ export default {
components: { editor, picUpload, mulpicUpload, Treeselect, MaterialList, UeditorWrap, singlePic }, components: { editor, picUpload, mulpicUpload, Treeselect, MaterialList, UeditorWrap, singlePic },
data() { data() {
return { return {
hotList:[],
tabIndex: 0, tabIndex: 0,
editableTabsValue: '1', editableTabsValue: '1',
editableTabs:[], editableTabs:[],
@ -502,6 +528,8 @@ export default {
is_benefit: 0, is_benefit: 0,
is_best: 0, is_best: 0,
is_new: 0, is_new: 0,
is_hot_list:0,
hotListId:null,
is_good: 0, is_good: 0,
is_postage: 0, is_postage: 0,
is_sub: 0, is_sub: 0,
@ -788,6 +816,15 @@ export default {
getInfo () { getInfo () {
let that = this; let that = this;
let id = that.$route.params.id || 0; let id = that.$route.params.id || 0;
//
initData('/bxg/api/yxStoreHotList', {
page: 0,
size: 999,
sort: 'id,desc'
}).then(data => {
that.hotList=data.content
//
}),
// //
initData('/bxg/api/yxStoreBrand', { initData('/bxg/api/yxStoreBrand', {
page: 0, page: 0,
@ -874,6 +911,9 @@ export default {
if(this.formValidate.spec_type === 1 && this.manyFormValidate.length===0){ if(this.formValidate.spec_type === 1 && this.manyFormValidate.length===0){
return this.$message.warning('请点击生成规格!'); return this.$message.warning('请点击生成规格!');
} }
if(this.formValidate.is_hot_list === 1 && (this.formValidate.hotListId==null||this.formValidate.hotListId=="")){
return this.$message.warning('需设置参与的榜单列表');
}
// console.log(this.formValidate,'') // console.log(this.formValidate,'')
// return // return
add(this.formValidate).then(async res => { add(this.formValidate).then(async res => {

4
src/views/bxg/shop/set/form.vue

@ -73,6 +73,10 @@ export default {
value:3, value:3,
label:'活动专区轮播图', label:'活动专区轮播图',
}, },
{
value:4,
label:'榜单列表轮播图',
},
], ],
form: { form: {
id: '', id: '',

276
src/views/bxg/shop/yxStoreHotList/index.vue

@ -16,34 +16,34 @@
<el-form-item label="展示图片" prop="listImage"> <el-form-item label="展示图片" prop="listImage">
<single-pic v-model="form.listImage" type="image" :num="1" :width="150" :height="150" /> <single-pic v-model="form.listImage" type="image" :num="1" :width="150" :height="150" />
</el-form-item> </el-form-item>
<el-form-item label="所属月份" prop="mouth" > <!-- <el-form-item label="所属月份" prop="mouth" >-->
<el-date-picker <!-- <el-date-picker-->
format="yyyy 年 MM 月" <!-- format="yyyy 年 MM 月"-->
value-format="yyyy-MM" <!-- value-format="yyyy-MM"-->
v-model="form.mouth" <!-- v-model="form.mouth"-->
type="month" <!-- type="month"-->
placeholder="选择榜单所属年月"> <!-- placeholder="选择榜单所属年月">-->
</el-date-picker> <!-- </el-date-picker>-->
</el-form-item> <!-- </el-form-item>-->
<el-form-item label="商品列表"> <!-- <el-form-item label="商品列表">-->
<el-input style="width: 200px;" v-model="product" v-if="productNameList.length==0" <!-- <el-input style="width: 200px;" v-model="product" v-if="productNameList.length==0"-->
:readonly="true" @click.native="changeShow=!changeShow" placeholder="点击选择商品或收起商品列表"> <!-- :readonly="true" @click.native="changeShow=!changeShow" placeholder="点击选择商品或收起商品列表">-->
</el-input> <!-- </el-input>-->
<div v-else style="border:#c3c3c3 1px solid;border-radius:3px;margin-bottom:2px;padding-left:17px" @click="changeShow=!changeShow"> <!-- <div v-else style="border:#c3c3c3 1px solid;border-radius:3px;margin-bottom:2px;padding-left:17px" @click="changeShow=!changeShow">-->
<div v-for="(item,index) in this.productNameList"> <!-- <div v-for="(item,index) in this.productNameList">-->
<span>top{{index+1}}:{{item}}</span> <!-- <span>top{{index+1}}:{{item}}</span>-->
</div> <!-- </div>-->
</div> <!-- </div>-->
<el-cascader-panel <!-- <el-cascader-panel-->
v-if="changeShow" <!-- v-if="changeShow"-->
:props="props" <!-- :props="props"-->
@change="cascaderChange($event)" <!-- @change="cascaderChange($event)"-->
v-model="productList" <!-- v-model="productList"-->
placeholder="多选,按选择顺序排序" <!-- placeholder="多选,按选择顺序排序"-->
:options="cateList" <!-- :options="cateList"-->
ref="quitCascader" <!-- ref="quitCascader"-->
filterable></el-cascader-panel> <!-- filterable></el-cascader-panel>-->
</el-form-item> <!-- </el-form-item>-->
<el-form-item label="是否显示"> <el-form-item label="是否显示">
<!-- <el-input v-model="form.isShow" style="width: 370px;" />--> <!-- <el-input v-model="form.isShow" style="width: 370px;" />-->
@ -52,9 +52,9 @@
<el-radio :label="0">隐藏</el-radio> <el-radio :label="0">隐藏</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="排序"> <!-- <el-form-item label="排序">-->
<el-input v-model="form.sort" style="width: 380px;" type="number" /> <!-- <el-input v-model="form.sort" style="width: 380px;" type="number" />-->
</el-form-item> <!-- </el-form-item>-->
<!-- <el-form-item label="添加时间">--> <!-- <el-form-item label="添加时间">-->
<!-- <el-input v-model="form.createTime" style="width: 370px;" />--> <!-- <el-input v-model="form.createTime" style="width: 370px;" />-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
@ -78,15 +78,15 @@
<el-table-column type="selection" width="55" /> <el-table-column type="selection" width="55" />
<el-table-column v-if="columns.visible('id')" prop="id" label="榜单列表ID" /> <el-table-column v-if="columns.visible('id')" prop="id" label="榜单列表ID" />
<el-table-column v-if="columns.visible('listName')" prop="listName" label="榜单名称" /> <el-table-column v-if="columns.visible('listName')" prop="listName" label="榜单名称" />
<el-table-column v-if="columns.visible('mouth')" prop="mouth" label="所属月份" /> <!-- <el-table-column v-if="columns.visible('mouth')" prop="mouth" label="所属月份" />-->
<el-table-column v-if="columns.visible('sort')" prop="sort" label="排序" /> <!-- <el-table-column v-if="columns.visible('sort')" prop="sort" label="排序" />-->
<el-table-column v-if="columns.visible('productlist')" prop="productlist" label="商品列表" width="250"> <!-- <el-table-column v-if="columns.visible('productlist')" prop="productlist" label="商品列表" width="250">-->
<template slot-scope="scope"> <!-- <template slot-scope="scope">-->
<div v-for="(item,index) in (scope.row.productInfoList)"> <!-- <div v-for="(item,index) in (scope.row.productInfoList)">-->
<span>top{{index+1}}:{{item.storeName}}</span> <!-- <span>top{{index+1}}:{{item.storeName}}</span>-->
</div> <!-- </div>-->
</template> <!-- </template>-->
</el-table-column> <!-- </el-table-column>-->
<el-table-column v-if="columns.visible('isShow')" label="状态" align="center" prop="isShow"> <el-table-column v-if="columns.visible('isShow')" label="状态" align="center" prop="isShow">
<template slot-scope="scope"> <template slot-scope="scope">
<div> <div>
@ -136,8 +136,8 @@ import {initData} from "@/api/bxg/data";
import singlePic from '@/components/singlematerial' import singlePic from '@/components/singlematerial'
// crudpresenter // crudpresenter
const defaultCrud = CRUD({ title: '热门榜单', url: 'bxg/api/yxStoreHotList', sort: 'id,desc', crudMethod: { ...crudYxStoreHotList }}) const defaultCrud = CRUD({ title: '热门榜单', url: 'bxg/api/yxStoreHotList', sort: 'id,desc', crudMethod: { ...crudYxStoreHotList }})
const defaultForm = { id: null, listName: null, sort: 0, productList: null, isShow: 1,listImage:'', const defaultForm = { id: null, listName: null, isShow: 1,listImage:'',
mouth:null, mouth:null, sort: 0, productList:"[]",
createTime: null, updateTime: null, isDel: null, tenantId: Cookies.get('tenantId') } createTime: null, updateTime: null, isDel: null, tenantId: Cookies.get('tenantId') }
export default { export default {
name: 'YxStoreHotList', name: 'YxStoreHotList',
@ -173,107 +173,107 @@ export default {
// }, // },
}, },
mounted () { mounted () {
this.getInfo(); // this.getInfo();
}, },
methods: { methods: {
cancel(){ cancel(){
this.productNameList=[] this.productNameList=[]
}, },
cascaderChange(val) { // cascaderChange(val) {
this.productList=[] // this.productList=[]
this.productNameList=[]; // this.productNameList=[];
let productList=[]; // let productList=[];
productList=this.getCascader(val,this.oldProductList,this.$refs.quitCascader.getCheckedNodes(true)); // productList=this.getCascader(val,this.oldProductList,this.$refs.quitCascader.getCheckedNodes(true));
this.productList = productList // // this.productList = productList //
this.oldProductList=productList; // this.oldProductList=productList;
// console.log('val',val,'element',productList,'Nodes',this.$refs.quitCascader.getCheckedNodes(true)) // // console.log('val',val,'element',productList,'Nodes',this.$refs.quitCascader.getCheckedNodes(true))
this.form.productList=JSON.stringify(this.productList.map(item=>item[1])); // this.form.productList=JSON.stringify(this.productList.map(item=>item[1]));
}, // },
getCascader(newVal,oldVal,Nodes) { // getCascader(newVal,oldVal,Nodes) {
let productList = [] // let productList = []
// console.log('val',newVal,'element',oldVal,'Nodes',Nodes) // // console.log('val',newVal,'element',oldVal,'Nodes',Nodes)
//, // //,
if(newVal.length <= 1) { // if(newVal.length <= 1) {
productList=newVal; // productList=newVal;
// // //
}else if(newVal.length < this.oldProductList.length) { // }else if(newVal.length < this.oldProductList.length) {
let newValList=newVal.map(item=>item[1]) // let newValList=newVal.map(item=>item[1])
let oldValList=oldVal.map(item=>item[1]) // let oldValList=oldVal.map(item=>item[1])
let diff = newValList.concat(oldValList).filter((value, index, arr) => { // let diff = newValList.concat(oldValList).filter((value, index, arr) => {
return arr.indexOf(value) === arr.lastIndexOf(value) // return arr.indexOf(value) === arr.lastIndexOf(value)
}); // });
oldVal.forEach((item,index)=> { // oldVal.forEach((item,index)=> {
diff.forEach(ele=>{ // diff.forEach(ele=>{
if(item[1]==ele) { // if(item[1]==ele) {
oldVal.splice(index,1) // oldVal.splice(index,1)
} // }
}) // })
}) // })
productList=oldVal // productList=oldVal
// // //
}else { // }else {
let newValList=newVal.map(item=>item[1]) // let newValList=newVal.map(item=>item[1])
let oldValList=oldVal.map(item=>item[1]) // let oldValList=oldVal.map(item=>item[1])
let diff = newValList.concat(oldValList).filter((value, index, arr) => { // let diff = newValList.concat(oldValList).filter((value, index, arr) => {
return arr.indexOf(value) === arr.lastIndexOf(value) // return arr.indexOf(value) === arr.lastIndexOf(value)
}); // });
newVal.forEach((item)=> { // newVal.forEach((item)=> {
diff.forEach(ele=>{ // diff.forEach(ele=>{
if(item[1]==ele) { // if(item[1]==ele) {
oldVal.push(item) // oldVal.push(item)
} // }
}) // })
}); // });
productList=oldVal // productList=oldVal
} // }
console.log('val',newVal,'productList',productList) // console.log('val',newVal,'productList',productList)
let productNameList=[]; // let productNameList=[];
productList.forEach(ele=>{ // productList.forEach(ele=>{
Nodes.forEach(item=>{ // Nodes.forEach(item=>{
if (item.value==ele[1]){ // if (item.value==ele[1]){
// productNameList=item.parent.label+'/'+item.label+productNameList; // // productNameList=item.parent.label+'/'+item.label+productNameList;
// console.log('item.parent.label+\'/\'+item.label',item.parent.label+'/'+item.label) // // console.log('item.parent.label+\'/\'+item.label',item.parent.label+'/'+item.label)
productNameList.push(item.parent.label+'/'+item.label) // productNameList.push(item.parent.label+'/'+item.label)
} // }
}) // })
}) // })
console.log('productList',productNameList) // console.log('productList',productNameList)
this.productNameList=productNameList; // this.productNameList=productNameList;
return productList; // return productList;
}, // },
change(val){ // change(val){
console.log('选的子级',val) // console.log('',val)
let productList=val.map(item=>item[1]) // let productList=val.map(item=>item[1])
this.form.productList=JSON.stringify(productList) // this.form.productList=JSON.stringify(productList)
console.log('选的子级',this.form.productList) // console.log('',this.form.productList)
}, // },
async getInfo(){ // async getInfo(){
// // //
let that = this; // let that = this;
await getInfo(0).then( res => { // await getInfo(0).then( res => {
// // //
that.cateList = res.cateList // that.cateList = res.cateList
}) // })
for (const item of that.cateList) { // for (const item of that.cateList) {
await initData('/bxg/api/yxStoreProduct', { // await initData('/bxg/api/yxStoreProduct', {
page: 0, // page: 0,
size: 999, // size: 999,
sort: 'id,desc', // sort: 'id,desc',
cateId:item.value, // cateId:item.value,
}).then(data=>{ // }).then(data=>{
data.content.forEach(ele=>{ // data.content.forEach(ele=>{
//使ele // //使ele
// let ele1=JSON.parse(JSON.stringify(ele)) // // let ele1=JSON.parse(JSON.stringify(ele))
// that.$set(ele,'value',ele1) // // that.$set(ele,'value',ele1)
that.$set(ele,'value',ele.id) // that.$set(ele,'value',ele.id)
that.$set(ele,'label',ele.storeName) // that.$set(ele,'label',ele.storeName)
} // }
) // )
that.$set(item,'children',data.content) // that.$set(item,'children',data.content)
}) // })
} // }
console.log(that.cateList,'that.cateList') // console.log(that.cateList,'that.cateList')
}, // },
// //
[CRUD.HOOK.beforeRefresh]() { [CRUD.HOOK.beforeRefresh]() {
return true return true

284
src/views/bxg/shop/yxStoreHotListRecord/index.vue

@ -0,0 +1,284 @@
<template>
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<div v-if="crud.props.searchToggle">
<!-- 搜索 -->
<el-date-picker
style="margin-right: 20px"
size="mini"
format="yyyy 年 MM 月"
value-format="yyyy-MM"
v-model="query.mouth"
type="month"
placeholder="选择榜单所属年月">
</el-date-picker>
<el-select size="mini" v-model="query.hotListId" clearable placeholder="榜单类型" class="filter-item" filterable :filter-method="dataFilter" style="width: 130px;margin-right: 20px">
<el-option v-for="item in hotList"
:value="item.id"
:key="item.id"
:label="item.listName" ></el-option>
</el-select>
<rrOperation :crud="crud" />
</div>
<crudOperation :permission="permission" />
<!-- <el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="crud.toQuery">搜索</el-button>-->
<!--表单组件-->
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
<!-- <el-form-item label="id">-->
<!-- <el-input v-model="form.id" style="width: 370px;" />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="商品分类">-->
<!-- &lt;!&ndash; <el-input v-model="form.cateid" style="width: 370px;" />&ndash;&gt;-->
<!-- <el-select v-model="form.cateId" filterable :filter-method="dataFilter" style="width: 220px" clearable>-->
<!-- <el-option v-for="item in cateList"-->
<!-- :value="item.value"-->
<!-- :key="item.id"-->
<!-- :label="item.label" ></el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item label="商品名称" prop="productId">
<el-cascader style="width: 220px" clearable
v-model="form.productId"
@change="change"
placeholder="选择商品"
:options="cateList"
filterable>
</el-cascader>
</el-form-item>
<el-form-item label="参与榜单" prop="hotListId">
<el-select v-model="form.hotListId" filterable :filter-method="dataFilter" style="width: 220px" clearable>
<el-option v-for="item in hotList"
:value="item.id"
:key="item.id"
:label="item.listName" ></el-option>
</el-select>
</el-form-item>
<el-form-item label="入榜价格" prop="price">
<el-input v-model="form.price" type="number" placeholder="默认商品真实价格" style="width: 370px;" />
</el-form-item>
<el-form-item label="入榜销量" prop="hotSales">
<el-input v-model="form.hotSales" type="number" placeholder="默认商品真实销量" style="width: 370px;" />
</el-form-item>
<el-form-item label="所属月份" prop="mouth" >
<el-date-picker
format="yyyy 年 MM 月"
value-format="yyyy-MM"
v-model="form.mouth"
type="month"
placeholder="选择榜单所属年月">
</el-date-picker>
</el-form-item>
<el-form-item label="是否显示">
<el-radio-group v-model="form.isShow" style="width: 178px">
<el-radio :label="1">显示</el-radio>
<el-radio :label="0">隐藏</el-radio>
</el-radio-group>
</el-form-item>
<!-- <el-form-item label="添加时间">-->
<!-- <el-input v-model="form.createTime" style="width: 370px;" />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="updateTime">-->
<!-- <el-input v-model="form.updateTime" style="width: 370px;" />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="删除状态">-->
<!-- <el-input v-model="form.isDel" style="width: 370px;" />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="tenantId">-->
<!-- <el-input v-model="form.tenantId" style="width: 370px;" />-->
<!-- </el-form-item>-->
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="crud.cancelCU">取消</el-button>
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
</div>
</el-dialog>
<!--表格渲染-->
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
<el-table-column type="selection" width="55" />
<el-table-column v-if="columns.visible('id')" prop="id" label="id" />
<el-table-column v-if="columns.visible('mouth')" prop="mouth" label="所属月份" />
<el-table-column v-if="columns.visible('productId')" prop="productName" label="商品名称" />
<el-table-column v-if="columns.visible('hotListName')" prop="hotListName" label="所属榜单" />
<el-table-column v-if="columns.visible('price')" prop="price" label="入榜价格" />
<el-table-column v-if="columns.visible('hotSales')" prop="hotSales" label="入榜销量" />
<el-table-column v-if="columns.visible('cateId')" prop="hotListName" label="商品分类" />
<!-- <el-table-column v-if="columns.visible('isShow')" prop="isShow" label="是否显示" />-->
<el-table-column v-if="columns.visible('isShow')" label="状态" align="center" prop="isShow">
<template slot-scope="scope">
<div>
<el-tag v-if="scope.row.isShow === 1" :type="''">显示</el-tag>
<el-tag v-else :type=" 'info' ">隐藏</el-tag>
</div>
</template>
</el-table-column>
<el-table-column v-if="columns.visible('createTime')" prop="createTime" label="添加时间">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<!-- <el-table-column v-if="columns.visible('updateTime')" prop="updateTime" label="updateTime">-->
<!-- <template slot-scope="scope">-->
<!-- <span>{{ parseTime(scope.row.updateTime) }}</span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column v-if="columns.visible('isDel')" prop="isDel" label="删除状态" />-->
<!-- <el-table-column v-if="columns.visible('tenantId')" prop="tenantId" label="tenantId" />-->
<el-table-column v-permission="['admin','yxStoreHotListRecord:edit','yxStoreHotListRecord:del']" label="操作" width="150px" align="center">
<template slot-scope="scope">
<udOperation
:data="scope.row"
:permission="permission"
/>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<pagination />
</div>
</div>
</template>
<script>
import crudYxStoreHotListRecord from '@/api/bxg/yxStoreHotListRecord'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import udOperation from '@crud/UD.operation'
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";
// crudpresenter
const defaultCrud = CRUD({ title: '榜单记录', url: 'bxg/api/yxStoreHotListRecord', sort: 'id,desc', crudMethod: { ...crudYxStoreHotListRecord }})
const defaultForm = { id: null, productId: null, hotListId: null, price: null, hotSales: null, cateId: null, mouth: null, isShow: 1, createTime: null,
updateTime: null, isDel: null, tenantId: null }
export default {
name: 'YxStoreHotListRecord',
components: { pagination,crudOperation, rrOperation, udOperation ,MaterialList},
mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
data() {
return {
hotList:[],
cateList:[],
permission: {
add: ['admin', 'yxStoreHotListRecord:add'],
edit: ['admin', 'yxStoreHotListRecord:edit'],
del: ['admin', 'yxStoreHotListRecord:del']
},
rules: {
productId: [{ required: true, message: "商品未选择", trigger: "blur" }],
hotListId: [{ required: true, message: "参与榜单不能为空", trigger: "blur" }],
price: [{ required: true, message: "商品价格不能为空", trigger: "blur" }],
hotSales: [{ required: true, message: "商品销量不能为空", trigger: "blur" }],
mouth: [{ required: true, message: "参与月份不能为空", trigger: "blur" }],
}
}
},
mounted () {
this.getInfo();
},
watch: {
},
methods: {
//
change(val){
console.log('val',val)
if (val.length==0){
this.form.cateId=null;
this.form.price=null;
this.form.hotSales=null;
}else {
this.form.cateId=val[0]
this.form.productId=val[1]
getInfo(val[1]).then(async res => {
this.form.hotSales=res.productInfo.sales
this.form.price=res.productInfo.price
// console.log(res,'res')
})
}
},
//
async getInfo(){
//
let that = this;
initData('/bxg/api/yxStoreHotList', {
page: 0,
size: 999,
sort: 'id,desc'
}).then(data => {
// console.log('dara', data);
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)
})
}
console.log(that.cateList,'that.cateList')
},
dataFilter(val){
this.value=val
if(val){
this.optionsMetaShow=this.treeSelect.filter((item=>{
if (!!~item.label.indexOf(val) || !!~item.label.toUpperCase().indexOf(val.toUpperCase())) {
return true
}
}))
}else{
this.optionsMetaShow=this.treeSelect
}
},
//
[CRUD.HOOK.beforeRefresh]() {
return true
}, //
[CRUD.HOOK.afterToCU](crud, form) {
},
}
}
</script>
<style scoped>
.table-img {
display: inline-block;
text-align: center;
background: #ccc;
color: #fff;
white-space: nowrap;
position: relative;
overflow: hidden;
vertical-align: middle;
width: 32px;
height: 32px;
line-height: 32px;
}
</style>
Loading…
Cancel
Save