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",
};
/**
......
......@@ -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