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.

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