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.

295 lines
9.7 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
  1. <template>
  2. <section>
  3. <el-row :gutter="5" >
  4. <el-col :span="18">
  5. <div>
  6. <div class="echart-box" id="testDayTimesCalc"></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" :iterationId="xmTestPlan?xmTestPlan.id:null" @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 label="日期区间">
  42. <br>
  43. <mdp-date-range v-model="filters" value-format="yyyy-MM-dd" start-key="startExecDate" end-key="endExecDate"></mdp-date-range>
  44. </el-form-item>
  45. <el-form-item>
  46. <el-button type="primary" icon="el-icon-search" @click="getXmTestDayTimesList">查询</el-button>
  47. </el-form-item>
  48. </el-form>
  49. </el-col>
  50. </el-row>
  51. <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 >
  52. </section>
  53. </template>
  54. <script>
  55. import util from '@/common/js/util';//全局公共库
  56. import { initSimpleDicts } from '@/api/mdp/meta/item';//下拉框数据查询
  57. import { mapGetters } from 'vuex'
  58. import { getXmTestDayTimesList } from '@/api/xm/core/xmTestPlanCase';
  59. import XmProjectSelect from '@/views/xm/core/components/XmProjectSelect';//项目
  60. import XmProductSelect from '@/views/xm/core/components/XmProductSelect';//产品
  61. import XmIterationSelect from '@/views/xm/core/components/XmIterationSelect';//迭代选择界面
  62. import xmTestPlanSelect from '@/views/xm/core/xmTestPlan/XmTestPlanSelect';//计划选择器
  63. export default {
  64. components: {
  65. XmProjectSelect,XmProductSelect,XmIterationSelect,xmTestPlanSelect,
  66. },
  67. props:['xmProject','xmProduct','xmIteration','xmTestCasedb','xmTestPlan'],
  68. computed: {
  69. ...mapGetters([
  70. 'userInfo','roles'
  71. ]),
  72. datesCpd(){
  73. if(!this.xmTestDayTimesList || this.xmTestDayTimesList.length==0){
  74. return []
  75. }else{
  76. return this.xmTestDayTimesList.map(i=>i.execDate)
  77. }
  78. },
  79. testDayTimesCpd(){
  80. if(!this.xmTestDayTimesList || this.xmTestDayTimesList.length==0){
  81. return []
  82. }else{
  83. return this.xmTestDayTimesList.map(i=>i.hadExec)
  84. }
  85. },
  86. title(){
  87. var preName=""
  88. if(this.filters.testPlan && this.filters.testPlan.id){
  89. preName=`测试计划【${this.filters.testPlan.name}`
  90. }else if(this.filters.testCasedb && this.filters.testCasedb.id){
  91. preName=`测试库【${this.filters.testCasedb.name}`
  92. }else if(this.filters.iteration && this.filters.iteration.id){
  93. preName=`迭代【${this.filters.iteration.iterationName}`
  94. }else if(this.filters.project && this.filters.project.id){
  95. if(this.filters.project.name){
  96. preName=`项目【${this.filters.project.name}`
  97. }else{
  98. preName=`项目【${this.filters.project.id}`
  99. }
  100. }else if(this.filters.product && this.filters.product.id){
  101. if(this.filters.product.productName){
  102. preName=`产品【${this.filters.product.productName}`
  103. }else{
  104. preName=`产品【${this.filters.product.id}`
  105. }
  106. }
  107. return preName+ "测试用例每日执行次数统计"
  108. },
  109. xmProductCpd(){
  110. if(this.xmProduct && this.xmProduct.id){
  111. return this.xmProduct
  112. }
  113. return null;
  114. }
  115. },
  116. watch: {
  117. datesCpd(){
  118. this.$nextTick(()=>{
  119. this.drawCharts();
  120. })
  121. }
  122. },
  123. data() {
  124. return {
  125. filters:{
  126. category:'',
  127. product:null,
  128. project:null,
  129. testPlan:null,
  130. iteration:null,
  131. testCasedb:null,
  132. },
  133. dicts:{},//下拉选择框的所有静态数据 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]}
  134. load:{ list: false, edit: false, del: false, add: false },//查询中...
  135. dateRanger:[],
  136. maxTableHeight:300,
  137. visible:false,
  138. xmTestDayTimesList:[],
  139. }//end return
  140. },//end data
  141. methods: {
  142. getXmTestDayTimesList(){
  143. var params={ }
  144. if(this.filters.product && this.filters.product.id){
  145. params.productId=this.filters.product.id
  146. }
  147. if(this.filters.project && this.filters.project.id){
  148. params.projectId=this.filters.project.id
  149. }
  150. if(this.filters.iteration && this.filters.iteration.id){
  151. params.linkIterationId=this.filters.iteration.id
  152. }
  153. if(this.filters.testPlan && this.filters.testPlan.id){
  154. params.planId=this.filters.testPlan.id
  155. }
  156. if(this.filters.testCasedb && this.filters.testCasedb.id){
  157. params.casedbId=this.filters.testCasedb.id
  158. }
  159. getXmTestDayTimesList(params).then(res=>{
  160. this.xmTestDayTimesList=res.data.tips.isOk?res.data.data:this.xmTestDayTimesList;
  161. })
  162. },
  163. open(){
  164. this.visible=true;
  165. this.filters.testPlan=this.xmTestPlan
  166. this.filters.product=this.xmProduct
  167. this.filters.project=this.xmProject
  168. this.filters.iteration=this.xmIteration
  169. this.filters.testCasedb=this.xmTestCasedb
  170. if(this.$refs['xmProductSelect'])this.$refs['xmProductSelect'].clearSelect();
  171. this.$nextTick(()=>{
  172. this.getXmTestDayTimesList();
  173. })
  174. },
  175. drawCharts() {
  176. this.myChart = this.$echarts.init(document.getElementById("testDayTimesCalc"));
  177. this.myChart.setOption(
  178. {
  179. title: {
  180. text: this.title,
  181. left: 'center'
  182. },
  183. tooltip: {
  184. trigger: 'axis',
  185. },
  186. barMaxWidth: 100,
  187. toolbox: {
  188. show: true,
  189. top:"5%",
  190. right:"10px",
  191. feature: {
  192. dataView: { show: true, readOnly: false },
  193. magicType: { show: true, type: ['line', 'bar'] },
  194. saveAsImage: { show: true }
  195. }
  196. },
  197. calculable: true,
  198. xAxis: {
  199. type: 'category',
  200. data: this.datesCpd
  201. },
  202. yAxis: {
  203. type: 'value'
  204. },
  205. series: [
  206. {
  207. name:'次数',
  208. data: this.testDayTimesCpd,
  209. type: 'line',
  210. label:{
  211. show: true,
  212. },
  213. smooth: true,
  214. }
  215. ]
  216. }
  217. )
  218. },
  219. onProjectSelected(project){
  220. this.filters.project=project
  221. },
  222. onProjectClear(){
  223. this.filters.project=null
  224. },
  225. onProductSelected(product){
  226. this.filters.product=product
  227. },
  228. onProductClear(){
  229. this.filters.product=null
  230. },
  231. onIterationSelected(iteration){
  232. this.filters.iteration=iteration
  233. },
  234. onIterationClear(){
  235. this.filters.iteration=null
  236. },
  237. onXmTestPlanSelected(xmTestPlan){
  238. this.filters.testPlan=xmTestPlan
  239. },
  240. onXmTestPlanClear(){
  241. this.filters.testPlan=null
  242. },
  243. },//end method
  244. mounted() {
  245. /**
  246. initSimpleDicts('all',['demandSource','demandLvl','demandType','priority','menuStatus'] ).then(res=>{
  247. this.dicts=res.data.data;
  248. })
  249. */
  250. this.maxTableHeight = util.calcTableMaxHeight(this.$refs.filtersRef.$el)
  251. //this.charts();
  252. this.open();
  253. }//end mounted
  254. }
  255. </script>
  256. <style scoped>
  257. .image {
  258. width: 100%;
  259. display: block;
  260. }
  261. </style>