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.

302 lines
9.3 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <section>
  3. <el-row :gutter="5" >
  4. <el-col :span="18">
  5. <div>
  6. <div class="main" id="testPlanCaseExecStatusDist"
  7. style="width:100%;height:600px;margin:0 auto;"></div>
  8. <div class="progress"></div>
  9. </div>
  10. </el-col>
  11. <el-col :span="6" class="border">
  12. <el-form :model="filters" class="padding">
  13. <el-form-item label="测试库" v-if="xmTestCasedb && xmTestCasedb.id" >
  14. <span >{{xmTestCasedb.id}} <span v-if="xmTestCasedb.name"><br/>{{ xmTestCasedb.name }} </span> </span>
  15. </el-form-item>
  16. <el-form-item label="归属项目" >
  17. <xm-project-select v-if="!xmProject" ref="xmProjectSelect" style="display:inline;" :auto-select="false" :link-product-id="xmProductCpd?xmProductCpd.id:null" @row-click="onProjectSelected" @clear="onProjectClear"></xm-project-select>
  18. <span v-else>{{xmProject.id}} <span v-if="xmProject.name"><br/>{{ xmProject.name }} </span> </span>
  19. </el-form-item>
  20. <el-form-item label="归属产品" >
  21. <xm-product-select v-if="!xmProductCpd || !xmProductCpd.id" ref="xmProductSelect" style="display:inline;" :auto-select="false" :link-project-id="xmProject?xmProject.id:null" @row-click="onProductSelected" :iterationId="xmTestPlan?xmTestPlan.id:null" @clear="onProductClear"></xm-product-select>
  22. <span v-else>{{xmProductCpd.id}} <span v-if="xmProductCpd.productName"><br/>{{ xmProductCpd.productName }} </span> </span>
  23. </el-form-item>
  24. <el-form-item label="归属迭代" v-if="xmIteration && xmIteration.id">
  25. <span> {{xmIteration.id}}
  26. <span v-if="xmIteration.iterationName"><br/>{{ xmIteration.iterationName }} </span>
  27. </span>
  28. </el-form-item>
  29. <el-form-item label="归属迭代" v-else-if="filters.product && filters.product.id">
  30. <xm-iteration-select ref="xmIterationSelect" :auto-select="false" :product-id="filters.product?filters.product.id:null" :link-project-id="xmProject?xmProject.id:null" placeholder="迭代" @row-click="onIterationSelected" @clear="onIterationClear"></xm-iteration-select>
  31. </el-form-item>
  32. <el-form-item label="测试计划" v-if="xmTestPlan && xmTestPlan.id">
  33. <span> {{xmTestPlan.id}}
  34. <span v-if="xmTestPlan.name"><br/>{{ xmTestPlan.name }} </span>
  35. </span>
  36. </el-form-item>
  37. <el-form-item label="测试计划" v-else-if="filters.product && filters.product.id">
  38. <span v-if="filters.testPlan">{{ filters.testPlan.name }}</span>
  39. <el-button v-if="filters.testPlan" type="text" @click="filters.testPlan=null" plain icon="el-icon-circle-close">清除</el-button>
  40. <el-button v-if="!filters.testPlan" type="text" @click="$refs['xmTestPlanSelectRef'].open()" plain>选择计划</el-button>
  41. </el-form-item>
  42. <el-form-item>
  43. <el-button type="primary" icon="el-icon-search" @click="searchXmTestPlanCaseExecStatusDist">查询</el-button>
  44. </el-form-item>
  45. </el-form>
  46. </el-col>
  47. </el-row>
  48. <xm-test-plan-select ref="xmTestPlanSelectRef" :casedb-id="xmTestCasedb?xmTestCasedb.id:null" :product-id="xmProduct?xmProduct.id:null" :project-id="xmProject?xmProject.id:null" placeholder="迭代" @select="onXmTestPlanSelected" @clear="onXmTestPlanClear"></xm-test-plan-select >
  49. </section>
  50. </template>
  51. <script>
  52. import util from '@/common/js/util';//全局公共库
  53. import { initSimpleDicts } from '@/api/mdp/meta/item';//下拉框数据查询
  54. import { mapGetters } from 'vuex'
  55. import { getXmTestCaseToPlanCalcList } from '@/api/xm/core/xmTestPlanCase';
  56. import XmProjectSelect from '@/views/xm/core/components/XmProjectSelect';//项目
  57. import XmProductSelect from '@/views/xm/core/components/XmProductSelect';//产品
  58. import XmIterationSelect from '@/views/xm/core/components/XmIterationSelect';//迭代选择界面
  59. import xmTestPlanSelect from '@/views/xm/core/xmTestPlan/XmTestPlanSelect';//计划选择器
  60. export default {
  61. components: {
  62. XmProjectSelect,XmProductSelect,XmIterationSelect,xmTestPlanSelect,
  63. },
  64. props:['xmProject','xmProduct','xmIteration','xmTestCasedb','xmTestPlan'],
  65. computed: {
  66. ...mapGetters([
  67. 'userInfo','roles'
  68. ]),
  69. xmTestCaseToPlanCalcListCpd(){
  70. if(!this.xmTestCaseToPlanCalcList || this.xmTestCaseToPlanCalcList.length==0){
  71. return []
  72. }else{
  73. var names=this.legendCpd;
  74. var datas=[]
  75. this.xmTestCaseToPlanCalcList.forEach(i=>{
  76. var nameIndex=0;
  77. if(i.useTimes<=2){
  78. nameIndex=i.useTimes
  79. }else if(i.useTimes>=3 && i.useTimes<=5){
  80. nameIndex=3
  81. }else if(i.useTimes>5 && i.useTimes<=10){
  82. nameIndex=4
  83. }else if(i.useTimes>10){
  84. nameIndex=5
  85. }
  86. var data={name:names[nameIndex],value:i.caseNum}
  87. datas.push(data)
  88. })
  89. return datas;
  90. }
  91. },
  92. title(){
  93. return '测试用例规划分析'
  94. },
  95. /**0-未测,1-通过,2-受阻,3-忽略,4-失败 */
  96. legendCpd(){
  97. return ['0次','1次','2次','3-5次','5-10次','10次以上']
  98. },
  99. xmProductCpd(){
  100. if(this.xmTestPlan && this.xmTestPlan.id){
  101. return {id:this.xmTestPlan.productId,productName:this.xmTestPlan.productName}
  102. }
  103. if(this.xmProduct && this.xmProduct.id){
  104. return this.xmProduct
  105. }
  106. return null;
  107. }
  108. },
  109. watch: {
  110. xmTestCaseToPlanCalcListCpd(){
  111. this.drawCharts();
  112. }
  113. },
  114. data() {
  115. return {
  116. filters:{
  117. product:null,
  118. project:null,
  119. testPlan:null,
  120. iteration:null,
  121. testCasedb:null,
  122. },
  123. dicts:{testStepTcode:[]},//下拉选择框的所有静态数据 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]}
  124. load:{ list: false, edit: false, del: false, add: false },//查询中...
  125. dateRanger:[],
  126. maxTableHeight:300,
  127. visible:false,
  128. xmTestCaseToPlanCalcList:[],
  129. conditionBtnVisible:false,
  130. }//end return
  131. },//end data
  132. methods: {
  133. formatDict(itemId,val){
  134. var dict=this.dicts[itemId]
  135. if(dict){
  136. var item=dict.find(i=>i.id==val)
  137. if(item){
  138. return item.name
  139. }
  140. }
  141. return val;
  142. },
  143. drawCharts() {
  144. this.myChart = this.$echarts.init(document.getElementById("testPlanCaseExecStatusDist"));
  145. this.myChart.setOption(
  146. {
  147. title: {
  148. text: this.title,
  149. left: 'center'
  150. },
  151. tooltip: {
  152. trigger: 'item',
  153. formatter:'{b} {c}个 {d}%',
  154. },
  155. toolbox: {
  156. show: true,
  157. right:"20px",
  158. feature: {
  159. dataView: { show: true, readOnly: false },
  160. saveAsImage: { show: true },
  161. }
  162. },
  163. calculable: true,
  164. legend: {
  165. top:'5%',
  166. left: 'center',
  167. data:this.legendCpd,
  168. },
  169. series: [
  170. {
  171. type: 'pie',
  172. radius: '50%',
  173. data: this.xmTestCaseToPlanCalcListCpd,
  174. emphasis: {
  175. itemStyle: {
  176. shadowBlur: 10,
  177. shadowOffsetX: 0,
  178. shadowColor: 'rgba(0, 0, 0, 0.5)'
  179. }
  180. },
  181. label: {
  182. show: true,
  183. formatter:'{b} {c}个 {d}%',
  184. },
  185. }
  186. ]
  187. }
  188. )
  189. },
  190. onXmQuestionSomeFieldsChange(fieldName,$event){
  191. this.xmTestCaseToPlanCalcList=[]
  192. },
  193. searchXmTestPlanCaseExecStatusDist(){
  194. var params={ }
  195. if(this.filters.product && this.filters.product.id){
  196. params.productId=this.filters.product.id
  197. }
  198. if(this.filters.project && this.filters.project.id){
  199. params.projectId=this.filters.project.id
  200. }
  201. if(this.filters.iteration && this.filters.iteration.id){
  202. params.linkIterationId=this.filters.iteration.id
  203. }
  204. if(this.filters.testPlan && this.filters.testPlan.id){
  205. params.planId=this.filters.testPlan.id
  206. }
  207. if(this.filters.testCasedb && this.filters.testCasedb.id){
  208. params.casedbId=this.filters.testCasedb.id
  209. }
  210. getXmTestCaseToPlanCalcList(params).then(res=>{
  211. this.xmTestCaseToPlanCalcList=res.data.data
  212. })
  213. },
  214. onProjectSelected(project){
  215. this.filters.project=project
  216. },
  217. onProjectClear(){
  218. this.filters.project=null
  219. },
  220. onProductSelected(product){
  221. this.filters.product=product
  222. },
  223. onProductClear(){
  224. this.filters.product=null
  225. },
  226. onIterationSelected(iteration){
  227. this.filters.iteration=iteration
  228. },
  229. onIterationClear(){
  230. this.filters.iteration=null
  231. },
  232. onXmTestPlanSelected(xmTestPlan){
  233. this.filters.testPlan=xmTestPlan
  234. },
  235. onXmTestPlanClear(){
  236. this.filters.testPlan=null
  237. },
  238. initData(){
  239. if(this.xmTestPlan){
  240. this.filters.testPlan=this.xmTestPlan
  241. }
  242. },
  243. sizeAutoChange(){
  244. this.myChart.resize();
  245. },
  246. open(){
  247. this.visible=true;
  248. this.filters.testPlan=this.xmTestPlan
  249. this.filters.product=this.xmProduct
  250. this.filters.project=this.xmProject
  251. this.filters.iteration=this.xmIteration
  252. this.filters.testCasedb=this.xmTestCasedb
  253. this.searchXmTestPlanCaseExecStatusDist();
  254. }
  255. },//end method
  256. mounted() {
  257. initSimpleDicts('all',['testStepTcode'] ).then(res=>{
  258. this.dicts=res.data.data;
  259. })
  260. this.initData();
  261. this.open();
  262. }//end mounted
  263. }
  264. </script>
  265. <style scoped>
  266. .image {
  267. width: 100%;
  268. display: block;
  269. }
  270. </style>