You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

512 lines
22 KiB

<template>
<div class="demo-wrap min-flex-right">
<div class="flex-between">
1 month ago
<h2>{{ pageTitle }}</h2>
<CustomDropdown ref="dropdownRef"
:placeholder="'('+viewDesc[this.view]+')'+text"
width="280px">
<DateSelect slot="normal"
:view="view"
v-model="selectedDate"
@update-count="handleUpdateView"
@change="handleDateChange"/>
</CustomDropdown>
</div>
<div class=" flex-common" id="">
<el-form>
1 month ago
<el-table :data="tableData"
style="width: 100%"
@sort-change="handleSortChange"
@cell-mouse-enter="handleRowHover">
<el-table-column prop="sort" label="排序" width="100"></el-table-column>
1 month ago
<el-table-column
v-if="(dataRank == 1 || dataRank == 2) && (dataType == 'ver_type' || dataType == 'check_type')"
prop="name"
:key="selectedType"
:label="type_select[selectedType]">
<template slot="header">
1 month ago
<el-select class="custom-select" popper-class="custom-select-dropdown" v-model="selectedType" @change="changeRankType">
1 month ago
<el-option v-for="(item,type) in type_select"
:key="type"
:label="item"
:value="type">
</el-option>
</el-select>
</template>
1 month ago
<template slot-scope="scope">
{{ scope.row.name }}
</template>
1 month ago
</el-table-column>
<el-table-column v-else prop="name" :label="type_desc[dataType]" width="150"></el-table-column>
1 month ago
<el-table-column v-for="(field, index) in valueFields"
:key="field"
:label="labels[index]"
:prop="String(index + 1)"
sortable="custom">
<template v-if="index == 3 && dataRank == 1 && type != 'agent'" v-slot="{ row, $index }">
1 month ago
<el-popover v-model="row.id_popover"
placement="top"
trigger="manual"
:ref="`popover-${$index}`"
@show="popshow">
<div class="pop-wrap">
<div class="flex-between flex pop-top">
1 month ago
<h3>
{{ text }} {{ row.name }}
<span @click="goLookMoreData(row.id)">查看更多</span>
</h3>
<span class="flex point" @click="closePop(row,'id')">
关闭<img src="@/assets/register/close.svg">
</span>
</div>
<el-table :data="tableData1" style="width: 100%">
<el-table-column prop="value_1" width="208" label="日期"></el-table-column>
1 month ago
<el-table-column width="348" :label="rank_type_desc[dataRank]">
<template slot-scope="scope">
<div class="flex">
{{ scope.row.value_2 }}
<template v-if="Object.keys(growth_list1).length > 0">
1 month ago
<span v-if="growth_list1[scope.row.id]"
class="flex growth-text">
<span v-if="growth_list1[scope.row.id].value>0">
<span class="growth-up">
1 month ago
<img class="edit_icon"
src="@/assets/super/growth-up.svg">
{{ growth_list1[scope.row.id].value }}%
</span>同比上年
</span>
<span v-if="growth_list1[scope.row.id].value<0">
<span class="growth-down">
1 month ago
<img class="edit_icon"
src="@/assets/super/growth-down.svg">
{{ growth_list1[scope.row.id].value }}%
</span>同比上年
</span>
<span v-if="growth_list1[scope.row.id].value==0">
1 month ago
<img class="edit_icon"
src="@/assets/super/growth-flat.svg">同比上年持平
</span>
</span>
1 month ago
<span v-else class="flex growth-text">上年无数据</span>
</template>
</div>
</template>
</el-table-column>
</el-table>
</div>
1 month ago
<div class="flex" slot="reference">
{{ row[field] }}
<template v-if="Object.keys(growth_list).length > 0">
<template v-if="growth_list[row.id] && growth_list[row.id][field]">
<span v-if="growth_list[row.id][field].value > 0" class="growth-text">
<span class="growth-up">
1 month ago
<img class="edit_icon" src="@/assets/super/growth-up.svg"/>
{{ growth_list[row.id][field].value }}%
</span>同比上年
</span>
<span v-else-if="growth_list[row.id][field].value < 0" class="growth-text">
<span class="growth-down">
1 month ago
<img class="edit_icon" src="@/assets/super/growth-down.svg"/>
{{ growth_list[row.id][field].value }}%
</span>同比上年
</span>
<span v-else class="growth-text">
1 month ago
<img class="edit_icon" src="@/assets/super/growth-flat.svg"/>同比上年持平
</span>
</template>
<span v-else class="growth-text">上年无数据</span>
</template>
1 month ago
<img v-if="show_detail_index == row.sort"
@click="handleClick(row, $index, 'id')"
class="detail_icon" src="@/assets/super/list-detail.svg">
</div>
</el-popover>
</template>
<template v-else slot-scope="scope">
<div class="flex">
{{ scope.row[field] }}
<template v-if="Object.keys(growth_list).length > 0">
<template v-if="growth_list[scope.row.id] && growth_list[scope.row.id][field]">
<span v-if="growth_list[scope.row.id][field].value > 0" class="growth-text">
<span class="growth-up">
1 month ago
<img class="edit_icon" src="@/assets/super/growth-up.svg"/>
{{ growth_list[scope.row.id][field].value }}%
1 month ago
</span>同比上年
</span>
1 month ago
<span v-else-if="growth_list[scope.row.id][field].value < 0"
class="growth-text">
<span class="growth-down">
1 month ago
<img class="edit_icon" src="@/assets/super/growth-down.svg"/>
{{ growth_list[scope.row.id][field].value }}%
1 month ago
</span>同比上年
</span>
<span v-else class="growth-text">
1 month ago
<img class="edit_icon" src="@/assets/super/growth-flat.svg"/>同比上年持平
</span>
</template>
<span v-else class="growth-text">上年无数据</span>
</template>
</div>
</template>
</el-table-column>
</el-table>
1 month ago
<el-pagination background
@size-change='handleSizeChange'
@current-change='handleCurrentChange'
:current-page="currentPage"
:page-size=pageSize
layout="prev, pager, next,jumper"
:total="total">
</el-pagination>
</el-form>
</div>
</div>
</template>
<script>
import DateSelect from '@/components/super/DateSelect.vue';
import CustomDropdown from '@/components/CustomDropdown.vue';
export default {
name: 'rank_batch_list',
1 month ago
props: {
pageTitle: {
type: String,
default: ''
},
rank_type: {
type: Number,
default: 0
},
type: {
type: String,
default: ''
}
},
components: {
DateSelect,
CustomDropdown
},
data() {
return {
1 month ago
viewDesc: {
'month': '月份',
'monthTwo': '月份',
'year': '年份',
},
1 month ago
rank_type_desc: {
1: '毛利润/元',
2: '订单数',
3: '退单数',
4: '充值金额',
},
1 month ago
type_desc: {
'agent': '代理商昵称',
'ver_type': '品牌名称',
'check_type': '服务名称',
},
1 month ago
type_select: {
'ver_type': '按品牌名称',
'check_type': '按服务名称',
},
selectedType: 'check_type',
1 month ago
view: 'month',
labels: ['', '', '', ''],
valueFields: ['value_1', 'value_2', 'value_3', 'value_4'],
currentPage: 1, //当前页
pageSize: 20, //每页的容量
total: 0, //列表总数
1 month ago
sort_by: 4,
sort_order: 2,
1 month ago
text: '',//下拉框显示具体文案
selectedDate: new Date(),//默认当天日期
dataType: '',
dataRank: '',
tableData: [],
growth_list: [],
tableData1: [],
growth_list1: [],
show_detail_index: 0,
}
},
mounted() {
this.init()
},
1 month ago
computed: {},
watch: {
'$route'() {
this.init()
}
},
methods: {
1 month ago
init() {
this.text = this.getNowDate()
this.dataType = this.type
this.dataRank = this.rank_type
1 month ago
this.getRankingData();
},
handleUpdateView(newView) {
this.view = newView;
},
1 month ago
getNowDate() {
const now = new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始,补零
const currentYearMonth = `${year}-${month}`;
return `${currentYearMonth}`
},
1 month ago
getDate(dateStr) {
const date = new Date(dateStr);
const year = date.getFullYear(); // 2025
const month = date.getMonth() + 1; // 3 (表示3月)
1 month ago
if (this.view == 'year') {
return `${year}`
1 month ago
} else {
return `${year}-${month}`
}
},
handleDateChange(date) {
this.text = this.getDate(date)
this.selectedDate = date;
1 month ago
localStorage.setItem('date', JSON.stringify(date))
this.$refs.dropdownRef.closeDropdown();
this.currentPage = 1;
this.getRankingData()
},
goLookMoreData(id) {
let query = {}
query.date = this.text
query.rank_type = this.dataRank
1 month ago
if (this.dataType == 'agent') {
query.aid = id
}
1 month ago
if (this.dataType == 'ver_type') {
query.ver_type = id
}
1 month ago
if (this.dataType == 'check_type') {
query.check_type = id
}
window.open(this.$router.resolve({
1 month ago
path: '/super/ranking/detail',
query: query
}).href, '_blank')
},
1 month ago
closePop(row, type) {
row[type + '_popover'] = false; // 关闭弹框
},
handleClick(row, index, type) {
// 关闭其他行的弹框
this.tableData.forEach((item, i) => {
if (i !== index) {
item[type + '_popover'] = false;
}
});
// 打开当前行的弹框
row[type + '_popover'] = true;
let obj = {}
1 month ago
if (this.dataType == 'agent') {
obj.aid = row.id
}
1 month ago
if (this.dataType == 'ver_type') {
obj.ver_type = row.id
}
1 month ago
if (this.dataType == 'check_type') {
obj.check_type = row.id
}
this.getRankingDetail(obj);
},
popshow() {
var ariaEls = document.querySelectorAll('.el-popover')
ariaEls.forEach((item) => {
item.removeAttribute('aria-hidden')
})
ariaEls = document.querySelectorAll('.el-radio__original')
ariaEls.forEach((item) => {
item.removeAttribute('aria-hidden')
})
},
1 month ago
handleSortChange({prop, order}) {
1 month ago
this.sort_by = 4;
this.sort_order = 2;
if (order == 'ascending') {
1 month ago
this.sort_by = prop;
this.sort_order = 1;
}
if (order == 'descending') {
1 month ago
this.sort_by = prop;
this.sort_order = 2;
}
this.currentPage = 1;
this.getRankingData()
},
handleRowHover(row) {
this.show_detail_index = row.sort
},
1 month ago
changeRankType() {
this.dataType = this.selectedType
this.getRankingData()
},
getRankingData() {
this.setLabelText();
1 month ago
if (this.dataType == 'agent') {
if (this.dataRank == 4) {
this.getAgentRecharge()
} else {
this.getAgentRanking()
}
}
1 month ago
if (this.dataType == 'ver_type') {
this.getVerRanking()
}
1 month ago
if (this.dataType == 'check_type') {
this.getTypeRanking()
}
},
1 month ago
setLabelText() {
const date = new Date(this.text);
1 month ago
const year = date.getFullYear();
const month = date.getMonth() + 1;
this.labels = [];
if (this.view === 'year') {
1 month ago
for (let i = 3; i >= 0; i--) {
this.labels.push((year - i) + '年' + this.rank_type_desc[this.dataRank]);
}
} else {
1 month ago
const monthLabels = [];
for (let i = 3; i >= 0; i--) {
let m = month - i;
if (m <= 0) m += 12;
monthLabels.push(m + '月' + this.rank_type_desc[this.dataRank]);
}
this.labels = monthLabels;
}
},
getAgentRanking() {
1 month ago
//代理商排行
const that = this
1 month ago
this.$http('POST', '/supernew/ajax_get_agent_batch_list', {
date: that.text,
1 month ago
rank_type: that.dataRank,
1 month ago
sort_by: that.sort_by,
sort_order: that.sort_order,
cur_page: that.currentPage,
page_size: that.pageSize,
1 month ago
}).then(response => {
this.$nextTick(() => {
1 month ago
that.tableData = response.data.list
that.growth_list = response.data.growth_list
that.total = response.data.total
})
1 month ago
}).catch(error => {
console.error(error, 'error')
1 month ago
})
},
getAgentRecharge() {
//充值排行
const that = this
this.$http('POST', '/supernew/ajax_get_rank_recharge', {
date: that.text,
1 month ago
sort_by: that.sort_by,
sort_order: that.sort_order,
cur_page: that.currentPage,
page_size: that.pageSize,
}).then(response => {
this.$nextTick(() => {
1 month ago
that.tableData = response.data.list
that.growth_list = response.data.growth_list
that.total = response.data.total
})
}).catch(error => {
console.error(error, 'error')
})
},
getVerRanking() {
1 month ago
//品牌排行
const that = this
this.$http('POST', '/supernew/ajax_get_ver_batch_list', {
date: that.text,
rank_type: that.dataRank,
1 month ago
sort_by: that.sort_by,
sort_order: that.sort_order,
1 month ago
cur_page: that.currentPage,
page_size: that.pageSize,
}).then(response => {
this.$nextTick(() => {
that.tableData = response.data.list
that.top_list = response.data.top_list
that.growth_list = response.data.growth_list
that.total = response.data.total
})
}).catch(error => {
console.error(error, 'error')
})
},
getTypeRanking() {
1 month ago
//产品排行
const that = this
this.$http('POST', '/supernew/ajax_get_type_batch_list', {
date: that.text,
rank_type: that.dataRank,
1 month ago
sort_by: that.sort_by,
sort_order: that.sort_order,
cur_page: that.currentPage,
page_size: that.pageSize,
}).then(response => {
this.$nextTick(() => {
1 month ago
that.tableData = response.data.list
that.top_list = response.data.top_list
that.growth_list = response.data.growth_list
that.total = response.data.total
})
}).catch(error => {
1 month ago
console.error(error, 'error')
})
},
getRankingDetail(obj) {
const that = this
that.tableData1 = []
that.growth_list1 = []
this.$http('POST', '/supernew/ajax_get_rank_detail', {
date: that.text,
rank_type: that.dataRank,
1 month ago
sort_by: 2,
sort_order: 2,
...obj
}).then(response => {
this.$nextTick(() => {
that.tableData1 = response.data.list.slice(0, 5)
that.growth_list1 = response.data.growth_list
})
}).catch(error => {
console.error(error, 'error')
})
},
handleSizeChange(val) {
this.pageSize = val
this.getRankingData()
},
handleCurrentChange(val) {
this.currentPage = val
this.getRankingData()
},
}
}
</script>
<style scoped lang="scss">
</style>