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.

263 lines
7.8 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
  1. <template>
  2. <section>
  3. <el-dialog fullscreen :title="title" append-to-body modal-append-to-body width="80%" top="20px" :visible.sync="visible">
  4. <el-row :gutter="5" v-if="visible">
  5. <el-col :span="18">
  6. <div>
  7. <div class="main" id="testPlanCaseExecStatusDist"
  8. style="width:100%;height:600px;margin:0 auto;"></div>
  9. <div class="progress"></div>
  10. </div>
  11. </el-col>
  12. <el-col :span="6" class="border">
  13. <el-form :model="filters" class="padding">
  14. <el-form-item label="归属项目" >
  15. <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>
  16. <span v-else>{{xmProject.id}} <span v-if="xmProject.name"><br/>{{ xmProject.name }} </span> </span>
  17. </el-form-item>
  18. <el-form-item label="归属产品" >
  19. <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>
  20. <span v-else>{{xmProductCpd.id}} <span v-if="xmProductCpd.productName"><br/>{{ xmProductCpd.productName }} </span> </span>
  21. </el-form-item>
  22. <el-form-item label="测试计划" v-if="xmTestPlan && xmTestPlan.id">
  23. <span> {{xmTestPlan.id}}
  24. <span v-if="xmTestPlan.name"><br/>{{ xmTestPlan.name }} </span>
  25. </span>
  26. </el-form-item>
  27. <el-form-item label="测试计划" v-else-if="filters.product && filters.product.id">
  28. <span v-if="filters.testPlan">{{ filters.testPlan.name }}</span><el-button type="primary" @click="$refs['xmTestPlanSelectRef'].open()">选择计划</el-button>
  29. </el-form-item>
  30. <el-form-item>
  31. <el-button type="primary" icon="el-icon-search" @click="searchXmTestPlanCaseExecStatusDist">查询</el-button>
  32. </el-form-item>
  33. </el-form>
  34. </el-col>
  35. </el-row>
  36. <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 >
  37. </el-dialog>
  38. </section>
  39. </template>
  40. <script>
  41. import util from '@/common/js/util';//全局公共库
  42. import { initSimpleDicts } from '@/api/mdp/meta/item';//下拉框数据查询
  43. import { mapGetters } from 'vuex'
  44. import { getXmTestPlanCaseExecStatusDist } from '@/api/xm/core/xmTestPlanCase';
  45. import XmProjectSelect from '@/views/xm/core/components/XmProjectSelect';//项目
  46. import XmProductSelect from '@/views/xm/core/components/XmProductSelect';//产品
  47. import xmTestPlanSelect from '@/views/xm/core/xmTestPlan/XmTestPlanSelect';//计划选择器
  48. export default {
  49. components: {
  50. XmProjectSelect,XmProductSelect,xmTestPlanSelect,
  51. },
  52. props:['xmProject','xmProduct','xmTestCasedb','xmTestPlan'],
  53. computed: {
  54. ...mapGetters([
  55. 'userInfo','roles'
  56. ]),
  57. xmTestPlanCaseExecStatusDistsCpd(){
  58. if(this.xmTestPlanCaseExecStatusDists.length==0){
  59. return []
  60. }else{
  61. var datas=[]
  62. this.xmTestPlanCaseExecStatusDists.forEach(i=>{
  63. var data={}
  64. var itemId="testStepTcode";
  65. data.name=this.formatDict(itemId,i.execStatus)
  66. data.value=i.totalCnt
  67. datas.push(data)
  68. })
  69. return datas;
  70. }
  71. },
  72. title(){
  73. return '测试用例执行结果数量分布'
  74. },
  75. /**0-未测,1-通过,2-受阻,3-忽略,4-失败 */
  76. legendCpd(){
  77. var itemId="testStepTcode";
  78. return this.dicts[itemId].map(i=>this.formatDict(itemId,i.id))
  79. },
  80. xmProductCpd(){
  81. if(this.xmTestPlan && this.xmTestPlan.id){
  82. return {id:this.xmTestPlan.productId,productName:this.xmTestPlan.productName}
  83. }
  84. if(this.xmProduct && this.xmProduct.id){
  85. return this.xmProduct
  86. }
  87. return null;
  88. }
  89. },
  90. watch: {
  91. xmTestPlanCaseExecStatusDistsCpd(){
  92. this.drawCharts();
  93. }
  94. },
  95. data() {
  96. return {
  97. filters:{
  98. testPlan:null,
  99. product:null,
  100. project:null,
  101. },
  102. dicts:{testStepTcode:[]},//下拉选择框的所有静态数据 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]}
  103. load:{ list: false, edit: false, del: false, add: false },//查询中...
  104. dateRanger:[],
  105. maxTableHeight:300,
  106. visible:false,
  107. xmTestPlanCaseExecStatusDists:[],
  108. conditionBtnVisible:false,
  109. }//end return
  110. },//end data
  111. methods: {
  112. formatDict(itemId,val){
  113. var dict=this.dicts[itemId]
  114. if(dict){
  115. var item=dict.find(i=>i.id==val)
  116. if(item){
  117. return item.name
  118. }
  119. }
  120. return val;
  121. },
  122. drawCharts() {
  123. this.myChart = this.$echarts.init(document.getElementById("testPlanCaseExecStatusDist"));
  124. this.myChart.setOption(
  125. {
  126. title: {
  127. text: this.title,
  128. left: 'center'
  129. },
  130. tooltip: {
  131. trigger: 'item'
  132. },
  133. legend: {
  134. top:'5%',
  135. left: 'center',
  136. data:this.legendCpd,
  137. },
  138. series: [
  139. {
  140. type: 'pie',
  141. radius: '50%',
  142. data: this.xmTestPlanCaseExecStatusDistsCpd,
  143. emphasis: {
  144. itemStyle: {
  145. shadowBlur: 10,
  146. shadowOffsetX: 0,
  147. shadowColor: 'rgba(0, 0, 0, 0.5)'
  148. }
  149. },
  150. label: {
  151. show: true,
  152. position: 'center'
  153. },
  154. }
  155. ]
  156. }
  157. )
  158. },
  159. onXmQuestionSomeFieldsChange(fieldName,$event){
  160. this.xmTestPlanCaseExecStatusDists=[]
  161. },
  162. searchXmTestPlanCaseExecStatusDist(){
  163. var params={ }
  164. if(this.filters.product && this.filters.product.id){
  165. params.productId=this.filters.product.id
  166. }
  167. if(this.filters.project && this.filters.project.id){
  168. params.projectId=this.filters.project.id
  169. }
  170. if(this.filters.project && this.filters.project.id){
  171. params.projectId=this.filters.project.id
  172. }
  173. if(this.filters.testPlan && this.filters.testPlan.id){
  174. params.planId=this.filters.testPlan.id
  175. }
  176. if(this.filters.testCasedb && this.filters.testCasedb.id){
  177. params.casedbId=this.filters.testCasedb.id
  178. }
  179. if(params.productId || params.projectId || params.planId || params.casedbId){
  180. getXmTestPlanCaseExecStatusDist(params).then(res=>{
  181. this.xmTestPlanCaseExecStatusDists=res.data.data
  182. })
  183. }else{
  184. this.$message.error("请选择查询条件,产品、项目、测试计划最少选择一个")
  185. }
  186. },
  187. onProductSelected(product){
  188. this.filters.product=product
  189. },
  190. onProductClear(){
  191. this.filters.product=null
  192. },
  193. onProjectSelected(project){
  194. this.filters.project=project
  195. },
  196. onProjectClear(){
  197. this.filters.project=null
  198. },
  199. onXmTestPlanSelected(xmTestPlan){
  200. this.filters.testPlan=xmTestPlan
  201. },
  202. onXmTestPlanClear(){
  203. this.filters.testPlan=null
  204. },
  205. initData(){
  206. if(this.xmTestPlan){
  207. this.filters.testPlan=this.xmTestPlan
  208. }
  209. },
  210. sizeAutoChange(){
  211. this.myChart.resize();
  212. },
  213. open(params){
  214. this.visible=true;
  215. this.filters.testPlan=this.xmTestPlan
  216. this.filters.product=this.xmProduct
  217. this.filters.project=this.xmProject
  218. this.filters.testCasedb=this.xmTestCasedb
  219. this.searchXmTestPlanCaseExecStatusDist();
  220. }
  221. },//end method
  222. mounted() {
  223. initSimpleDicts('all',['testStepTcode'] ).then(res=>{
  224. this.dicts=res.data.data;
  225. })
  226. this.initData();
  227. }//end mounted
  228. }
  229. </script>
  230. <style scoped>
  231. .image {
  232. width: 100%;
  233. display: block;
  234. }
  235. </style>