钊-礼品卡

This commit is contained in:
zhaotianfeng 2024-09-09 22:59:21 +08:00
parent 9d8bd25072
commit 0e081c8969
2 changed files with 817 additions and 597 deletions

View File

@ -1,13 +1,53 @@
import request from '@/utils/request'
// 上传文件
export function uploadFile(data,activeNum,interType) {
return request({
url: '/cardGiftActive/importCardInfo?activeNum='+activeNum+'&interType='+interType,
method: 'post',
data: data,
headers: {
'Content-Type': 'multipart/form-data'
}
})
}
// 分页查询列表
export function getList(query) {
return request({
url: 'business/marketingActivity/cardGift',
url: '/cardGiftActive',
method: 'get',
params: query
})
}
//修改
export function updateId(data) {
return request({
url: '/cardGiftActive',
method: 'put',
data: data
})
}
//新增
export function add(data) {
return request({
url: '/cardGiftActive',
method: 'post',
data: data
})
}
//下载模板
export function downloadTemplate() {
return request({
url: 'business/marketingActivity/cardGift/template',
method: 'get',
responseType: 'blob'
})
}
export function getListtj(query) {
return request({
url: 'business/marketingActivity/cardGift/list/11',

View File

@ -3,23 +3,16 @@
<div class="card-box" style="margin-bottom: 20px">
<div class="top-hang">
<div class="d-s">
<el-select v-model="queryParams.cardAmount" clearable style="margin-right: 10px" placeholder="请选择面值">
<el-option
v-for="item in jglist"
:key="item.cardAmount"
:label="item.cardAmount"
:value="item.cardAmount">
</el-option>
</el-select>
<el-select v-model="queryParams.activateStatus" clearable style="margin-right: 10px" placeholder="请选择激活状态">
<el-option
v-for="item in option"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<el-select v-model="queryParams.sailStatus" clearable style="margin-right: 10px" placeholder="请选择出售状态">
<el-input
placeholder="请输入内容"
v-model="queryParams.activeName"
clearable
width="150px"
>
</el-input>
<el-select v-model="queryParams.status" clearable style="margin-left: 10px" placeholder="请选择状态">
<el-option
v-for="item in options"
:key="item.value"
@ -31,7 +24,7 @@
<div class="d-s">
<el-button type="primary" icon="el-icon-search" @click="getlist">查询</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
<el-button type="primary" icon="el-icon-search" >下载模板</el-button>
<el-button type="primary" icon="el-icon-search" @click="downloadTemplate()">下载模板</el-button>
<el-button type="primary" @click="centerDialogVisible =! centerDialogVisible">新增礼品卡活动</el-button>
</div>
@ -46,27 +39,27 @@
>
</el-table-column>
<el-table-column
prop="number"
prop="activeNum"
label="活动编号"
>
</el-table-column>
<el-table-column
prop="cardAmount"
prop="activeName"
label="活动名称"
>
</el-table-column>
<el-table-column
prop="useTime"
prop="cardAmount"
label="礼品卡面值"
>
</el-table-column>
<el-table-column
prop="sailTime"
prop="sumNum"
label="制卡数量"
>
</el-table-column>
<el-table-column
prop="createTime"
prop="lastNum"
label="剩余制卡数量"
>
</el-table-column>
@ -74,24 +67,27 @@
prop="createTime"
label="有效期"
>
<template slot-scope="scope">
{{ scope.row.effectiveTimeStart + '~' + scope.row.effectiveTimeEnd }}
</template>
</el-table-column>
<el-table-column
prop="createTime"
label="关联油品油号"
>
</el-table-column>
<el-table-column
prop="createTime"
prop="pwdType"
label="密码"
>
<template slot-scope="scope">
<span v-if="scope.row.pwdType == 0">免密</span>
<span v-if="scope.row.pwdType == 1">密码</span>
</template>
</el-table-column>
<el-table-column
prop="sailStatus"
prop="status"
label="状态"
>
<template slot-scope="scope">
<span v-if="scope.row.sailStatus == 1">已售</span>
<span v-if="scope.row.sailStatus != 1">未售</span>
<span v-if="scope.row.status == 0">待上传</span>
<span v-if="scope.row.status == 1">待加密</span>
<span v-if="scope.row.status == 2">生效中</span>
</template>
</el-table-column>
<el-table-column
@ -106,27 +102,28 @@
<div style="display: flex;flex-wrap: wrap">
<el-button
type="text"
>修改</el-button>
@click="updateId(scope.row)"
>修改
</el-button>
<el-button
type="text"
@click="uploadShow()"
>上传礼品卡数据</el-button>
@click="uploadShow(scope.row)"
>上传礼品卡数据
</el-button>
<el-button
type="text"
@click="Encryption =! Encryption"
>密码加密</el-button>
>密码加密
</el-button>
<el-button
type="text"
@click="orderShow =! orderShow"
>查看订单信息</el-button>
>查看订单信息
</el-button>
</div>
</template>
</el-table-column>
<!-- <el-table-column
prop="remark"
label="备注信息"
width="280">
</el-table-column>-->
</el-table>
<pagination
v-show="total>0"
@ -214,27 +211,79 @@
title="上传礼品卡数据"
:visible.sync="uploadingShow"
width="40%"
@close="handleClose2"
>
<el-form :model="ruleForm2" :rules="rules2" ref="ruleForm2" label-width="100px" class="demo-ruleForm">
<el-form-item label="活动编号" prop="activeNum">
<el-input v-model="ruleForm2.activeNum"></el-input>
</el-form-item>
<el-form-item label="上传数据形式">
<div class="d-s">
<div class="icon-type" v-for="(item,index) in modalitylsit2" :key="index"
:class="{ 'acvtive' : index === tindex2 }" @click="Typeindex2(index)">
<img src="../../../assets/images/wx.png" style="width: 20px;height: 20px" v-if="index != tindex2">
<img src="../../../assets/images/xz.png" style="width: 20px;height: 20px" v-if="index == tindex2">
{{ item }}
</div>
</div>
</el-form-item>
<el-form-item label="文件" prop="activeNum">
<el-upload
:action=uploadUrl
ref="upload2"
class="upload-demo"
drag
:auto-upload="false"
:before-upload="beforeUpload"
:on-success="handleSuccess"
:on-error="handleError"
:on-exceed="handleExceed"
:file-list="fileList2"
:limit="1"
:on-change="handleChange"
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip" slot="tip">
<span>上传文件必须符合模板格式请下载
<a @click="downloadTemplate" style="color:blue">导入模板</a>
</span>
</div>
</el-upload>
<el-button @click="uploadingShow = false">取消</el-button>
<el-button type="primary" @click="submitUpload">导入</el-button>
</el-form-item>
</el-form>
</el-dialog>
<el-dialog
title="新增/修改礼品卡活动"
:visible.sync="centerDialogVisible"
width="40%"
@close="handleClose1"
>
<el-form :model="ruleForm" :rules="rules" :label-position="labelPosition" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="活动编号" prop="quantity">
<el-input v-model="ruleForm.quantity"></el-input>
<el-form ref="formName" :model="ruleForm" :rules="rules" :label-position="labelPosition" label-width="100px"
class="demo-ruleForm">
<el-form-item label="活动编号" prop="activeNum">
<el-input v-model="ruleForm.activeNum"></el-input>
</el-form-item>
<el-form-item label="活动名称" prop="quantity">
<el-input v-model="ruleForm.name"></el-input>
<el-form-item label="活动名称" prop="activeName">
<el-input v-model="ruleForm.activeName"></el-input>
</el-form-item>
<el-form-item label="礼品卡面值" prop="quantity">
<el-input placeholder="请输入内容" v-model="ruleForm.name">
<el-form-item label="礼品卡面值" prop="cardAmount">
<el-input placeholder="请输入内容" v-model="ruleForm.cardAmount">
<template slot="append"></template>
</el-input>
</el-form-item>
<el-form-item label="有效期" prop="quantity">
<el-form-item label="有效期" prop="value1">
<el-date-picker
v-model="ruleForm.value1"
type="datetimerange"
@ -243,51 +292,30 @@
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item label="关联油品油号" prop="name" >
<div class="d-s">
<div class="icon-type" v-for="(item,index) in oillist" :key="index"
:class="{ 'acvtive' : index === tindex }" @click="Typeindex(index)">
<img src="../../../assets/images/wx.png" style="width: 20px;height: 20px" v-if="index != tindex">
<img src="../../../assets/images/xz.png" style="width: 20px;height: 20px" v-if="index == tindex">
{{ item }}
</div>
<el-select v-model="ruleForm.value" placeholder="请选择">
<el-option
v-for="item in oilnumlist"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
<el-form-item label="卡类型" prop="cardType">
<el-select v-model="ruleForm.cardType" placeholder="请选择投放类型" style="width: 300px">
<el-option v-for="dict in dict.type.card_gift_type" :key="dict.value" :label="dict.label"
:value="dict.value"/>
</el-select>
</div>
</el-form-item>
<el-form-item label="卡类型" prop="quantity">
<el-date-picker
v-model="ruleForm.value1"
type="datetimerange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item label="关联油品油号" prop="name" >
<el-form-item label="密码形式" prop="name">
<div class="d-s">
<div class="icon-type" v-for="(item,index) in modalitylsit" :key="index"
:class="{ 'acvtive' : index === tindex }" @click="Typeindex(index)">
:class="{ 'acvtive' : index === tindex }" @click="Typeindex2(index)">
<img src="../../../assets/images/wx.png" style="width: 20px;height: 20px" v-if="index != tindex">
<img src="../../../assets/images/xz.png" style="width: 20px;height: 20px" v-if="index == tindex">
{{ item }}
</div>
</div>
</el-form-item>
<el-form-item label="礼品卡说明" prop="name" >
<el-input type="textarea" v-model="ruleForm.desc"></el-input>
<el-form-item label="礼品卡说明" prop="remark">
<el-input type="textarea" v-model="ruleForm.remark"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="centerDialogVisible = false"> </el-button>
<el-button type="primary" @click="addBlock()">创建</el-button>
<el-button type="primary" @click="addBlock('formName')">创建</el-button>
</span>
</el-dialog>
<el-dialog
@ -342,8 +370,12 @@
<script>
import {
add,
updateId,
getList,
getListtj,
uploadFile,
downloadTemplate,
addList,
eitList,
deleteList,
@ -356,10 +388,15 @@ import {
getsk
} from "@/api/EventMarketing/giftBlock";
import {getToken} from "@/utils/auth";
import saveAs from 'file-saver';
export default {
name: 'index',
dicts: ['card_gift_type'],
data() {
return {
//http://localhost:81/dev-api/cardGiftActive
uploadUrl: process.env.VUE_APP_BASE_API + ' /cardGiftActive/importCardInfo',
Encryption: false,
uploadingShow: false,
oillist: [
@ -370,6 +407,10 @@ import {
"免密",
"密码"
],
modalitylsit2: [
"新增",
"覆盖新增"
],
oilnumlist: [
{
value: '1',
@ -381,6 +422,7 @@ import {
},
],
tindex: 0,
tindex2: 0,
jglist: [],
onelist: [],
twolist: [],
@ -396,12 +438,13 @@ import {
},
uploading: false,
fileList: [],
fileList2: [],
labelPosition: 'left',
queryParams: {
number:'',
remark:'',
activateStatus:null,
status:'',
//
activeName: '',
pageNo: 1,
pageSize: 10
},
@ -420,12 +463,18 @@ import {
},],
options: [
{
value: '1',
label: '已售'
}, {
value: '0',
label: '未售'
},],
label: '待上传'
}, {
value: '1',
label: '待加密'
},
{
value: '2',
label: '生效中'
}
],
value: '',
tjdata: {},
tableData: [
@ -447,22 +496,41 @@ import {
address: '上海市普陀区金沙江路 1516 弄'
}],
ruleForm: {
status:'1',
quantity:'1',
cardAmount:'1',
remark:''
//
activeNum: '',
//
activeName: '',
//
cardAmount: '',
//
value1: '',
//
cardType: '',
//
remark: '',
},
ruleForm2: {},
rules: {
status: [
activeNum: [
{required: true, message: '此为必填项', trigger: 'blur'},
],
quantity: [
activeName: [
{required: true, message: '此为必填项', trigger: 'blur'},
],
cardAmount: [
{required: true, message: '此为必填项', trigger: 'blur'},
],
value1: [
{required: true, message: '此为必填项', trigger: 'blur'},
],
cardType: [
{required: true, message: '此为必填项', trigger: 'change'},
],
remark: [
{required: true, message: '此为必填项', trigger: 'blur'},
],
}
@ -472,13 +540,95 @@ import {
this.getlist()
this.gettj()
},
methods: {
uploadShow(){
beforeUpload(file) {
//
return new Promise((resolve, reject) => {
//
console.log('Before Upload:', file);
resolve(true); //
});
},
handleSuccess(response, file, fileList) {
console.log('上传成功:', response);
this.$message.success('上传成功!');
this.uploadingShow = false;
},
handleError(error, file, fileList) {
console.error('上传失败:', error);
this.$message.error('上传失败!');
this.uploadingShow = false;
},
handleExceed(files, fileList) {
this.$message.warning(`当前限制选择一个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
},
submitUpload() {
if (this.fileList2.length > 0) {
//
this.customUpload(this.fileList2[0])
} else {
this.$message.warning('请选择一个文件上传!');
}
},
customUpload(file) {
const formData = new FormData();
formData.append('file', file.raw); // FormData
uploadFile(formData, this.ruleForm2.activeNum, this.tindex2) //
.then(response => {
this.handleSuccess(response.data, file, this.fileList2);
})
.catch(error => {
this.handleError(error, file, this.fileList2);
});
},
downloadTemplate() {
const link = document.createElement('a');
link.href = '/CardGiftActiveTemplate.xlsx'; // public
link.download = 'CardGiftActiveTemplate.xlsx';
link.click();
},
handleClose1() {
//
this.$refs['formName'].resetFields();
//
this.ruleForm = {};
},
handleClose2() {
this.fileList2 = []
},
updateId(row) {
this.centerDialogVisible = !this.centerDialogVisible
this.ruleForm = row
//
this.ruleForm.value1 = [row.effectiveTimeStart, row.effectiveTimeEnd]
//
this.ruleForm.cardType = row.cardType
},
uploadShow(row) {
this.uploadingShow = !this.uploadingShow
//
this.ruleForm2.activeNum = row.activeName
},
Typeindex(index) {
this.tindex = index
},
Typeindex2(index) {
this.tindex2 = index
},
toggleSelection(rows) {
if (rows) {
rows.forEach(row => {
@ -511,20 +661,12 @@ import {
})
},
//
handleChange(file, fileList) {
this.uploading = true;
console.log(file)
if(file.status === 'success'){
this.uploading = false;
this.openUpload = false;
this.openUser = false;
this.fileList.splice(0,1)
this.result = file.response.data
this.getlist()
}
//
console.log('文件变化:', file, fileList);
this.fileList2 = fileList; // fileList
},
putStatus(id) {
let data = {
id: 1,
@ -551,21 +693,7 @@ import {
this.getlist();
},
getlist() {
getselectGiftValue().then(res=>{
console.log(res)
this.jglist = res.data
})
getqb().then(res=>{
this.onelist = res.data
console.log(this.onelist)
})
getyi().then(res=>{
this.twolist = res.data
})
getwei().then(res=>{
this.threelist = res.data
})
this.queryParams.pageNo = this.pageNo
this.queryParams.pageSize = this.pageSize
getList(this.queryParams).then(res => {
@ -597,22 +725,55 @@ import {
remark: ''
}
},
addBlock(){
if(this.ruleForm.quantity == '' ||this.ruleForm.cardAmount == '' ||this.ruleForm.status == '' ){
this.$message.error('必填项不能有空')
return
addBlock(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
//
this.ruleForm.pwdType = this.tindex
//
this.ruleForm.effectiveTimeStart = this.ruleForm.value1[0]
this.ruleForm.effectiveTimeEnd = this.ruleForm.value1[1]
// id
if (this.ruleForm.id) {
updateId(this.ruleForm).then(
(res) => {
if (res.code == 200) {
this.$message.success('修改成功');
} else {
this.$message.error('修改失败');
}
let data = this.ruleForm
addList(data).then(res=>{
}
)
} else {
add(this.ruleForm).then(res => {
if (res.code == 200) {
this.$message.success('添加成功');
this.gettj()
this.getlist()
} else {
this.$message.error('操作失败请稍后再试');
this.$message.error('添加失败');
}
})
}
//
this.centerDialogVisible = false
//
this.$refs[formName].resetFields();
//
this.getlist()
} else {
console.log('error submit!!');
return false;
}
});
}
}
}
@ -625,16 +786,19 @@ import {
justify-content: space-between;
}
.box-der {
box-sizing: border-box;
padding: 15px;
}
.kar {
width: 100%;
background: #FFFFFF;
margin-bottom: 10px;
}
.d-b {
display: flex;
align-items: center;
@ -642,21 +806,25 @@ import {
width: 100%;
margin-bottom: 10px;
}
.one-size {
font-size: 20px;
font-weight: bold;
color: #000;
}
.two-size {
font-size: 20px;
font-weight: bold;
color: #78b0fb;
}
.three-size {
font-size: 20px;
font-weight: bold;
color: #f73f3f;
}
.ds {
width: 100%;
display: flex;
@ -667,22 +835,26 @@ import {
box-sizing: border-box;
padding: 15px 5px;
}
.tj-text {
font-size: 18px;
font-weight: bold;
}
.tj-num {
margin: 5px auto;
//font-size: 28px;
color: #666;
text-align: center;
}
.tj-siez {
margin: 5px auto;
color: #909399;
font-size: 14px;
text-align: center;
}
.top-hang {
width: 100%;
display: flex;
@ -690,10 +862,12 @@ import {
justify-content: space-between;
margin-bottom: 15px;
}
.d-s {
display: flex;
align-items: center;
}
.butoon {
box-sizing: border-box;
padding: 6px 10px;
@ -702,6 +876,7 @@ import {
font-size: 16px;
margin-left: 15px;
}
.sshi {
width: 33%;
background: #FFFFFF;
@ -711,12 +886,14 @@ import {
border-radius: 6px;
//background: #f9f9f9;
}
.tjaocuo {
width: 100%;
margin-bottom: 15px;
display: flex;
justify-content: space-between;
}
.title_ {
width: 100%;
display: flex;
@ -726,6 +903,7 @@ import {
justify-content: center;
margin-bottom: 20px;
}
.card-box {
width: 100%;
background: #fff;
@ -733,6 +911,7 @@ import {
padding: 15px;
border-radius: 10px;
}
.icon-type {
display: flex;
align-items: center;
@ -742,6 +921,7 @@ import {
margin-right: 20px;
cursor: pointer;
}
.acvtive {
color: #FF770F !important;
}