Commit 6e9469c3 authored by chenwei's avatar chenwei

提交积分规则

parent 105d91ea
......@@ -157,3 +157,64 @@ export function editMemberLevel(data) {
data,
});
}
//获得目的国、目的城市、目的仓列表
export function getRegionTreeList() {
return request({
url: "/member/score-rule/warehouse-tree-region-list",
method: "get",
});
}
//获取渠道列表
export function getChannelList() {
return request({
url: "/ecw/channel/list-all-simple",
method: "get",
});
}
//积分规则创建
export function createIntegralRule(data) {
return request({
url: "/member/score-rule/create",
method: "post",
data,
});
}
//启用关闭 积分规则
export function integralRuleStatus(data) {
return request({
url: "/member/score-rule/status",
method: "post",
data,
});
}
//复制积分规则
export function integralRuleCopy(data) {
return request({
url: "/member/score-rule/copy",
method: "post",
data,
});
}
//延期积分规则
export function integralRuleDelay(data) {
return request({
url: "/member/score-rule/delay",
method: "post",
data,
});
}
//删除积分规则
export function integralRuleDelete(data) {
return request({
url: "/member/score-rule/delete",
method: "post",
data,
});
}
<template>
<div class="dict-selector">
<el-select v-if="formType == 'select'" v-model="valueSync" :placeholder="placeholder || $t('请选择')" :clearable="clearable" :multiple="multiple" :disabled="disabled" @change="val => $emit('change', val)">
<el-option v-for="dict in formattedList"
:key="dict.value" :label="$l(dict, 'label')" :value="dict.value"/>
</el-select>
<el-radio-group v-if="formType == 'radio'" v-model="valueSync" :disabled="disabled">
<el-radio v-for="dict in formattedList" :label="dict.value" :checked="valueSync === dict.value" :key="dict.value">{{$l(dict, 'label')}}</el-radio>
</el-radio-group>
<el-checkbox-group v-if="formType == 'checkbox'" v-model="valueSync" :disabled="disabled">
<el-checkbox v-for="dict in formattedList" :label="dict.value" :key="dict.value">{{$l(dict, 'label')}}</el-checkbox>
</el-checkbox-group>
</div>
<div class="dict-selector">
<el-select
v-if="formType == 'select'"
v-model="valueSync"
:placeholder="placeholder || $t('请选择')"
:clearable="clearable"
:multiple="multiple"
:disabled="disabled"
@change="(val) => $emit('change', val)"
>
<el-option
v-for="dict in formattedList"
:key="dict.value"
:label="$l(dict, 'label')"
:value="dict.value"
/>
</el-select>
<el-radio-group
v-if="formType == 'radio'"
v-model="valueSync"
:disabled="disabled"
>
<el-radio
v-for="dict in formattedList"
:label="dict.value"
:checked="valueSync === dict.value"
:key="dict.value"
>{{ $l(dict, "label") }}</el-radio
>
</el-radio-group>
<el-checkbox-group
v-if="formType == 'checkbox'"
v-model="valueSync"
:disabled="disabled"
>
<el-checkbox
v-for="dict in formattedList"
:label="dict.value"
:key="dict.value"
>{{ $l(dict, "label") }}</el-checkbox
>
</el-checkbox-group>
</div>
</template>
<script>
const FORMATTERS = {
"string": String,
"bool": function(val){
return [false, 'false', 0, "0"].indexOf(val) < 0
},
'number': Number,
'array': function(val){
return typeof val == 'string' ? val.split(',').filter(item => item && item !== '') : val
}
}
string: String,
bool: function (val) {
return [false, "false", 0, "0"].indexOf(val) < 0;
},
number: Number,
array: function (val) {
return typeof val == "string"
? val.split(",").filter((item) => item && item !== "")
: val;
},
};
export default {
props:{
placeholder: {
type: String,
default: null
},
type: String,
value: [String, Number, Array, Boolean],
multiple: Boolean,
formType:{
type: String,
default: 'select'
},
formatter: {
type: [Function, String],
default: String
},
defaultable: Boolean, // 是否默认选择第一个
disabled: Boolean,
/**
* 过滤字典项,用于只使用部分字典项的场景
*/
filter: {
type: Function,
default: () => true
},
clearable: Boolean
props: {
placeholder: {
type: String,
default: null,
},
data(){
return {
valueSync: this.multiple ? [] : null
}
type: String,
value: [String, Number, Array, Boolean],
multiple: Boolean,
formType: {
type: String,
default: "select",
},
computed:{
dicts(){
return this.getList(this.type)
},
dictList(){
return this.dicts.filter(this.filter)
},
formattedList(){
let arr = []
this.dictList.forEach(item => {
arr.push({
label: item.label,
labelEn: item.labelEn,
value: this.format(item.value),
cssClass: item.cssClass,
colorType: item.colorType
})
})
return arr
}
formatter: {
type: [Function, String],
default: String,
},
watch:{
valueSync(val){
this.$emit('input', val)
},
value(val){
if(val != this.valueSync)this.setValueSync()
},
dictList(){
this.setDefault()
}
defaultable: Boolean, // 是否默认选择第一个
disabled: Boolean,
/**
* 过滤字典项,用于只使用部分字典项的场景
*/
filter: {
type: Function,
default: () => true,
},
clearable: Boolean,
},
data() {
return {
valueSync: this.multiple ? [] : null,
};
},
computed: {
dicts() {
return this.getList(this.type);
},
dictList() {
return this.dicts.filter(this.filter);
},
formattedList() {
let arr = [];
this.dictList.forEach((item) => {
arr.push({
label: item.label,
labelEn: item.labelEn,
value: this.format(item.value),
cssClass: item.cssClass,
colorType: item.colorType,
});
});
return arr;
},
created(){
this.setValueSync()
this.setDefault()
},
watch: {
valueSync(val) {
this.$emit("input", val);
},
methods:{
format(val){
if(val === null || val == undefined || val == '') return val
let formatter = typeof this.formatter == 'function' ? this.formatter : FORMATTERS[this.formatter]
if(!formatter){
console.warn('格式器无效', this.formatter)
return val
}
return formatter(val)
},
changeValue(val){
this.valueSync = val
},
setValueSync(){
if(this.value === null || this.value === undefined || this.value === ''){
return this.valueSync = this.multiple ? [] : this.value
}
if(this.multiple){
let value = this.value || []
if(typeof this.value == 'string'){
value = this.value.split(',').filter(item => item && item != '')
}
this.valueSync = value.map(item => this.format(item))
}else{
this.valueSync = this.format(this.value)
}
},
getList(){
return this.getDictDatas(this.type)
},
setDefault(){
if(!this.defaultable) return
if(this.dictList.length && (this.valueSync === null || this.valueSync == undefined || this.valueSync == '')){
this.valueSync = this.multiple ? [] : this.formattedList[0].value
}
value(val) {
if (val != this.valueSync) this.setValueSync();
},
dictList() {
this.setDefault();
},
},
created() {
this.setValueSync();
this.setDefault();
},
methods: {
format(val) {
if (val === null || val == undefined || val == "") return val;
let formatter =
typeof this.formatter == "function"
? this.formatter
: FORMATTERS[this.formatter];
if (!formatter) {
console.warn("格式器无效", this.formatter);
return val;
}
return formatter(val);
},
changeValue(val) {
this.valueSync = val;
},
setValueSync() {
if (
this.value === null ||
this.value === undefined ||
this.value === ""
) {
return (this.valueSync = this.multiple ? [] : this.value);
}
if (this.multiple) {
let value = this.value || [];
if (typeof this.value == "string") {
value = this.value.split(",").filter((item) => item && item != "");
}
}
}
this.valueSync = value.map((item) => this.format(item));
} else {
this.valueSync = this.format(this.value);
}
},
getList() {
return this.getDictDatas(this.type);
},
setDefault() {
if (!this.defaultable) return;
if (
this.dictList.length &&
(this.valueSync === null ||
this.valueSync == undefined ||
this.valueSync == "")
) {
this.valueSync = this.multiple ? [] : this.formattedList[0].value;
}
},
},
};
</script>
<style scoped>
.dict-selector{
display: inline-block;
.dict-selector {
display: inline-block;
}
</style>
......@@ -251,6 +251,8 @@ export const DICT_TYPE = {
REWARD_REDEEM_STATUS: "reward_redeem_status", //礼品兑换状态
MEMBER_SCORE_OPERATE_TYPE: "member_user_score_log_operate_type", //会员积分日志操作类型
SCORE_RULE_TYPE: "score_rule_type", //积分规则指标类型
YES_OR_NO: "yes_or_no",
CLIENT_PLATFORM: "client_platform",
};
/**
......
......@@ -4,56 +4,605 @@
:model="queryParams"
ref="queryForm"
size="small"
:rules="rules"
label-width="120px"
>
<el-form-item :label="$t('指标类型')">
<el-form-item :label="$t('指标类型')" prop="type">
<dict-selector
clearable
:type="DICT_TYPE.SCORE_RULE_TYPE"
v-model="queryParams.type"
@change="handleQuery"
>
</dict-selector>
</el-form-item>
<el-row :gutter="10">
<el-col :span="12">
<el-form-item :label="$t('中文标题:')">
<el-form-item :label="$t('中文标题')" prop="titleZh">
<el-input
style="width: 300px"
v-model.trim="queryParams.titleZh"
:placeholder="$t('请输入查找')"
clearable
@keyup.enter.native="handleQuery"
onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')"
/> </el-form-item
></el-col>
<el-col :span="12">
<el-form-item :label="$t('英文标题:')">
<el-form-item :label="$t('英文标题')" prop="titleEn">
<el-input
style="width: 300px"
v-model.trim="queryParams.titleEn"
:placeholder="$t('请输入查找')"
clearable
@keyup.enter.native="handleQuery"
onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')"
/> </el-form-item
></el-col>
</el-row>
<el-row :gutter="10">
<el-col :span="12">
<el-form-item :label="$t('中文封面图')">
<image-upload v-model="queryParams.coverImageZh" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :label="$t('英文封面图')">
<image-upload v-model="queryParams.coverImageEn" />
</el-form-item>
</el-col>
</el-row>
<!-- 分享文案 -->
<el-row :gutter="10">
<el-col :span="12">
<el-form-item :label="$t('中文分享文案 ')" prop="titleZh">
<el-input
type="textarea"
style="width: 300px"
v-model.trim="queryParams.titleZh"
:placeholder="$t('请输入分享文案')"
clearable
onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')"
/> </el-form-item
></el-col>
<el-col :span="12">
<el-form-item :label="$t('英文分享文案')" prop="titleEn">
<el-input
type="textarea"
style="width: 300px"
v-model.trim="queryParams.titleEn"
:placeholder="$t('请输入分享文案')"
clearable
onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')"
/> </el-form-item
></el-col>
</el-row>
<el-form-item v-if="queryParams.type == '1'" :label="$t('首单')">
<el-radio-group v-model="queryParams.extraOrderV.firstOrder">
<el-radio
v-for="dict in getDictDatas(DICT_TYPE.YES_OR_NO)"
:key="dict.value"
:label="dict.value"
>{{ $l(dict, "label") }}</el-radio
>
</el-radio-group>
</el-form-item>
<el-form-item
:label="$t('运输方式')"
v-if="queryParams.type == '1'"
prop="extraOrderV.transportType"
>
<dict-selector
clearable
:type="DICT_TYPE.TRANSPORT_TYPE"
v-model="queryParams.extraOrderV.transportType"
>
</dict-selector>
</el-form-item>
<el-form-item
:label="$t('提货点')"
v-if="queryParams.type == '1'"
prop="extraOrderV.receiveAddrList"
>
<el-cascader
v-if="cascaderState"
style="width: 400px"
:options="regionTreeList"
v-model="queryParams.extraOrderV.receiveAddrList"
:props="cascaderProps"
clearable
></el-cascader>
</el-form-item>
<el-form-item
:label="$t('渠道')"
v-if="queryParams.extraOrderV.transportType == '3'"
>
<el-select v-model="queryParams.channel" multiple placeholder="请选择">
<el-option
v-for="item in channelList"
:key="item.channelId"
:label="isChinese ? item.nameZh : item.nameEn"
:value="item.channelId"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item
:label="$t('积分规则')"
v-if="queryParams.type == '1'"
required
>
<el-row
type="flex"
justify="start"
v-for="(item, index) in queryParams.extraOrderV.orderVRule"
>
<el-col :span="2">
<el-form-item
:prop="'extraOrderV.orderVRule.' + index + '.low'"
:rules="rules.extraOrderV.orderVRule.low"
>
<el-input
style="width: 100px"
v-model.number="item.low"
></el-input
></el-form-item>
</el-col>
<el-col :span="1">
{{ queryParams.transportType == "3" ? "kg" : "" }} {{ $t("") }}
</el-col>
<el-col :span="2">
<el-form-item
:prop="'extraOrderV.orderVRule.' + index + '.high'"
:rules="rules.extraOrderV.orderVRule.high"
>
<el-input
style="width: 100px"
v-model.number="item.high"
></el-input> </el-form-item
></el-col>
<el-col :span="1">
{{ queryParams.transportType == "3" ? "kg" : "" }} =
</el-col>
<el-col :span="2">
<el-form-item
:prop="'extraOrderV.orderVRule.' + index + '.score'"
:rules="rules.extraOrderV.orderVRule.score"
><el-input
style="width: 100px"
v-model.number="item.score"
></el-input
></el-form-item>
</el-col>
<el-col :span="1">
{{ $t("积分") }}
</el-col>
<el-col :span="1">
<el-button
type="primary"
:icon="index == '0' ? 'el-icon-plus' : 'el-icon-minus'"
@click="handleOrderVRule(item, index)"
></el-button>
</el-col>
</el-row>
</el-form-item>
<!-- 除v值之外的积分规则 -->
<el-form-item
v-if="queryParams.type != '1'"
:label="$t('积分规则')"
prop="getScoreOnce"
>
<el-input
style="width: 300px"
v-model.number="queryParams.getScoreOnce"
:placeholder="$t('请输入数字')"
clearable
onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')"
/>
</el-form-item>
<el-form-item v-if="queryParams.type != '2'" :label="$t('累计最高积分')">
<el-input
style="width: 300px"
v-model.number="queryParams.maxScoreTotal"
:placeholder="$t('请输入累计最高积分')"
clearable
onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')"
/>
</el-form-item>
<el-form-item
v-if="queryParams.type == '1'"
:label="$t('订单入口')"
prop="extraOrderV.orderEntry"
>
<dict-selector
clearable
:multiple="true"
:type="DICT_TYPE.PLATFORM_TYPE"
v-model="queryParams.extraOrderV.orderEntry"
>
</dict-selector>
</el-form-item>
<el-form-item
:label="$t('活动有效期')"
prop="dateRangeCreateTime"
:rules="rules.dateRangeCreateTime"
>
<el-date-picker
type="datetimerange"
clearable
placement="bottom-start"
v-model="queryParams.dateRangeCreateTime"
style="width: 240px"
value-format="yyyy-MM-dd HH:mm:ss"
range-separator="-"
:start-placeholder="$t('开始日期')"
:end-placeholder="$t('结束日期')"
/>
</el-form-item>
<el-form-item :label="$t('积分有效期')" prop="scorePeriod">
<el-input
v-model.number="queryParams.scorePeriod"
:placeholder="$t('请输入积分有效期天数')"
clearable
onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')"
/>
</el-form-item>
<el-form-item :label="$t('排序')" prop="orderNum">
<el-input
v-model.number="queryParams.orderNum"
:placeholder="$t('请输入排序')"
clearable
onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')"
/>
</el-form-item>
<el-row :gutter="10">
<el-col :span="12">
<el-form-item :label="$t('中文规则说明')" prop="descZh">
<el-input type="textarea" v-model="queryParams.descZh"></el-input>
</el-form-item>
<span class="del-btn">{{
$t("注:此说明用于展示给会员查看积分原因,请规范填写")
}}</span>
</el-col>
<el-col :span="12">
<el-form-item :label="$t('英文规则说明')" prop="descEn">
<el-input type="textarea" v-model="queryParams.descEn"></el-input>
</el-form-item>
<span class="del-btn">{{
$t("注:此说明用于展示给会员查看积分原因,请规范填写")
}}</span>
</el-col>
</el-row>
<el-form-item :label="$t('是否推送')" prop="pushActivity">
<el-radio-group v-model="queryParams.pushActivity">
<el-radio
v-for="dict in getDictDatas(DICT_TYPE.YES_OR_NO)"
:key="dict.value"
:label="dict.value"
>{{ $l(dict, "label") }}</el-radio
>
</el-radio-group>
</el-form-item>
<el-form-item :label="$t('展示平台')">
<dict-selector
clearable
formType="checkbox"
:multiple="true"
:type="DICT_TYPE.PLATFORM_TYPE"
v-model="queryParams.showPlatform"
>
</dict-selector>
</el-form-item>
<el-form-item
v-if="queryParams.type == '2'"
:label="$t('注册平台')"
prop="extraRegister.registerPlatform"
>
<dict-selector
clearable
:multiple="true"
:type="DICT_TYPE.CLIENT_PLATFORM"
v-model="queryParams.extraRegister.registerPlatform"
>
</dict-selector>
</el-form-item>
</el-form>
<el-row justify="end" :gutter="20" type="flex">
<el-col :span="3">
<el-button type="primary" @click="handleSaveIntegralRule">{{
$t("保存")
}}</el-button>
</el-col>
<el-col :span="3">
<el-button type="primary" @click="handleEnableIntegralRule">{{
$t("保存并启用")
}}</el-button>
</el-col>
<el-col :span="3">
<el-button type="primary" @click="handleResetIntegralRule">{{
$t("重置")
}}</el-button>
</el-col>
<el-col :span="3">
<el-button @click="handleGoBack">{{ $t("返回") }}</el-button>
</el-col>
</el-row>
</div>
</template>
<script>
import { getDictDatas, DICT_TYPE } from "@/utils/dict";
import { queryMemberScoreRecord } from "@/api/ecw/memberManagement";
import {
queryMemberScoreRecord,
getRegionTreeList,
getChannelList,
createIntegralRule,
} from "@/api/ecw/memberManagement";
import { deepClone } from "@/utils/index";
import ImageUpload from "@/components/ImageUpload";
export default {
name: "addIntegrationRuleOperation",
components: {
ImageUpload,
},
data() {
var validatePass2 = (rule, value, callback) => {
const index = Number(rule.field.split(".")[2]);
if (index == "0") {
if (
this.queryParams.extraOrderV.orderVRule[index].low >=
this.queryParams.extraOrderV.orderVRule[index].high &&
this.queryParams.extraOrderV.orderVRule[index].high
) {
callback(this.$t("开始积分应小于本次最终积分"));
} else {
callback();
}
} else if (index > "0") {
if (
this.queryParams.extraOrderV.orderVRule[index].low >=
this.queryParams.extraOrderV.orderVRule[index].high &&
this.queryParams.extraOrderV.orderVRule[index].high
) {
callback(this.$t("开始积分应小于本次最终积分"));
} else if (
this.queryParams.extraOrderV.orderVRule[index].low <=
this.queryParams.extraOrderV.orderVRule[index - 1].high
) {
callback(this.$t("开始积分应大于上一次最终积分"));
} else {
callback();
}
} else {
callback();
}
};
var validatehigh = (rule, value, callback) => {
const index = Number(rule.field.split(".")[2]);
if (index == "0") {
if (
this.queryParams.extraOrderV.orderVRule[index].low &&
this.queryParams.extraOrderV.orderVRule[index].low >=
this.queryParams.extraOrderV.orderVRule[index].high
) {
callback(this.$t("本次最终积分应大于本次开始积分"));
} else if (
this.queryParams.extraOrderV.orderVRule[index + 1] &&
this.queryParams.extraOrderV.orderVRule[index + 1].low &&
this.queryParams.extraOrderV.orderVRule[index + 1].low <=
this.queryParams.extraOrderV.orderVRule[index].high
) {
callback(this.$t("本次最终积分应小于下一次开始积分"));
} else {
callback();
}
} else if (index > "0") {
if (
this.queryParams.extraOrderV.orderVRule[index].low &&
this.queryParams.extraOrderV.orderVRule[index].low >=
this.queryParams.extraOrderV.orderVRule[index].high
) {
callback(this.$t("本次最终积分应大于本次开始积分"));
} else if (
this.queryParams.extraOrderV.orderVRule[index].high <=
this.queryParams.extraOrderV.orderVRule[index + 1].low
) {
callback(this.$t("本次最终积分应小于下一次开始积分"));
} else {
callback();
}
} else {
callback();
}
};
return {
cascaderState: true,
channelList: [],
regionTreeList: [],
rules: {
pushActivity: [
{
required: true,
message: this.$t("请选择是否推送"),
trigger: "change",
},
],
getScoreOnce: [
{
required: true,
message: this.$t("请输入积分规则"),
trigger: "blur",
},
{
type: "number",
message: this.$t("请输入整数"),
trigger: "blur",
},
],
descEn: [
{
required: true,
message: this.$t("请输入英文规则说明"),
trigger: "blur",
},
],
descZh: [
{
required: true,
message: this.$t("请输入中文规则说明"),
trigger: "blur",
},
],
titleZh: [
{
required: true,
message: this.$t("请输入中文标题"),
trigger: "blur",
},
],
titleEn: [
{
required: true,
message: this.$t("请输入中文标题"),
trigger: "blur",
},
],
orderNum: [
{
required: true,
message: this.$t("请输入排序"),
trigger: "blur",
},
{
type: "number",
message: this.$t("请输入整数"),
trigger: "blur",
},
],
scorePeriod: [
{
type: "number",
message: this.$t("请输入整数"),
trigger: "blur",
},
{
required: true,
message: this.$t("请输入积分有效天数"),
trigger: "blur",
},
],
type: [
{
required: true,
message: this.$t("请选择指标类型"),
trigger: "change",
},
],
dateRangeCreateTime: [
{
required: true,
message: this.$t("请选择活动有效期"),
trigger: "change",
},
],
//推荐
//v值
extraOrderV: {
orderEntry: [
{ required: true, message: "请选择订单入口", trigger: "change" },
],
transportType: [
{ required: true, message: "请选择运输方式", trigger: "change" },
],
receiveAddrList: [
{ required: true, message: "请选择提货点", trigger: "change" },
],
orderVRule: {
low: [
{
required: true,
message: this.$t("不能为空"),
trigger: "blur",
},
{
type: "number",
message: this.$t("请输入整数"),
trigger: "blur",
},
{ validator: validatePass2, trigger: "blur" },
],
score: [
{
required: true,
message: this.$t("不能为空"),
trigger: "blur",
},
{
type: "number",
message: this.$t("请输入整数"),
trigger: "blur",
},
],
high: [
{
required: true,
message: this.$t("不能为空"),
trigger: "blur",
},
{
type: "number",
message: this.$t("请输入整数"),
trigger: "blur",
},
{ validator: validatehigh, trigger: "blur" },
],
},
},
//注册
extraRegister: {
registerPlatform: [
{
required: true,
message: this.$t("请选择注册平台"),
trigger: "change",
},
],
},
},
queryParams: {
type: "",
dateRangeCreateTime: [], //活动有效期
type: "", //指标类型
titleZh: "",
titleEn: "",
maxScoreTotal: "",
endTime: "",
startTime: "", //活动开始时间
scorePeriod: "", //积分有效期
orderNum: "", //排序
descZh: "",
pushActivity: "0", //是否推送(0是,1否)默认是
descEn: "",
getScoreOnce: "", //除v值之外的积分规则
showPlatform: "1,2,3", //展示平台
extraRecommend:{ //推荐
shareContentEn:"",
shareContentZh:"",
shareStatus:""
},
extraRegister: {
// 注册扩展字段
registerPlatform: "",
},
extraOrderV: {
//订单V值扩展字段
firstOrder: "1",
transportType: "", //运输方式
receiveAddrList: [],
orderVRule: [{ low: "", high: "", score: "" }],
},
},
};
},
......@@ -61,10 +610,122 @@ export default {
isChinese() {
return this.$i18n.locale === "zh_CN";
},
cascaderProps() {
const label = this.isChinese ? "labelZh" : "labelEn";
return { multiple: true, value: "id", label };
},
},
watch: {
"queryParams.dateRangeCreateTime": {
handler: function (newVal, oldVal) {
this.$nextTick(() => {
if (newVal.length > 0) {
this.queryParams.startTime = newVal[0];
this.queryParams.endTime = newVal[1];
} else {
this.queryParams.startTime = "";
this.queryParams.endTime = "";
}
});
},
immediate: true,
},
isChinese: {
handler: function (newVal, oldVal) {
this.cascaderState = false;
this.$nextTick(() => {
this.cascaderState = true;
});
},
immediate: true,
},
},
created() {
this.handleGetChannelList();
this.handleGetRegionTreeList();
},
created() {},
activated() {},
methods: {
//重置按钮操作
handleResetIntegralRule() {
this.$modal
.confirm(this.$t("是否确认重置此礼品规则表单"), this.$t("提示"))
.then(() => {
this.$refs["queryForm"].resetFields();
this.$modal.msgSuccess(this.$t("重置成功"));
})
.catch(() => {});
},
//返回按钮操作
handleGoBack() {
this.$modal
.confirm(this.$t("是否确认返回"), this.$t("提示"))
.then(() => {
this.$router.go(-1);
this.$modal.msgSuccess(this.$t("成功"));
})
.catch(() => {});
},
//保存
handleSaveIntegralRule() {
let params = deepClone(this.queryParams);
params.showPlatform = this.queryParams.showPlatform?.join();
params.extraOrderV.orderEntry =
this.queryParams.extraOrderV.orderEntry?.join();
params.extraRegister.registerPlatform =
this.queryParams.extraRegister.registerPlatform?.join();
params.status = this.queryParams.status || "2";
createIntegralRule(params).then((res) => {
this.$message.success(this.$t("成功"));
this.$router.go(-1);
});
},
//保存并启用
handleEnableIntegralRule() {
let params = deepClone(this.queryParams);
params.showPlatform = this.queryParams.showPlatform?.join();
params.extraOrderV.orderEntry =
this.queryParams.extraOrderV.orderEntry?.join();
params.extraRegister.registerPlatform =
this.queryParams.extraRegister.registerPlatform?.join();
params.status = this.queryParams.status || "1";
createIntegralRule(params).then((res) => {
this.$message.success(this.$t("成功"));
this.$router.go(-1);
});
},
handleOrderVRule(item, index) {
if (index == "0") {
this.queryParams.extraOrderV.orderVRule.push({
low: "",
high: "",
score: "",
});
} else {
this.queryParams.extraOrderV.orderVRule.splice(index, 1);
}
},
//获取渠道列表
handleGetChannelList() {
getChannelList().then((res) => {
this.channelList = res.data;
});
},
//获取目的仓列表
handleGetRegionTreeList() {
getRegionTreeList().then((res) => {
this.regionTreeList = res.data;
});
},
traverseTree(tree, newVal) {
for (let node of tree) {
node.labeluu = newVal ? node.labelZh : node.labelEn;
if (node.children && node.children.length > 0) {
this.traverseTree(node.children); // 递归遍历子节点
}
}
return tree;
},
//积分来源
handleSourceType(id) {
return this.getDictDatas(DICT_TYPE.SCORE_RULE_TYPE).filter(
......@@ -74,3 +735,9 @@ export default {
},
};
</script>
<style lang="scss" scoped>
.del-btn {
color: red;
padding-left: 120px;
}
</style>
......@@ -139,7 +139,7 @@
{{
isChinese
? handleSourceType(scope.row.sourceType).label
: handleholdScore(scope.row.sourceType).labelEn
: handleSourceType(scope.row.sourceType).labelEn
}}
</template>
</el-table-column>
......
......@@ -119,11 +119,174 @@
>{{ $t("添加规则") }}</el-button
>
</el-row>
<el-table
ref="multipleTable"
v-loading="loading"
:data="integrationRuleList"
>
<el-table-column width="140" :label="$t('指标类型')" align="center">
<template slot-scope="scope">
{{
isChinese
? handleSourceType(scope.row.type).label
: handleSourceType(scope.row.type).labelEn
}}
</template>
</el-table-column>
<el-table-column
:label="$t('标题')"
align="center"
:prop="isChinese ? 'titleZh' : 'titleEn'"
></el-table-column>
<el-table-column :label="$t('开始时间')" align="center">
<template v-slot="{ row }">
{{ parseTime(row.startTime) || "/" }}</template
>
</el-table-column>
<el-table-column :label="$t('结束时间')" align="center">
<template v-slot="{ row }">
{{ parseTime(row.endTime) || "/" }}</template
>
</el-table-column>
<el-table-column
:label="$t('单次积分')"
align="center"
prop="getScoreOnce"
>
</el-table-column>
<el-table-column
:label="$t('累计最高积分')"
align="center"
prop="maxScoreTotal"
>
</el-table-column>
<el-table-column
:label="$t('规则说明')"
align="center"
:prop="isChinese ? 'descZh' : 'descEn'"
>
</el-table-column>
<el-table-column :label="$t('展示平台')" align="center">
<template v-slot="{ row }">
{{ handlePlatform(row.showPlatform) || "/" }}</template
>
</el-table-column>
<el-table-column :label="$t('状态')" align="center">
<template v-slot="{ row }">
{{ $l(handleStatus(row.status), "label") || "/" }}</template
>
</el-table-column>
<el-table-column :label="$t('创建人')" align="center" prop="creator">
</el-table-column>
<el-table-column :label="$t('创建时间')" align="center">
<template v-slot="{ row }">
{{ parseTime(row.createTime) || "/" }}</template
>
</el-table-column>
<el-table-column :label="$t('最后更新人')" align="center" prop="updater">
</el-table-column>
<el-table-column :label="$t('最后更新时间')" align="center">
<template v-slot="{ row }">
{{ parseTime(row.updateTime) || "/" }}</template
>
</el-table-column>
<el-table-column width="220px" :label="$t('操作')" align="center">
<template slot-scope="scope">
<el-button size="mini" type="text" @click="handleUpdate(scope.row)">{{
$t("查看")
}}</el-button>
<el-button
size="mini"
type="text"
:disabled="scope.row.status != '1'"
@click="handleCloseButton(scope.row)"
>{{ $t("关闭") }}</el-button
>
<el-button
size="mini"
type="text"
@click="handleCopyButton(scope.row)"
>{{ $t("复制") }}</el-button
>
<el-button
size="mini"
type="text"
:disabled="scope.row.status != '1'"
@click="handleDelayButton(scope.row)"
>{{ $t("延期") }}</el-button
>
<el-button
size="mini"
:disabled="scope.row.status != '2'"
type="text"
@click="handleDelete(scope.row)"
>{{ $t("删除") }}</el-button
>
<el-button
size="mini"
type="text"
:disabled="scope.row.status == '1'"
@click="handleDelete(scope.row)"
>{{ $t("编辑") }}</el-button
>
<el-button
size="mini"
type="text"
@click="handleEnabledStatus(scope.row)"
>{{ $t("启用") }}</el-button
>
</template>
</el-table-column>
</el-table>
<!-- //分页列表 -->
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.rows"
@pagination="handleQueryPagination"
/>
<el-dialog
:title="$t('提示')"
:visible.sync="dialogPostponeVisible"
width="30%"
>
<el-row class="mb8">{{ $t("请选择延期时间") }}</el-row>
<el-date-picker
type="datetime"
clearable
v-model="postponeDatetime"
style="width: 240px"
value-format="yyyy-MM-dd HH:mm:ss"
:picker-options="pickerOptions"
:placeholder="$t('请选择时间')"
></el-date-picker>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogPostponeVisible = false">{{
$t("取 消")
}}</el-button>
<el-button type="primary" @click="confirmPostponeIntegral">{{
$t("确 定")
}}</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import { getDictDatas, DICT_TYPE } from "@/utils/dict";
import { getScoreRecordList } from "@/api/ecw/memberManagement";
import {
getScoreRecordList,
integralRuleStatus,
integralRuleCopy,
integralRuleDelay,
integralRuleDelete,
} from "@/api/ecw/memberManagement";
export default {
name: "integralRecord",
data() {
......@@ -131,7 +294,15 @@ export default {
dateRangeCreateTime: [],
total: 0,
loading: true,
memberList: [],
dialogPostponeVisible: false,
integrationRuleList: [],
postponeIntegralID: "",
postponeDatetime: "",
pickerOptions: {
disabledDate(time) {
return time.getTime() < Date.now() - 8.64e7;
},
},
queryParams: {
type: "",
title: "",
......@@ -158,6 +329,73 @@ export default {
this.handleQuery();
},
methods: {
//延期按钮操作
handleDelayButton(row) {
this.postponeIntegralID = row.id;
this.dialogPostponeVisible = true;
},
confirmPostponeIntegral() {
integralRuleDelay({
id: this.postponeIntegralID,
endTime: this.postponeDatetime,
}).then((res) => {
this.postponeDatetime = "";
this.$modal.msgSuccess(this.$t("延期成功"));
});
},
//删除按钮操作
handleDelete(row) {
this.$modal
.confirm(this.$t("是否确认删除此礼品规则"))
.then(function () {
return integralRuleDelete({ id: row.id });
})
.then(() => {
this.handleQuery();
this.$modal.msgSuccess(this.$t("删除成功"));
})
.catch(() => {});
},
//启用按钮操作
handleEnabledStatus(row) {
this.$modal
.confirm(this.$t("是否确认启用此礼品规则"))
.then(function () {
return integralRuleStatus({ id: row.id, status: "1" });
})
.then(() => {
this.handleQuery();
this.$modal.msgSuccess(this.$t("启用成功"));
})
.catch(() => {});
},
//复制按钮操作
handleCopyButton(row) {
this.$modal
.confirm(this.$t("是否确认复制礼品规则"))
.then(function () {
return integralRuleCopy({ id: row.id });
})
.then(() => {
this.handleQuery();
this.$modal.msgSuccess(this.$t("复制成功"));
})
.catch(() => {});
},
//关闭按钮操作
handleCloseButton(row) {
this.$modal
.confirm(this.$t("是否确认关闭此礼品规则"))
.then(function () {
return integralRuleStatus({ id: row.id, status: "3" });
})
.then(() => {
this.handleQuery();
this.$modal.msgSuccess(this.$t("关闭成功"));
})
.catch(() => {});
},
// new score rule func
handleNewScoreRule() {
this.$router.push({
......@@ -170,24 +408,45 @@ export default {
(item) => item.value == id
)[0];
},
handleholdScoreStatus(id) {
return this.getDictDatas(DICT_TYPE.MEMBER_SCORE_OPERATE_TYPE).filter(
// 活动状态
handleStatus(id) {
return this.getDictDatas(DICT_TYPE.GIFT_STATUS).filter(
(item) => item.value == id
)[0];
},
arraysEqual(arr1, arr2) {
return arr1.filter((current) => {
return arr2.find((item) => item == current.value.toString())
? true
: false;
});
},
//展示平台
handlePlatform(platformId) {
let platformIdLabel = [];
if (this.isChinese) {
this.arraysEqual(
this.getDictDatas(DICT_TYPE.PLATFORM_TYPE),
platformId.split(",")
).forEach((element) => {
platformIdLabel.push(element.label);
});
} else {
this.arraysEqual(
this.getDictDatas(DICT_TYPE.PLATFORM_TYPE),
platformId.split(",")
).forEach((element) => {
platformIdLabel.push(element.labelEn);
});
}
return platformIdLabel.join();
},
handleQuery() {
this.queryParams.page = 1;
let params = { ...this.queryParams };
this.addBeginAndEndTime(
params,
this.dateRangeCreateTime,
"createTime",
false
);
getScoreRecordList(params).then((res) => {
this.loading = false;
this.memberList = res.data.list;
this.integrationRuleList = res.data.list;
this.total = res.data.total;
});
},
......@@ -201,7 +460,7 @@ export default {
);
getScoreRecordList(params).then((res) => {
this.loading = false;
this.memberList = res.data.list;
this.integrationRuleList = res.data.list;
this.total = res.data.total;
});
},
......
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