Skip to content

Commit

Permalink
专题推荐功能完成
Browse files Browse the repository at this point in the history
  • Loading branch information
zhh committed Nov 13, 2018
1 parent 8c86685 commit 784e2ad
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 26 deletions.
10 changes: 9 additions & 1 deletion src/api/subject.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import request from '@/utils/request'
export function fetchList() {
export function fetchListAll() {
return request({
url:'/subject/listAll',
method:'get',
})
}

export function fetchList(params) {
return request({
url:'/subject/list',
method:'get',
params:params
})
}
2 changes: 1 addition & 1 deletion src/views/pms/product/components/ProductRelationDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</template>

<script>
import {fetchList as fetchSubjectList} from '@/api/subject'
import {fetchListAll as fetchSubjectList} from '@/api/subject'
import {fetchList as fetchPrefrenceAreaList} from '@/api/prefrenceArea'
export default {
Expand Down
2 changes: 1 addition & 1 deletion src/views/sms/brand/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@
},
created() {
this.getList();
this.getDialogList();
},
filters:{
formatRecommendStatus(status){
Expand Down Expand Up @@ -301,6 +300,7 @@
},
handleSelectBrand(){
this.selectDialogVisible=true;
this.getDialogList();
},
handleSelectSearch(){
this.getDialogList();
Expand Down
2 changes: 1 addition & 1 deletion src/views/sms/hot/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@
},
created() {
this.getList();
this.getDialogList();
},
filters:{
formatRecommendStatus(status){
Expand Down Expand Up @@ -300,6 +299,7 @@
},
handleSelectProduct(){
this.selectDialogVisible=true;
this.getDialogList();
},
handleSelectSearch(){
this.getDialogList();
Expand Down
2 changes: 1 addition & 1 deletion src/views/sms/new/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@
},
created() {
this.getList();
this.getDialogList();
},
filters:{
formatRecommendStatus(status){
Expand Down Expand Up @@ -300,6 +299,7 @@
},
handleSelectProduct(){
this.selectDialogVisible=true;
this.getDialogList();
},
handleSelectSearch(){
this.getDialogList();
Expand Down
51 changes: 30 additions & 21 deletions src/views/sms/subject/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div style="margin-top: 15px">
<el-form :inline="true" :model="listQuery" size="small" label-width="140px">
<el-form-item label="专题名称:">
<el-input v-model="listQuery.subjectName" class="input-width" placeholder="商品名称"></el-input>
<el-input v-model="listQuery.subjectName" class="input-width" placeholder="专题名称"></el-input>
</el-form-item>
<el-form-item label="推荐状态:">
<el-select v-model="listQuery.recommendStatus" placeholder="全部" clearable class="input-width">
Expand All @@ -38,10 +38,10 @@
<el-card class="operate-container" shadow="never">
<i class="el-icon-tickets"></i>
<span>数据列表</span>
<el-button size="mini" class="btn-add" @click="handleSelectProduct()">选择专题</el-button>
<el-button size="mini" class="btn-add" @click="handleSelectSubject()">选择专题</el-button>
</el-card>
<div class="table-container">
<el-table ref="newProductTable"
<el-table ref="newSubjectTable"
:data="list"
style="width: 100%;"
@selection-change="handleSelectionChange"
Expand Down Expand Up @@ -126,13 +126,13 @@
@selection-change="handleDialogSelectionChange" border>
<el-table-column type="selection" width="60" align="center"></el-table-column>
<el-table-column label="专题名称" align="center">
<template slot-scope="scope">{{scope.row.name}}</template>
<template slot-scope="scope">{{scope.row.title}}</template>
</el-table-column>
<el-table-column label="货号" width="160" align="center">
<template slot-scope="scope">NO.{{scope.row.productSn}}</template>
<el-table-column label="所属分类" width="160" align="center">
<template slot-scope="scope">{{scope.row.categoryName}}</template>
</el-table-column>
<el-table-column label="价格" width="120" align="center">
<template slot-scope="scope">{{scope.row.price}}</template>
<el-table-column label="添加时间" width="160" align="center">
<template slot-scope="scope">{{scope.row.createTime | formatTime}}</template>
</el-table-column>
</el-table>
<div class="pagination-container">
Expand Down Expand Up @@ -171,7 +171,8 @@
</template>
<script>
import {fetchList,updateRecommendStatus,deleteHomeSubject,createHomeSubject,updateHomeSubjectSort} from '@/api/homeSubject';
import {fetchList as fetchProductList} from '@/api/product';
import {fetchList as fetchSubjectList} from '@/api/subject';
import {formatDate} from '@/utils/date';
const defaultListQuery = {
pageNum: 1,
Expand Down Expand Up @@ -231,7 +232,6 @@
},
created() {
this.getList();
this.getDialogList();
},
filters:{
formatRecommendStatus(status){
Expand All @@ -240,7 +240,14 @@
}else{
return '未推荐';
}
}
},
formatTime(time){
if(time==null||time===''){
return 'N/A';
}
let date = new Date(time);
return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
},
},
methods: {
handleResetSearch() {
Expand All @@ -266,7 +273,7 @@
this.updateRecommendStatusStatus(row.id,row.recommendStatus);
},
handleDelete(index,row){
this.deleteProduct(row.id);
this.deleteSubject(row.id);
},
handleBatchOperate(){
if (this.multipleSelection < 1) {
Expand All @@ -289,7 +296,7 @@
this.updateRecommendStatusStatus(ids,0);
} else if(this.operateType===2){
//删除
this.deleteProduct(ids);
this.deleteSubject(ids);
}else {
this.$message({
message: '请选择批量操作类型',
Expand All @@ -298,8 +305,10 @@
});
}
},
handleSelectProduct(){
handleSelectSubject(){
this.selectDialogVisible=true;
this.dialogData.listQuery.keyword=null;
this.getDialogList();
},
handleSelectSearch(){
this.getDialogList();
Expand All @@ -325,19 +334,19 @@
});
return;
}
let selectProducts = [];
let selectSubjects = [];
for (let i = 0; i < this.dialogData.multipleSelection.length; i++) {
selectProducts.push({
productId:this.dialogData.multipleSelection[i].id,
productName:this.dialogData.multipleSelection[i].name
selectSubjects.push({
subjectId:this.dialogData.multipleSelection[i].id,
subjectName:this.dialogData.multipleSelection[i].title
});
}
this.$confirm('使用要进行添加操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
createHomeSubject(selectProducts).then(response=>{
createHomeSubject(selectSubjects).then(response=>{
this.selectDialogVisible=false;
this.dialogData.multipleSelection=[];
this.getList();
Expand Down Expand Up @@ -401,7 +410,7 @@
this.getList();
});
},
deleteProduct(ids){
deleteSubject(ids){
this.$confirm('是否要删除该推荐?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
Expand All @@ -419,7 +428,7 @@
})
},
getDialogList(){
fetchProductList(this.dialogData.listQuery).then(response=>{
fetchSubjectList(this.dialogData.listQuery).then(response=>{
this.dialogData.list=response.data.list;
this.dialogData.total=response.data.total;
})
Expand Down

0 comments on commit 784e2ad

Please sign in to comment.