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.

350 lines
11 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
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="this.id"></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:['id','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. total(){
  92. if(!this.xmTestCaseToPlanCalcList || this.xmTestCaseToPlanCalcList.length==0){
  93. return 0
  94. }else{
  95. return this.xmTestCaseToPlanCalcList.reduce((n, i) => {
  96. return (n += i.useTimes);
  97. }, 0)
  98. }
  99. },
  100. titleCpd(){
  101. var preName=""
  102. if(this.filters.testPlan && this.filters.testPlan.id){
  103. preName=`测试计划【${this.filters.testPlan.name}`
  104. }else if(this.filters.testCasedb && this.filters.testCasedb.id){
  105. preName=`测试库【${this.filters.testCasedb.name}`
  106. }else if(this.filters.iteration && this.filters.iteration.id){
  107. preName=`迭代【${this.filters.iteration.iterationName}`
  108. }else if(this.filters.product && this.filters.product.id){
  109. if(this.filters.product.productName){
  110. preName=`产品【${this.filters.product.productName}`
  111. }else{
  112. preName=`产品【${this.filters.product.id}`
  113. }
  114. }else if(this.filters.project && this.filters.project.id){
  115. if(this.filters.project.name){
  116. preName=`项目【${this.filters.project.name}`
  117. }else{
  118. preName=`项目【${this.filters.project.id}`
  119. }
  120. }
  121. return preName+'测试用例规划分析'
  122. },
  123. /**0-未测,1-通过,2-受阻,3-忽略,4-失败 */
  124. legendCpd(){
  125. return ['规划0次','规划1次','规划2次','规划3-5次','规划5-10次','规划10次以上']
  126. },
  127. xmProductCpd(){
  128. if(this.xmTestPlan && this.xmTestPlan.id){
  129. return {id:this.xmTestPlan.productId,productName:this.xmTestPlan.productName}
  130. }
  131. if(this.xmProduct && this.xmProduct.id){
  132. return this.xmProduct
  133. }
  134. return null;
  135. }
  136. },
  137. watch: {
  138. xmTestCaseToPlanCalcListCpd(){
  139. this.drawCharts();
  140. }
  141. },
  142. data() {
  143. return {
  144. filters:{
  145. product:null,
  146. project:null,
  147. testPlan:null,
  148. iteration:null,
  149. testCasedb:null,
  150. },
  151. dicts:{testStepTcode:[]},//下拉选择框的所有静态数据 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]}
  152. load:{ list: false, edit: false, del: false, add: false },//查询中...
  153. dateRanger:[],
  154. maxTableHeight:300,
  155. visible:false,
  156. xmTestCaseToPlanCalcList:[],
  157. conditionBtnVisible:false,
  158. }//end return
  159. },//end data
  160. methods: {
  161. formatDict(itemId,val){
  162. var dict=this.dicts[itemId]
  163. if(dict){
  164. var item=dict.find(i=>i.id==val)
  165. if(item){
  166. return item.name
  167. }
  168. }
  169. return val;
  170. },
  171. drawCharts() {
  172. this.myChart = this.$echarts.init(document.getElementById(this.id));
  173. this.myChart.setOption(
  174. {
  175. title: {
  176. text: this.titleCpd,
  177. left: 'center'
  178. },
  179. tooltip: {
  180. trigger: 'item',
  181. },
  182. toolbox: {
  183. show: true,
  184. top:"5%",
  185. right:"10px",
  186. feature: {
  187. dataView: { show: true, readOnly: false },
  188. saveAsImage: { show: true },
  189. }
  190. },
  191. calculable: true,
  192. legend:{
  193. bottom: 'bottom',
  194. data:this.legendCpd,
  195. },
  196. graphic: {
  197. type: 'text',
  198. left: 'center',
  199. top: 'center',
  200. style: {
  201. // text: '总数',
  202. text:
  203. '用例数'+this.total ,
  204. textAlign: 'center',
  205. fill: '#333',
  206. width: 30,
  207. height: 30,
  208. fontSize: 14
  209. }
  210. },
  211. series: [
  212. {
  213. type: 'pie',
  214. radius: ['50%','70%'],
  215. data: this.xmTestCaseToPlanCalcListCpd,
  216. emphasis: {
  217. itemStyle: {
  218. shadowBlur: 10,
  219. shadowOffsetX: 0,
  220. shadowColor: 'rgba(0, 0, 0, 0.5)'
  221. }
  222. },
  223. label: {
  224. show: true,
  225. formatter:'{b}的用例数: {c} ({d}%)'
  226. },
  227. }
  228. ]
  229. }
  230. )
  231. },
  232. onXmQuestionSomeFieldsChange(fieldName,$event){
  233. this.xmTestCaseToPlanCalcList=[]
  234. },
  235. searchXmTestCaseToPlanCalcList(){
  236. var params={ }
  237. if(this.filters.product && this.filters.product.id){
  238. params.productId=this.filters.product.id
  239. }
  240. if(this.filters.project && this.filters.project.id){
  241. params.projectId=this.filters.project.id
  242. }
  243. if(this.filters.iteration && this.filters.iteration.id){
  244. params.linkIterationId=this.filters.iteration.id
  245. }
  246. if(this.filters.testPlan && this.filters.testPlan.id){
  247. params.planId=this.filters.testPlan.id
  248. }
  249. if(this.filters.testCasedb && this.filters.testCasedb.id){
  250. params.casedbId=this.filters.testCasedb.id
  251. }
  252. getXmTestCaseToPlanCalcList(params).then(res=>{
  253. this.xmTestCaseToPlanCalcList=res.data.data
  254. })
  255. },
  256. onProjectSelected(project){
  257. this.filters.project=project
  258. },
  259. onProjectClear(){
  260. this.filters.project=null
  261. },
  262. onProductSelected(product){
  263. this.filters.product=product
  264. },
  265. onProductClear(){
  266. this.filters.product=null
  267. },
  268. onIterationSelected(iteration){
  269. this.filters.iteration=iteration
  270. },
  271. onIterationClear(){
  272. this.filters.iteration=null
  273. },
  274. onXmTestPlanSelected(xmTestPlan){
  275. this.filters.testPlan=xmTestPlan
  276. },
  277. onXmTestPlanClear(){
  278. this.filters.testPlan=null
  279. },
  280. initData(){
  281. if(this.xmTestPlan){
  282. this.filters.testPlan=this.xmTestPlan
  283. }
  284. },
  285. sizeAutoChange(){
  286. this.myChart.resize();
  287. },
  288. open(){
  289. this.visible=true;
  290. this.filters.testPlan=this.xmTestPlan
  291. this.filters.product=this.xmProduct
  292. this.filters.project=this.xmProject
  293. this.filters.iteration=this.xmIteration
  294. this.filters.testCasedb=this.xmTestCasedb
  295. this.searchXmTestCaseToPlanCalcList();
  296. }
  297. },//end method
  298. mounted() {
  299. initSimpleDicts('all',['testStepTcode'] ).then(res=>{
  300. this.dicts=res.data.data;
  301. })
  302. this.initData();
  303. this.maxTableHeight = util.calcTableMaxHeight(this.$refs.filtersRef.$el)
  304. //this.charts();
  305. this.open();
  306. }//end mounted
  307. }
  308. </script>
  309. <style scoped>
  310. .image {
  311. width: 100%;
  312. display: block;
  313. }
  314. </style>