Browse Source

🐞 fix: 小黄车无接口,暂时修改为无权限页面

zhangrenyuan/feature-20251104133449-现金管理二期
zhangrenyuan 2 weeks ago
parent
commit
0ddb4264d5
  1. 2
      src/router/index.js
  2. 450
      src/views/channelManage/cart/cart.vue

2
src/router/index.js

@ -407,7 +407,7 @@ const routes = [
{
path: 'cart',
name: "cart",
component: () => import("../views/channelManage/cart/cart.vue"),
component: () => import("../views/noPermissionPage.vue"),
meta: { permissionId: 127 }
}
]

450
src/views/channelManage/cart/cart.vue

@ -25,44 +25,17 @@ const adminData = ref({})
//
const tableData = ref([])
// articleVideo
const beanConsumeArticle = ref({
//
const beanCart = ref({
jwcode: null,
dept: "",
type: "",
payMode: "",
articleId: "",
articleName: "",
author: "",
goodsName: "",
channelName: "",
liveName: "",
startTime: '',
endTime: '',
})
//
const channels = ref([])
//
const consumeTypes = ref([
{ label: '打赏', value: 9 },
{ label: '打赏', value: 10 },
{ label: '付费购买', value: 11 },
])
// payMode
const handlePayModeChange = (value) => {
beanConsumeArticle.value.payMode = value;
//
ConsumeSelectBy();
}
//------------------------
//
const activeTimeRange = ref('')
//
const handleDatePickerChange = () => {
activeTimeRange.value = ''
}
//
const getObj = ref({
pageNum: 1,
@ -73,21 +46,32 @@ const getObj = ref({
const total = ref(100)
//
const getTime = ref({
startTime: '',
endTime: ''
})
const getTime = ref({})
//
const dept = ref([])
//
const sortField = ref('')
const sortOrder = ref('')
//
const permanentBean = ref(0)
const freeBean = ref(0)
const totalNum = ref(0)
/*
====================方法=================================
*/
//
const getDept = async function () {
try {
//
const result = await request({
// url: '/general/dept',
url: '/beanConsume/getDept', // todo
url: '/beanConsume/getDept', //
data: { account: adminData.value.account }
})
console.log('请求地区列表成功', result)
@ -103,27 +87,28 @@ const getDept = async function () {
}
}
// //
// const filterChannel = (query) => {
// if (query) {
// return channels.value.filter(item => item.toLowerCase().includes(query.toLowerCase()));
// }
// return channels.value;
// };
//
const sortField = ref('')
const sortOrder = ref('')
//
const permanentBean = ref(0)
const freeBean = ref(0)
const totalNum = ref(0)
//
const channels = ref([])
//
const getChannel = async function () {
try {
const result = await request({
url: '/beanConsume/getLiveChannel', // todo
data: { account: adminData.value.account }
})
console.log('请求频道列表成功', result)
//
channels.value = result.data
console.log('频道数据', channels.value)
} catch (error) {
console.log('请求频道列表失败', error)
ElMessage({
type: 'error',
message: '获取频道列表失败,请稍后重试'
})
}
}
/*
====================方法=================================
*/
//
const getAdminData = async function () {
try {
@ -139,10 +124,9 @@ const getAdminData = async function () {
}
}
const ConsumeSelectBy = async function (val) {
//
const searchCart = async function () {
try {
//
if (typeof val === 'number') {
getObj.value.pageNum = val
@ -151,19 +135,16 @@ const ConsumeSelectBy = async function (val) {
if (getTime.value != null) {
if (getTime.value.startTime != '' && getTime.value.endTime != '') {
beanConsumeArticle.value.startTime = formatTime(getTime.value[0])
beanConsumeArticle.value.endTime = formatTime(getTime.value[1])
beanCart.value.startTime = formatTime(getTime.value[0])
beanCart.value.endTime = formatTime(getTime.value[1])
}
} else {
beanConsumeArticle.value.startTime = ''
beanConsumeArticle.value.endTime = ''
beanCart.value.startTime = ''
beanCart.value.endTime = ''
}
beanConsumeArticle.value.sortField = sortField.value
beanConsumeArticle.value.sortOrder = sortOrder.value
beanCart.value.sortField = sortField.value
beanCart.value.sortOrder = sortOrder.value
console.log('搜索参数_时间', beanConsumeArticle.value.startTime)
console.log('搜索参数1', getObj.value)
console.log('搜索参数2', beanConsumeArticle.value)
// POST
const result = await request({
@ -171,210 +152,134 @@ const ConsumeSelectBy = async function (val) {
data: {
pageNum: getObj.value.pageNum,
pageSize: getObj.value.pageSize,
beanConsumeArticle: {
...beanConsumeArticle.value,
jwcode: beanConsumeArticle.value.jwcode,
dept: beanConsumeArticle.value.dept,
payMode: beanConsumeArticle.value.payMode,
articleId: beanConsumeArticle.value.articleId,
articleName: beanConsumeArticle.value.articleName,
author: beanConsumeArticle.value.author,
startTime: beanConsumeArticle.value.startTime,
endTime: beanConsumeArticle.value.endTime,
sortField: beanConsumeArticle.value.sortField,
sortOrder: beanConsumeArticle.value.sortOrder,
beanCart: {
...beanCart.value,
sortField: sortField.value,
sortOrder: sortOrder.value,
}
}
})
console.log('请求成功4', sortField)
console.log('接口响应结果', result); //
if (result.code === 200 && result.data && result.data.list) {
// type payMode
const filteredList = result.data.list.filter(item => {
if (beanConsumeArticle.value.payMode === '0') {
return [9, 10].includes(Number(item.type));
} else if (beanConsumeArticle.value.payMode === '1') {
return Number(item.type) === 11;
}
return true;
});
tableData.value = filteredList;
}
//
// beanConsumeArticle.value payType 8
const sumConsumeParams = {
payType: 8, // payType 8
beanConsumeArticle: {
...beanConsumeArticle.value,
beanCart: {
...beanCart.value,
}
};
}
// POST
const resultTotalGold = await request({
url: '/beanConsume/sumConsumeGold',
data: sumConsumeParams
});
})
console.log("总计", resultTotalGold);
console.log("总计", resultTotalGold)
const data = resultTotalGold.data || resultTotalGold;
console.log('请求成功3', resultTotalGold.data)
console.log('permanentBean3', data.permanentBean)
const data = resultTotalGold.data || resultTotalGold
// permanentBeanfreeBeantotalNum
permanentBean.value = Number(data.permanentBean) || 0;
freeBean.value = Number(data.freeBean) || 0;
totalNum.value = Number(data.totalNum) || 0;
permanentBean.value = Number(data.permanentBean) || 0
freeBean.value = Number(data.freeBean) || 0
totalNum.value = Number(data.totalNum) || 0
//
total.value = result.data.total
console.log('total', total.value)
} catch (error) {
console.log('请求失败', error)
ElMessage({
type: 'error',
message: '搜索失败,请稍后重试'
})
}
}
//
const search = function () {
getObj.value.pageNum = 1
if (beanConsumeArticle.value.jwcode) {
if (beanConsumeLive.value.jwcode) {
const numRef = /^\d{1,9}$/;
if (!numRef.test(beanConsumeArticle.value.jwcode)) {
if (!numRef.test(beanConsumeLive.value.jwcode)) {
ElMessage.error('请检查精网号格式')
return
}
}
if (beanConsumeArticle.value.articleId) {
const numRef = /^\d{1,9}$/;
if (!numRef.test(beanConsumeArticle.value.articleId)) {
ElMessage.error('请检查文章ID格式')
return
}
}
ConsumeSelectBy()
searchCart()
}
//
const reset = function () {
console.log('文章/视频的重置')
beanConsumeArticle.value.jwcode = null
beanConsumeArticle.value.dept = ''
beanConsumeArticle.value.type = ''
beanConsumeArticle.value.payMode = ''
beanConsumeArticle.value.articleId = ''
beanConsumeArticle.value.articleName = ''
beanConsumeArticle.value.author = ''
beanConsumeArticle.value.startTime = ''
beanConsumeArticle.value.endTime = ''
//
const reset = function () {
console.log('重置搜索条件')
beanCart.value = {
jwcode: null,
dept: "",
goodsName: "",
channelName: "",
liveName: "",
startTime: '',
endTime: '',
}
sortField.value = ''
sortOrder.value = ''
getTime.value = {}
activeTimeRange.value = '' //
//
ConsumeSelectBy()
console.log(' beanConsumeArticle', beanConsumeArticle.value)
}
//
const getToday = function () {
const today = dayjs()
const startTime = today.startOf('day').format('YYYY-MM-DD HH:mm:ss')
const endTime = today.endOf('day').format('YYYY-MM-DD HH:mm:ss')
getTime.value = [startTime, endTime]
console.log('getTime', getTime.value)
activeTimeRange.value = 'today' //
ConsumeSelectBy()
}
//
const getYesterday = function () {
const today = dayjs()
const startTime = today.subtract(1, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss')
const endTime = today.subtract(1, 'day').endOf('day').format('YYYY-MM-DD HH:mm:ss')
getTime.value = [startTime, endTime]
console.log('getTime', getTime.value)
activeTimeRange.value = 'yesterday' //
ConsumeSelectBy()
}
// 7
const get7Days = function () {
const today = dayjs()
const startTime = today.subtract(6, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss')
const endTime = today.endOf('day').format('YYYY-MM-DD HH:mm:ss')
getTime.value = [startTime, endTime]
console.log('getTime', getTime.value)
activeTimeRange.value = '7days' //
ConsumeSelectBy()
//
searchCart()
}
//
const handleDatePickerChange = (value) => {
if (value && value.length === 2) {
beanCart.value.startTime = formatTime(value[0])
beanCart.value.endTime = formatTime(value[1])
} else {
beanCart.value.startTime = ''
beanCart.value.endTime = ''
}
}
//
const handleSortChange = (column) => {
console.log('排序字段:', column.prop)
console.log('排序方式:', column.order)
if (column.prop === 'beanNum') {
sortField.value = 'beanNum'
} else if (column.prop === 'consumeTime') {
sortField.value = 'consumeTime'
} else if (column.prop === 'buyBean') {
sortField.value = 'buyBean'
} else if (column.prop === 'freeBean') {
sortField.value = 'freeBean'
//
const allowedSortFields = ['beanNum', 'consumeTime']
if (allowedSortFields.includes(column.prop)) {
sortField.value = column.prop
sortOrder.value = column.order === 'ascending' ? 'DESC' : 'ASC'
searchCart()
}
sortOrder.value = column.order === 'ascending' ? 'DESC' : 'ASC'
ConsumeSelectBy()
}
const handlePageSizeChange = function (val) {
getObj.value.pageSize = val
ConsumeSelectBy()
searchCart()
}
const handleCurrentChange = function (val) {
getObj.value.pageNum = val
ConsumeSelectBy()
searchCart()
}
/*
====================计算属性=================================
*/
//
// const totalBean = computed(() => permanentBean.value + freeBean.value)
/*
====================监听=================================
*/
/*
====================挂载=================================
*/
const format3 = (num) => {
//
return num.toLocaleString('en-US')
}
onMounted(async function () {
await getAdminData()
await ConsumeSelectBy()
await getDept()
await getChannel()
await searchCart()
})
const exportExcel = async function () {
const params = { //
const params = {
...getObj.value,
"beanConsumeArticle": {
...beanConsumeArticle.value,
"beanCart": {
...beanCart.value,
sortField: sortField.value,
sortOrder: sortOrder.value,
},
@ -384,7 +289,10 @@ const exportExcel = async function () {
ElMessage.success('导出成功')
}
}
const exportListVisible = ref(false)
const exportList = ref([])
const exportListLoading = ref(false)
//
const openExportList = () => {
@ -392,22 +300,15 @@ const openExportList = () => {
exportListVisible.value = true
}
//
const exportList = ref([])
//
const exportListLoading = ref(false)
//
const getExportList = async () => {
exportListLoading.value = true
try {
const result = await API({ url: '/export/export' })
const result = await API({ url: '/export/export' })
if (result.code === 200) {
const filteredData = result.data.filter(item => {
return item.type === 8; //8/
});
exportList.value = filteredData
ElMessage.success('导出成功')
} else {
ElMessage.error(result.msg || '获取导出列表失败')
ElMessage.error(result.msg || '获取导出列表失败')
}
} catch (error) {
console.error('获取导出列表出错:', error)
@ -416,6 +317,7 @@ const getExportList = async () => {
exportListLoading.value = false
}
}
//
const downloadExportFile = (item) => {
if (item.state === 2) {
@ -427,34 +329,36 @@ const downloadExportFile = (item) => {
ElMessage.warning('文件还在导出中,请稍后再试')
}
}
//
const getTagType = (state) => {
switch (state) {
case 0:
return 'info';
return 'info'
case 1:
return 'primary';
return 'primary'
case 2:
return 'success';
return 'success'
case 3:
return 'danger';
return 'danger'
default:
return 'info';
return 'info'
}
}
//
const getTagText = (state) => {
switch (state) {
case 0:
return '待执行';
return '待执行'
case 1:
return '执行中';
return '执行中'
case 2:
return '执行完成';
return '执行完成'
case 3:
return '执行出错';
return '执行出错'
default:
return '未知状态';
return '未知状态'
}
}
</script>
@ -465,31 +369,28 @@ const getTagText = (state) => {
<div class="select">
<div class="selectRow">
<el-text class="text" size="large">精网号</el-text>
<el-input class="selectContent" v-model="beanConsumeArticle.jwcode" placeholder="请输入精网号" clearable />
<el-input class="selectContent" v-model="beanCart.jwcode" placeholder="请输入精网号" clearable />
</div>
<div class="selectRow">
<el-text class="text" size="large">所属地区</el-text>
<el-select class="selectContent" v-model="beanConsumeArticle.dept" placeholder="请选择地区" clearable>
<el-select class="selectContent" v-model="beanCart.dept" placeholder="请选择地区" clearable>
<el-option v-for="(item, index) in dept" :key="index" :label="item" :value="item" />
</el-select>
</div>
<div class="selectRow">
<el-text class="text" size="large">商品名称</el-text>
<el-select class="selectContent" style="width: 20px" v-model="beanConsumeArticle.payMode" placeholder="请选择类型"
clearable @change="handlePayModeChange">
<el-option label="打赏" value="0" />
<el-option label="付费购买" value="1" />
<el-option label="其他" value="2" />
</el-select>
<el-input class="selectContent" v-model="beanCart.goodsName" placeholder="请输入商品名称" clearable />
</div>
<div class="selectRow">
<el-text class="text">频道名称</el-text>
<el-select class="selectContent" placeholder="请选择频道" clearable filterable>
<el-option v-for="(item, index) in channels" :key="index" :label="item" :value="item" />
<div class="selectRow" style="width: 12vw;">
<el-text class="textB" size="large">频道</el-text>
<el-select class="selectContent" v-model="beanCart.channelName" placeholder="请选择频道" clearable
filterable allow-create default-first-option>
<el-option v-for="(item, index) in channels"
:key="index"
:label="item"
:value="item" />
</el-select>
</div>
</div>
</el-col>
@ -497,31 +398,34 @@ const getTagText = (state) => {
<div class="select">
<div class="selectRow" style="width: 33vw;">
<el-text class="text" size="large">下单时间</el-text>
<el-date-picker class="selectContent" v-model="getTime" type="datetimerange" range-separator=""
start-placeholder="起始时间" end-placeholder="结束时间" style="width:25vw" @change="handleDatePickerChange"
value-format="YYYY-MM-DD HH:mm:ss" :default-time="defaultTime" />
<div v-if="false">
<el-button @click="getToday()" :type="activeTimeRange === 'today' ? 'primary' : ''"></el-button>
<el-button @click="getYesterday()" :type="activeTimeRange === 'yesterday' ? 'primary' : ''"></el-button>
<el-button @click="get7Days()" :type="activeTimeRange === '7days' ? 'primary' : ''">近7天</el-button>
</div>
<el-date-picker
class="selectContent"
v-model="getTime"
type="datetimerange"
range-separator="至"
start-placeholder="起始时间"
end-placeholder="结束时间"
style="width:25vw"
@change="handleDatePickerChange"
value-format="YYYY-MM-DD HH:mm:ss"
/>
</div>
<div class="selectRow">
<el-text class="text" size="large">直播间名称</el-text>
<el-input class="selectContent" placeholder="请输入直播间" clearable />
<el-input class="selectContent" v-model="beanCart.liveName" placeholder="请输入直播间名称" clearable />
</div>
</div>
</el-col>
<el-col>
<div class="selectButton">
<el-button type="primary" @click="search()">查询</el-button>
<el-button type="primary" @click="exportExcel()">导出Excel</el-button>
<el-button type="primary" @click="search">查询</el-button>
<el-button type="primary" @click="exportExcel">导出Excel</el-button>
<el-button type="primary" @click="openExportList">查看导出列表</el-button>
<el-button type="success" @click="reset()">重置</el-button>
<el-button type="success" @click="reset">重置</el-button>
</div>
</el-col>
</el-card>
<el-card class="card2">
<div class="goldStatistics">
金豆总数{{ format3(Math.abs(permanentBean + freeBean)) }}&nbsp;&nbsp;&nbsp;&nbsp;
@ -529,8 +433,13 @@ const getTagText = (state) => {
免费金豆数{{ format3(Math.abs(freeBean)) }}
</div>
<div style="overflow-y: auto">
<el-table :data="tableData" style="width: 82vw" height="64vh" @sort-change="handleSortChange"
:row-style="{ height: '50px' }">
<el-table
:data="tableData"
style="width: 82vw"
height="64vh"
@sort-change="handleSortChange"
:row-style="{ height: '50px' }"
>
<el-table-column type="index" label="序号" width="110px" fixed="left">
<template #default="scope">
<span>{{
@ -543,10 +452,10 @@ const getTagText = (state) => {
<!-- 固定精网号列 -->
<el-table-column prop="jwcode" label="精网号" width="140px" fixed="left" />
<el-table-column prop="dept" label="地区" width="140px" />
<el-table-column prop="type" label="商品名称" width="160px"/>
<el-table-column prop="goodsName" label="商品名称" width="160px"/>
<el-table-column prop="beanNum" label="金币数量" sortable="custom" width="140px" />
<el-table-column prop="buyBean" label="频道名称" width="160px" show-overflow-tooltip />
<el-table-column prop="freeBean" label="直播间名称" width="160px" show-overflow-tooltip />
<el-table-column prop="channelName" label="频道名称" width="160px" show-overflow-tooltip />
<el-table-column prop="liveName" label="直播间名称" width="160px" show-overflow-tooltip />
<el-table-column prop="consumeTime" label="下单时间" sortable="custom" width="180px">
<template #default="scope">
{{ formatTime(scope.row.consumeTime) }}
@ -557,9 +466,15 @@ const getTagText = (state) => {
<!-- 分页 -->
<div class="pagination">
<el-pagination background :page-size="getObj.pageSize" :page-sizes="[5, 10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handlePageSizeChange"
@current-change="handleCurrentChange"></el-pagination>
<el-pagination
background
:page-size="getObj.pageSize"
:page-sizes="[5, 10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
@size-change="handlePageSizeChange"
@current-change="handleCurrentChange"
></el-pagination>
</div>
</el-card>
@ -581,8 +496,7 @@ const getTagText = (state) => {
</el-table-column>
<el-table-column label="操作">
<template #default="scope">
<el-button type="primary" size="small" @click="downloadExportFile(scope.row)"
:disabled="scope.row.state !== 2">
<el-button type="primary" size="small" @click="downloadExportFile(scope.row)" :disabled="scope.row.state !== 2">
下载
</el-button>
</template>
@ -663,10 +577,6 @@ const getTagText = (state) => {
width: 5vw;
font-size: 15px;
}
.textB {
width: 7vw;
font-size: 15px;
}
.selectContent {
flex: 1;

Loading…
Cancel
Save