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.

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