Commit 744c09cd by crushh

update: 规则列表

parent fd7f6e16
...@@ -111,7 +111,7 @@ const router = new Router({ ...@@ -111,7 +111,7 @@ const router = new Router({
}, },
}, },
{ {
path: '/editRule', path: '/editRule/:id',
name: 'editRule', name: 'editRule',
component: ruleInfo, component: ruleInfo,
meta: { meta: {
...@@ -127,6 +127,14 @@ const router = new Router({ ...@@ -127,6 +127,14 @@ const router = new Router({
}, },
}, },
{ {
path: '/copyRule/:id',
name: 'copyRule',
component: ruleInfo,
meta: {
type: 'copy',
},
},
{
path: '/giftExchange', path: '/giftExchange',
name: 'giftExchange', name: 'giftExchange',
component: giftExchange, component: giftExchange,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import axios from 'axios'; import axios from 'axios';
import store from '../store/index'; import store from '../store/index';
import router from '../router'; import router from '../router';
import { Message } from 'element-ui';
// axios 配置 // axios 配置
// axios.defaults.timeout = 5000; // axios.defaults.timeout = 5000;
// let adminUrl = 'http://gicdev.demogic.com' // let adminUrl = 'http://gicdev.demogic.com'
...@@ -46,26 +46,65 @@ request.interceptors.request.use( ...@@ -46,26 +46,65 @@ request.interceptors.request.use(
// http response 拦截器 // http response 拦截器
request.interceptors.response.use( request.interceptors.response.use(
response => { response => {
if (response.status == 200 && response.data.errorCode === 401) { console.log('===>');
window.location.href = window.location.origin + '/gic-web'; console.log(response);
// window.location.href = 'http://gicdev.com/gic-web'
const { data, config } = response;
let err;
const { errorCode } = data;
switch (errorCode) {
case 0:
return response;
case 401:
Message({
message: '登录失效',
type: 'error',
});
window.location.href = window.location.origin + '/gic-web';
break;
case undefined:
break;
default:
Message({
message: data.message,
type: 'error',
});
err = new Error(`${data.message}: ${config.url}`);
if (__DEVELOPMENT) {
console.log('>>>>>>>>>> response data error >>>>>>>>>>');
}
return Promise.reject(err);
} }
return response;
}, },
error => { error => {
if (error.response) { console.log('===>');
switch (error.response.status) { console.log(error);
case 401: const status = err.response.status;
// 401 清除token信息并跳转到登录页面 switch (status) {
store.commit(types.LOGOUT); case 400: err.message = '请求错误'; break;
router.replace({ case 401: err.message = '未授权,请登录';
name: 'login', store.commit(types.LOGOUT);
query: { redirect: router.currentRoute.fullPath } window.location.href = window.location.origin + '/gic-web';
}); break;
} case 403: err.message = '拒绝访问'; break;
case 404: err.message = `请求地址出错: ${err.response.config.url}`; break;
case 408: err.message = '请求超时'; break;
case 500: err.message = '服务器内部错误'; break;
case 501: err.message = '服务未实现'; break;
case 502: err.message = '网关错误'; break;
case 503: err.message = '服务不可用'; break;
case 504: err.message = '网关超时'; break;
case 505: err.message = 'HTTP版本不受支持'; break;
default: break;
} }
return Promise.reject(error.response.data); if (__DEVELOPMENT) {
console.log('>>>>>>>>>> response error >>>>>>>>>>');
}
Message({
message: '系统异常',
type: 'error',
});
return Promise.reject(err);
} }
); );
......
...@@ -8,11 +8,13 @@ ...@@ -8,11 +8,13 @@
</el-breadcrumb-item> </el-breadcrumb-item>
<el-breadcrumb-item>积分商城</el-breadcrumb-item> <el-breadcrumb-item>积分商城</el-breadcrumb-item>
<el-breadcrumb-item>商品</el-breadcrumb-item> <el-breadcrumb-item>商品</el-breadcrumb-item>
<el-breadcrumb-item>上架规则</el-breadcrumb-item> <el-breadcrumb-item :to="{ path: '/ruleList' }">
<el-breadcrumb-item>新建上架规则</el-breadcrumb-item> 上架规则
</el-breadcrumb-item>
<el-breadcrumb-item>{{ breadcrumbTitle }}</el-breadcrumb-item>
</el-breadcrumb> </el-breadcrumb>
<h3> <h3>
<span>新建上架规则</span> <span>{{ breadcrumbTitle }}</span>
</h3> </h3>
</div> </div>
<div class="section"> <div class="section">
...@@ -29,6 +31,8 @@ ...@@ -29,6 +31,8 @@
show-word-limit show-word-limit
placeholder="请输入上架规则名称" placeholder="请输入上架规则名称"
v-model="ruleForm.ruleTitle" v-model="ruleForm.ruleTitle"
clearable
@clear="ruleForm.ruleTitle=''"
style="width:340px" style="width:340px"
/> />
</el-form-item> </el-form-item>
...@@ -41,35 +45,18 @@ ...@@ -41,35 +45,18 @@
style="width:340px" style="width:340px"
/> />
</el-form-item> </el-form-item>
<el-form-item label="适用人群" prop="activityTime"> <el-form-item label="适用人群" prop="memberType">
<el-radio v-model="ruleForm.memberType" :label="1"> <el-radio v-model="ruleForm.memberType" :label="1">
全部会员 全部会员
</el-radio> </el-radio>
<el-radio v-model="ruleForm.memberType" :label="2">
会员分组
</el-radio>
<el-radio v-model="ruleForm.memberType" :label="3"> <el-radio v-model="ruleForm.memberType" :label="3">
会员筛选 会员筛选
</el-radio> </el-radio>
</el-form-item> </el-form-item>
<el-form-item v-if="ruleForm.memberType === 2"> <el-form-item v-show="ruleForm.memberType === 3">
<vue-gic-member-group
style="padding-left:0"
:readonly="readonly"
:height="543"
:defaltSelected="defaltSelected"
:projectName="projectName"
:effectiveStatus="1"
@handleDataTransferred="handleDataTransferred"
@handleDataLeft="handleDataLeft"
/>
</el-form-item>
<el-form-item v-if="ruleForm.memberType === 3">
<vue-gic-people <vue-gic-people
v-bind="storeParams"
:projectName="projectName" :projectName="projectName"
:searchBackTxt.sync="searchBackTxt"
:conditionList.sync="conditionList"
:triggerReset="true" :triggerReset="true"
:useId="useId" :useId="useId"
:hasSearchData="hasSearchData" :hasSearchData="hasSearchData"
...@@ -90,11 +77,12 @@ ...@@ -90,11 +77,12 @@
</el-button> </el-button>
</div> </div>
</el-form-item> </el-form-item>
<div>
<div class="confim-btn" :style="{ width: fixedWidth + 'px' }"> <el-form-item style="margin-top:50px">
<el-button type="primary" size="small" @click="nextStep()"> <el-button type="primary" size="small" @click="submit()">
确认新建 确认新建
</el-button> </el-button>
</el-form-item>
</div> </div>
</el-form> </el-form>
</div> </div>
...@@ -103,15 +91,17 @@ ...@@ -103,15 +91,17 @@
</template> </template>
<script> <script>
import request from '../../../service/request';
export default { export default {
data () { data () {
const activityTimeVal = (rule, value, callback) => { const activityTimeVal = (rule, value, callback) => {
callback(new Error('请填写')); callback(new Error('请填写'));
}; };
return { return {
breadcrumbTitle: '新建上架规则',
fixedWidth: document.documentElement.clientWidth - 200, fixedWidth: document.documentElement.clientWidth - 200,
ruleForm: { ruleForm: {
memberType: 1,
}, },
rules: { rules: {
ruleTitle: [ ruleTitle: [
...@@ -122,58 +112,113 @@ export default { ...@@ -122,58 +112,113 @@ export default {
], ],
}, },
projectName: 'integral-mall', projectName: 'integral-mall',
searchBackTxt: '', // 保存选中的筛选条件用来不走接口查缩略信息
conditionList: [],
useId: '', useId: '',
hasSearchData: '', hasSearchData: '',
sceneValue: 'member', // 场景值 sceneValue: 'member', // 场景值
responseParams: [], // 回显的数据 toggleTag: true,
defaltSelected: [], isEdit: this.$route.meta.type === 'edit',
headerList: ['isRealTime', 'latestUpdateTime', 'updateType', 'effectiveStatus', 'effectiveDate'], // 表头配置,默认全部,分组名称默认显示不可配置 isAdd: this.$route.meta.type === 'add',
isCopy: this.$route.meta.type === 'copy',
}; };
}, },
computed: {
storeParams () {
return !this.isAdd ? { creatorId: this.ruleForm.creatorId } : {};
},
},
mounted () {
console.log(this.$route.params.id);
if (!this.isAdd) {
this.integralMallProRuleId = this.$route.params.id;
this.getDatail(this.$route.params.id);
}
const obj = {
edit: '编辑上架规则',
add: '新建上架规则',
copy: '复制上架规则',
};
this.breadcrumbTitle = obj[this.$route.meta.type];
},
methods: { methods: {
// 子组件触发父组件事件,返回过滤条件数据 /** 人群筛选器 */
findFilter (value) { cancelFilter () { // 取消
this.$refs.peopleFilter.cancelSet();
},
getData () {
this.$refs.peopleFilter.confirmSet();
}, },
// 获取需要回显的数据, 供保存时候使用 // 获取需要回显的数据, 供保存时候使用
getBackData () { getBackData (val) {
console.log(val);
this.ruleForm.searchJson = val;
},
// 显示编辑,保存按钮隐藏,确认按钮显示 (子组件会调用)
editShow () {
console.log('hideBtn');
this.toggleTag = true;
}, },
// 显示保存按钮,隐藏确认按钮显示 (子组件会调用) // 显示保存按钮,隐藏确认按钮显示 (子组件会调用)
editHide () { editHide () {
console.log('hideBtn');
console.log(this.useId);
this.toggleTag = false;
}, },
// 显示编辑,保存按钮隐藏,确认按钮显示 (子组件会调用) // 子组件触发父组件事件,返回过滤条件数据
editShow () { findFilter (value) {
console.log(value);
this.ruleForm.filterJson = value;
}, },
// 隐藏保存按钮和确认按钮 (子组件会调用) // 隐藏保存按钮和确认按钮 (子组件会调用)
// 传个参数给父组件 来查数据 // 传个参数给父组件 来查数据
hideBtn (refresh) { hideBtn () {
console.log('hideBtn');
this.toggleTag = false;
}, },
handleDataTransferred (data) { getDatail (integralMallProRuleId) {
this.defaltSelected = data; request.get('/api-integral-mall/get-rule', { params: { integralMallProRuleId } }).then(res => {
if (res.data.result) {
this.ruleForm = res.data.result;
if (this.ruleForm.memberType == 3) {
this.hasSearchData = this.ruleForm.filterJson;
}
}
});
}, },
handleDataLeft (selectedData, selectionToRemove) { submit () {
this.defaltSelected = selectedData; if (this.ruleForm.memberType === 3) {
if (this.toggleTag && !this.ruleForm.filterJson) {
this.$message.error('请选中人群筛选器的数据');
return false;
}
}
this.$refs.ruleForm.validate(val => {
if (val) {
let params = {};
if (this.isCopy) {
const { ruleTitle, ruleExplanation, filterJson, memberType, searchJson } = this.ruleForm;
params = { ruleTitle, ruleExplanation, memberType, filterJson, searchJson };
} else {
params = this.ruleForm;
}
if (params.memberType == 1) {
delete params.filterJson;
delete params.searchJson;
}
request.get('/api-integral-mall/add-update-rule', { params }).then(res => {
this.$router.go(-1);
});
}
});
}, },
}, },
}; };
</script> </script>
<style scoped> <style scoped>
.confim-btn { .gic-people--button{
height: 32px; background: #f2f3f4;
padding: 12px 0; padding: 0 0 20px 124px;
position: fixed;
bottom: 0px;
left: 200px;
background: #fff;
z-index: 2;
text-align: center;
border-top: 1px solid #dcdfe6;
}
.fix-btn {
margin-left: -100px;
} }
</style> </style>
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
prefix-icon="el-icon-search" prefix-icon="el-icon-search"
clearable clearable
class="w-260" class="w-260"
@keyup.enter.native="getSearchList" @keyup.enter.native="getList"
@clear="getSearchList" @clear="getList"
/> />
</div> </div>
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
type="primary" type="primary"
size="small" size="small"
:disabled="tableDate.length>=20" :disabled="tableDate.length>=20"
@click="addRule" @click="$router.push('/addRule')"
> >
新建上架规则({{ tableDate.length }}/20) 新建上架规则({{ tableDate.length }}/20)
</el-button> </el-button>
...@@ -76,6 +76,12 @@ ...@@ -76,6 +76,12 @@
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="创建时间">
<template slot-scope="{row}">
<p>{{ getTime(row.createTime) }}</p>
<p>{{ getSeconds(row.createTime) }}</p>
</template>
</el-table-column>
<el-table-column <el-table-column
label="操作" label="操作"
> >
...@@ -88,19 +94,19 @@ ...@@ -88,19 +94,19 @@
</el-button> </el-button>
<el-button <el-button
type="text" type="text"
@click="editRule(row)" @click="$router.push('/editRule/' + row.integralMallProRuleId)"
> >
编辑 编辑
</el-button> </el-button>
<el-button <el-button
type="text" type="text"
@click="copyRule(row)" @click="$router.push('/copyRule/' + row.integralMallProRuleId)"
> >
复制 复制
</el-button> </el-button>
<el-button <el-button
type="text" type="text"
@click="delRule(row)" @click="delRelating(row.integralMallProRuleId)"
> >
删除 删除
</el-button> </el-button>
...@@ -108,11 +114,16 @@ ...@@ -108,11 +114,16 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-dialog :title="`${type}关联商品`" :visible.sync="dialogTableVisible" width="850px"> <el-dialog
:title="`${type}关联商品`"
:visible.sync="dialogTableVisible"
width="850px"
:before-close="cancel"
>
<div :class="['infoTips',type=='查看'?'infoTips_waring':'']"> <div :class="['infoTips',type=='查看'?'infoTips_waring':'']">
<i :class="['el-icon-info','infoTipsIcon',type=='查看'?'infoTips_waring':'']" /> <i :class="['el-icon-info','infoTipsIcon',type=='查看'?'infoTips_waring':'']" />
<div class="infoTipsContent"> <div class="infoTipsContent">
{{ type=='查看'?'移除规则后,上架规则不再作用于商品,商品将不能在会员小程序-积分商城上展示,请谨慎操作!':'选中已关联上架规则的商品,则规则被更新' }} {{ type=='查看'?'从规则中移除商品后,上架规则不再作用于商品,商品将不能在会员小程序-积分商城上展示,请谨慎操作!':'选中已关联上架规则的商品,则规则被更新' }}
<br> <br>
</div> </div>
</div> </div>
...@@ -150,11 +161,37 @@ ...@@ -150,11 +161,37 @@
@keyup.enter.native="searchGoods" @keyup.enter.native="searchGoods"
/> />
</div> </div>
<el-button type="primary" size="small" v-if="type=='查看'"> <el-popconfirm
批量移除 title="确认删除吗?"
@confirm="multipleDel"
:loading="btnLoading"
>
<el-button
type="primary"
size="small"
v-if="type=='查看'"
slot="reference"
>
批量移除
</el-button>
</el-popconfirm>
<el-button
type="primary"
size="small"
:loading="btnLoading"
@click="submit"
v-if="type=='选择'"
>
批量添加
</el-button> </el-button>
</div> </div>
<el-table :data="relatingGoodsTable" v-loading="loading" @selection-change="handleSelectionChange"> <el-table
:data="relatingGoodsTable"
v-loading="loading"
@selection-change="handleSelectionChange"
ref="relatingGoodsTable"
@row-click="onRowClick"
>
<el-table-column <el-table-column
type="selection" type="selection"
width="55" width="55"
...@@ -197,14 +234,8 @@ ...@@ -197,14 +234,8 @@
</div> </div>
</div> </div>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button size="small" @click="dialogTableVisible=false">取消</el-button> <el-button size="small" @click="cancel">取消</el-button>
<el-button
type="primary"
size="small"
:loading="btnLoading"
@click="submit"
v-if="type=='选择'"
>确定</el-button>
</span> </span>
</el-dialog> </el-dialog>
</div> </div>
...@@ -214,10 +245,14 @@ ...@@ -214,10 +245,14 @@
<script> <script>
import request from '@/service/request.js'; import request from '@/service/request.js';
import getInputVal from '@/utils/common.js';
export default { export default {
data () { data () {
return { return {
getTime: getInputVal.getTime,
getSeconds: getInputVal.getSeconds,
loading: false, loading: false,
btnLoading: false,
tableDate: [ tableDate: [
], ],
relatingGoodsTable: [ relatingGoodsTable: [
...@@ -241,83 +276,114 @@ export default { ...@@ -241,83 +276,114 @@ export default {
}, },
methods: { methods: {
getList () { getList () {
request.get('/api-integral-mall/list-rule', { ruleTitle: this.ruleTitle }).then(res => { request.get('/api-integral-mall/list-rule', { params: { ruleTitle: this.ruleTitle } }).then(res => {
if (res.data.errorCode === 0) { console.log(res.data.result);
if (res.data.result.result) {
this.tableDate = res.data.result.result; this.tableDate = res.data.result || [];
}
}
}); });
for (let i = 0; i < 19; i++) {
this.tableDate.push(
{
ruleTitle: '新客积分兑换上架规则规则',
ruleExplanation: '上架规则说明内容内容上架规则说明内容内容上架规则说明内容内容',
relationCount: 236,
},
);
}
}, },
relatingDetail (integralMallProRuleId, type) { relatingDetail (integralMallProRuleId, type) {
this.dialogTableVisible = true; this.dialogTableVisible = true;
this.type = type; this.type = type;
this.relateForm.currentPage = 1; this.relateForm.currentPage = 1;
this.relateForm.integralMallProRuleId = integralMallProRuleId; if (type == '查看') {
this.relateForm.integralMallProRuleId = integralMallProRuleId;
}
this.getRelatingGoodsTable(); this.getRelatingGoodsTable();
}, },
editRule (row) { delRelating (integralMallProRuleId) {
this.$router.push({ path: '/editRule', query: { id: row.id } }); this.loading = true;
},
addRule (row) {
this.$router.push({ path: '/addRule' });
},
copyRule (row) {
},
delRelating (row) {
this.$confirm('上架规则删除后,无法被商品关联使用,是否确认删除?', '提示', { this.$confirm('上架规则删除后,无法被商品关联使用,是否确认删除?', '提示', {
confirmButtonText: '确认', confirmButtonText: '确认',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning',
}) })
.then(() => { .then(() => {
this.$message.success('删除成功'); request.get('/api-integral-mall/del-rule', { params: { integralMallProRuleId } }).then(res => {
this.getList(); this.$message.success('删除成功');
this.getList();
}).finally(_ => {
this.loading = false;
});
}); });
}, },
handleSelectionChange (val) { handleSelectionChange (val) {
this.multipleSelection = val; this.multipleSelection = val;
}, },
multipleDel () {
if (!this.multipleSelection.length) {
this.$message.warning('请至少选择一件商品');
return;
}
this.btnLoading = true;
const data = {};
data.integralMallProIdList = this.multipleSelection.map(item => item.integralMallProId);
data.integralMallProRuleId = this.integralMallProRuleId;
request.post('/api-integral-mall/del-rule-pro', data).then(res => {
this.$message.success('删除成功');
this.getRelatingGoodsTable();
}).finally(_ => {
this.btnLoading = false;
});
},
onRowClick (row) {
this.$refs.relatingGoodsTable.toggleRowSelection(row);
},
searchGoods () {
this.relateForm.currentPage = 1;
this.getRelatingGoodsTable();
},
cancel () {
this.dialogTableVisible = false;
this.relateForm = {
search: '',
proType: '',
pageSize: 5,
currentPage: 1,
ruleRelationFlag: '',
};
},
getRelatingGoodsTable () { getRelatingGoodsTable () {
this.loading = true; this.loading = true;
const api = this.type == '选择' ? '/api-integral-mall/page-select-rule-pro' : '/api-integral-mall/page-rule-pro'; if (this.type == '选择') {
// const params = this.type =='选择'? delete this.relateForm.integralMallProRuleId;
request.get(api, { params: this.relateForm }).then(res => { }
if (res.data.errorCode === 0) { const params = this.relateForm;
if (res.data.result.result) { request.get('/api-integral-mall/page-rule-pro', { params }).then(res => {
this.relatingGoodsTable = res.data.result.result; this.relatingGoodsTable = res.data.result.result || [];
this.totalCount = res.data.result.totalCount; this.totalCount = res.data.result.totalCount;
} for (let i = 0; i < 5; i++) {
this.relatingGoodsTable.push({
mallProImageUrl: 'https://pic01-10001430.image.myqcloud.com/f39e4665-db45-487e-847a-673fedddab44',
proName: '上架规则说明内容内容上架规则说明内容内容上架规则说明内容内容',
proCode: 236,
proType: '实物礼品',
costValue: 1000.00,
virtualStock: 1000,
integralMallProId: i,
ruleTitle: '新客积分兑换上架规则规则',
});
} }
}).finally(_ => { }).finally(_ => {
this.loading = false; this.loading = false;
}); });
this.relatingGoodsTable = [];
for (let i = 0; i < 5; i++) {
this.relatingGoodsTable.push({
mallProImageUrl: 'https://pic01-10001430.image.myqcloud.com/f39e4665-db45-487e-847a-673fedddab44',
proName: '上架规则说明内容内容上架规则说明内容内容上架规则说明内容内容',
proCode: 236,
proType: '实物礼品',
costValue: 1000.00,
virtualStock: 1000,
ruleTitle: '新客积分兑换上架规则规则',
});
}
}, },
searchGoods () { submit () {
this.relateForm.currentPage = 1; if (!this.multipleSelection.length) {
this.getRelatingGoodsTable(); this.$message.warning('请至少选择一件商品');
return;
}
this.btnLoading = true;
const data = {};
data.integralMallProIdList = this.multipleSelection.map(item => item.integralMallProId);
data.integralMallProRuleId = this.integralMallProRuleId;
request.post('/api-integral-mall/add-rule-pro', data).then(res => {
this.$message.success('添加成功');
this.getRelatingGoodsTable();
}).finally(_ => {
this.btnLoading = false;
});
}, },
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment