Commit ba5b726c by xinla

红包接口调试

1 parent 4dd1e919
...@@ -27,23 +27,7 @@ export function getChartList(params) { ...@@ -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 * @param {*} params
* { * {
pageNum 是 当前页 pageNum 是 当前页
...@@ -52,87 +36,9 @@ status 是 0:启用;1:停用 ...@@ -52,87 +36,9 @@ status 是 0:启用;1:停用
sceneType 是 1:客户;2:客群;3:客户与客群 sceneType 是 1:客户;2:客群;3:客户与客群
} }
*/ */
export function redEnvelopes(params) { export function getRecordList(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) {
return request({ return request({
url: service + '/findLimitUserRedEnvelops', url: service + '/findRecordGroupByUserId',
params params
}) })
} }
...@@ -119,8 +119,13 @@ export default { ...@@ -119,8 +119,13 @@ export default {
this.query.pageSize || (this.query.pageSize = 10) this.query.pageSize || (this.query.pageSize = 10)
} }
this.query.beginTime = this.dateRange && this.dateRange[0] if (this.dateRange) {
this.query.endTime = this.dateRange && this.dateRange[1] this.query.beginTime = this.dateRange[0]
this.query.endTime = this.dateRange[1]
} else {
this.query.beginTime = ''
this.query.endTime = ''
}
if (this.dialogType === '_users') { if (this.dialogType === '_users') {
if (Array.isArray(this.userArray)) { if (Array.isArray(this.userArray)) {
this.query.deptIds = this.userArray this.query.deptIds = this.userArray
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
<div class="g-card g-pad20" style="margin-top: 0"> <div class="g-card g-pad20" style="margin-top: 0">
<CardGroupIndex :data="cardData"></CardGroupIndex> <CardGroupIndex :data="cardData"></CardGroupIndex>
</div> </div>
<!-- <div class="divider-content"></div> -->
<div class="g-card g-pad20"> <div class="g-card g-pad20">
<div class="table-header">支出统计</div> <div class="table-header">支出统计</div>
<div class="chart-header"> <div class="chart-header">
...@@ -31,7 +30,7 @@ ...@@ -31,7 +30,7 @@
@change="getList" @change="getList"
></el-date-picker> ></el-date-picker>
</div> </div>
<div> <div v-loading="loadingChart">
<div id="chart" class="chart" ref="chart" style="width: 90%; height: 400px"></div> <div id="chart" class="chart" ref="chart" style="width: 90%; height: 400px"></div>
</div> </div>
</div> </div>
...@@ -65,7 +64,7 @@ import * as echarts from 'echarts' ...@@ -65,7 +64,7 @@ import * as echarts from 'echarts'
import { parseTime } from '@/utils/common' import { parseTime } from '@/utils/common'
import CardGroupIndex from '@/components/CardGroupIndex' import CardGroupIndex from '@/components/CardGroupIndex'
// import TabContent from './components/TabContent' // import TabContent from './components/TabContent'
import { getAnalysis, countLineChart, exportGroup } from '@/api/redPacketTool/sendRecord' import { getAnalysis, getChartList, getRecordList } from '@/api/redPacketTool/spendStatistics'
function generateMockData() { function generateMockData() {
// 7天和30天的假数据 // 7天和30天的假数据
...@@ -101,14 +100,15 @@ export default { ...@@ -101,14 +100,15 @@ export default {
timeRange: 7, timeRange: 7,
dateRange: [], dateRange: [],
loading: false, loading: false,
list: [], loadingChart: false,
total: 0,
query: { query: {
pageNum: 1, pageNum: 1,
pageSize: 0 pageSize: 0
}, },
cardData: [], list: [],
mockData: null total: 0,
cardData: []
// mockData: null
} }
}, },
mounted() { mounted() {
...@@ -118,8 +118,10 @@ export default { ...@@ -118,8 +118,10 @@ export default {
<div>统计分析企业支出金额及笔数情况</div> <div>统计分析企业支出金额及笔数情况</div>
` `
) )
this.mockData = generateMockData()
// this.mockData = generateMockData()
this.setTime(7) this.setTime(7)
this.getRecordList(7)
}, },
methods: { methods: {
getList() { getList() {
...@@ -157,9 +159,36 @@ export default { ...@@ -157,9 +159,36 @@ export default {
}) })
}, },
getChartList() { 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 this.loading = true
getChartList() getRecordList(this.query)
.then(({ data }) => {}) .then(({ data, total }) => {
this.list = data
this.total = +total
})
.catch((e) => { .catch((e) => {
console.log(e) console.log(e)
}) })
...@@ -174,7 +203,6 @@ export default { ...@@ -174,7 +203,6 @@ export default {
date.setDate(date.getDate() - days) date.setDate(date.getDate() - days)
this.dateRange = [this.getTime(date), this.getTime()] this.dateRange = [this.getTime(date), this.getTime()]
this.getChartList() this.getChartList()
this.setEchart()
}, },
getTime(datePar) { getTime(datePar) {
const d = datePar ? new Date(datePar) : new Date() const d = datePar ? new Date(datePar) : new Date()
...@@ -186,80 +214,89 @@ export default { ...@@ -186,80 +214,89 @@ export default {
getHandledValue(num) { getHandledValue(num) {
return num < 10 ? '0' + num : num return num < 10 ? '0' + num : num
}, },
setEchart() { setEchart(seriesData) {
setTimeout(() => { setTimeout(() => {
this.drawLine( this.drawLine('chart', ['支出金额', '支出笔数'], seriesData, ['#5AD2D2', '#637BC0'])
'chart',
['累计支出金额(元)', '今日支出笔数'],
this.mockData[this.timeRange],
['#5AD2D2', '#637BC0']
)
}, 1000) }, 1000)
}, },
drawLine(id, arrData, data, color) { drawLine(id, legend, xAxisData, seriesData, color) {
const obj = document.getElementById(id) const dom = document.getElementById(id)
let width = obj.parentNode.offsetWidth || window.innerWidth - 100 let width = obj.parentNode.offsetWidth || window.innerWidth - 100
obj.style.width = width + 'px' dom.style.width = width + 'px'
obj.style.height = '400px' dom.style.height = '400px'
const charts = echarts.init(obj) 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, color: color,
tooltip: { tooltip: {
trigger: 'axis' trigger: 'axis'
}, },
legend: { legend: {
data: arrData data: legend,
bottom: '0%'
}, },
grid: { grid: {
left: '3%', left: '3%',
right: '4%', right: '4%',
bottom: '3%', bottom: '40px',
containLabel: true containLabel: true
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
boundaryGap: false, // boundaryGap: false,
data: data.xAxis, data: xAxisData,
axisLine: { axisLine: {
lineStyle: { lineStyle: {
color: '#ccc' color: '#ccc'
} }
} }
}, },
yAxis: { yAxis,
type: 'value', series
axisLine: {
lineStyle: {
color: '#ccc'
}
} }
},
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) charts.setOption(chartOption)
this.$nextTick(() => { new ResizeObserver((entries) => {
charts.resize() charts.resize()
}) }).observe(dom)
// if (process.client) { // if (process.client) {
// window.addEventListener('resize', function() { // 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!