Commit 126c5a9c authored by daywrite's avatar daywrite

销售数据

parent 6480c2c3
export default { export default {
methods: { methods: {
/* eslint-disable */ /* eslint-disable */
c () { c (id, data) {
var chart = Highcharts.chart('key', { let _data = data.values
Highcharts.chart(id, {
chart: { chart: {
type: 'column' type: 'column'
}, },
title: { title: {
text: '堆叠柱形图' text: ''
},
subtitle: {
text: ''
}, },
xAxis: { xAxis: {
categories: ['苹果', '橘子', '梨', '葡萄', '香蕉'] type: 'category',
gridLineWidth: 1,
labels: {
useHTML:true
}
}, },
yAxis: { yAxis: {
min: 0,
title: { title: {
text: '水果消费总量' text: ''
}, },
stackLabels: { // 堆叠数据标签 gridLineWidth: 1,
enabled: true, labels: {
style: { formatter: function () {
fontWeight: 'bold', return (this.value / 10000) + '万'
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
}, },
legend: {
align: 'right',
x: -30,
verticalAlign: 'top',
y: 25,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
}, },
tooltip: { plotLines:[{
formatter: function () { color:'red',
return '<b>' + this.x + '</b><br/>' + dashStyle:'solid',
this.series.name + ': ' + this.y + '<br/>' + value: _data.average,
'总量: ' + this.point.stackTotal; label: _data.average + '',
} width:2
}]
},
legend: {
enabled: false
}, },
plotOptions: { plotOptions: {
column: { series: {
stacking: 'normal', borderWidth: 0,
dataLabels: { dataLabels: {
enabled: true, enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white', format: '{point.y}'
style: {
// 如果不需要数据标签阴影,可以将 textOutline 设置为 'none'
textOutline: '1px 1px black'
}
} }
} }
}, },
tooltip: {
headerFormat: '<span style="font-size:12px">业绩分析</span><br>',
pointFormat: '<span>{point.name}</span>: <b>{point.y}</b><br/>'
},
series: [{ series: [{
name: '小张', colorByPoint: true,
data: [5, 3, 4, 7, 2] data: _data.summary
}, {
name: '小彭',
data: [2, 2, 3, 2, 1]
}, {
name: '小潘',
data: [3, 4, 4, 2, 5]
}] }]
}); });
} }
......
<template> <template>
<section> <section>
<div class="content"> <div class="content">
<search-header
ref="searchHeader"
:title="'销售数据'"
@update:headerClear="() => searchClear()">
</search-header>
<time-search-form <time-search-form
ref="timeSearchForm" ref="timeSearchForm"
formSearchKey="projectSearch" formSearchKey="projectSearch"
@update:list="search => timeSearchForm(search)">
</time-search-form>
<search-form
ref="clientForm"
:filter="filter" :filter="filter"
@update:clientList="form =>{ updateForm(form) }"> @update:form="search => timeSearchForm(search)">
</search-form> </time-search-form>
<div class="page-body-content"> <div class="page-body-content">
<div class="mb10"> <div class="mb10">
<singleRadioTool <singleRadioTool
...@@ -32,12 +23,8 @@ ...@@ -32,12 +23,8 @@
</el-col> </el-col>
</el-row> </el-row>
<div class="header-title header-flex" style="height: 100%;"> <div class="header-title header-flex" style="height: 100%;">
<!-- <div v-for="item in chartTypeArray">
<span class="title-two">{{ item.name }}</span>
<div :id="item.key" style="height:400px;"></div>
</div> -->
<div> <div>
<span class="title-two">123</span> <span class="title-two">售前工程师统计信息</span>
<div id="key" style="height:400px;"></div> <div id="key" style="height:400px;"></div>
</div> </div>
</div> </div>
...@@ -51,7 +38,7 @@ ...@@ -51,7 +38,7 @@
import SearchHeader from '../../common/searchHeader' import SearchHeader from '../../common/searchHeader'
import SearchForm from '../../common/SearchForm' import SearchForm from '../../common/SearchForm'
import countArr from '../analysis/countArr' import countArr from '../analysis/countArr'
import TimeSearchForm from '../analysis/searchForm' import TimeSearchForm from './searchForm'
import singleRadioTool from '../../common/singleRadioTool' import singleRadioTool from '../../common/singleRadioTool'
import preSales from './preSales.js' import preSales from './preSales.js'
import { import {
...@@ -91,14 +78,13 @@ export default { ...@@ -91,14 +78,13 @@ export default {
methods: { methods: {
init () { init () {
this.getFilter() this.getFilter()
this.getSalesChart()
}, },
getSalesChart () { getSalesChart (params) {
requestAPI(api.getPreSalesChart, {}) requestAPI(api.getPreSalesChart, params)
.then(res => { .then(res => {
this.result.countList = res.counts this.result.countList = res.counts
this.c() this.c('key', res.chars.individualJournalContributions)
}) })
}, },
...@@ -106,12 +92,6 @@ export default { ...@@ -106,12 +92,6 @@ export default {
getFilter () { getFilter () {
requestAPI(api.getFilterSalesChart).then(res => { requestAPI(api.getFilterSalesChart).then(res => {
this.filter = res this.filter = res
// let _inx = res.findIndex(item => item.key === 'CaseSearch[case_status]')
// let _newRes = res.splice(_inx, 1)
// this.filter = res
// let _navArray = _newRes[0].value
// _navArray.unshift({key: 'all', name: '全部'})
// this.navArray = _navArray
}) })
}, },
...@@ -127,22 +107,9 @@ export default { ...@@ -127,22 +107,9 @@ export default {
searchClear () { searchClear () {
}, },
// 5.1查询条件
updateForm (search) {
let ret = this.setParams({
...this.form,
page: this.pagenation.thispage
}, search)
this.getList(ret)
},
// 5.3 TimeSearchForm // 5.3 TimeSearchForm
timeSearchForm (search) { timeSearchForm (search) {
let ret = this.setParams({ this.getSalesChart(search)
...this.form,
page: this.pagenation.thispage
}, search)
this.getList(ret)
} }
} }
......
<template>
<section class="analysis-client">
<el-row :gutter="10" class="header-title">
<el-col :span="4">
<h2>销售数据</h2>
</el-col>
<el-col :span="20">
<el-form ref="form" size="mini">
<el-col :span="6" :xs="24">
<el-form-item label=" " label-width="42">
<el-radio-group v-model="form.period" size="mini" @change="periodChangeEvent">
<el-radio-button label="thisweek">本周</el-radio-button>
<el-radio-button label="lastweek">上周</el-radio-button>
<el-radio-button label="thismonth">本月</el-radio-button>
<el-radio-button label="lastmonth">上月</el-radio-button>
</el-radio-group>
<el-button-group>
<el-button type="primary" size="mini" :class="setYearClass" @click="triggerYear">{{setYearText}}
</el-button>
<el-dropdown size="small" placement="bottom-start" @command="handleCommand" trigger="click">
<el-button type="primary" size="mini" icon="el-icon-caret-bottom" class="trigger-year yearClass"></el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="year.value" v-for="(year, key) in perYears" :key="key">{{year.name}}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-button-group>
</el-form-item>
</el-col>
</el-form>
<el-form ref="clientTimeRange" size="mini">
<el-col :span="10" :offset="0" :xs="{span: 24, offset: 0}" class="form-content-time-range">
<el-form-item label-width="0">
<el-date-picker
size="mini"
v-model="form.from"
type="date"
value-format="yyyy-MM-dd"
placeholder="开始时间">
</el-date-picker>
<el-date-picker
size="mini"
v-model="form.to"
type="date"
value-format="yyyy-MM-dd"
placeholder="结束时间">
</el-date-picker>
<el-button type="primary" size="mini" class="head-date-button" @click="setSearchTime">确定</el-button>
</el-form-item>
</el-col>
</el-form>
<el-form ref="clientForm" size="mini" label-width="0" label-position="top">
<el-col :span="4">
<el-form-item>
<el-select v-model="form.dataUserId">
<el-option v-for="sItem in userArr"
:key="sItem.key"
:label="sItem.name"
:value="sItem.key"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-form>
</el-col>
</el-row>
</section>
</template>
<script>
let checkDate = () => {
let setTimeFormat = (date) => {
let myYear = date.getFullYear()
let myMonth = date.getMonth() + 1
let myWeekday = date.getDate()
if (myMonth < 10) {
myMonth = '0' + myMonth
}
if (myWeekday < 10) {
myWeekday = '0' + myWeekday
}
return (myYear + '-' + myMonth + '-' + myWeekday)
}
let now = new Date() // 当前日期
let nowDayOfWeek = now.getDay() // 今天本周的第几天
let nowDay = now.getDate() // 当前日
let nowMonth = now.getMonth() // 当前月
let nowYear = now.getFullYear() // 当前年
return {
currentStartDate: nowYear + '-1' + '-1',
currentEndDate: nowYear + '-12' + '-31',
startWeek: setTimeFormat(new Date(nowYear, nowMonth, nowDay - nowDayOfWeek)),
endWeek: setTimeFormat(new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek))),
beforeStartWeek: setTimeFormat(new Date(nowYear, nowMonth, nowDay - nowDayOfWeek - 7)),
beforeEndWeek: setTimeFormat(new Date(nowYear, nowMonth, nowDay - nowDayOfWeek - 1)),
startMonth: setTimeFormat(new Date(nowYear, nowMonth, 1)),
endMonth: setTimeFormat(new Date(nowYear, nowMonth + 1, 0)),
beforeStartMonth: setTimeFormat(new Date(nowYear, nowMonth - 1, 1)),
beforeEndMonth: setTimeFormat(new Date(nowYear, nowMonth, 0))
}
}
const perYears = [
{
name: '本财年',
value: 'currentfascalyear'
},
{
name: '2017年',
value: 'year2017'
},
{
name: '2018年',
value: 'year2018'
},
{
name: '2019年',
value: 'year2019'
}
]
export default {
name: 'timeSearchForm',
props: ['filter'],
data () {
return {
form: {
from: checkDate().currentStartDate,
to: checkDate().currentEndDate,
period: '',
dataUserId: ''
},
perYears,
checkYear: 'currentfascalyear',
checkDate: checkDate()
}
},
created () {
},
computed: {
userArr () {
let _ret = this.filter
if (_ret && _ret.length !== 0) {
let _userArr = _ret.filter.find(item => item.key === 'dataUserId').value
this.form.dataUserId = _userArr[0].key
return _userArr
} else {
return []
}
},
setYearText () {
let year = this.perYears.find(i => i.value === this.checkYear)
if (year) {
return year.name
} else {
return '本财年'
}
},
setYearClass () {
if (this.form.period === '' && this.checkYear !== '') {
return 'check-year'
} else {
return ''
}
}
},
methods: {
triggerYear () {
if (this.checkYear === '') {
this.checkYear = 'currentfascalyear'
this.form.period = ''
this.setFullYear(new Date().getFullYear())
let _val = JSON.parse(JSON.stringify(this.form))
if (this.checkYear !== '') {
_val.period = this.checkYear
}
this.$emit('update:form', _val)
}
},
handleCommand (command) {
this.checkYear = command
this.form.period = ''
if (command === 'currentfascalyear') {
this.setFullYear(new Date().getFullYear())
} else {
this.setFullYear(command.replace(/[^0-9]/ig, ''))
}
let _val = JSON.parse(JSON.stringify(this.form))
if (this.checkYear !== '') {
_val.period = this.checkYear
}
this.$emit('update:form', _val)
},
setFullYear (year) {
let d = new Date()
d.setFullYear(year)
this.form.from = d.getFullYear() + '-01-01'
this.form.to = d.getFullYear() + '-12-31'
},
periodChangeEvent (val) {
this.checkYear = ''
if (val === 'thisweek') {
this.form.from = this.checkDate.startWeek
this.form.to = this.checkDate.endWeek
} else if (val === 'lastweek') {
this.form.from = this.checkDate.beforeStartWeek
this.form.to = this.checkDate.beforeEndWeek
} else if (val === 'thismonth') {
this.form.from = this.checkDate.startMonth
this.form.to = this.checkDate.endMonth
} else if (val === 'lastmonth') {
this.form.from = this.checkDate.beforeStartMonth
this.form.to = this.checkDate.beforeEndMonth
}
},
setSearchTime () {}
},
watch: {
'form': {
handler (val) {
let _val = JSON.parse(JSON.stringify(val))
if (this.checkYear !== '') {
_val.period = this.checkYear
}
this.$emit('update:form', _val)
},
deep: true,
immediate: true
}
}
}
</script>
<style scoped>
.form-content-time-top {
background: #FFF;
}
.form-content-time-top .el-form-item {
margin: 7px 0 9px;
}
.form-content-time-top .el-col {
padding: 0 15px;
}
.el-dropdown {
top: -1px;
}
.analysis-client .el-button-group > .el-button {
color: #333;
background-color: #fff;
border: 1px solid #ccc;
}
.analysis-client .el-dropdown > .el-button {
padding-left: 6px;
padding-right: 6px;
border-left-width: 1px;
border-left-color: #ccc;
}
.analysis-client .trigger-year {
color: #333;
background-color: #fff;
border-color: #ccc;
border-right: 1px solid #ccc !important;
}
.analysis-client .head-date-button {
color: #fff;
background-color: #333744;
border-color: #282b35;
}
.analysis-client .check-year {
color: #fff !important;
background-color: #17a2b8 !important;
border-color: #17a2b8 !important;
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment