新增黑名单

This commit is contained in:
dengbw
2023-03-07 14:10:13 +08:00
parent 80be328353
commit cc86158f6e
3 changed files with 280 additions and 1 deletions
+27
View File
@@ -371,3 +371,30 @@ export async function updateActivityVisitTag(data) {
}
return Promise.reject(new Error(res.data.message));
}
/**
* 修改黑名单
* @param data 信息
*/
export async function updateActivityBlacklist(data) {
const res = await request.put('/sylive/activity/blacklist', data);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 导入黑名单
* @param file excel文件
*/
export async function importActivityBlacklist(file, activityId) {
const formData = new FormData();
formData.append('file', file);
formData.append('activityId', activityId);
const res = await request.post('/sylive/activity/blacklist_import', formData);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
@@ -0,0 +1,235 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
width="930px"
:visible="visible"
:append-to-body="true"
:close-on-click-modal="true"
custom-class="ele-dialog-form"
title="修改黑名单"
@update:visible="updateVisible"
>
<el-form ref="form" :model="form" label-width="82px">
<el-form-item label="导入名单:">
<el-upload
drag
action=""
class="ele-block"
v-loading="loading"
accept=".xls,.xlsx"
:show-file-list="false"
:before-upload="doUpload"
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">
将文件拖到此处, <em>点击上传</em>
</div>
<template v-slot:tip>
<div class="el-upload__tip ele-text-center">
<span>只能上传xlsxlsx文件, </span>
<el-link
download
:href="url"
type="primary"
:underline="false"
style="vertical-align: baseline"
>
下载模板
</el-link>
</div>
</template>
</el-upload>
<el-button
icon="el-icon-plus"
style="width: 100%; margin-top: 15px"
@click="addMobile"
>
新增手机号
</el-button>
</el-form-item>
<el-form-item label="名单列表:">
<el-table :data="form.blacklist" :border="true" style="width: 100%">
<el-table-column label="手机号" align="center">
<template v-slot="{ row }">
<el-input
v-if="row.type == 'add'"
v-model="row.mobile"
placeholder="请输入手机号"
/>
{{ row.type != 'add' ? row.mobile : '' }}
</template>
</el-table-column>
<el-table-column
label="操作"
width="70px"
align="center"
:resizable="false"
>
<template v-slot="{ row, $index }">
<span class="ele-action" v-if="row.type != 'del'">
<el-popconfirm
title="确定要删除此手机号?"
@confirm="removeMobile($index)"
>
<template v-slot:reference>
<el-link
icon="el-icon-delete"
type="danger"
:underline="false"
>
删除
</el-link>
</template>
</el-popconfirm>
</span>
<span class="ele-action" v-else>已删除</span>
</template>
</el-table-column>
</el-table>
</el-form-item>
</el-form>
<template v-slot:footer>
<el-button @click="updateVisible(false)">取消</el-button>
<el-button type="primary" :loading="loading" @click="save">
保存
</el-button>
</template>
</ele-modal>
</template>
<script>
import {
updateActivityBlacklist,
importActivityBlacklist
} from '@/api/sylive/activity';
import { API_BASE_URL } from '@/config/setting';
export default {
components: {},
props: {
// 弹窗是否打开
visible: Boolean,
// 修改回显的数据
data: Object
},
data() {
const defaultForm = {
activityId: null,
blacklist: []
};
return {
defaultForm,
// 表单数据
form: { ...defaultForm },
// 提交状态
loading: false,
// 是否是修改
isUpdate: false,
// 导入请求状态
// 导入模板下载地址
url: API_BASE_URL.replace('api', '') + 'temp/blacklist.xlsx'
};
},
computed: {
// 是否开启响应式布局
styleResponsive() {
return this.$store.state.theme.styleResponsive;
}
},
methods: {
/* 上传 */
doUpload(file) {
if (
![
'application/vnd.ms-excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
].includes(file.type)
) {
this.$message.error('只能选择 excel 文件');
return false;
}
if (file.size / 1024 / 1024 > 5) {
this.$message.error('大小不能超过 5MB');
return false;
}
this.loading = true;
importActivityBlacklist(file, this.form.activityId)
.then((msg) => {
this.loading = false;
this.$message.success(msg);
this.updateVisible(false);
this.$emit('done');
})
.catch((e) => {
this.loading = false;
this.$message.error(e.message);
});
return false;
},
/* 保存编辑 */
save() {
this.$refs.form.validate((valid) => {
if (!valid) {
return false;
}
this.loading = true;
const data = {
...this.form
};
updateActivityBlacklist(data)
.then((msg) => {
this.loading = false;
this.$message.success(msg);
this.updateVisible(false);
this.$emit('done');
})
.catch((e) => {
this.loading = false;
this.$message.error(e.message);
});
});
},
/* 添加手机 */
addMobile() {
this.form.blacklist.push({ mobile: '', type: 'add' });
},
/* 删除手机 */
removeMobile(index) {
if (!this.form.blacklist[index].id) {
this.form.blacklist.splice(index, 1);
} else {
this.form.blacklist[index].type = 'del';
}
},
/* 更新visible */
updateVisible(value) {
this.$emit('update:visible', value);
}
},
watch: {
visible(visible) {
if (visible) {
if (this.data) {
this.$util.assignObject(this.form, {
...this.data
});
this.isUpdate = true;
} else {
this.form.blacklist = [];
this.isUpdate = false;
}
} else {
this.$refs.form.clearValidate();
this.form = { ...this.defaultForm };
}
}
}
};
</script>
<style lang="scss" scoped>
.ele-block {
:deep(.el-upload),
:deep(.el-upload-dragger) {
width: 100%;
}
}
</style>
+18 -1
View File
@@ -95,6 +95,9 @@
<el-dropdown-item command="copy">复制活动</el-dropdown-item>
<el-dropdown-item command="draw">抽奖配置</el-dropdown-item>
<el-dropdown-item command="visitTag">回访标签</el-dropdown-item>
<el-dropdown-item command="blacklist" v-if="row.blacklist">
黑名单
</el-dropdown-item>
<!--
<el-dropdown-item command="item">修改权益商品</el-dropdown-item>
<el-dropdown-item command="coupon">修改券</el-dropdown-item>
@@ -143,12 +146,16 @@
:visible.sync="showEditDraw"
@done="reload"
/>
<!-- 抽奖配置弹窗 -->
<activity-visit-tag
:data="current"
:visible.sync="showEditVisitTag"
@done="reload"
/>
<activity-blacklist
:data="current"
:visible.sync="showEditBlacklist"
@done="reload"
/>
</div>
</template>
@@ -160,6 +167,8 @@
import ActivityCoupon from './components/activity-coupon.vue';
import ActivityDraw from './components/activity-draw.vue';
import ActivityVisitTag from './components/activity-visit-tag';
import ActivityBlacklist from './components/activity-blacklist';
import {
pageActivity,
removeActivity,
@@ -172,6 +181,7 @@
export default {
name: 'syliveActivity',
components: {
ActivityBlacklist,
ActivityVisitTag,
QrCode,
ActivitySearch,
@@ -265,6 +275,7 @@
// 是否显示编辑券弹窗
showEditDraw: false,
showEditVisitTag: false,
showEditBlacklist: false,
// 是否显示二维码弹窗
showCode: false
};
@@ -296,6 +307,12 @@
activityId: row.activityId
};
this.showEditVisitTag = true;
} else if (command === 'blacklist') {
this.current = {
blacklist: row.showBlacklist,
activityId: row.activityId
};
this.showEditBlacklist = true;
} else if (command === 'goods') {
this.$router.replace('/sylive/goods?id=' + row.activityId);
} else if (command === 'groups') {