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

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;
}
});
}
}
}
}
},
};

View File

@ -5,7 +5,7 @@
<el-date-picker clearable size="small" style="width: 200px"
v-model="queryParams.importFanDate"
type="date"
value-format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
placeholder="选择导粉日期">
</el-date-picker>
</el-form-item>
@ -79,6 +79,9 @@
v-hasPermi="['custom:importFanRecord:export']"
>导出</el-button>
</el-col>-->
<el-col :span="1.5">
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
@ -114,15 +117,15 @@
</el-table-column>
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
<!--<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['custom:importFanRecord:edit']"
>修改</el-button>
>修改</el-button>-->
<el-button
size="mini"
type="text"
@ -131,16 +134,37 @@
v-hasPermi="['custom:importFanRecord:remove']"
>删除</el-button>
</template>
</el-table-column>-->
</el-table-column>
</el-table>
<pagination
<!--<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
:layout="'total, slot, sizes, prev, pager, next, jumper'"
@pagination="getList"
<span style="margin-right: 12px"
>总计导粉量{{totalFanNum}}
</span
>
</pagination>-->
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
:layout="`${'total, slot, sizes, prev, pager, next, jumper'}`"
@pagination="getList"
/>
>
<span style="margin-right: 12px" v-if="!isMobile"
>总计导粉量{{
totalFanNum
}}
</span
>
</pagination>
<!-- 添加或修改导粉管理对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
@ -212,7 +236,9 @@ export default {
rules: {
},
//导粉账号渠道
fanChanneloptions:[]
fanChanneloptions:[],
//总导粉量
totalFanNum:0
};
},
created() {
@ -229,6 +255,11 @@ export default {
getList() {
this.loading = true;
listImportFanRecord(this.queryParams).then(response => {
if(response.rows != null && response.rows.length > 0){
this.totalFanNum = response.rows[0].totalFanNum;
}else{
this.totalFanNum = 0;
}
this.importFanRecordList = response.rows;
this.total = response.total;
this.loading = false;