会员管理

This commit is contained in:
cun-nan 2023-10-19 18:47:09 +08:00
parent b990ed0b86
commit ab6a4a5279
11 changed files with 664 additions and 60 deletions

View File

@ -2,7 +2,7 @@
<div class="upload-file">
<el-upload
multiple
:action="uploadFileUrl"
:action="uploadPathRes"
:before-upload="handleBeforeUpload"
:file-list="fileList"
:limit="limit"
@ -66,8 +66,14 @@ export default {
isShowTip: {
type: Boolean,
default: true
},
//
uploadPath: {
type: String,
default: "backendApi/file/upload"
}
},
data() {
return {
number: 0,
@ -109,6 +115,9 @@ export default {
showTip() {
return this.isShowTip && (this.fileType || this.fileSize);
},
uploadPathRes() {
return this.uploadPath;
},
},
methods: {
//

View File

@ -161,7 +161,7 @@
icon="el-icon-plus"
@click="handleAdd"
v-hasPermi="['member:add']"
>新增</el-button>
>新增会员</el-button>
<el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange">
<el-table-column label="会员ID" prop="id" align="center" width="60"/>
<el-table-column label="头像" align="center" width="70">
@ -173,10 +173,6 @@
<el-table-column label="会员号" align="center" prop="userNo" width="150"/>
<el-table-column label="名称" align="center" prop="name" >
<template slot-scope="scope">
<!-- <router-link :to="'/system/dict/data/' + scope.row.dictId" class="link-type">-->
<!-- <span>{{ scope.row.dictType }}</span>-->
<!-- </router-link>-->
<span style="color: #409EFF;cursor: pointer " @click="goDedi(scope.row.id)">{{ scope.row.name }}</span>
</template>
</el-table-column>
@ -193,25 +189,11 @@
<el-table-column label="储值卡" align="center" prop="balance">
<template slot-scope="scope">
<div>{{ scope.row.balance ? scope.row.balance.toFixed(2) : '0.00' }}</div>
<!-- <el-button-->
<!-- class="mini-btn"-->
<!-- type="primary"-->
<!-- size="mini"-->
<!-- @click="handleBalance(scope.row.id)"-->
<!-- v-hasPermi="['balance:modify']"-->
<!-- >充值</el-button>-->
</template>
</el-table-column>
<el-table-column label="升数卡" align="center" prop="balance">
<template slot-scope="scope">
<div>{{ scope.row.literCard ? scope.row.literCard.toFixed(2) : '0.00' }}L</div>
<!-- <el-button-->
<!-- class="mini-btn"-->
<!-- type="primary"-->
<!-- size="mini"-->
<!-- @click="handleBalance(scope.row.id)"-->
<!-- v-hasPermi="['balance:modify']"-->
<!-- >充值</el-button>-->
</template>
</el-table-column>
<el-table-column label="加油金" align="center" prop="balance">
@ -222,13 +204,6 @@
<el-table-column label="积分" align="center" prop="point">
<template slot-scope="scope">
<div><span>{{ scope.row.point ? scope.row.point : '0.00' }}</span></div>
<!-- <el-button-->
<!-- class="mini-btn"-->
<!-- type="primary"-->
<!-- size="mini"-->
<!-- @click="handlePoint(scope.row.id)"-->
<!-- v-hasPermi="['point:modify']"-->
<!-- >变更</el-button>-->
</template>
</el-table-column>
<el-table-column label="加油次数" align="center" prop="balance">
@ -242,14 +217,6 @@
</template>
</el-table-column>
<el-table-column label="状态" align="center" prop="status">
<!-- <template slot-scope="scope">-->
<!-- <el-switch-->
<!-- v-model="scope.row.status"-->
<!-- active-value="A"-->
<!-- inactive-value="N"-->
<!-- @change="handleStatusChange(scope.row)"-->
<!-- ></el-switch>-->
<!-- </template>-->
<template slot-scope="scope">
<dict-tag :options="dict.type.zhzt" :value="scope.row.status"/>
</template>
@ -288,6 +255,44 @@
/>
</el-card>
<!-- 添加会员信息选择是否批量录入-->
<el-dialog :close-on-click-modal="false" :title="title" :visible.sync="openUser" append-to-body>
<el-alert
type="info"
:closable="false">
<p v-for="(item,index) in addMember" :id="index">
{{item}}
</p>
</el-alert>
<div>
<el-button type="primary"
icon="el-icon-edit-outline" @click="addOne" round>录入单个会员</el-button>
<el-button type="primary"
icon="el-icon-connection" @click="addMult" round>批量导入会员</el-button>
</div>
<div>
<el-table ref="tables" v-loading="loading" :data="userList">
<el-table-column prop="date" label="批次号"/>
<el-table-column prop="date" label="类型"/>
<el-table-column prop="date" label="会员数"/>
<el-table-column label="执行结果">
<el-table-column prop="date" label="成功人数"/>
<el-table-column prop="date" label="失败人数"/>
<el-table-column prop="date" label="重复人数"/>
</el-table-column>
<el-table-column prop="date" label="处理时间"/>
<el-table-column prop="date" label="处理结果详情"/>
</el-table>
<pagination
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
</el-dialog>
<!-- 添加或修改对话框 -->
<el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" width="800px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
@ -391,6 +396,28 @@
</div>
</el-dialog>
<!-- 批量录入会员信息-->
<el-dialog :close-on-click-modal="false" :title="title" :visible.sync="openUpload" append-to-body>
<div style="height: 60px;line-height: 30px">
<div> 第一步: 下载示例模板,按照模板填写会员数据,手机号为必填项 </div>
<a style="margin-left: 50px;color: #00afff"
href="/dev-api/excel/export"> 会员示例模板.xlsx </a>
</div>
<div style="margin: 20px 0">
<div>第二步: 选择用户数据上传并导入会员</div>
<el-upload
class="upload-demo"
action="/dev-api/excel/import"
:headers="headers"
:on-change="handleChange"
:file-list="fileList">
<el-button size="small" type="success" icon="el-icon-upload">点击上传</el-button>
<div slot="tip">只能上传xls/xlsx文件单次最大5000行会员数据且不超过1M 超出请分文件处理</div>
</el-upload>
</div>
</el-dialog>
<!-- 余额充值对话框 -->
<balanceRecharge :showDialog="openBalance" :userId="userId" @closeDialog="closeDialog" @close="closeDialog"/>
@ -406,12 +433,21 @@ import pointRecharge from "./pointRecharge";
import {addUser, delUser, getUser, listStatistic, listUser, updateUser} from "@/api/staff/user/user";
import {listUserGrade} from "@/api/staff/user/usergrade";
import {ljStoreList} from "@/api/staff/store";
import {getSysConfig} from "@/api/staff/user/sysconfig";
import { getToken } from "@/utils/auth";
export default {
name: "MemberIndex",
components: { balanceRecharge, pointRecharge },
dicts: ['official','zhzt'],
data() {
return {
headers: {
'Access-Token': getToken(),
},
//
fileList: [],
addMember:[],
//
balance:'',
//
@ -438,6 +474,8 @@ export default {
total: 0,
//
list: [],
//
userList: [],
//
userGradeList: [],
//
@ -445,6 +483,8 @@ export default {
storeIds: [],
//
open: false,
openUser: false,
openUpload: false,
//
userId: '',
//
@ -487,6 +527,7 @@ export default {
created() {
this.getList();
this.getStatistic();
this.getConfig();
},
methods: {
//
@ -583,6 +624,10 @@ export default {
handleBalance(userId) {
this.openBalance = true;
this.userId = userId.toString();
},
//
importUser(){
},
//
handlePoint(userId) {
@ -602,9 +647,24 @@ export default {
},
//
handleAdd() {
this.openUser = true;
this.title = "新增会员";
},
//
addOne() {
this.reset();
this.open = true;
this.title = "新增会员";
this.title = "录入会员";
},
addMult(){
this.openUpload = true;
this.title = "批量导入会员";
},
//
getConfig(){
getSysConfig('addMember').then(response => {
this.addMember = response.data.split(";")
});
},
//
reset() {
@ -659,6 +719,9 @@ export default {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
handleChange(file, fileList) {
this.fileList = fileList.slice(-3);
}
}
};
@ -676,4 +739,9 @@ export default {
background: #f6f8f9;
padding-top: 30px;
}
.el-upload, .el-upload--text {
width: 150px;
height: 60px !important;
line-height: 60px !important;
}
</style>

View File

@ -1,11 +1,12 @@
<template>
<div class="app-container">
<el-card>
<div slot="header" class="clearfix" style="display: flex;justify-content: space-between">
<el-page-header @back="goBack" content="详情页面">
</el-page-header>
<div slot="header" style="display: flex;justify-content: space-between;padding-right: 0px">
<div>
<el-button type="primary" plain round>子卡管理<i class="el-icon-bank-card el-icon--right"></i></el-button>
<el-page-header @back="goBack" content="详情页面"></el-page-header>
</div>
<div>
<el-button type="primary" plain round @click="subCard">子卡管理<i class="el-icon-bank-card el-icon--right"></i></el-button>
<el-button type="primary" plain round>会员码</el-button>
</div>
</div>
@ -34,11 +35,20 @@
<el-descriptions-item label="加油总金额">{{form.refuelMoney}}</el-descriptions-item>
<el-descriptions-item label="所属油站">{{ store.name }}</el-descriptions-item>
<el-descriptions-item label="注册时间">{{form.createTime}}</el-descriptions-item>
<el-descriptions-item label="关联副卡">{{form.secondCard}}</el-descriptions-item>
<el-descriptions-item label="会员等级">{{ grade.name }}</el-descriptions-item>
<el-descriptions-item label="关联副卡">
<span style="color: #00afff" @click="secondCard">副卡管理</span>
</el-descriptions-item>
<el-descriptions-item label="会员等级">
<span style="color: #00afff" @click="userGrade">{{ grade.name }}</span>
</el-descriptions-item>
<el-descriptions-item label="储值优惠"></el-descriptions-item>
<el-descriptions-item label="每日笔数"></el-descriptions-item>
<el-descriptions-item label="固定等级"></el-descriptions-item>
<el-descriptions-item label="每日笔数">
<span style="color: #00afff" @click="configuration">跟随全局总配置</span>
</el-descriptions-item>
<el-descriptions-item label="固定等级">
<span style="color: #00afff" @click="level">
<dict-tag :options="dict.type.zcrzdj" :value="form.fixingLevel"/></span>
</el-descriptions-item>
<el-descriptions-item label="备注信息">{{ form.description }}</el-descriptions-item>
</el-descriptions>
</div>
@ -113,7 +123,6 @@
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.pageSize"
@ -134,7 +143,6 @@
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.pageSize"
@ -166,7 +174,6 @@
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.pageSize"
@ -185,7 +192,6 @@
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.pageSize"
@ -203,7 +209,6 @@
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.pageSize"
@ -235,7 +240,6 @@
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.pageSize"
@ -260,7 +264,6 @@
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.pageSize"
@ -280,7 +283,6 @@
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.pageSize"
@ -311,6 +313,286 @@
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 副卡管理-->
<el-dialog :close-on-click-modal="false" :title="title" :visible.sync="openSecondCard" width="60%" append-to-body>
<div style="display: flex;justify-content: space-between;margin: 10px 0">
<div style="font-size: 16px">副卡账户</div>
<el-button type="primary">创建副卡账户</el-button>
</div>
<div>
<el-alert
type="error"
title="关于副卡"
:closable="false">
<p v-for="(item,index) in aboutSecondCard" :id="index">
{{item}}
</p>
</el-alert>
</div>
<div>
<el-table ref="tables" v-loading="loading" :data="list">
<el-table-column prop="date" label="账户ID"/>
<el-table-column prop="date" label="账户名称"/>
<el-table-column label="余额">
<el-table-column prop="name" label="储值卡"/>
<el-table-column prop="address" label="升数卡"/>
</el-table-column>
<el-table-column label="会员等级">
<el-table-column prop="name" label="汽油"/>
<el-table-column prop="address" label="柴油"/>
</el-table-column>
<el-table-column label="统计">
<el-table-column prop="name" label="可用积分"/>
<el-table-column prop="address" label="消费次数"/>
</el-table-column>
<el-table-column prop="date" label="实体卡号"/>
<el-table-column prop="date" label="状态"/>
<el-table-column prop="date" label="创建时间"/>
</el-table>
<pagination
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
</el-dialog>
<!-- 会员成长值-->
<el-dialog :close-on-click-modal="false" width="60%" :title="title" :visible.sync="openUserGrade" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-row>
<el-col :span="24">
<div style="display: flex;justify-content: center">
<div>
<img v-if="form.avatar" :src="form.avatar">
<img v-else src="@/assets/images/avatar.png">
</div>
<div style="height: 64px;line-height: 32px;width: 100px;margin-left: 20px;margin-bottom: 20px">
<div style="color: #00afff">{{form.name}}</div>
{{form.mobile}}
</div>
</div>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="当前成长值" prop="mobile">
<e-row>
<el-col :span="8">
<el-form-item prop="gasoline">
<el-input v-model="grade.gasoline" placeholder="1" disabled>
<template slot="prepend">汽油</template>
<template slot="append">成长值</template>
</el-input>
</el-form-item>
</el-col>
</e-row>
<e-row>
<el-col :span="8">
<el-form-item prop="dieselOil">
<el-input v-model="grade.dieselOil" placeholder="1" disabled>
<template slot="prepend">柴油</template>
<template slot="append">成长值</template>
</el-input>
</el-form-item>
</el-col>
</e-row>
<e-row>
<el-col :span="8">
<el-form-item prop="naturalGas">
<el-input v-model="grade.naturalGas" placeholder="1" disabled>
<template slot="prepend">天然气</template>
<template slot="append">成长值</template>
</el-input>
</el-form-item>
</el-col>
</e-row>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="操作类型" prop="type">
<el-radio-group v-model="type">
<el-radio label="add">增加</el-radio>
<el-radio label="reduce">减少</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="变动数值" prop="type">
<template>
<el-input-number v-model="num" controls-position="right" @change="handleChange" :min="1" :max="10"></el-input-number>
</template>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 子卡管理-->
<el-dialog :close-on-click-modal="false" width="60%" :title="title" :visible.sync="openSubCard" append-to-body>
<el-tabs v-model="subCardActive" @tab-click="handleClick">
<el-tab-pane label="子卡管理" name="subCardManage">
<div style="display: flex;justify-content: space-between;margin: 10px 0">
<div style="font-size: 16px">会员信息{{form.mobile}}</div>
<el-button type="primary">新增子卡</el-button>
</div>
<div>
<el-table ref="tables" v-loading="loading" :data="list">
<el-table-column prop="date" label="子卡卡号"/>
<el-table-column label="基础信息">
<el-table-column prop="name" label="子卡姓名"/>
<el-table-column prop="address" label="手机号"/>
<el-table-column prop="address" label="车牌号"/>
</el-table-column>
<el-table-column label="额度管理">
<el-table-column prop="name" label="配额额度"/>
<el-table-column prop="address" label="已用额度"/>
<el-table-column prop="address" label="可用额度"/>
</el-table-column>
<el-table-column prop="date" label="状态"/>
<el-table-column prop="date" label="操作"/>
</el-table>
<pagination
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
<el-alert
title="关于子卡"
type="info"
description="子卡为会员子母卡功能,子卡共享母卡的储值额度及信息,子卡为实体会员卡信息,消费需在PC或手持机中才可进行使用">
</el-alert>
</el-tab-pane>
<el-tab-pane label="子卡消费记录" name="consumption">
<div style="display: flex;justify-content: space-between;margin: 10px 0">
<div style="font-size: 16px">
<el-form ref="form" :model="subCardList" :rules="rules" label-width="120px">
<el-row>
<el-col :span="8">
<el-form-item label="子卡卡号" prop="userNo">
<el-input
v-model="subCardList.idCard"
placeholder="请输入卡号信息"
clearable
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="关联单号">
<el-input
v-model="subCardList.orderId"
placeholder="关联单号信息"
clearable
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item>
<el-button type="primary">新增子卡</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
</div>
<div>
<el-table ref="tables" v-loading="loading" :data="list">
<el-table-column prop="date" label="子卡卡号"/>
<el-table-column prop="date" label="消费金额"/>
<el-table-column label="消费信息">
<el-table-column prop="name" label="关联单号"/>
<el-table-column prop="address" label="描述信息"/>
</el-table-column>
<el-table-column prop="date" label="消费时间"/>
</el-table>
<pagination
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
<el-alert
title="关于子卡"
type="info"
description="当前会员的所有子卡消费记录信息,可根据对应子卡卡号进行检索查询">
</el-alert>
</el-tab-pane>
</el-tabs>
</el-dialog>
<!-- 每日交易次数-->
<el-dialog :close-on-click-modal="false" :title="title" :visible.sync="openConfig" style="margin-top: 200px" width="400px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-row>
<el-col :span="24">
<div style="margin-bottom: 20px">
{{transaction}}
</div>
<el-input v-model="config" />
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 固定等级-->
<el-dialog :close-on-click-modal="false" :title="title" :visible.sync="openLevel" style="margin-top: 200px" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-row>
<el-col :span="24">
<el-form-item label="当前认证" prop="level" style="width: 420px">
<!-- <dict-tag :options="dict.type.zcrzdj" :value="form.fixingLevel"/>-->
<el-input v-model="form.fixingLevel" disabled />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="变更认证" prop="level" style="width: 420px">
<el-select
v-model="form.fixingLevel"
clearable
style="width: 240px"
>
<el-option
v-for="dict in dict.type.zcrzdj"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
@ -318,18 +600,32 @@
import {getUser, updateUser} from "@/api/staff/user/user";
import {ljStoreInfo} from "@/api/staff/store";
import {getUserGrade} from "@/api/staff/user/usergrade";
import {getSysConfig} from "@/api/staff/user/sysconfig";
export default {
dicts: ['official','zhzt'],
dicts: ['official','zhzt','zcrzdj'],
data(){
return{
//
transaction:"",
config:'-1',
num:1,
//
type:'add',
title:'',
//
openMobile: false,
openSecondCard:false,
openUserGrade:false,
openSubCard:false,
openConfig:false,
openLevel:false,
growthValue:'whole',
cardList:'notUse',
tabPosition: 'giftCard',
balanceRecord: 'first',
//
aboutSecondCard:[],
//
loading: false,
id:'',
@ -340,8 +636,9 @@ export default {
//
grade:'',
activeName: 'refuelOrder',
subCardActive:'subCardManage',
tableData:[],
total:'',
total:0,
queryParams: {
page: 1,
pageSize: 10,
@ -350,16 +647,19 @@ export default {
name: '',
status: '',
},
subCardList:[],
list: [],
//
rules: {
mobile: [{ required: true, message: "请输入手机号", trigger: "blur" }],
type: [{ required: true, message: "请选择操作类型", trigger: "blur" }],
}
}
},
created() {
this.id = this.$route.query.id;
this.getUserInfo();
this.getInformation();
},
methods: {
//
@ -367,6 +667,40 @@ export default {
this.openMobile = true;
this.title = '更换手机号'
},
//
secondCard(){
this.openSecondCard = true;
this.title = this.form.secondCard+'-副卡账户管理'
},
//
userGrade(){
this.openUserGrade = true;
this.title = '更换手机号'
},
//
subCard(){
this.openSubCard = true;
this.title = '子卡管理'
},
//
configuration(){
this.openConfig = true;
this.title = '每日交易次数'
},
//
level(){
this.openLevel = true;
this.title = '固定等级(原专车认证)'
},
//
getInformation(){
getSysConfig('second_card').then(response => {
this.aboutSecondCard = response.data.split(";")
});
getSysConfig('transaction').then(response => {
this.transaction = response.data
});
},
getList(){
},
@ -416,10 +750,16 @@ export default {
//
cancel() {
this.openMobile = false;
this.openUserGrade = false;
this.openConfig = false;
this.openLevel = false;
},
handleClick(tab, event) {
console.log(tab, event);
},
handleChange(value) {
console.log(value);
},
//
goBack() {
this.$router.back(-1);

View File

@ -259,7 +259,7 @@
</el-card>
<!-- 添加或修改对话框 -->
<el-dialog :title="title" :visible.sync="open" :close-on-click-modal="false" width="50%" append-to-body>
<el-dialog :title="title" :visible.sync="open" :close-on-click-modal="false" width="60%" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-row>
<el-col :span="24">
@ -281,7 +281,7 @@
<e-row>
<el-col :span="8">
<el-form-item prop="gasoline">
<el-input v-model="form.gasoline" placeholder="1" style="width: 240px">
<el-input v-model="form.gasoline" placeholder="1">
<template slot="prepend">汽油</template>
<template slot="append">成长值</template>
</el-input>
@ -291,7 +291,7 @@
<e-row>
<el-col :span="8">
<el-form-item prop="dieselOil">
<el-input v-model="form.dieselOil" placeholder="1" style="width: 240px">
<el-input v-model="form.dieselOil" placeholder="1">
<template slot="prepend">柴油</template>
<template slot="append">成长值</template>
</el-input>
@ -301,7 +301,7 @@
<e-row>
<el-col :span="8">
<el-form-item prop="naturalGas">
<el-input v-model="form.naturalGas" placeholder="1" style="width: 240px">
<el-input v-model="form.naturalGas" placeholder="1">
<template slot="prepend">天然气</template>
<template slot="append">成长值</template>
</el-input>

View File

@ -135,6 +135,23 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!-- 导入导出表格依赖-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
</dependencies>
<build>

View File

@ -0,0 +1,94 @@
package com.fuint.business.userManager.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.EasyExcelFactory;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fuint.business.userManager.entity.LJUser;
import com.fuint.business.userManager.listener.EasyExcelListener;
import com.fuint.business.userManager.mapper.LJUserMapper;
import com.fuint.business.userManager.service.LJUserService;
import com.fuint.framework.web.BaseController;
import com.fuint.framework.web.ResponseObject;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.List;
@RestController
@RequestMapping("/excel")
public class ExportController extends BaseController{
@Autowired
private EasyExcelListener listener;
@Autowired
private LJUserService service;
@Autowired
private LJUserMapper mapper;
@RequestMapping("/import")
public ResponseObject myImport(MultipartFile file) throws IOException {
try {
//获取文件名
String filename = file.getOriginalFilename();
//获取文件流
InputStream inputStream = file.getInputStream();
//实例化实现了AnalysisEventListener接口的类
EasyExcelListener listener = new EasyExcelListener();
EasyExcelFactory.read(inputStream, LJUser.class, listener).headRowNumber(1).build().readAll();
//获取数据
List<Object> list = listener.getDatas();
if (list.size() > 1) {
for (int i = 0; i < list.size(); i++) {
LJUser user = (LJUser) list.get(i);
//使用mybatis-plus添加到数据库
service.insertUser(user);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return getSuccessResult("OK");
}
@RequestMapping("/export")
public void export(HttpServletResponse response, HttpServletRequest request) {
try {
String filenames = "会员信息导入示列";
String userAgent = request.getHeader("User-Agent");
if (userAgent.contains("MSIE") || userAgent.contains("Trident")) {
filenames = URLEncoder.encode(filenames, "UTF-8");
} else {
filenames = new String(filenames.getBytes("UTF-8"), "ISO-8859-1");
}
response.setContentType("application/json.ms-exce");
response.setCharacterEncoding("utf-8");
response.addHeader("Content-Disposition", "filename=" + filenames + ".xlsx");
// Step1创建一个 QueryWrapper 对象
QueryWrapper queryWrapper = new QueryWrapper<>();
// Step2 构造查询条件
queryWrapper
.select("*");
// Step3执行查询
List<LJUser> userList = mapper.selectList(queryWrapper);
EasyExcel.write(response.getOutputStream(), LJUser.class).sheet("sheet").doWrite(userList);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -1,5 +1,8 @@
package com.fuint.business.userManager.entity;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
@ -23,6 +26,7 @@ import java.util.List;
@Getter
@Setter
@TableName("mt_user")
@ExcelIgnoreUnannotated
@ApiModel(value = "MtUser对象", description = "会员个人信息")
public class LJUser extends BaseEntity implements Serializable {
@ -30,93 +34,126 @@ public class LJUser extends BaseEntity implements Serializable {
@ApiModelProperty("会员ID")
@TableId(value = "ID", type = IdType.AUTO)
@ExcelProperty(index = 0,value = "id")
private Integer id;
@ApiModelProperty("会员号")
@ExcelProperty(index = 1,value = "会员号")
private String userNo;
@ApiModelProperty("头像")
@ExcelProperty(index = 2,value = "头像")
private String avatar;
@ApiModelProperty("称呼")
@ExcelProperty(index = 3,value = "称呼")
private String name;
@ApiModelProperty("微信open_id")
@ExcelProperty(index = 4,value = "微信open_id")
private String openId;
@ApiModelProperty("手机号码")
@ExcelProperty(index = 5,value = "手机号码")
private String mobile;
@ApiModelProperty("证件号码")
@ExcelProperty(index = 6,value = "证件号码")
private String idcard;
@ApiModelProperty("等级ID")
@ExcelProperty(index = 7,value = "等级ID")
private String gradeId;
@ApiModelProperty("会员开始时间")
@TableField(strategy = FieldStrategy.IGNORED)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ExcelProperty(index = 8,value = "会员开始时间")
private Date startTime;
@ApiModelProperty("会员结束时间")
@TableField(strategy=FieldStrategy.IGNORED)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ExcelProperty(index = 9,value = "会员结束时间")
private Date endTime;
@ApiModelProperty("余额")
@ExcelProperty(index = 10,value = "余额")
private BigDecimal balance;
@ApiModelProperty("积分")
@ExcelProperty(index = 11,value = "积分")
private Integer point;
@ApiModelProperty("性别 1男0女")
@ExcelProperty(index = 12,value = "性别 1男0女")
private Integer sex;
@ApiModelProperty("出生日期")
@ExcelProperty(index = 13,value = "出生日期")
private String birthday;
@ApiModelProperty("车牌号")
@ExcelProperty(index = 14,value = "车牌号")
private String carNo;
@ApiModelProperty("来源渠道")
@ExcelProperty(index = 15,value = "来源渠道")
private String source;
@ApiModelProperty("密码")
@ExcelProperty(index = 16,value = "密码")
private String password;
@ApiModelProperty("salt")
@ExcelProperty(index = 17,value = "salt")
private String salt;
@ApiModelProperty("地址")
@ExcelProperty(index = 18,value = "地址")
private String address;
@ApiModelProperty("所属商户ID")
@ExcelProperty(index = 19,value = "所属商户ID")
private Integer merchantId;
@ApiModelProperty("默认店铺")
@ExcelProperty(index = 20,value = "默认店铺")
private Integer storeId;
@ApiModelProperty("状态A激活N禁用D删除")
@ExcelProperty(index = 21,value = "状态")
private String status;
@ApiModelProperty("备注信息")
@ExcelProperty(index = 22,value = "备注信息")
private String description;
@ApiModelProperty("最后操作人")
@ExcelProperty(index = 23,value = "最后操作人")
private String operator;
@ApiModelProperty("升数卡")
@ExcelProperty(index = 24,value = "升数卡")
private BigDecimal literCard;
@ApiModelProperty("公众号")
@ExcelProperty(index = 25,value = "公众号")
private String official;
@ApiModelProperty("加油金")
@ExcelProperty(index = 26,value = "加油金")
private BigDecimal refuelMoney;
@ApiModelProperty("加油次数")
@ExcelProperty(index = 27,value = "加油次数")
private BigDecimal consumeNum;
@ApiModelProperty("副卡信息")
@ExcelProperty(index = 28,value = "副卡信息")
private String secondCard;
@ApiModelProperty("固定等级")
@ExcelProperty(index = 29,value = "固定等级")
private String fixingLevel;
}

View File

@ -0,0 +1,38 @@
package com.fuint.business.userManager.listener;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Component;
import java.util.*;
@Component
public class EasyExcelListener extends AnalysisEventListener {
//可以通过实例获取该值
private List<Object> datas = new ArrayList<Object>();
@Override
public void invoke(Object o, AnalysisContext analysisContext) {
datas.add(o);//数据存储到list供批量处理或后续自己业务逻辑处理
doSomething(o);//根据自己业务做处理
}
private void doSomething(Object object) {
//1入库调用接口
}
public List<Object> getDatas() {
return datas;
}
public void setDatas(List<Object> datas) {
this.datas = datas;
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
// datas.clear();//解析结束销毁不用的资源
}
}

View File

@ -31,6 +31,7 @@
<result property="refuelMoney" column="refuel_money" />
<result property="consumeNum" column="consume_num" />
<result property="secondCard" column="second_card" />
<result property="fixingLevel" column="fixing_level" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
@ -40,7 +41,7 @@
<sql id="selectUser">
select id, mobile, user_no, avatar, name, open_id, idcard, grade_id, start_time, end_time, balance, point,
sex, birthday, car_no, source, password, salt, address, merchant_id, store_id, create_time, update_time,
status, description, operator,official,liter_card,refuel_money,consume_num,second_card from mt_user
status, description, operator,official,liter_card,refuel_money,consume_num,second_card,fixing_level from mt_user
</sql>
<select id="selectUserList" resultMap="UserResult">

View File

@ -40,7 +40,7 @@ public class ExcelUtil {
// 第四步创建单元格并设置值表头 设置表头居中
HSSFCellStyle style = wb.createCellStyle();
style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
// style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
//声明列对象
HSSFCell cell = null;