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.

337 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
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="testPlanCaseUserDist"></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="searchXmTestPlanCaseUserDist">查询</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 { getXmTestPlanCaseUserDist } 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. hadExecCpd(){
  69. if(!this.xmTestPlanCaseUserDists ||this.xmTestPlanCaseUserDists.length==0){
  70. return []
  71. }else{
  72. return this.xmTestPlanCaseUserDists.map(i=>i.hadExec)
  73. }
  74. },
  75. notExecCpd(){
  76. if(!this.xmTestPlanCaseUserDists ||this.xmTestPlanCaseUserDists.length==0){
  77. return []
  78. }else{
  79. return this.xmTestPlanCaseUserDists.map(i=>i.notExec)
  80. }
  81. },
  82. legendCpd(){
  83. if(!this.xmTestPlanCaseUserDists ||this.xmTestPlanCaseUserDists.length==0){
  84. return []
  85. }else{
  86. return this.xmTestPlanCaseUserDists.map(i=>i.execUsername)
  87. }
  88. },
  89. xmTestPlanCaseUserDistsCpd(){
  90. if(!this.xmTestPlanCaseUserDists || this.xmTestPlanCaseUserDists.length==0){
  91. return []
  92. }else{
  93. var datas=[]
  94. this.xmTestPlanCaseUserDists.forEach(i=>{
  95. var data={}
  96. var itemId="testPlanTcode";
  97. data.name=this.formatDict(itemId,i.execStatus)
  98. data.value=i.totalCnt
  99. datas.push(data)
  100. })
  101. return datas;
  102. }
  103. },
  104. title(){
  105. var preName=""
  106. if(this.filters.testPlan && this.filters.testPlan.id){
  107. preName=`测试计划【${this.filters.testPlan.name}`
  108. }else if(this.filters.testCasedb && this.filters.testCasedb.id){
  109. preName=`测试库【${this.filters.testCasedb.name}`
  110. }else if(this.filters.iteration && this.filters.iteration.id){
  111. preName=`迭代【${this.filters.iteration.iterationName}`
  112. }else if(this.filters.product && this.filters.product.id){
  113. if(this.filters.product.productName){
  114. preName=`产品【${this.filters.product.productName}`
  115. }else{
  116. preName=`产品【${this.filters.product.id}`
  117. }
  118. }else if(this.filters.project && this.filters.project.id){
  119. if(this.filters.project.name){
  120. preName=`项目【${this.filters.project.name}`
  121. }else{
  122. preName=`项目【${this.filters.project.id}`
  123. }
  124. }
  125. return preName+ '测试用例执行结果数量分布'
  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. xmTestPlanCaseUserDistsCpd(){
  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:{testPlanTcode:[]},//下拉选择框的所有静态数据 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. xmTestPlanCaseUserDists:[],
  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("testPlanCaseUserDist"));
  173. this.myChart.setOption(
  174. {
  175. title: {
  176. text: this.title,
  177. left: 'center'
  178. },
  179. tooltip: {
  180. trigger: 'item',
  181. },
  182. barMaxWidth: 100,
  183. toolbox: {
  184. show: true,
  185. top:"5%",
  186. right:"10px",
  187. feature: {
  188. dataView: { show: true, readOnly: false },
  189. magicType: { show: true, type: ['line', 'bar'] },
  190. saveAsImage: { show: true }
  191. }
  192. },
  193. calculable: true,
  194. legend: {
  195. bottom: 'bottom',
  196. data: ['已执行', '未执行']
  197. },
  198. xAxis: {
  199. type: 'category',
  200. data: this.legendCpd
  201. },
  202. yAxis: {
  203. type: 'value'
  204. },
  205. series: [
  206. {
  207. name: '已执行',
  208. type: 'bar',
  209. data: this.hadExecCpd,
  210. label:{
  211. show: true,
  212. },
  213. },
  214. {
  215. name: '未执行',
  216. type: 'bar',
  217. data: this.notExecCpd,
  218. label:{
  219. show: true,
  220. },
  221. },
  222. ]
  223. }
  224. )
  225. },
  226. searchXmTestPlanCaseUserDist(){
  227. var params={ }
  228. if(this.filters.product && this.filters.product.id){
  229. params.productId=this.filters.product.id
  230. }
  231. if(this.filters.project && this.filters.project.id){
  232. params.projectId=this.filters.project.id
  233. }
  234. if(this.filters.iteration && this.filters.iteration.id){
  235. params.linkIterationId=this.filters.iteration.id
  236. }
  237. if(this.filters.testPlan && this.filters.testPlan.id){
  238. params.planId=this.filters.testPlan.id
  239. }
  240. if(this.filters.testCasedb && this.filters.testCasedb.id){
  241. params.casedbId=this.filters.testCasedb.id
  242. }
  243. getXmTestPlanCaseUserDist(params).then(res=>{
  244. this.xmTestPlanCaseUserDists=res.data.data
  245. })
  246. },
  247. onProjectSelected(project){
  248. this.filters.project=project
  249. },
  250. onProjectClear(){
  251. this.filters.project=null
  252. },
  253. onProductSelected(product){
  254. this.filters.product=product
  255. },
  256. onProductClear(){
  257. this.filters.product=null
  258. },
  259. onIterationSelected(iteration){
  260. this.filters.iteration=iteration
  261. },
  262. onIterationClear(){
  263. this.filters.iteration=null
  264. },
  265. onXmTestPlanSelected(xmTestPlan){
  266. this.filters.testPlan=xmTestPlan
  267. },
  268. onXmTestPlanClear(){
  269. this.filters.testPlan=null
  270. },
  271. initData(){
  272. if(this.xmTestPlan){
  273. this.filters.testPlan=this.xmTestPlan
  274. }
  275. },
  276. sizeAutoChange(){
  277. this.myChart.resize();
  278. },
  279. open(){
  280. this.visible=true;
  281. this.filters.testPlan=this.xmTestPlan
  282. this.filters.product=this.xmProduct
  283. this.filters.project=this.xmProject
  284. this.filters.iteration=this.xmIteration
  285. this.filters.testCasedb=this.xmTestCasedb
  286. this.searchXmTestPlanCaseUserDist();
  287. }
  288. },//end method
  289. mounted() {
  290. initSimpleDicts('all',['testPlanTcode'] ).then(res=>{
  291. this.dicts=res.data.data;
  292. })
  293. this.initData();
  294. this.maxTableHeight = util.calcTableMaxHeight(this.$refs.filtersRef.$el)
  295. //this.charts();
  296. this.open();
  297. }//end mounted
  298. }
  299. </script>
  300. <style scoped>
  301. .image {
  302. width: 100%;
  303. display: block;
  304. }
  305. </style>