123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444 |
- <template>
- <div class="drawer-statistics" :class="{'drawer-padding': !show}">
- <transition name="fade-drawer">
- <div v-show="show" class="statistics">
- <div class="statistics-data">
- <h2>{{ title }}统计</h2>
- <div class="data-main">
- <div v-for="(item,index) in statisticsList" :key="title+'-statistics-'+index" class="data-item" :class="{'active': clickItem === index }" @click="changeData(item.idList,item.label);clickItem=index">
- <label>
- {{ item.label }}
- <template v-if="(title === '需求' || title ==='任务') && index<7">
- <el-tooltip class="item" effect="dark" :content="tips[title][index]" placement="top">
- <i class="el-icon-info" />
- </el-tooltip>
- </template>
- </label>
- <div
- class="number"
- :class="{'color-red': (index === 0 || index === 1) && item.total>0}"
- >
- {{ item.total }}
- </div>
- </div>
- </div>
- </div>
- <div v-if="title !=='缺陷'" class="statistics-chart">
- <!-- <h2>未上线{{ title }}状态分布</h2> -->
- <el-radio-group v-model="itemType" @change="onChangeTagRadio">
- <el-radio-button label="0">未上线{{ title }}状态分布</el-radio-button>
- <el-radio-button label="1">
- {{ title }}状态流入图
- <el-tooltip class="item" effect="dark" :content="'推进状态的时间是在本周的需求数量/推进状态的时间是在本周的任务数量'" placement="top">
- <i class="el-icon-info" />
- </el-tooltip>
- </el-radio-button>
- </el-radio-group>
- <div v-if="itemType === '1'" class="spaceBetween">
- <div class="date-select">
- <span :class="[dateType==='WEEK'?'date-active':'']" class="date-item" @click.stop="dateType='WEEK';setDate('WEEK')">本周</span>
- <span :class="[dateType==='MONTH'?'date-active':'']" class="date-item" @click.stop="dateType='MONTH';setDate('MONTH')">本月</span>
- <span :class="[dateType==='YEAR'?'date-active':'']" class="date-item" @click.stop="dateType='YEAR';setDate('YEAR')">本年</span>
- </div>
- <el-date-picker
- v-model="stratAndEnd"
- type="daterange"
- unlink-panels
- range-separator="至"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- size="small"
- value-format="yyyy.MM.dd"
- :default-time="['00:00:00','23:59:59']"
- @change="setDateList()"
- />
- <h3 class="mt5" @click="getAll()">总数:<span>{{ totalTask }}</span></h3>
- </div>
- <h3 v-if="itemType === '0'" class="mt5" @click="getAll()">总数:<span>{{ totalTask }}</span></h3>
- <div class="chart-contain">
- <status-stay-chart :chart-data="echartsOption" @onClick="chartChange" />
- <!-- <normal-echart v-if="echartsOption" :chart-id="type+title" :option="echartsOption" @onClick="chartChange" /> -->
- </div>
- </div>
- <div v-if="title ==='缺陷'" class="statistics-chart">
- <div class="two-title">
- <h2 v-if="type === 'person'">我提报的-未完成缺陷状态分布</h2>
- <h2 v-if="type === 'person'">提给我的-未完成缺陷状态分布</h2>
- <h2 v-if="type === 'team'">团队提报的-未完成缺陷状态分布</h2>
- <h2 v-if="type === 'team'">提给团队的-未完成缺陷状态分布</h2>
- </div>
- <div class="two-chart-contain">
- <div class="chart-contain">
- <normal-echart v-if="echartsOption" :chart-id="type+title+'1'" :option="echartsOption" @onClick="chartChange" />
- </div>
- <div class="chart-contain">
- <normal-echart v-if="echartsOption2" :chart-id="type+title+'2'" :option="echartsOption2" @onClick="chartChange" />
- </div>
- </div>
- </div>
- </div>
- </transition>
- <div class="drawer" @click="show = !show">
- <i v-show="show" class="el-icon-arrow-up" />
- <i v-show="!show" class="el-icon-arrow-down" />
- </div>
- </div>
- </template>
- <script>
- import moment from 'moment'
- moment.locale('zh-cn')
- // import { getPersonalRequireDisData } from '@/api/workSchedule.js'
- import normalEchart from '@/components/chart/normalEchart'
- import statusStayChart from '@/components/chart/statusStayChart'
- export default {
- name: 'StatisticsSectionVue',
- components: {
- normalEchart,
- statusStayChart
- },
- props: {
- searchForm: { // 搜索项的信息
- type: Object,
- default: () => {
- return {
- teamId: null,
- bizId: null
- }
- },
- required: true
- },
- type: { // 个人还是团队
- type: String,
- default: 'team',
- required: false
- },
- title: {
- type: String,
- default: '需求',
- required: false
- },
- requestObj: { // 请求的接口
- type: Object,
- default: () => null,
- required: false
- }
- },
- data() {
- return {
- show: true,
- statisticsList: [],
- echartsOption: null,
- echartsOption2: null,
- stratAndEnd: [], // 开始结束日期
- dateType: 'WEEK', // 时间选择类型
- bugCountTimeType: 1, // 获取趋缺陷势图数据接口入参:1本周 2本月 3本年
- timeTypeList: [ // 日期选择
- { code: 1, label: '周' },
- { code: 2, label: '月' },
- { code: 3, label: '年' }
- ],
- totalTask: 0, // 所有总数
- totalIdList: 0, // 所有总数的idList
- itemType: '0', // 0: 未上线的需求分布 1: 本周状态流入图
- tips: {
- '需求': [
- '交付日期为今天,且状态仍未变更为“已上线”的需求数量(不包含当前状态为hold的需求)。',
- '已过交付日期,状态仍未变更为“已上线”的需求数量(不包含当前状态为hold的需求)。',
- '交付日期在本周内的需求数量(不包含当前状态为hold的需求)。',
- '交付日期在本周,且状态仍未变更为“已上线”的需求数量(不包含当前状态为hold的需求)。',
- '最近一次变更状态为“已上线”是在本周,且当前状态为“已上线”或“已完成”的需求',
- '交付日期在下周的需求数量(不包含当前状态为hold的需求)。',
- '当前状态为“已上线”及后续状态的需求'
- ],
- '任务': [
- '交付日期为今天,且状态仍未变更为“已上线”的任务数量(不包含当前状态为hold的任务)。',
- '已过交付日期,状态仍未变更为“已上线”的任务数量(不包含当前状态为hold的任务)。',
- '交付日期在本周内的任务数量(不包含当前状态为hold的任务)。',
- '交付日期在本周,且状态仍未变更为“已上线”的任务数量(不包含当前状态为hold的任务)。',
- '最近一次变更状态为“已上线”是在本周,且当前状态为“已上线”的任务',
- '交付日期在下周任务数量(不包含当前状态为hold的任务)。',
- '当前状态为“已上线”的任务'
- ]
- },
- clickItem: 0
- }
- },
- watch: {
- searchForm: {
- handler(newV) {
- this.initData()
- },
- deep: true,
- immediate: true
- },
- title: {
- handler(newV) {
- this.clickItem = 0
- this.initData()
- }
- // immediate: true
- }
- },
- methods: {
- initData() { // 初始化
- if (this.requestObj) {
- const { requestData, requestChart } = this.requestObj
- this.getData(requestData)
- if (this.title === '缺陷') {
- this.getChart(requestChart, '3')
- this.getChart(requestChart, '5')
- } else {
- this.itemType = '0'
- this.getChart(requestChart, this.itemType)
- }
- }
- },
- setDate(type) { // 日期筛选
- this.stratAndEnd = []
- const { requestChart } = this.requestObj
- this.getChart(requestChart, this.itemType, { dateType: this.dateType })
- },
- setDateList() { // 日期筛选
- this.dateType = ''
- const { requestChart } = this.requestObj
- this.getChart(requestChart, this.itemType, { dayTime: this.stratAndEnd })
- },
- onChangeTagRadio(e) {
- const { requestChart } = this.requestObj
- this.getChart(requestChart, this.itemType, { dateType: this.dateType })
- },
- async getData(requestUrl) { // 获取顶部数据
- const res = await requestUrl({ teamSearchInfo: this.searchForm })
- if (res.code === 200) {
- this.statisticsList = res.data || []
- if (this.statisticsList.length > 0) {
- const show = this.statisticsList[0].total + this.statisticsList[1].total > 0
- this.$emit('showTips', this.title, show)
- }
- // 如果是点击左边6个区域的,保留idList,如果点击是图表,默认回到左边第一个区域中的idList
- if (this.clickItem < 0) {
- this.clickItem = 0
- this.changeData(this.statisticsList[0].idList, this.statisticsList[0].label)
- } else {
- this.changeData(this.statisticsList[this.clickItem].idList, this.statisticsList[this.clickItem].label)
- }
- }
- },
- async getChart(requestUrl, type, data) { // 获取图表数据
- const res = await requestUrl({ teamSearchInfo: this.searchForm, type: type })
- if (type === '3') {
- this.echartsOption = this.setChart(res.data)
- } else if (type === '5') {
- this.echartsOption2 = this.setChart(res.data)
- } else if (type === '1') {
- const res = await requestUrl({ teamSearchInfo: this.searchForm, type, ...data })
- this.totalTask = res.data.total
- this.totalIdList = res.data.idList
- this.echartsOption = { ...res.data, type: this.itemType }
- } else {
- const res = await requestUrl({ teamSearchInfo: this.searchForm, type })
- this.totalTask = res.data.total
- this.totalIdList = res.data.idList
- this.echartsOption = { ...res.data, type: this.itemType }
- }
- },
- setChart(chartData) { // 设置图表options
- const childArr = chartData.xaxis.map((item, index) => {
- return {
- value: chartData.yaxis[0] && chartData.yaxis[0].data[index] || 0,
- idList: chartData.yaxis[0] && chartData.yaxis[0].idList[index] || []
- }
- })
- const option = {
- color: ['#3AA1FF'],
- tooltip: { trigger: 'axis', axisPointer: { type: 'line' }}, // 默认为直线,可选为:'line' | 'shadow'
- grid: { left: '0', right: '0', top: '10%', bottom: '0', containLabel: true },
- xAxis: [{ type: 'category', data: chartData.xaxis, axisLabel: { interval: 0, rotate: 15 }, axisTick: { alignWithLabel: true }}],
- yAxis: [{ type: 'value', axisLine: { show: false }, splitLine: { lineStyle: { type: 'dashed' }}}],
- series: [{
- name: '数量', type: 'bar', barWidth: '20px', data: childArr,
- itemStyle: { normal: { label: { show: true, formatter: '{c}', position: 'top' }}}
- }]
- }
- return option
- },
- getAll() {
- this.clickItem = -1
- this.changeData(this.totalIdList, `未上线的`)
- },
- chartChange(params) { // 点击图表产生触发列表更改
- let idList = params.data.idList || []
- // 本周需求状态流入图需要特殊处理。循环出对应下标的idlist
- if (this.itemType === '1') {
- // console.log(this.echartsOption.xaxis)
- const dataIndex = params.dataIndex
- this.echartsOption.yaxis.forEach(t => {
- idList = [...idList, ...t.idList[dataIndex]]
- })
- }
- this.clickItem = -1
- this.changeData(idList, params.name)
- },
- changeData(idList, name) { // 点击顶部数据触发列表更改
- this.$emit('change', this.title, idList, name)
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .drawer-statistics {
- position: relative;
- width: 100%;
- padding-bottom: 1px;
- }
- .drawer-padding {
- padding-bottom: 13px;
- }
- //.fade-drawer-enter-active {
- // transition: all 1.5s ease
- //}
- //.fade-drawer-leave-active {s
- // transition: all 1.5s ease
- //}
- //.fade-drawer-enter, .fade-drawer-leave-to {
- // transition: all 1.5s ease;
- //}
- .statistics {
- position: relative;
- width: 100%;
- height: 474px;
- padding: 27px 35px;
- display: grid;
- grid-template-columns: 40% 60%;
- h2 {
- color: #333333;
- font-size: 16px;
- margin-bottom: 15px;
- font-weight: bold;
- }
- h3 {
- cursor: pointer;
- color: #999999;
- font-size: 18px;
- margin-bottom: 0px;
- span {
- color:#409EFF;
- font-size: 26px;
- }
- }
- }
- .statistics-data {
- .data-main{
- width: 80%;
- display: grid;
- grid-template-columns: repeat(2,190px);
- grid-column-gap: 30px;
- grid-template-rows: repeat(4,80px);
- grid-row-gap: 20px;
- }
- .data-item {
- cursor:pointer;
- box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.2);
- border-radius: 5px;
- display: grid;
- grid-template-rows: repeat(2,50%);
- align-items: center;
- padding: 5px 3px 5px 11px;
- label {
- font-weight: 400;
- color: #666666;
- cursor:pointer;
- }
- .number {
- font-weight: 500;
- color: #333333;
- font-size: 26px;
- }
- .color-red {
- color:#E02020;
- }
- }
- .active {
- border: 1px solid #409EFF;
- box-shadow: 0px 6px 12px rgba(64, 158, 255, 0.2);
- }
- }
- .statistics-chart {
- .mt5 {
- margin-top: 5px;
- }
- .two-title {
- width: 100%;
- display: grid;
- grid-template-columns: repeat(2,47.5%);
- grid-column-gap: 5%;
- }
- .two-chart-contain {
- width: 100%;
- height: 100%;
- display: grid;
- grid-template-columns: repeat(2,47.5%);
- grid-column-gap: 5%;
- }
- .chart-contain {
- width: 100%;
- height: 360px;
- }
- }
- .drawer-statistics:after {
- content: '';
- width: 100%;
- height: 14px;
- background-color: #F2F3F6;
- position: absolute;
- left: 0;
- bottom: 0;
- }
- .drawer {
- width: 26px;
- height: 12px;
- left: 50%;
- position: absolute;
- bottom: 1px;
- transform: translateX(-50%);
- z-index: 98;
- display: flex;
- justify-content: center;
- align-items: center;
- color: #666666;
- font-weight: bold;
- background-color: #ffffff;
- // border-bottom: 1px solid #999999;
- // border-left: 1px solid #999999;
- // border-right: 1px solid #999999;
- box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.2);
- border-bottom-left-radius: 2px;
- border-bottom-right-radius: 2px;
- }
- .drawer-pull {
- top: 1px;
- }
- .date-select {
- line-height: 20px;
- display: inline-block;
- .date-item {
- display: inline-block;
- width: 40px;
- text-align: center;
- cursor: pointer;
- border-radius: 2px;
- }
- .date-active {
- color: #FFFFFF;
- background-color: #409EFF;
- }
- }
- .spaceBetween {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-top: 5px;
- }
- </style>
|