statisticsSection.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. <template>
  2. <div class="drawer-statistics" :class="{'drawer-padding': !show}">
  3. <transition name="fade-drawer">
  4. <div v-show="show" class="statistics">
  5. <div class="statistics-data">
  6. <h2>{{ title }}统计</h2>
  7. <div class="data-main">
  8. <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">
  9. <label>
  10. {{ item.label }}
  11. <template v-if="(title === '需求' || title ==='任务') && index<7">
  12. <el-tooltip class="item" effect="dark" :content="tips[title][index]" placement="top">
  13. <i class="el-icon-info" />
  14. </el-tooltip>
  15. </template>
  16. </label>
  17. <div
  18. class="number"
  19. :class="{'color-red': (index === 0 || index === 1) && item.total>0}"
  20. >
  21. {{ item.total }}
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. <div v-if="title !=='缺陷'" class="statistics-chart">
  27. <!-- <h2>未上线{{ title }}状态分布</h2> -->
  28. <el-radio-group v-model="itemType" @change="onChangeTagRadio">
  29. <el-radio-button label="0">未上线{{ title }}状态分布</el-radio-button>
  30. <el-radio-button label="1">
  31. {{ title }}状态流入图
  32. <el-tooltip class="item" effect="dark" :content="'推进状态的时间是在本周的需求数量/推进状态的时间是在本周的任务数量'" placement="top">
  33. <i class="el-icon-info" />
  34. </el-tooltip>
  35. </el-radio-button>
  36. </el-radio-group>
  37. <div v-if="itemType === '1'" class="spaceBetween">
  38. <div class="date-select">
  39. <span :class="[dateType==='WEEK'?'date-active':'']" class="date-item" @click.stop="dateType='WEEK';setDate('WEEK')">本周</span>
  40. <span :class="[dateType==='MONTH'?'date-active':'']" class="date-item" @click.stop="dateType='MONTH';setDate('MONTH')">本月</span>
  41. <span :class="[dateType==='YEAR'?'date-active':'']" class="date-item" @click.stop="dateType='YEAR';setDate('YEAR')">本年</span>
  42. </div>
  43. <el-date-picker
  44. v-model="stratAndEnd"
  45. type="daterange"
  46. unlink-panels
  47. range-separator="至"
  48. start-placeholder="开始日期"
  49. end-placeholder="结束日期"
  50. size="small"
  51. value-format="yyyy.MM.dd"
  52. :default-time="['00:00:00','23:59:59']"
  53. @change="setDateList()"
  54. />
  55. <h3 class="mt5" @click="getAll()">总数:<span>{{ totalTask }}</span></h3>
  56. </div>
  57. <h3 v-if="itemType === '0'" class="mt5" @click="getAll()">总数:<span>{{ totalTask }}</span></h3>
  58. <div class="chart-contain">
  59. <status-stay-chart :chart-data="echartsOption" @onClick="chartChange" />
  60. <!-- <normal-echart v-if="echartsOption" :chart-id="type+title" :option="echartsOption" @onClick="chartChange" /> -->
  61. </div>
  62. </div>
  63. <div v-if="title ==='缺陷'" class="statistics-chart">
  64. <div class="two-title">
  65. <h2 v-if="type === 'person'">我提报的-未完成缺陷状态分布</h2>
  66. <h2 v-if="type === 'person'">提给我的-未完成缺陷状态分布</h2>
  67. <h2 v-if="type === 'team'">团队提报的-未完成缺陷状态分布</h2>
  68. <h2 v-if="type === 'team'">提给团队的-未完成缺陷状态分布</h2>
  69. </div>
  70. <div class="two-chart-contain">
  71. <div class="chart-contain">
  72. <normal-echart v-if="echartsOption" :chart-id="type+title+'1'" :option="echartsOption" @onClick="chartChange" />
  73. </div>
  74. <div class="chart-contain">
  75. <normal-echart v-if="echartsOption2" :chart-id="type+title+'2'" :option="echartsOption2" @onClick="chartChange" />
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. </transition>
  81. <div class="drawer" @click="show = !show">
  82. <i v-show="show" class="el-icon-arrow-up" />
  83. <i v-show="!show" class="el-icon-arrow-down" />
  84. </div>
  85. </div>
  86. </template>
  87. <script>
  88. import moment from 'moment'
  89. moment.locale('zh-cn')
  90. // import { getPersonalRequireDisData } from '@/api/workSchedule.js'
  91. import normalEchart from '@/components/chart/normalEchart'
  92. import statusStayChart from '@/components/chart/statusStayChart'
  93. export default {
  94. name: 'StatisticsSectionVue',
  95. components: {
  96. normalEchart,
  97. statusStayChart
  98. },
  99. props: {
  100. searchForm: { // 搜索项的信息
  101. type: Object,
  102. default: () => {
  103. return {
  104. teamId: null,
  105. bizId: null
  106. }
  107. },
  108. required: true
  109. },
  110. type: { // 个人还是团队
  111. type: String,
  112. default: 'team',
  113. required: false
  114. },
  115. title: {
  116. type: String,
  117. default: '需求',
  118. required: false
  119. },
  120. requestObj: { // 请求的接口
  121. type: Object,
  122. default: () => null,
  123. required: false
  124. }
  125. },
  126. data() {
  127. return {
  128. show: true,
  129. statisticsList: [],
  130. echartsOption: null,
  131. echartsOption2: null,
  132. stratAndEnd: [], // 开始结束日期
  133. dateType: 'WEEK', // 时间选择类型
  134. bugCountTimeType: 1, // 获取趋缺陷势图数据接口入参:1本周 2本月 3本年
  135. timeTypeList: [ // 日期选择
  136. { code: 1, label: '周' },
  137. { code: 2, label: '月' },
  138. { code: 3, label: '年' }
  139. ],
  140. totalTask: 0, // 所有总数
  141. totalIdList: 0, // 所有总数的idList
  142. itemType: '0', // 0: 未上线的需求分布 1: 本周状态流入图
  143. tips: {
  144. '需求': [
  145. '交付日期为今天,且状态仍未变更为“已上线”的需求数量(不包含当前状态为hold的需求)。',
  146. '已过交付日期,状态仍未变更为“已上线”的需求数量(不包含当前状态为hold的需求)。',
  147. '交付日期在本周内的需求数量(不包含当前状态为hold的需求)。',
  148. '交付日期在本周,且状态仍未变更为“已上线”的需求数量(不包含当前状态为hold的需求)。',
  149. '最近一次变更状态为“已上线”是在本周,且当前状态为“已上线”或“已完成”的需求',
  150. '交付日期在下周的需求数量(不包含当前状态为hold的需求)。',
  151. '当前状态为“已上线”及后续状态的需求'
  152. ],
  153. '任务': [
  154. '交付日期为今天,且状态仍未变更为“已上线”的任务数量(不包含当前状态为hold的任务)。',
  155. '已过交付日期,状态仍未变更为“已上线”的任务数量(不包含当前状态为hold的任务)。',
  156. '交付日期在本周内的任务数量(不包含当前状态为hold的任务)。',
  157. '交付日期在本周,且状态仍未变更为“已上线”的任务数量(不包含当前状态为hold的任务)。',
  158. '最近一次变更状态为“已上线”是在本周,且当前状态为“已上线”的任务',
  159. '交付日期在下周任务数量(不包含当前状态为hold的任务)。',
  160. '当前状态为“已上线”的任务'
  161. ]
  162. },
  163. clickItem: 0
  164. }
  165. },
  166. watch: {
  167. searchForm: {
  168. handler(newV) {
  169. this.initData()
  170. },
  171. deep: true,
  172. immediate: true
  173. },
  174. title: {
  175. handler(newV) {
  176. this.clickItem = 0
  177. this.initData()
  178. }
  179. // immediate: true
  180. }
  181. },
  182. methods: {
  183. initData() { // 初始化
  184. if (this.requestObj) {
  185. const { requestData, requestChart } = this.requestObj
  186. this.getData(requestData)
  187. if (this.title === '缺陷') {
  188. this.getChart(requestChart, '3')
  189. this.getChart(requestChart, '5')
  190. } else {
  191. this.itemType = '0'
  192. this.getChart(requestChart, this.itemType)
  193. }
  194. }
  195. },
  196. setDate(type) { // 日期筛选
  197. this.stratAndEnd = []
  198. const { requestChart } = this.requestObj
  199. this.getChart(requestChart, this.itemType, { dateType: this.dateType })
  200. },
  201. setDateList() { // 日期筛选
  202. this.dateType = ''
  203. const { requestChart } = this.requestObj
  204. this.getChart(requestChart, this.itemType, { dayTime: this.stratAndEnd })
  205. },
  206. onChangeTagRadio(e) {
  207. const { requestChart } = this.requestObj
  208. this.getChart(requestChart, this.itemType, { dateType: this.dateType })
  209. },
  210. async getData(requestUrl) { // 获取顶部数据
  211. const res = await requestUrl({ teamSearchInfo: this.searchForm })
  212. if (res.code === 200) {
  213. this.statisticsList = res.data || []
  214. if (this.statisticsList.length > 0) {
  215. const show = this.statisticsList[0].total + this.statisticsList[1].total > 0
  216. this.$emit('showTips', this.title, show)
  217. }
  218. // 如果是点击左边6个区域的,保留idList,如果点击是图表,默认回到左边第一个区域中的idList
  219. if (this.clickItem < 0) {
  220. this.clickItem = 0
  221. this.changeData(this.statisticsList[0].idList, this.statisticsList[0].label)
  222. } else {
  223. this.changeData(this.statisticsList[this.clickItem].idList, this.statisticsList[this.clickItem].label)
  224. }
  225. }
  226. },
  227. async getChart(requestUrl, type, data) { // 获取图表数据
  228. const res = await requestUrl({ teamSearchInfo: this.searchForm, type: type })
  229. if (type === '3') {
  230. this.echartsOption = this.setChart(res.data)
  231. } else if (type === '5') {
  232. this.echartsOption2 = this.setChart(res.data)
  233. } else if (type === '1') {
  234. const res = await requestUrl({ teamSearchInfo: this.searchForm, type, ...data })
  235. this.totalTask = res.data.total
  236. this.totalIdList = res.data.idList
  237. this.echartsOption = { ...res.data, type: this.itemType }
  238. } else {
  239. const res = await requestUrl({ teamSearchInfo: this.searchForm, type })
  240. this.totalTask = res.data.total
  241. this.totalIdList = res.data.idList
  242. this.echartsOption = { ...res.data, type: this.itemType }
  243. }
  244. },
  245. setChart(chartData) { // 设置图表options
  246. const childArr = chartData.xaxis.map((item, index) => {
  247. return {
  248. value: chartData.yaxis[0] && chartData.yaxis[0].data[index] || 0,
  249. idList: chartData.yaxis[0] && chartData.yaxis[0].idList[index] || []
  250. }
  251. })
  252. const option = {
  253. color: ['#3AA1FF'],
  254. tooltip: { trigger: 'axis', axisPointer: { type: 'line' }}, // 默认为直线,可选为:'line' | 'shadow'
  255. grid: { left: '0', right: '0', top: '10%', bottom: '0', containLabel: true },
  256. xAxis: [{ type: 'category', data: chartData.xaxis, axisLabel: { interval: 0, rotate: 15 }, axisTick: { alignWithLabel: true }}],
  257. yAxis: [{ type: 'value', axisLine: { show: false }, splitLine: { lineStyle: { type: 'dashed' }}}],
  258. series: [{
  259. name: '数量', type: 'bar', barWidth: '20px', data: childArr,
  260. itemStyle: { normal: { label: { show: true, formatter: '{c}', position: 'top' }}}
  261. }]
  262. }
  263. return option
  264. },
  265. getAll() {
  266. this.clickItem = -1
  267. this.changeData(this.totalIdList, `未上线的`)
  268. },
  269. chartChange(params) { // 点击图表产生触发列表更改
  270. let idList = params.data.idList || []
  271. // 本周需求状态流入图需要特殊处理。循环出对应下标的idlist
  272. if (this.itemType === '1') {
  273. // console.log(this.echartsOption.xaxis)
  274. const dataIndex = params.dataIndex
  275. this.echartsOption.yaxis.forEach(t => {
  276. idList = [...idList, ...t.idList[dataIndex]]
  277. })
  278. }
  279. this.clickItem = -1
  280. this.changeData(idList, params.name)
  281. },
  282. changeData(idList, name) { // 点击顶部数据触发列表更改
  283. this.$emit('change', this.title, idList, name)
  284. }
  285. }
  286. }
  287. </script>
  288. <style scoped lang="scss">
  289. .drawer-statistics {
  290. position: relative;
  291. width: 100%;
  292. padding-bottom: 1px;
  293. }
  294. .drawer-padding {
  295. padding-bottom: 13px;
  296. }
  297. //.fade-drawer-enter-active {
  298. // transition: all 1.5s ease
  299. //}
  300. //.fade-drawer-leave-active {s
  301. // transition: all 1.5s ease
  302. //}
  303. //.fade-drawer-enter, .fade-drawer-leave-to {
  304. // transition: all 1.5s ease;
  305. //}
  306. .statistics {
  307. position: relative;
  308. width: 100%;
  309. height: 474px;
  310. padding: 27px 35px;
  311. display: grid;
  312. grid-template-columns: 40% 60%;
  313. h2 {
  314. color: #333333;
  315. font-size: 16px;
  316. margin-bottom: 15px;
  317. font-weight: bold;
  318. }
  319. h3 {
  320. cursor: pointer;
  321. color: #999999;
  322. font-size: 18px;
  323. margin-bottom: 0px;
  324. span {
  325. color:#409EFF;
  326. font-size: 26px;
  327. }
  328. }
  329. }
  330. .statistics-data {
  331. .data-main{
  332. width: 80%;
  333. display: grid;
  334. grid-template-columns: repeat(2,190px);
  335. grid-column-gap: 30px;
  336. grid-template-rows: repeat(4,80px);
  337. grid-row-gap: 20px;
  338. }
  339. .data-item {
  340. cursor:pointer;
  341. box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.2);
  342. border-radius: 5px;
  343. display: grid;
  344. grid-template-rows: repeat(2,50%);
  345. align-items: center;
  346. padding: 5px 3px 5px 11px;
  347. label {
  348. font-weight: 400;
  349. color: #666666;
  350. cursor:pointer;
  351. }
  352. .number {
  353. font-weight: 500;
  354. color: #333333;
  355. font-size: 26px;
  356. }
  357. .color-red {
  358. color:#E02020;
  359. }
  360. }
  361. .active {
  362. border: 1px solid #409EFF;
  363. box-shadow: 0px 6px 12px rgba(64, 158, 255, 0.2);
  364. }
  365. }
  366. .statistics-chart {
  367. .mt5 {
  368. margin-top: 5px;
  369. }
  370. .two-title {
  371. width: 100%;
  372. display: grid;
  373. grid-template-columns: repeat(2,47.5%);
  374. grid-column-gap: 5%;
  375. }
  376. .two-chart-contain {
  377. width: 100%;
  378. height: 100%;
  379. display: grid;
  380. grid-template-columns: repeat(2,47.5%);
  381. grid-column-gap: 5%;
  382. }
  383. .chart-contain {
  384. width: 100%;
  385. height: 360px;
  386. }
  387. }
  388. .drawer-statistics:after {
  389. content: '';
  390. width: 100%;
  391. height: 14px;
  392. background-color: #F2F3F6;
  393. position: absolute;
  394. left: 0;
  395. bottom: 0;
  396. }
  397. .drawer {
  398. width: 26px;
  399. height: 12px;
  400. left: 50%;
  401. position: absolute;
  402. bottom: 1px;
  403. transform: translateX(-50%);
  404. z-index: 98;
  405. display: flex;
  406. justify-content: center;
  407. align-items: center;
  408. color: #666666;
  409. font-weight: bold;
  410. background-color: #ffffff;
  411. // border-bottom: 1px solid #999999;
  412. // border-left: 1px solid #999999;
  413. // border-right: 1px solid #999999;
  414. box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.2);
  415. border-bottom-left-radius: 2px;
  416. border-bottom-right-radius: 2px;
  417. }
  418. .drawer-pull {
  419. top: 1px;
  420. }
  421. .date-select {
  422. line-height: 20px;
  423. display: inline-block;
  424. .date-item {
  425. display: inline-block;
  426. width: 40px;
  427. text-align: center;
  428. cursor: pointer;
  429. border-radius: 2px;
  430. }
  431. .date-active {
  432. color: #FFFFFF;
  433. background-color: #409EFF;
  434. }
  435. }
  436. .spaceBetween {
  437. display: flex;
  438. align-items: center;
  439. justify-content: space-between;
  440. margin-top: 5px;
  441. }
  442. </style>