You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

288 lines
8.4 KiB

4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
  1. <template>
  2. <section>
  3. <el-row :gutter="5" >
  4. <el-col :span="18">
  5. <div>
  6. <div class="echart-box" id="xmTaskAgeDist"></div>
  7. <div class="progress"></div>
  8. </div>
  9. </el-col>
  10. <el-col :span="6" class="border">
  11. <el-form :model="filters" class="padding" :style="{width:'100%',maxHeight:maxTableHeight+'px',overflow: 'auto'}" ref="filtersRef">
  12. <el-form-item label="归属项目" >
  13. <xm-project-select v-if="!xmProject || !xmProject.id" ref="xmProjectSelect" style="display:inline;" :auto-select="false" :link-project-id="xmProject?xmProject.id:null" @row-click="onProjectSelected" @clear="onProjectClear"></xm-project-select>
  14. <span v-else>{{xmProject.id}} <span v-if="xmProject.name"><br/>{{ xmProject.name }} </span> </span>
  15. </el-form-item>
  16. <el-form-item label="任务状态" prop="taskState">
  17. <el-select v-model="filters.taskState" @change="onXmTaskSomeFieldsChange('taskState',$event)" clearable>
  18. <el-option v-for="i in this.dicts.taskState" :label="i.name" :key="i.id" :value="i.id"></el-option>
  19. </el-select>
  20. </el-form-item>
  21. <el-form-item label="任务类型" prop="taskType" >
  22. <el-select v-model="filters.taskType" @change="onXmTaskSomeFieldsChange('taskType',$event)" clearable>
  23. <el-option v-for="i in this.dicts.taskType" :label="i.name" :key="i.id" :value="i.id"></el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item label="任务来源" prop="planType">
  27. <el-select v-model="filters.planType" @change="onXmTaskSomeFieldsChange('planType',$event)" clearable>
  28. <el-option v-for="i in this.dicts.planType" :label="i.name" :key="i.id" :value="i.id"></el-option>
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item label="任务层次" prop="settleSchemel" >
  32. <el-select v-model="filters.settleSchemel" @change="onXmTaskSomeFieldsChange('settleSchemel',$event)" clearable>
  33. <el-option v-for="i in this.dicts.xmTaskSettleSchemel" :label="i.name" :key="i.id" :value="i.id"></el-option>
  34. </el-select>
  35. </el-form-item>
  36. <el-form-item label="优先级" prop="priority" >
  37. <el-select v-model="filters.priority" @change="onXmTaskSomeFieldsChange('priority',$event)" clearable>
  38. <el-option v-for="i in dicts.priority" :label="i.name" :key="i.id" :value="i.id"></el-option>
  39. </el-select>
  40. </el-form-item>
  41. <el-form-item>
  42. <el-button type="primary" icon="el-icon-search" @click="searchXmTaskAgeDist">查询</el-button>
  43. </el-form-item>
  44. </el-form>
  45. </el-col>
  46. </el-row>
  47. </section>
  48. </template>
  49. <script>
  50. import util from '@/common/js/util';//全局公共库
  51. import { initSimpleDicts } from '@/api/mdp/meta/item';//下拉框数据查询
  52. import { mapGetters } from 'vuex'
  53. import { getXmTaskAgeDist } from '@/api/xm/core/xmTask';
  54. import XmProjectSelect from '@/views/xm/core/components/XmProjectSelect';//新增界面
  55. export default {
  56. components: {
  57. XmProjectSelect,
  58. },
  59. props:['xmProduct','xmIteration','xmProject'],
  60. computed: {
  61. ...mapGetters([
  62. 'userInfo','roles'
  63. ]),
  64. xmTaskAgeDistsCpd(){
  65. if(this.xmTaskAgeDists.length==0){
  66. return []
  67. }else{
  68. var datas=[]
  69. this.xmTaskAgeDists.forEach(i=>{
  70. var data={...i}
  71. data.name=this.legendCpd[i.name]
  72. datas.push(data)
  73. })
  74. return datas;
  75. }
  76. },
  77. total(){
  78. if(!this.xmTaskAgeDists || this.xmTaskAgeDists.length==0){
  79. return 0
  80. }else{
  81. return this.xmTaskAgeDists.reduce((n, i) => {
  82. return (n += i.value);
  83. }, 0)
  84. }
  85. },
  86. title(){
  87. var preName=""
  88. if(this.filters.testPlan && this.filters.testPlan.id){
  89. preName=`测试计划【${this.filters.testPlan.name}`
  90. }else if(this.filters.testCasedb && this.filters.testCasedb.id){
  91. preName=`测试库【${this.filters.testCasedb.name}`
  92. }else if(this.filters.iteration && this.filters.iteration.id){
  93. preName=`迭代【${this.filters.iteration.iterationName}`
  94. }else if(this.filters.project && this.filters.project.id){
  95. if(this.filters.project.name){
  96. preName=`项目【${this.filters.project.name}`
  97. }else{
  98. preName=`项目【${this.filters.project.id}`
  99. }
  100. }else if(this.filters.product && this.filters.product.id){
  101. if(this.filters.product.productName){
  102. preName=`产品【${this.filters.product.productName}`
  103. }else{
  104. preName=`产品【${this.filters.product.id}`
  105. }
  106. }
  107. return preName+'任务年龄数量分布'
  108. },
  109. legendCpd(){
  110. return ['0-2天','3-5天','6-7天','8-15天','16-30天','30天以上']
  111. }
  112. },
  113. watch: {
  114. xmTaskAgeDistsCpd(){
  115. this.drawCharts();
  116. }
  117. },
  118. data() {
  119. return {
  120. filters:{
  121. product:null,
  122. project:null,
  123. testPlan:null,
  124. iteration:null,
  125. testCasedb:null,
  126. },
  127. dicts:{},//下拉选择框的所有静态数据 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]}
  128. load:{ list: false, edit: false, del: false, add: false },//查询中...
  129. dateRanger:[],
  130. maxTableHeight:300,
  131. visible:false,
  132. xmTaskAgeDists:[],
  133. }//end return
  134. },//end data
  135. methods: {
  136. open(){
  137. this.visible=true;
  138. this.filters.product=this.xmProduct
  139. this.filters.project=this.xmProject
  140. this.filters.iteration=this.xmIteration
  141. this.searchXmTaskAgeDist();
  142. },
  143. drawCharts() {
  144. this.myChart = this.$echarts.init(document.getElementById("xmTaskAgeDist"));
  145. this.myChart.setOption(
  146. {
  147. title: {
  148. text: this.title,
  149. left: 'center'
  150. },
  151. tooltip: {
  152. trigger: 'item',
  153. },
  154. toolbox: {
  155. show: true,
  156. top:"5%",
  157. right:"10px",
  158. feature: {
  159. dataView: { show: true, readOnly: false },
  160. saveAsImage: { show: true },
  161. }
  162. },
  163. calculable: true,
  164. legend:{
  165. bottom: 'bottom',
  166. data:this.legendCpd,
  167. },
  168. graphic: {
  169. type: 'text',
  170. left: 'center',
  171. top: 'center',
  172. style: {
  173. // text: '总数',
  174. text:
  175. '总数'+this.total ,
  176. textAlign: 'center',
  177. fill: '#333',
  178. width: 30,
  179. height: 30,
  180. fontSize: 14
  181. }
  182. },
  183. series: [
  184. {
  185. type: 'pie',
  186. radius: ['50%','70%'],
  187. data: this.xmTaskAgeDistsCpd,
  188. emphasis: {
  189. itemStyle: {
  190. shadowBlur: 10,
  191. shadowOffsetX: 0,
  192. shadowColor: 'rgba(0, 0, 0, 0.5)'
  193. }
  194. },
  195. label: {
  196. show: true,
  197. formatter:'{b}: {c}  ({d}%)'
  198. },
  199. }
  200. ]
  201. }
  202. )
  203. },
  204. onXmTaskSomeFieldsChange(fieldName,$event){
  205. this.xmTaskAgeDists=[]
  206. },
  207. searchXmTaskAgeDist(){
  208. var params={}
  209. if(this.filters.taskType){
  210. params.taskType=this.filters.taskType
  211. }
  212. if(this.filters.taskState){
  213. params.taskState=this.filters.taskState
  214. }
  215. if(this.filters.planType){
  216. params.planType=this.filters.planType
  217. }
  218. if(this.filters.settleSchemel){
  219. params.settleSchemel=this.filters.settleSchemel
  220. }
  221. if(this.filters.priority){
  222. params.priority=this.filters.priority
  223. }
  224. params.groupBy=this.groupBy
  225. if(this.filters.project){
  226. params.projectId=this.filters.project.id
  227. }
  228. if(this.filters.iteration){
  229. params.iterationId=this.filters.iteration.id
  230. }
  231. params.ntype='0'
  232. getXmTaskAgeDist(params).then(res=>{
  233. this.xmTaskAgeDists=res.data.data
  234. })
  235. },
  236. onProjectSelected(project){
  237. this.filters.project=project
  238. },
  239. onProjectClear(){
  240. this.filters.project=null
  241. },
  242. onIterationSelected(iteration){
  243. this.filters.iteration=iteration
  244. },
  245. onIterationClear(){
  246. this.filters.iteration=null
  247. }
  248. },//end method
  249. mounted() {
  250. initSimpleDicts('all',['planType','xmTaskSettleSchemel','taskType','priority','taskState'] ).then(res=>{
  251. this.dicts=res.data.data;
  252. })
  253. this.maxTableHeight = util.calcTableMaxHeight(this.$refs.filtersRef.$el)
  254. //this.charts();
  255. this.open();
  256. }//end mounted
  257. }
  258. </script>
  259. <style scoped>
  260. .image {
  261. width: 100%;
  262. display: block;
  263. }
  264. </style>