Commit 3eede311 authored by daywrite's avatar daywrite

销售分析

parent 71e38278
......@@ -67,6 +67,7 @@
</section>
</template>
<script>
let checkDate = () => {
let setTimeFormat = (date) => {
let myYear = date.getFullYear()
......@@ -202,7 +203,6 @@ export default {
},
periodChangeEvent (val) {
this.checkYear = ''
debugger
if (val === 'thisweek') {
this.form.from = this.checkDate.startWeek
this.form.to = this.checkDate.endWeek
......
<template>
<section>
<div class="content">
<search-header
ref="searchHeader"
:title="'销售数据'"
@update:headerClear="() => searchClear()">
</search-header>
<time-search-form
ref="timeSearchForm"
formSearchKey="projectSearch"
:filter="filter"
@update:list="search => timeSearchForm(search)">
</time-search-form>
<search-form
ref="clientForm"
:filter="filter"
@update:clientList="form =>{ updateForm(form) }">
</search-form>
<div class="page-body-content">
<div class="mb10">
<singleRadioTool
......@@ -41,7 +32,7 @@
import SearchHeader from '../../common/searchHeader'
import SearchForm from '../../common/SearchForm'
import countArr from '../analysis/countArr'
import TimeSearchForm from '../analysis/searchForm'
import TimeSearchForm from './searchForm'
import singleRadioTool from '../../common/singleRadioTool'
import dataArchiveProfit from './dataArchiveProfit.js'
import {
......@@ -107,12 +98,6 @@ export default {
getFilter () {
requestAPI(api.getFilterSalesChart).then(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
})
},
......
<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="lastseason">上季度</el-radio-button>
<el-radio-button label="thisseason">本季度</el-radio-button>
<el-radio-button label="currentfascalyear">本财年</el-radio-button>
</el-radio-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 getQuarterStartMonth = () => {
var quarterStartMonth = 0
if (nowMonth < 3) {
quarterStartMonth = 0
}
if (nowMonth > 2 && nowMonth < 6) {
quarterStartMonth = 3
}
if (nowMonth > 5 && nowMonth < 9) {
quarterStartMonth = 6
}
if (nowMonth > 8) {
quarterStartMonth = 9
}
return quarterStartMonth
}
let getMonthDays = (myMonth) => {
var monthStartDate = new Date(nowYear, myMonth, 1)
var monthEndDate = new Date(nowYear, myMonth + 1, 1)
var days = (monthEndDate - monthStartDate) / (1000 * 60 * 60 * 24)
return days
}
let getPriorSeasonFirstDay = (year, month) => {
// var quarterMonthStart = 0
var spring = 0
var summer = 3
var fall = 6
var winter = 9
// 月份从0-11
if (month >= 0 && month <= 2) {
year--
month = winter
} else if (month >= 3 && month <= 6) {
month = spring
} else if (month >= 7 && month <= 9) {
month = summer
} else if (month >= 10 && month <= 12) {
month = fall
}
return new Date(year, month, 1)
}
let getPreviousSeason = () => {
// 起止日期数组
var startStop = []
// 获取当前时间
// var currentDate = now
// 获得当前月份0-11
var currentMonth = nowMonth
// 获得当前年份4位年
var currentYear = nowYear
// 上季度的第一天
debugger
var priorSeasonFirstDay = getPriorSeasonFirstDay(currentYear, currentMonth)
// 上季度的最后一天
var priorSeasonLastDay = new Date(priorSeasonFirstDay.getFullYear(), priorSeasonFirstDay.getMonth() + 2, getMonthDays(priorSeasonFirstDay.getFullYear(), priorSeasonFirstDay.getMonth() + 2))
// 添加至数组
startStop.push(priorSeasonFirstDay)
startStop.push(priorSeasonLastDay)
return startStop
}
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',
quarterStartDate: setTimeFormat(new Date(nowYear, getQuarterStartMonth(), 1)),
quarterEndDate: setTimeFormat(new Date(nowYear, getQuarterStartMonth() + 2, getMonthDays(getQuarterStartMonth() + 2))),
getPreviousSeason: getPreviousSeason()
}
}
export default {
name: 'timeSearchForm',
props: ['filter'],
data () {
return {
form: {
from: checkDate().currentStartDate,
to: checkDate().currentEndDate,
period: 'currentfascalyear',
dataUserId: ''
},
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 []
}
}
},
methods: {
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 === 'currentfascalyear') {
this.form.from = this.checkDate.currentStartDate
this.form.to = this.checkDate.currentEndDate
} else if (val === 'thisseason') {
this.form.from = this.checkDate.quarterStartDate
this.form.to = this.checkDate.quarterEndDate
} else if (val === 'lastseason') {
this.form.from = this.checkDate.getPreviousSeason[0]
this.form.to = this.checkDate.getPreviousSeason[1]
}
},
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