taskStatistics.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. <template>
  2. <el-container class="defect-container">
  3. <el-header class="defect-main" style="height: auto;">
  4. <el-form :model="chartForm" class="demo-form-inline" :inline="true">
  5. <el-form-item label="时间:">
  6. <div class="date-select">
  7. <span :class="[dateType==='week'?'date-active':'']" class="date-item" @click.stop="dateType='week';setDate('week')">本周</span>
  8. <span :class="[dateType==='month'?'date-active':'']" class="date-item" @click.stop="dateType='month';setDate('month')">本月</span>
  9. <span :class="[dateType==='year'?'date-active':'']" class="date-item" @click.stop="dateType='year';setDate('year')">本年</span>
  10. </div>
  11. <el-date-picker
  12. v-model="stratAndEnd"
  13. type="daterange"
  14. align="right"
  15. unlink-panels
  16. range-separator="至"
  17. start-placeholder="开始日期"
  18. end-placeholder="结束日期"
  19. size="small"
  20. value-format="yyyy.MM.dd"
  21. :default-time="['00:00:00','23:59:59']"
  22. @change="dateType = ''"
  23. />
  24. </el-form-item>
  25. </el-form>
  26. <el-form :model="chartForm" class="demo-form-inline" :inline="true">
  27. <el-form-item label="团队:">
  28. <el-select
  29. v-model="chartForm.team"
  30. placeholder="请选择"
  31. size="small"
  32. clearable
  33. filterable
  34. multiple
  35. >
  36. <el-option-group
  37. v-for="group in teamOptions"
  38. :key="group.label"
  39. :label="group.label"
  40. >
  41. <el-option
  42. v-for="item in group.options"
  43. :key="item.teamId"
  44. :label="item.teamName"
  45. :value="item.teamId"
  46. />
  47. </el-option-group>
  48. </el-select>
  49. </el-form-item>
  50. <el-form-item label="技术模块:">
  51. <el-cascader
  52. v-model="chartForm.moduleIds"
  53. size="small"
  54. clearable
  55. collapse-tags
  56. :props="{ multiple: true }"
  57. :options="moduleList"
  58. placeholder="请选择"
  59. />
  60. </el-form-item>
  61. <el-form-item>
  62. <el-button type="primary" size="mini" @click="onSubmit">查询</el-button>
  63. </el-form-item>
  64. </el-form>
  65. <div class="data-total">
  66. <div v-for="(item,index) in Summary" :key="'Summary'+index" class="data-item" :class="['item'+ (index + 1)]">
  67. <article>
  68. <div class="item-top">
  69. <div class="item-circle">
  70. <img v-show="index === 0" src="../../../src/assets/defect_images/add.png">
  71. <img v-show="index === 1" src="../../../src/assets/defect_images/repair.png">
  72. <img v-show="index === 2" src="../../../src/assets/defect_images/reopen.png">
  73. </div>
  74. <span>{{ item.label }}</span>
  75. <el-tooltip v-if="index === 0" class="item" effect="dark" content="统计区间内,新建的任务数量" placement="top-start">
  76. <i class="el-icon-info" />
  77. </el-tooltip>
  78. <el-tooltip v-if="index === 1" class="item" effect="dark" content="任务最近一次更新状态为“已上线”在统计区间内,并且当前状态是“已上线”的任务数量" placement="top-start">
  79. <i class="el-icon-info" />
  80. </el-tooltip>
  81. <el-tooltip v-if="index === 2" class="item" effect="dark" content="任务最近一次更新状态为“Hold”在统计区间内,并且当前状态是“Hold”的任务数量" placement="top-start">
  82. <i class="el-icon-info" />
  83. </el-tooltip>
  84. </div>
  85. <div class="item-title">{{ item.total }}</div>
  86. <div class="item-line" />
  87. <div v-show="Number(item.relativeRatio)>=0" class="item-up">环比:<i class="el-icon-caret-top" />{{ item.relativeRatio }}%</div>
  88. <div v-show="Number(item.relativeRatio)<0" class="item-down">环比:<i class="el-icon-caret-bottom" />{{ item.relativeRatio.substring(1,item.relativeRatio.length) }}%</div>
  89. <div v-show="item.relativeRatio === '--'" class="item-down">环比:{{ item.relativeRatio }}%</div>
  90. </article>
  91. </div>
  92. </div>
  93. <div class="chart-item bottom-padding">
  94. <h3>状态累积流量图</h3>
  95. <status-chart :chart-data="cumulativeData" />
  96. </div>
  97. </el-header>
  98. <el-main class="charts-main">
  99. <el-tabs v-model="activeTab" class="tab-change" @tab-click="onSubmit">
  100. <el-tab-pane name="1">
  101. <span slot="label" class="tab-item">累计新增</span>
  102. </el-tab-pane>
  103. <el-tab-pane name="2">
  104. <span slot="label" class="tab-item">累计上线</span>
  105. </el-tab-pane>
  106. </el-tabs>
  107. <div class="chart-item">
  108. <h3 v-show="activeTab === '1'">新增趋势图</h3>
  109. <h3 v-show="activeTab === '2'">上线趋势图</h3>
  110. <tendency-chart :chart-data="tendencyData" type-title="任务数量" />
  111. </div>
  112. <div class="chart-item">
  113. <h3>所属需求方向分布图</h3>
  114. <belong-requirement-chart :chart-data="belongRequirementData" />
  115. </div>
  116. <div class="chart-item">
  117. <h3>周期统计<span>(根据排期计算)</span></h3>
  118. <div class="chart-item-tip">
  119. <i class="el-icon-warning-outline" />
  120. <span>仅统计状态已变更“已排期”且排期不为空的任务</span>
  121. </div>
  122. <cycle-statistic :chart-data="cycleData" type="task" />
  123. </div>
  124. <div class="chart-item">
  125. <h3>研发交付周期分布图<span>(根据排期计算)</span></h3>
  126. <div class="chart-item-tip">
  127. <i class="el-icon-warning-outline" />
  128. <span>仅统计状态已变更“已排期”且排期不为空的任务;横坐标表示任务交付日期,纵坐标代表研发交付周期(研发、联调、上线类型排期的总周期)</span>
  129. </div>
  130. <development-cycle :chart-data="developmentCycleData" type="task" />
  131. </div>
  132. <div class="chart-item">
  133. <h3>任务分布图</h3>
  134. <distribution-chart
  135. :chart-data="distributeData"
  136. :status-list="distributeStatusList"
  137. :status.sync="distributeStatus"
  138. :active-tab="activeTab"
  139. @change="getDistributeData()"
  140. />
  141. </div>
  142. <div class="chart-item">
  143. <h3>状态停留分布图</h3>
  144. <status-stay-chart :chart-data="statusStayData" />
  145. </div>
  146. <div class="chart-item">
  147. <h3>模块分布图</h3>
  148. <belong-chart :chart-data="moduleDistributeData" />
  149. </div>
  150. <div class="chart-item">
  151. <h3>排期发生变更的任务(<span class="strong-font">{{ changeTotal }}</span>个)</h3>
  152. <change-require-chart :chart-data="changeTaskData" type-name="任务" />
  153. </div>
  154. <div class="chart-item">
  155. <h3>报告统计</h3>
  156. <cycle-statistic :chart-data="reportSummaryData" child-data="relativeRatio" :show-tips="false" />
  157. </div>
  158. <div class="chart-item">
  159. <h3>缺陷统计</h3>
  160. <bug-list :chart-data="bugListData" />
  161. </div>
  162. </el-main>
  163. </el-container>
  164. </template>
  165. <script>
  166. import moment from 'moment'
  167. moment.locale('zh-cn')
  168. import { settingQueryBizModuleList } from '@/api/defectManage'
  169. import { teamQueryTeamInfoList } from '@/api/configure'
  170. import {
  171. getSummary,
  172. getCumulativeFlowDiagram,
  173. getTaskCountTrend,
  174. getRequirementOrientationDistributeData,
  175. getTaskPeriodicData,
  176. getTaskRdDeliveryPeriodicData,
  177. getDistributeData,
  178. getStatusStayData,
  179. getModuleDistributeData,
  180. getTaskUnlockData,
  181. getReportSummary,
  182. getBugStatisticData
  183. } from '@/api/statisticsApi/taskStatistics'
  184. import statusChart from './components/statusChart'
  185. import tendencyChart from './components/tendencyChart'
  186. import belongRequirementChart from './components/belongRequirementChart'
  187. import cycleStatistic from './components/cycleStatistic'
  188. import developmentCycle from './components/developmentCycle'
  189. import distributionChart from './components/distributionChart'
  190. import statusStayChart from './components/statusStayChart'
  191. import belongChart from './components/belongChart'
  192. import changeRequireChart from './components/changeRequireChart'
  193. import bugList from './components/bugList'
  194. export default {
  195. components: {
  196. statusChart,
  197. tendencyChart,
  198. belongRequirementChart,
  199. cycleStatistic,
  200. developmentCycle,
  201. distributionChart,
  202. statusStayChart,
  203. belongChart,
  204. changeRequireChart,
  205. bugList
  206. },
  207. data() {
  208. return {
  209. bugCountTimeType: 1, // 获取趋缺陷势图数据接口入参:1本周 2本月 3本年
  210. timeTypeList: [ // 日期选择
  211. { code: 1, label: '周' },
  212. { code: 2, label: '月' },
  213. { code: 3, label: '年' }
  214. ],
  215. teamOptions: [], // 团队列表
  216. chartForm: {}, // 筛选表单
  217. stratAndEnd: [], // 开始结束日期
  218. dateType: 'week', // 时间选择类型
  219. moduleList: [], // 任务方向列表
  220. Summary: [], // 顶部数据
  221. activeTab: '1', // tab标签
  222. cumulativeData: null, // 任务状态累计流数据
  223. tendencyData: null, // 趋势图数据
  224. belongRequirementData: null, // 所属需求方向分布图
  225. cycleData: [], // 周期统计数据
  226. developmentCycleData: [], // 研发交付周期分布数据
  227. distributeStatus: 1, // 任务分布图任务状态
  228. distributeStatusList: [
  229. { code: 1, label: '任务状态' },
  230. { code: 2, label: '任务等级' },
  231. { code: 3, label: '开发负责人' },
  232. { code: 4, label: '测试负责人' },
  233. { code: 5, label: '跟版客户端' },
  234. { code: 6, label: '直接归属' }
  235. ], // 任务分布图任务状态列表
  236. moduleDistributeData: null, // 任务模块分布
  237. distributeData: null, // 任务分布图数据
  238. statusStayData: null, // 状态停留图数据
  239. moduleDistribute: null, // 模块分布图数据
  240. changeTaskData: null, // 排期变更任务数据
  241. changeTotal: 0, // 变更总数
  242. reportSummaryData: null, // 报告统计数据
  243. bugListData: {} // 缺陷统计数据
  244. }
  245. },
  246. computed: {
  247. globalParams: { // 通用接口参数
  248. get() {
  249. const moduleIds = this.chartForm.moduleIds
  250. const team = this.chartForm.team
  251. const params = {
  252. startTime: this.stratAndEnd[0] || null,
  253. endTime: this.stratAndEnd[1] || null,
  254. bizId: Number(localStorage.getItem('bizId')),
  255. teamIds: team && team.length > 0 ? team : null,
  256. moduleIds: moduleIds && moduleIds.length > 0 ? moduleIds : null
  257. }
  258. return params
  259. }
  260. },
  261. timeType: {
  262. get() {
  263. let timeType = 0
  264. switch (this.dateType) {
  265. case 'week':
  266. timeType = 1
  267. break
  268. case 'month':
  269. timeType = 2
  270. break
  271. case 'year':
  272. timeType = 3
  273. break
  274. default:
  275. timeType = 0
  276. break
  277. }
  278. return timeType
  279. }
  280. }
  281. },
  282. created() {
  283. this.$store.state.data.status = true
  284. this.setDate(this.dateType)
  285. this.getTeamList()
  286. this.getMoudlesList()
  287. },
  288. methods: {
  289. onSubmit() {
  290. if (this.activeTab === '2' && this.distributeStatus === 1) {
  291. this.distributeStatus = 2
  292. }
  293. this.getSummary()
  294. this.getCumulativeFlowDiagram()
  295. this.getTaskCountTrend()
  296. this.getBelongRequirementData()
  297. this.getCycleData()
  298. this.getDevelopmentCycle()
  299. this.getModuleDistributeData()
  300. this.getDistributeData()
  301. this.getStatusStayData()
  302. this.getTaskUnlockData()
  303. this.getReportSummary()
  304. this.getBugStatisticData()
  305. },
  306. setDate(type) { // 日期筛选
  307. let startDate = null
  308. let endDate = null
  309. switch (type) {
  310. case 'week':
  311. startDate = moment().startOf('week').format('YYYY.MM.DD')
  312. endDate = moment().endOf('week').format('YYYY.MM.DD')
  313. this.bugCountTimeType = this.timeTypeList[0].code
  314. break
  315. case 'month':
  316. startDate = moment().startOf('month').format('YYYY.MM.DD')
  317. endDate = moment().endOf('month').format('YYYY.MM.DD')
  318. this.bugCountTimeType = this.timeTypeList[1].code
  319. break
  320. case 'year':
  321. startDate = moment().startOf('year').format('YYYY.MM.DD')
  322. endDate = moment().endOf('year').format('YYYY.MM.DD')
  323. this.bugCountTimeType = this.timeTypeList[2].code
  324. break
  325. }
  326. this.stratAndEnd = [startDate, endDate]
  327. this.onSubmit()
  328. },
  329. async getMoudlesList() { // 技术模块
  330. const res = await settingQueryBizModuleList(Number(localStorage.getItem('bizId')))
  331. if (res.code === 200) {
  332. this.moduleList = this.handlerModules(res.data)
  333. }
  334. },
  335. handlerModules(arr) {
  336. return arr.map(item => ({
  337. ...item,
  338. value: item.id,
  339. label: item.moduleName,
  340. children: item.childModules.length ? this.handlerModules(item.childModules) : null
  341. }))
  342. },
  343. async getTeamList() { // 获取我的团队和所有团队
  344. const myRes = await teamQueryTeamInfoList({ type: 0 })// 我的团队
  345. const allRes = await teamQueryTeamInfoList({ type: 1 })// 所有团队
  346. this.teamOptions = [
  347. { label: '我的团队', options: [...myRes.data.list] },
  348. { label: '全部团队', options: [...allRes.data.list] }
  349. ]
  350. },
  351. async getSummary() { // 获取顶部数据
  352. const res = await getSummary(this.globalParams)
  353. if (res.code === 200) this.Summary = res.data || []
  354. },
  355. async getTaskCountTrend() { // 趋势图日期变动
  356. const params = {
  357. ...this.globalParams,
  358. type: Number(this.activeTab),
  359. timeType: this.timeType
  360. }
  361. const res = await getTaskCountTrend(params)
  362. if (res.code === 200) this.tendencyData = res.data
  363. },
  364. async getBelongRequirementData() { // 所属需求方向分布图
  365. const params = {
  366. ...this.globalParams,
  367. type: Number(this.activeTab)
  368. }
  369. const res = await getRequirementOrientationDistributeData(params)
  370. if (res.code === 200) this.belongRequirementData = res.data
  371. },
  372. async getCumulativeFlowDiagram() { // 任务状态累计流图
  373. const params = {
  374. ...this.globalParams,
  375. timeType: this.timeType
  376. }
  377. const res = await getCumulativeFlowDiagram(params)
  378. if (res.code === 200) this.cumulativeData = res.data
  379. },
  380. async getCycleData() { // 周期统计数据
  381. const params = {
  382. ...this.globalParams,
  383. type: Number(this.activeTab)
  384. }
  385. const res = await getTaskPeriodicData(params)
  386. if (res.code === 200) this.cycleData = res.data
  387. },
  388. async getDevelopmentCycle() { // 获取研发交付周期分布数据
  389. const params = {
  390. ...this.globalParams,
  391. type: Number(this.activeTab)
  392. }
  393. const res = await getTaskRdDeliveryPeriodicData(params)
  394. if (res.code === 200) {
  395. res.data.length > 0
  396. ? this.developmentCycleData = res.data
  397. : this.developmentCycleData = [moment().format('YYYY-MM-DD'), '0']
  398. }
  399. },
  400. async getDistributeData() { // 获取任务分布图
  401. const params = {
  402. ...this.globalParams,
  403. type: Number(this.activeTab),
  404. distributeType: this.distributeStatus
  405. }
  406. const res = await getDistributeData(params)
  407. if (res.code === 200) this.distributeData = res.data
  408. },
  409. async getStatusStayData() { // 状态停留时长分布
  410. const params = {
  411. ...this.globalParams,
  412. type: Number(this.activeTab)
  413. }
  414. const res = await getStatusStayData(params)
  415. if (res.code === 200) this.statusStayData = res.data
  416. },
  417. async getModuleDistributeData() { // 获取模块分布
  418. const params = {
  419. ...this.globalParams,
  420. type: Number(this.activeTab)
  421. }
  422. const res = await getModuleDistributeData(params)
  423. if (res.code === 200) this.moduleDistributeData = this.handlerData(res.data)
  424. },
  425. handlerData(arr) { // 处理任务模块分布图数据
  426. const bfs = (arr) => {
  427. for (const item of arr) {
  428. if (item.children && item.children.length > 0) {
  429. delete item.value
  430. bfs(item.children)
  431. } else {
  432. delete item.children
  433. }
  434. }
  435. }
  436. bfs(arr)
  437. return { children: arr, name: '模块分布' }
  438. },
  439. async getTaskUnlockData() { // 排期发生变更的任务
  440. const params = {
  441. ...this.globalParams,
  442. type: Number(this.activeTab),
  443. distributeType: this.distributeStatus
  444. }
  445. const res = await getTaskUnlockData(params)
  446. if (res.code === 200) {
  447. this.changeTaskData = res.data || []
  448. this.changeTotal = this.changeTaskData.length
  449. }
  450. },
  451. async getReportSummary() { // 报告统计
  452. const params = {
  453. ...this.globalParams,
  454. type: Number(this.activeTab)
  455. }
  456. const res = await getReportSummary(params)
  457. if (res.code === 200) this.reportSummaryData = res.data
  458. },
  459. async getBugStatisticData() { // 缺陷统计
  460. const params = {
  461. ...this.globalParams,
  462. type: Number(this.activeTab)
  463. }
  464. const res = await getBugStatisticData(params)
  465. if (res.code === 200) this.bugListData = res.data
  466. }
  467. }
  468. }
  469. </script>
  470. <style lang="scss" scoped>
  471. .defect-container {
  472. width: 100%;
  473. height:100%;
  474. background:#F2F3F6;
  475. display: inline-block;
  476. color: #666666;
  477. h3 {
  478. font-size: 18px;
  479. margin: 0;
  480. padding: 0;
  481. span {
  482. font-size: 14px;
  483. color: #666666;
  484. }
  485. }
  486. .defect-main {
  487. padding: 20px 20px 0 20px;
  488. height:100%;
  489. width:auto;
  490. background:#ffffff;
  491. margin: 10px;
  492. border-radius: 4px;
  493. .date-select {
  494. line-height: 20px;
  495. display: inline-block;
  496. .date-item {
  497. display: inline-block;
  498. width: 40px;
  499. text-align: center;
  500. cursor: pointer;
  501. border-radius: 2px;
  502. }
  503. .date-active {
  504. color: #FFFFFF;
  505. background-color: #409EFF;
  506. }
  507. }
  508. }
  509. }
  510. .data-total {
  511. display: grid;
  512. width: 100%;
  513. margin: auto;
  514. grid-template-columns: repeat(3,25%);
  515. grid-gap: 12.5%;
  516. padding-bottom: 40px;
  517. ul,li{
  518. padding:0;margin:0;list-style:none
  519. }
  520. .data-item {
  521. position: relative;
  522. width: 100%;
  523. border-radius: 8px;
  524. article {
  525. display: flex;
  526. flex-direction: column;
  527. align-items: flex-start;
  528. color: #FFFFFF;
  529. }
  530. .item-top {
  531. width: 100%;
  532. display: flex;
  533. align-items: center;
  534. padding: 10px 20px;
  535. font-size: 13px;
  536. .item-circle {
  537. height: 36px;
  538. width: 36px;
  539. border-radius: 50%;
  540. background:rgba(255,255,255,0.24);
  541. margin-right: 10px;
  542. display: flex;
  543. justify-content: center;
  544. align-items: center;
  545. img {
  546. height: 20px;
  547. width: 20px;
  548. }
  549. }
  550. span {
  551. margin-right: 5px;
  552. }
  553. }
  554. .item-line {
  555. width: 100%;
  556. border-bottom:1px solid rgba(255,255,255,0.2);
  557. }
  558. .item-title {
  559. font-size: 40px;
  560. padding: 5% 20px;
  561. }
  562. .item-up,.item-down {
  563. font-size: 13px;
  564. padding: 10px 20px 0 20px;
  565. margin-bottom: 20px;
  566. }
  567. .item-up i {
  568. color:#F32850
  569. }
  570. .item-down i {
  571. color:#9FFF39
  572. }
  573. }
  574. .item1 {
  575. background-image: url('../../../src/assets/defect_images/数据1.png');
  576. background-size: 100% 100%;
  577. background-position: 50% 50%;
  578. box-shadow:0px 50px 24px -25px rgba(64,137,255,0.30);
  579. }
  580. .item2 {
  581. background-image: url('../../../src/assets/defect_images/数据2.png');
  582. background-size: 100% 100%;
  583. background-position: 50% 50%;
  584. box-shadow:0px 50px 24px -25px rgba(78,188,250,0.40);
  585. }
  586. .item3 {
  587. background-image: url('../../../src/assets/defect_images/数据3.png');
  588. background-size: 100% 100%;
  589. background-position: 50% 50%;
  590. box-shadow:0px 50px 24px -25px rgba(255,136,134,0.30);
  591. }
  592. .item4 {
  593. background-image: url('../../../src/assets/defect_images/数据4.png');
  594. background-size: 100% 100%;
  595. background-position: 50% 50%;
  596. box-shadow:0px 50px 24px -25px rgba(83,97,255,0.30);
  597. }
  598. }
  599. .bottom-padding {
  600. padding-bottom: 30px;
  601. }
  602. .charts-main {
  603. padding-bottom: 20px;
  604. width:auto;
  605. background:#ffffff;
  606. margin: 10px;
  607. border-radius: 4px;
  608. .chart-item {
  609. margin-bottom: 30px;
  610. }
  611. .tab-change {
  612. overflow: hidden;
  613. }
  614. .chart-item-tip {
  615. padding: 6px 10px;
  616. margin-top: 5px;
  617. font-size: 12px;
  618. color: #444444;
  619. background: rgba(230, 162, 61, 0.1);
  620. border: 2px;
  621. i {
  622. margin-right: 10px;
  623. }
  624. }
  625. }
  626. .strong-font {
  627. color: #F01A1A !important;
  628. font-size: 18px !important;
  629. }
  630. /deep/.el-tabs__nav-wrap:after {
  631. background-color: #E4E7ED !important;
  632. }
  633. </style>