sj
2 years ago
5 changed files with 496 additions and 141 deletions
@ -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 } |
@ -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="商品分类">--> |
||||
<!-- <!– <el-input v-model="form.cateid" style="width: 370px;" />–>--> |
||||
<!-- <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"; |
||||
|
||||
// crud交由presenter持有 |
||||
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…
Reference in new issue