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.

270 lines
8.0 KiB

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()" plain>选择计划</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 { getXmTestCaseToPlanCalcList } 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. xmTestCaseToPlanCalcListCpd(){
  58. if(this.xmTestCaseToPlanCalcList.length==0){
  59. return []
  60. }else{
  61. var names=this.legendCpd;
  62. var datas=[]
  63. this.xmTestCaseToPlanCalcList.forEach(i=>{
  64. var nameIndex=0;
  65. if(i.useTimes<=2){
  66. nameIndex=i.useTimes
  67. }else if(i.useTimes>=3 && i.useTimes<=5){
  68. nameIndex=3
  69. }else if(i.useTimes>5 && i.useTimes<=10){
  70. nameIndex=4
  71. }else if(i.useTimes>10){
  72. nameIndex=5
  73. }
  74. var data={name:names[nameIndex],value:i.caseNum}
  75. datas.push(data)
  76. })
  77. return datas;
  78. }
  79. },
  80. title(){
  81. return '测试用例规划分析'
  82. },
  83. /**0-未测,1-通过,2-受阻,3-忽略,4-失败 */
  84. legendCpd(){
  85. return ['0次','1次','2次','3-5次','5-10次','10次以上']
  86. },
  87. xmProductCpd(){
  88. if(this.xmTestPlan && this.xmTestPlan.id){
  89. return {id:this.xmTestPlan.productId,productName:this.xmTestPlan.productName}
  90. }
  91. if(this.xmProduct && this.xmProduct.id){
  92. return this.xmProduct
  93. }
  94. return null;
  95. }
  96. },
  97. watch: {
  98. xmTestCaseToPlanCalcListCpd(){
  99. this.drawCharts();
  100. }
  101. },
  102. data() {
  103. return {
  104. filters:{
  105. testPlan:null,
  106. product:null,
  107. project:null,
  108. },
  109. dicts:{testStepTcode:[]},//下拉选择框的所有静态数据 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]}
  110. load:{ list: false, edit: false, del: false, add: false },//查询中...
  111. dateRanger:[],
  112. maxTableHeight:300,
  113. visible:false,
  114. xmTestCaseToPlanCalcList:[],
  115. conditionBtnVisible:false,
  116. }//end return
  117. },//end data
  118. methods: {
  119. formatDict(itemId,val){
  120. var dict=this.dicts[itemId]
  121. if(dict){
  122. var item=dict.find(i=>i.id==val)
  123. if(item){
  124. return item.name
  125. }
  126. }
  127. return val;
  128. },
  129. drawCharts() {
  130. this.myChart = this.$echarts.init(document.getElementById("testPlanCaseExecStatusDist"));
  131. this.myChart.setOption(
  132. {
  133. title: {
  134. text: this.title,
  135. left: 'center'
  136. },
  137. tooltip: {
  138. trigger: 'item'
  139. },
  140. legend: {
  141. top:'5%',
  142. left: 'center',
  143. data:this.legendCpd,
  144. },
  145. series: [
  146. {
  147. type: 'pie',
  148. radius: '50%',
  149. data: this.xmTestCaseToPlanCalcListCpd,
  150. emphasis: {
  151. itemStyle: {
  152. shadowBlur: 10,
  153. shadowOffsetX: 0,
  154. shadowColor: 'rgba(0, 0, 0, 0.5)'
  155. }
  156. },
  157. label: {
  158. show: true,
  159. position: 'center'
  160. },
  161. }
  162. ]
  163. }
  164. )
  165. },
  166. onXmQuestionSomeFieldsChange(fieldName,$event){
  167. this.xmTestCaseToPlanCalcList=[]
  168. },
  169. searchXmTestPlanCaseExecStatusDist(){
  170. var params={ }
  171. if(this.filters.product && this.filters.product.id){
  172. params.productId=this.filters.product.id
  173. }
  174. if(this.filters.project && this.filters.project.id){
  175. params.projectId=this.filters.project.id
  176. }
  177. if(this.filters.project && this.filters.project.id){
  178. params.projectId=this.filters.project.id
  179. }
  180. if(this.filters.testPlan && this.filters.testPlan.id){
  181. params.planId=this.filters.testPlan.id
  182. }
  183. if(this.filters.testCasedb && this.filters.testCasedb.id){
  184. params.casedbId=this.filters.testCasedb.id
  185. }
  186. if(params.productId || params.projectId || params.planId || params.casedbId){
  187. getXmTestCaseToPlanCalcList(params).then(res=>{
  188. this.xmTestCaseToPlanCalcList=res.data.data
  189. })
  190. }else{
  191. this.$message.error("请选择查询条件,产品、项目、测试计划最少选择一个")
  192. }
  193. },
  194. onProductSelected(product){
  195. this.filters.product=product
  196. },
  197. onProductClear(){
  198. this.filters.product=null
  199. },
  200. onProjectSelected(project){
  201. this.filters.project=project
  202. },
  203. onProjectClear(){
  204. this.filters.project=null
  205. },
  206. onXmTestPlanSelected(xmTestPlan){
  207. this.filters.testPlan=xmTestPlan
  208. },
  209. onXmTestPlanClear(){
  210. this.filters.testPlan=null
  211. },
  212. initData(){
  213. if(this.xmTestPlan){
  214. this.filters.testPlan=this.xmTestPlan
  215. }
  216. },
  217. sizeAutoChange(){
  218. this.myChart.resize();
  219. },
  220. open(params){
  221. this.visible=true;
  222. this.filters.testPlan=this.xmTestPlan
  223. this.filters.product=this.xmProduct
  224. this.filters.project=this.xmProject
  225. this.filters.testCasedb=this.xmTestCasedb
  226. this.searchXmTestPlanCaseExecStatusDist();
  227. }
  228. },//end method
  229. mounted() {
  230. initSimpleDicts('all',['testStepTcode'] ).then(res=>{
  231. this.dicts=res.data.data;
  232. })
  233. this.initData();
  234. }//end mounted
  235. }
  236. </script>
  237. <style scoped>
  238. .image {
  239. width: 100%;
  240. display: block;
  241. }
  242. </style>