Commit ba5b726c by xinla

红包接口调试

1 parent 4dd1e919
......@@ -27,23 +27,7 @@ export function getChartList(params) {
}
/**
* 新建或编辑红包
* params {
"money": 45, //金额
"sceneType": 37,//场景 1:客户;2:客群;3:客户与客群
"name": "华东界派" //红包名称
}
*/
export function addorUpdateRedEnvelopes(params) {
return request({
url: service + '/addorUpdateRedEnvelopes',
method: 'post',
data: params
})
}
/**
* 获取企业红包列表
* 支出统计-支出记录
* @param {*} params
* {
pageNum 是 当前页
......@@ -52,87 +36,9 @@ status 是 0:启用;1:停用
sceneType 是 1:客户;2:客群;3:客户与客群
}
*/
export function redEnvelopes(params) {
return request({
url: service + '/redEnvelopes',
params
})
}
/**
* 启用或者停用红包
* @param {*}
{
"id": 1483268831952322561, //主键
"status": 1 //0:启用;1:停用
}
*/
export function startOrStopRedEnvelope(params) {
return request({
url: service + '/startOrStopRedEnvelope',
method: 'put',
data: params
})
}
/**
* 删除红包
ids 红包主键,多个用逗号隔开
*/
export function deleteRedEnvelop(ids) {
return request({
url: service + `deleteRedEnvelop/${ids}`,
method: 'delete'
})
}
/**
* 新建或编辑员工限额
* @param {*} params
{
"id":1483367396696686593,//存在则传,不存在则传null
"userId": "haon", //员工id
"singleCustomerReceiveNum": 39, //单日每员工发红包次数
"singleCustomerReceiveMoney": 23.94 //单日每员工发红包总额
}
*/
export function addOrUpdateUserRedEnvelopsLimit(params) {
return request({
url: service + '/addOrUpdateUserRedEnvelopsLimit',
method: 'post',
data: params
})
}
/**
* 批量更新或编辑员工限额
* @param {*} params
{
"ids": "1483367396696686593,1483369708055994370",//id,多个使用逗号隔开
"singleCustomerReceiveNum": 90,//单日每员工发红包次数
"singleCustomerReceiveMoney": 90 //单日每员工发红包总额
}
*/
export function batchUpdateUserRedEnvelopsLimit(params) {
return request({
url: service + '/batchUpdateUserRedEnvelopsLimit',
method: 'post',
data: params
})
}
/**
* 员工限额列表获取
* @param {*} params
{
pageNum 是 当前页
pageSize 是 每页显示条数
userId 是 检索条件,传员工id
}
*/
export function findLimitUserRedEnvelops(params) {
export function getRecordList(params) {
return request({
url: service + '/findLimitUserRedEnvelops',
url: service + '/findRecordGroupByUserId',
params
})
}
......@@ -119,8 +119,13 @@ export default {
this.query.pageSize || (this.query.pageSize = 10)
}
this.query.beginTime = this.dateRange && this.dateRange[0]
this.query.endTime = this.dateRange && this.dateRange[1]
if (this.dateRange) {
this.query.beginTime = this.dateRange[0]
this.query.endTime = this.dateRange[1]
} else {
this.query.beginTime = ''
this.query.endTime = ''
}
if (this.dialogType === '_users') {
if (Array.isArray(this.userArray)) {
this.query.deptIds = this.userArray
......
......@@ -4,7 +4,6 @@
<div class="g-card g-pad20" style="margin-top: 0">
<CardGroupIndex :data="cardData"></CardGroupIndex>
</div>
<!-- <div class="divider-content"></div> -->
<div class="g-card g-pad20">
<div class="table-header">支出统计</div>
<div class="chart-header">
......@@ -31,7 +30,7 @@
@change="getList"
></el-date-picker>
</div>
<div>
<div v-loading="loadingChart">
<div id="chart" class="chart" ref="chart" style="width: 90%; height: 400px"></div>
</div>
</div>
......@@ -65,7 +64,7 @@ import * as echarts from 'echarts'
import { parseTime } from '@/utils/common'
import CardGroupIndex from '@/components/CardGroupIndex'
// import TabContent from './components/TabContent'
import { getAnalysis, countLineChart, exportGroup } from '@/api/redPacketTool/sendRecord'
import { getAnalysis, getChartList, getRecordList } from '@/api/redPacketTool/spendStatistics'
function generateMockData() {
// 7天和30天的假数据
......@@ -101,14 +100,15 @@ export default {
timeRange: 7,
dateRange: [],
loading: false,
list: [],
total: 0,
loadingChart: false,
query: {
pageNum: 1,
pageSize: 0
},
cardData: [],
mockData: null
list: [],
total: 0,
cardData: []
// mockData: null
}
},
mounted() {
......@@ -118,8 +118,10 @@ export default {
<div>统计分析企业支出金额及笔数情况</div>
`
)
this.mockData = generateMockData()
// this.mockData = generateMockData()
this.setTime(7)
this.getRecordList(7)
},
methods: {
getList() {
......@@ -157,9 +159,36 @@ export default {
})
},
getChartList() {
this.loadingChart = true
if (this.dateRange) {
this.query.beginTime = this.dateRange[0]
this.query.endTime = this.dateRange[1]
} else {
this.query.beginTime = ''
this.query.endTime = ''
}
getChartList(this.query)
.then(({ data }) => {
let seriesData = [] // this.mockData[this.timeRange]
seriesData[0] = data.map((e) => e.totalMoney)
seriesData[1] = data.map((e) => e.totalNum)
xAxisData = data.map((e) => e.createTime)
this.setEchart(xAxisData, seriesData)
})
.catch((e) => {
console.log(e)
})
.finally(() => {
this.loadingChart = false
})
},
getRecordList() {
this.loading = true
getChartList()
.then(({ data }) => {})
getRecordList(this.query)
.then(({ data, total }) => {
this.list = data
this.total = +total
})
.catch((e) => {
console.log(e)
})
......@@ -174,7 +203,6 @@ export default {
date.setDate(date.getDate() - days)
this.dateRange = [this.getTime(date), this.getTime()]
this.getChartList()
this.setEchart()
},
getTime(datePar) {
const d = datePar ? new Date(datePar) : new Date()
......@@ -186,80 +214,89 @@ export default {
getHandledValue(num) {
return num < 10 ? '0' + num : num
},
setEchart() {
setEchart(seriesData) {
setTimeout(() => {
this.drawLine(
'chart',
['累计支出金额(元)', '今日支出笔数'],
this.mockData[this.timeRange],
['#5AD2D2', '#637BC0']
)
this.drawLine('chart', ['支出金额', '支出笔数'], seriesData, ['#5AD2D2', '#637BC0'])
}, 1000)
},
drawLine(id, arrData, data, color) {
const obj = document.getElementById(id)
drawLine(id, legend, xAxisData, seriesData, color) {
const dom = document.getElementById(id)
let width = obj.parentNode.offsetWidth || window.innerWidth - 100
obj.style.width = width + 'px'
obj.style.height = '400px'
const charts = echarts.init(obj)
dom.style.width = width + 'px'
dom.style.height = '400px'
const charts = echarts.init(dom)
let series = []
let yAxis = []
seriesData.forEach((iData, index) => {
let max = iData.slice().sort((a, b) => b - a)[0]
// 最大值上取整最近的10的正数倍
max = Math.ceil(max / 10) * 10
yAxis.push({
name: legend[index],
type: 'value',
min: 0,
max,
interval: max / 5,
axisLine: {
// show: false,
lineStyle: {
color: '#ccc'
}
}
})
series.push({
name: legend[index],
type: index === 0 ? 'line' : 'bar',
yAxisIndex: index,
smooth: true,
data: iData,
itemStyle: {
normal: {
lineStyle: {
color: color[index]
}
}
},
textStyle: {
color: '#fff' // 主标题文字的颜色。
}
})
})
const chartOption = {
let chartOption = {
color: color,
tooltip: {
trigger: 'axis'
},
legend: {
data: arrData
data: legend,
bottom: '0%'
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
bottom: '40px',
containLabel: true
},
xAxis: {
type: 'category',
boundaryGap: false,
data: data.xAxis,
axisLine: {
lineStyle: {
color: '#ccc'
}
}
},
yAxis: {
type: 'value',
// boundaryGap: false,
data: xAxisData,
axisLine: {
lineStyle: {
color: '#ccc'
}
}
},
series: []
yAxis,
series
}
chartOption.series = data.data.map((i, index) => ({
name: arrData[index],
type: 'line',
stack: arrData[index],
smooth: true,
data: i,
itemStyle: {
normal: {
lineStyle: {
color: color[index]
}
}
},
textStyle: {
color: '#fff' // 主标题文字的颜色。
}
}))
charts.setOption(chartOption)
this.$nextTick(() => {
new ResizeObserver((entries) => {
charts.resize()
})
}).observe(dom)
// if (process.client) {
// window.addEventListener('resize', function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!