Commit 6e9469c3 authored by chenwei's avatar chenwei

提交积分规则

parent 105d91ea
...@@ -157,3 +157,64 @@ export function editMemberLevel(data) { ...@@ -157,3 +157,64 @@ export function editMemberLevel(data) {
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> <template>
<div class="dict-selector"> <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-select
<el-option v-for="dict in formattedList" v-if="formType == 'select'"
:key="dict.value" :label="$l(dict, 'label')" :value="dict.value"/> v-model="valueSync"
</el-select> :placeholder="placeholder || $t('请选择')"
<el-radio-group v-if="formType == 'radio'" v-model="valueSync" :disabled="disabled"> :clearable="clearable"
<el-radio v-for="dict in formattedList" :label="dict.value" :checked="valueSync === dict.value" :key="dict.value">{{$l(dict, 'label')}}</el-radio> :multiple="multiple"
</el-radio-group> :disabled="disabled"
<el-checkbox-group v-if="formType == 'checkbox'" v-model="valueSync" :disabled="disabled"> @change="(val) => $emit('change', val)"
<el-checkbox v-for="dict in formattedList" :label="dict.value" :key="dict.value">{{$l(dict, 'label')}}</el-checkbox> >
</el-checkbox-group> <el-option
</div> 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> </template>
<script> <script>
const FORMATTERS = { const FORMATTERS = {
"string": String, string: String,
"bool": function(val){ bool: function (val) {
return [false, 'false', 0, "0"].indexOf(val) < 0 return [false, "false", 0, "0"].indexOf(val) < 0;
}, },
'number': Number, number: Number,
'array': function(val){ array: function (val) {
return typeof val == 'string' ? val.split(',').filter(item => item && item !== '') : val return typeof val == "string"
} ? val.split(",").filter((item) => item && item !== "")
} : val;
},
};
export default { export default {
props:{ props: {
placeholder: { placeholder: {
type: String, type: String,
default: null 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
}, },
data(){ type: String,
return { value: [String, Number, Array, Boolean],
valueSync: this.multiple ? [] : null multiple: Boolean,
} formType: {
type: String,
default: "select",
}, },
computed:{ formatter: {
dicts(){ type: [Function, String],
return this.getList(this.type) default: String,
},
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
}
}, },
watch:{ defaultable: Boolean, // 是否默认选择第一个
valueSync(val){ disabled: Boolean,
this.$emit('input', val) /**
}, * 过滤字典项,用于只使用部分字典项的场景
value(val){ */
if(val != this.valueSync)this.setValueSync() filter: {
}, type: Function,
dictList(){ default: () => true,
this.setDefault() },
} 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() watch: {
this.setDefault() valueSync(val) {
this.$emit("input", val);
}, },
methods:{ value(val) {
format(val){ if (val != this.valueSync) this.setValueSync();
if(val === null || val == undefined || val == '') return val },
let formatter = typeof this.formatter == 'function' ? this.formatter : FORMATTERS[this.formatter] dictList() {
if(!formatter){ this.setDefault();
console.warn('格式器无效', this.formatter) },
return val },
} created() {
return formatter(val) this.setValueSync();
}, this.setDefault();
changeValue(val){ },
this.valueSync = val methods: {
}, format(val) {
setValueSync(){ if (val === null || val == undefined || val == "") return val;
if(this.value === null || this.value === undefined || this.value === ''){ let formatter =
return this.valueSync = this.multiple ? [] : this.value typeof this.formatter == "function"
} ? this.formatter
if(this.multiple){ : FORMATTERS[this.formatter];
let value = this.value || [] if (!formatter) {
if(typeof this.value == 'string'){ console.warn("格式器无效", this.formatter);
value = this.value.split(',').filter(item => item && item != '') return val;
} }
this.valueSync = value.map(item => this.format(item)) return formatter(val);
}else{ },
this.valueSync = this.format(this.value) changeValue(val) {
} this.valueSync = val;
}, },
getList(){ setValueSync() {
return this.getDictDatas(this.type) if (
}, this.value === null ||
setDefault(){ this.value === undefined ||
if(!this.defaultable) return this.value === ""
if(this.dictList.length && (this.valueSync === null || this.valueSync == undefined || this.valueSync == '')){ ) {
this.valueSync = this.multiple ? [] : this.formattedList[0].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> </script>
<style scoped> <style scoped>
.dict-selector{ .dict-selector {
display: inline-block; display: inline-block;
} }
</style> </style>
...@@ -251,6 +251,8 @@ export const DICT_TYPE = { ...@@ -251,6 +251,8 @@ export const DICT_TYPE = {
REWARD_REDEEM_STATUS: "reward_redeem_status", //礼品兑换状态 REWARD_REDEEM_STATUS: "reward_redeem_status", //礼品兑换状态
MEMBER_SCORE_OPERATE_TYPE: "member_user_score_log_operate_type", //会员积分日志操作类型 MEMBER_SCORE_OPERATE_TYPE: "member_user_score_log_operate_type", //会员积分日志操作类型
SCORE_RULE_TYPE: "score_rule_type", //积分规则指标类型 SCORE_RULE_TYPE: "score_rule_type", //积分规则指标类型
YES_OR_NO: "yes_or_no",
CLIENT_PLATFORM: "client_platform",
}; };
/** /**
......
...@@ -139,7 +139,7 @@ ...@@ -139,7 +139,7 @@
{{ {{
isChinese isChinese
? handleSourceType(scope.row.sourceType).label ? handleSourceType(scope.row.sourceType).label
: handleholdScore(scope.row.sourceType).labelEn : handleSourceType(scope.row.sourceType).labelEn
}} }}
</template> </template>
</el-table-column> </el-table-column>
......
...@@ -119,11 +119,174 @@ ...@@ -119,11 +119,174 @@
>{{ $t("添加规则") }}</el-button >{{ $t("添加规则") }}</el-button
> >
</el-row> </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> </div>
</template> </template>
<script> <script>
import { getDictDatas, DICT_TYPE } from "@/utils/dict"; 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 { export default {
name: "integralRecord", name: "integralRecord",
data() { data() {
...@@ -131,7 +294,15 @@ export default { ...@@ -131,7 +294,15 @@ export default {
dateRangeCreateTime: [], dateRangeCreateTime: [],
total: 0, total: 0,
loading: true, loading: true,
memberList: [], dialogPostponeVisible: false,
integrationRuleList: [],
postponeIntegralID: "",
postponeDatetime: "",
pickerOptions: {
disabledDate(time) {
return time.getTime() < Date.now() - 8.64e7;
},
},
queryParams: { queryParams: {
type: "", type: "",
title: "", title: "",
...@@ -158,6 +329,73 @@ export default { ...@@ -158,6 +329,73 @@ export default {
this.handleQuery(); this.handleQuery();
}, },
methods: { 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 // new score rule func
handleNewScoreRule() { handleNewScoreRule() {
this.$router.push({ this.$router.push({
...@@ -170,24 +408,45 @@ export default { ...@@ -170,24 +408,45 @@ export default {
(item) => item.value == id (item) => item.value == id
)[0]; )[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 (item) => item.value == id
)[0]; )[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() { handleQuery() {
this.queryParams.page = 1; this.queryParams.page = 1;
let params = { ...this.queryParams }; let params = { ...this.queryParams };
this.addBeginAndEndTime(
params,
this.dateRangeCreateTime,
"createTime",
false
);
getScoreRecordList(params).then((res) => { getScoreRecordList(params).then((res) => {
this.loading = false; this.loading = false;
this.memberList = res.data.list; this.integrationRuleList = res.data.list;
this.total = res.data.total; this.total = res.data.total;
}); });
}, },
...@@ -201,7 +460,7 @@ export default { ...@@ -201,7 +460,7 @@ export default {
); );
getScoreRecordList(params).then((res) => { getScoreRecordList(params).then((res) => {
this.loading = false; this.loading = false;
this.memberList = res.data.list; this.integrationRuleList = res.data.list;
this.total = res.data.total; 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