导粉记录页面以及接口修改

This commit is contained in:
xiezhijun
2021-05-21 18:59:26 +08:00
parent 17df1db9e2
commit f913774025
12 changed files with 250 additions and 21 deletions

View File

@ -1,6 +1,7 @@
<template>
<!-- -->
<!-- 添加或修改导粉管理对话框 -->
<el-dialog :title="title" :visible.sync="open" width="1100px" :close-on-click-modal="false" append-to-body>
<el-dialog :title="title" :visible.sync="open" width="1100px" :close-on-click-modal="false" append-to-body @closed="cancel">
<div style="height: 500px; overflow: auto">
<el-table v-loading="loading" :data="wxAccountList">
<!--<el-table-column label="微信昵称" align="center" prop="wxNickName" />-->
@ -15,6 +16,7 @@
clearable
filterable
size="small"
@change="autoSelectLive(scope.row)"
>
<el-option
v-for="dict in fanChanneloptions"
@ -55,17 +57,26 @@
type="text"
@click="addImportFanRecord(scope.row)"
v-hasPermi="['custom:importFanRecord:add']"
>导粉</el-button>
>保存</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div slot="footer" class="dialog-footer">
<el-button
type="primary"
@click="addMuchImport"
v-hasPermi="['custom:importFanRecord:add']"
>全部保存</el-button>
<el-button @click="cancel">取消</el-button>
</div>
</el-dialog>
</template>
<script>
import { addImportFanRecord,getWxAccountAndSale } from "@/api/custom/importFanRecord";
import { getAllLiveSchedulByDate } from "@/api/custom/liveSchedul";
import dayjs from "dayjs";
const nowTime = dayjs().format("YYYY-MM-DD HH:mm");
export default {
name: "ImportFan",
components: {
@ -93,7 +104,9 @@ export default {
//当日直播间
liveSchedukList:[],
//总导粉统计
fanNumList:[]
fanNumList:[],
//是否进行了导粉操作
importFanFlag: false
};
},
created(){
@ -105,6 +118,7 @@ export default {
if(!data || data == undefined || data == null){
return;
}
this.importFanFlag = false;
this.data = data;
this.fanChanneloptions = fanChanneloptions;
this.title = "「"+data.importFanDate+"」微信导粉(只显示可接粉微信号)";
@ -126,6 +140,9 @@ export default {
},
cancel(){
this.open = false;
if(this.importFanFlag){
this.callback && this.callback();
}
this.reset();
},
//获取所有可接粉的微信号
@ -135,6 +152,8 @@ export default {
response.data.wxSaleAccountList.forEach((item,index) => {
item.fanNum = 1;
item.importFanNum = this.getTotalFanNum(response.data.fanNumList, item.id);
item.importFanChannel = null;
item.importFanLive = null;
});
this.wxAccountList = response.data.wxSaleAccountList;
this.fanNumList = response.data.fanNumList;
@ -163,7 +182,7 @@ export default {
},
addImportFanRecord(row){
//账号渠道、进粉数量不能为空
if(row.importFanChannel == undefined || row.importFanChannel == null){
if(row.importFanChannel == undefined || row.importFanChannel == null || row.importFanChannel == ""){
this.$message({
type: 'warning',
message: '进粉渠道不能为空',
@ -171,7 +190,7 @@ export default {
});
return;
}
if(row.fanNum == undefined || row.fanNum == null){
if(row.fanNum == undefined || row.fanNum == null || row.fanNum == ""){
this.$message({
type: 'warning',
message: '进粉数量不能为空',
@ -188,14 +207,86 @@ export default {
}
addImportFanRecord(param).then((response) => {
if(response.code == 200){
this.msgSuccess("导粉成功");
this.msgSuccess("保存成功");
row.importFanChannel = null;
row.fanNum = 1;
row.importFanLive = null;
row.importFanNum += row.fanNum;
row.fanNum = 1;
this.importFanFlag = true;
}
});
},
addMuchImport(){
if(this.wxAccountList == null || this.wxAccountList.length == 0){
this.$message({
type: 'warning',
message: '微信号不存在',
center: true
});
return;
}
let param = {
'importFanDate': this.data.importFanDate,
'importFanChannels': null,
'importFanLives': null,
'wxAccountIds': null,
'fanNums': null
}
this.wxAccountList.forEach((item,index) => {
if(item.importFanChannel != undefined && item.importFanChannel != null && item.importFanChannel != ""){
param.importFanChannels += param.importFanChannels != null ? (","+this.nullToString(item.importFanChannel)) : item.importFanChannel;
param.importFanLives += param.importFanLives != null ? (","+this.nullToString(item.importFanLive)) : item.importFanLive;
param.wxAccountIds += param.wxAccountIds != null ? (","+this.nullToString(item.id)) : item.id;
param.fanNums += param.fanNums != null ? (","+this.nullToString(item.fanNum)) : item.fanNum;
}
if(index == this.wxAccountList.length -1){
if(param.importFanChannels == null){
this.$message({
type: 'warning',
message: '请至少存在一条数据',
center: true
});
}else{
addImportFanRecord(param).then((response) => {
if(response.code == 200){
this.msgSuccess("全部保存成功");
this.importFanFlag = true;
for(let i=0; i < this.wxAccountList.length; i++){
this.wxAccountList[i].importFanLive = null;
this.wxAccountList[i].importFanChannel = null;
this.wxAccountList[i].importFanNum += this.wxAccountList[i].fanNum;
this.wxAccountList[i].fanNum = 1;
//this.$set('wxAccountList', index, item);
}
}
});
}
}
});
},
nullToString(value){
return (value == undefined || value == null || value == "") ? "" : value;
},
autoSelectLive(row){
if(row.importFanLive == undefined || row.importFanLive == null || row.importFanLive == ""){
if(row.importFanChannel == undefined || row.importFanChannel == null || row.importFanChannel == ""){
row.importFanLive = null;
}else{
let now = dayjs();//"2021-05-19 16:42"
//console.log(now.unix());
if(this.liveSchedukList != null){
this.liveSchedukList.forEach((item,index) => {
if(item.fanChannel == row.importFanChannel && now.unix() >= dayjs(item.liveStartTime).unix() && dayjs(item.liveEndTime).unix() >= now.unix()){
row.importFanLive = item.id;
return;
}
if(index == this.liveSchedukList.length - 1){
row.importFanLive = null;
}
});
}
}
}
}
},
};