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.

379 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
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <section>
  3. <el-row :gutter="5" >
  4. <el-col :span="showParams?23:24">
  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="showParams?1:0" v-if="showParams">
  11. <el-popover trigger="manual" v-model="filterVisible" style="float:right;" width="500">
  12. <el-button slot="reference" style="margin-top:10px;margin-right:10px;z-index: 99999;" icon="el-icon-more" @click="filterVisible=!filterVisible"></el-button>
  13. <el-row>
  14. <el-button type="danger" icon="el-icon-delete" @click="$emit('delete',cfg)">从报告移出该报表</el-button>
  15. <el-button icon="el-icon-close" style="float:right;" @click="filterVisible=false">关闭</el-button>
  16. </el-row>
  17. <el-row>
  18. <el-form :model="params" class="padding" :style="{width:'100%',overflow: 'auto'}" ref="filtersRef">
  19. <el-form-item label="测试库" v-if="xmTestCasedb && xmTestCasedb.id" >
  20. <span >{{xmTestCasedb.id}} <span v-if="xmTestCasedb.name"><br/>{{ xmTestCasedb.name }} </span> </span>
  21. </el-form-item>
  22. <el-form-item label="归属项目" >
  23. <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>
  24. <span v-else>{{xmProject.id}} <span v-if="xmProject.name"><br/>{{ xmProject.name }} </span> </span>
  25. </el-form-item>
  26. <el-form-item label="归属产品" >
  27. <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>
  28. <span v-else>{{xmProductCpd.id}} <span v-if="xmProductCpd.productName"><br/>{{ xmProductCpd.productName }} </span> </span>
  29. </el-form-item>
  30. <el-form-item label="归属迭代" v-if="xmIteration && xmIteration.id">
  31. <span> {{xmIteration.id}}
  32. <span v-if="xmIteration.iterationName"><br/>{{ xmIteration.iterationName }} </span>
  33. </span>
  34. </el-form-item>
  35. <el-form-item label="归属迭代" v-else-if="filters.product && filters.product.id">
  36. <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>
  37. </el-form-item>
  38. <el-form-item label="测试计划" v-if="xmTestPlan && xmTestPlan.id">
  39. <span> {{xmTestPlan.id}}
  40. <span v-if="xmTestPlan.name"><br/>{{ xmTestPlan.name }} </span>
  41. </span>
  42. </el-form-item>
  43. <el-form-item label="测试计划" v-else-if="filters.product && filters.product.id">
  44. <span v-if="filters.testPlan">{{ filters.testPlan.name }}</span>
  45. <el-button v-if="filters.testPlan" type="text" @click="filters.testPlan=null" plain icon="el-icon-circle-close">清除</el-button>
  46. <el-button v-if="!filters.testPlan" type="text" @click="$refs['xmTestPlanSelectRef'].open()" plain>选择计划</el-button>
  47. </el-form-item>
  48. <el-form-item>
  49. <el-button type="primary" style="float:right;" icon="el-icon-search" @click="searchXmTestCaseToPlanCalcList">查询</el-button>
  50. </el-form-item>
  51. </el-form>
  52. </el-row>
  53. </el-popover>
  54. </el-col>
  55. </el-row>
  56. <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 >
  57. </section>
  58. </template>
  59. <script>
  60. import util from '@/common/js/util';//全局公共库
  61. import { initSimpleDicts } from '@/api/mdp/meta/item';//下拉框数据查询
  62. import { mapGetters } from 'vuex'
  63. import { getXmTestCaseToPlanCalcList } from '@/api/xm/core/xmTestPlanCase';
  64. import XmProjectSelect from '@/views/xm/core/components/XmProjectSelect';//项目
  65. import XmProductSelect from '@/views/xm/core/components/XmProductSelect';//产品
  66. import XmIterationSelect from '@/views/xm/core/components/XmIterationSelect';//迭代选择界面
  67. import xmTestPlanSelect from '@/views/xm/core/xmTestPlan/XmTestPlanSelect';//计划选择器
  68. export default {
  69. components: {
  70. XmProjectSelect,XmProductSelect,XmIterationSelect,xmTestPlanSelect,
  71. },
  72. props:['id','cfg','category','showToolBar','showParams','isRptCfg','xmProject','xmProduct','xmIteration','xmTestCasedb','xmTestPlan',],
  73. computed: {
  74. ...mapGetters([
  75. 'userInfo','roles'
  76. ]),
  77. xmTestCaseToPlanCalcListCpd(){
  78. if(!this.xmTestCaseToPlanCalcList || this.xmTestCaseToPlanCalcList.length==0){
  79. return []
  80. }else{
  81. var names=this.legendCpd;
  82. var datas=[]
  83. this.xmTestCaseToPlanCalcList.forEach(i=>{
  84. var nameIndex=0;
  85. if(i.useTimes<=2){
  86. nameIndex=i.useTimes
  87. }else if(i.useTimes>=3 && i.useTimes<=5){
  88. nameIndex=3
  89. }else if(i.useTimes>5 && i.useTimes<=10){
  90. nameIndex=4
  91. }else if(i.useTimes>10){
  92. nameIndex=5
  93. }
  94. var data={name:names[nameIndex],value:i.caseNum}
  95. datas.push(data)
  96. })
  97. return datas;
  98. }
  99. },
  100. total(){
  101. if(!this.xmTestCaseToPlanCalcList || this.xmTestCaseToPlanCalcList.length==0){
  102. return 0
  103. }else{
  104. return this.xmTestCaseToPlanCalcList.reduce((n, i) => {
  105. return (n += i.useTimes);
  106. }, 0)
  107. }
  108. },
  109. titleCpd(){
  110. var preName=""
  111. if(this.filters.testPlan && this.filters.testPlan.id){
  112. preName=`测试计划【${this.filters.testPlan.name}`
  113. }else if(this.filters.testCasedb && this.filters.testCasedb.id){
  114. preName=`测试库【${this.filters.testCasedb.name}`
  115. }else if(this.filters.iteration && this.filters.iteration.id){
  116. preName=`迭代【${this.filters.iteration.iterationName}`
  117. }else if(this.filters.product && this.filters.product.id){
  118. if(this.filters.product.productName){
  119. preName=`产品【${this.filters.product.productName}`
  120. }else{
  121. preName=`产品【${this.filters.product.id}`
  122. }
  123. }else if(this.filters.project && this.filters.project.id){
  124. if(this.filters.project.name){
  125. preName=`项目【${this.filters.project.name}`
  126. }else{
  127. preName=`项目【${this.filters.project.id}`
  128. }
  129. }
  130. return preName+'测试用例规划分析'
  131. },
  132. /**0-未测,1-通过,2-受阻,3-忽略,4-失败 */
  133. legendCpd(){
  134. return ['规划0次','规划1次','规划2次','规划3-5次','规划5-10次','规划10次以上']
  135. },
  136. xmProductCpd(){
  137. if(this.xmTestPlan && this.xmTestPlan.id){
  138. return {id:this.xmTestPlan.productId,productName:this.xmTestPlan.productName}
  139. }
  140. if(this.xmProduct && this.xmProduct.id){
  141. return this.xmProduct
  142. }
  143. return null;
  144. }
  145. },
  146. watch: {
  147. xmTestCaseToPlanCalcListCpd(){
  148. this.drawCharts();
  149. }
  150. },
  151. data() {
  152. return {
  153. filterVisible:false,
  154. filters:{
  155. product:null,
  156. project:null,
  157. testPlan:null,
  158. iteration:null,
  159. testCasedb:null,
  160. },
  161. params:{
  162. },
  163. title:'',//报表配置项
  164. remark:'', //报表配置项
  165. dicts:{testStepTcode:[]},//下拉选择框的所有静态数据 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]}
  166. load:{ list: false, edit: false, del: false, add: false },//查询中...
  167. dateRanger:[],
  168. maxTableHeight:300,
  169. visible:false,
  170. xmTestCaseToPlanCalcList:[],
  171. conditionBtnVisible:false,
  172. }//end return
  173. },//end data
  174. methods: {
  175. formatDict(itemId,val){
  176. var dict=this.dicts[itemId]
  177. if(dict){
  178. var item=dict.find(i=>i.id==val)
  179. if(item){
  180. return item.name
  181. }
  182. }
  183. return val;
  184. },
  185. drawCharts() {
  186. this.myChart = this.$echarts.init(document.getElementById(this.id));
  187. this.myChart.setOption(
  188. {
  189. title: {
  190. text: this.titleCpd,
  191. left: 'center'
  192. },
  193. tooltip: {
  194. trigger: 'item',
  195. },
  196. toolbox: {
  197. show: true,
  198. top:"5%",
  199. right:"10px",
  200. feature: {
  201. dataView: { show: true, readOnly: false },
  202. saveAsImage: { show: true },
  203. }
  204. },
  205. calculable: true,
  206. legend:{
  207. bottom: 'bottom',
  208. data:this.legendCpd,
  209. },
  210. graphic: {
  211. type: 'text',
  212. left: 'center',
  213. top: 'center',
  214. style: {
  215. // text: '总数',
  216. text:
  217. '用例数'+this.total ,
  218. textAlign: 'center',
  219. fill: '#333',
  220. width: 30,
  221. height: 30,
  222. fontSize: 14
  223. }
  224. },
  225. series: [
  226. {
  227. type: 'pie',
  228. radius: ['50%','70%'],
  229. data: this.xmTestCaseToPlanCalcListCpd,
  230. emphasis: {
  231. itemStyle: {
  232. shadowBlur: 10,
  233. shadowOffsetX: 0,
  234. shadowColor: 'rgba(0, 0, 0, 0.5)'
  235. }
  236. },
  237. label: {
  238. show: true,
  239. formatter:'{b}的用例数: {c} ({d}%)'
  240. },
  241. }
  242. ]
  243. }
  244. )
  245. },
  246. onXmQuestionSomeFieldsChange(fieldName,$event){
  247. this.xmTestCaseToPlanCalcList=[]
  248. },
  249. searchXmTestCaseToPlanCalcList(){
  250. var params={...this.params }
  251. getXmTestCaseToPlanCalcList(params).then(res=>{
  252. this.xmTestCaseToPlanCalcList=res.data.data
  253. })
  254. },
  255. onProjectSelected(project){
  256. this.filters.project=project
  257. },
  258. onProjectClear(){
  259. this.filters.project=null
  260. },
  261. onProductSelected(product){
  262. this.filters.product=product
  263. },
  264. onProductClear(){
  265. this.filters.product=null
  266. },
  267. onIterationSelected(iteration){
  268. this.filters.iteration=iteration
  269. },
  270. onIterationClear(){
  271. this.filters.iteration=null
  272. },
  273. onXmTestPlanSelected(xmTestPlan){
  274. this.filters.testPlan=xmTestPlan
  275. },
  276. onXmTestPlanClear(){
  277. this.filters.testPlan=null
  278. },
  279. initData(){
  280. if(this.xmTestPlan){
  281. this.filters.testPlan=this.xmTestPlan
  282. }
  283. },
  284. sizeAutoChange(){
  285. this.myChart.resize();
  286. },
  287. open(){
  288. this.visible=true;
  289. this.filters.testPlan=this.xmTestPlan
  290. this.filters.product=this.xmProduct
  291. this.filters.project=this.xmProject
  292. this.filters.iteration=this.xmIteration
  293. this.filters.testCasedb=this.xmTestCasedb
  294. if( this.filters.testPlan && this.filters.testPlan.id){
  295. this.params.planId= this.filters.testPlan.id
  296. }
  297. if( this.filters.product && this.filters.product.id){
  298. this.params.productId= this.filters.product.id
  299. }
  300. if( this.filters.project && this.filters.project.id){
  301. this.params.projectId= this.filters.project.id
  302. }
  303. if( this.filters.iteration && this.filters.iteration.id){
  304. this.params.iterationId= this.filters.iteration.id
  305. }
  306. if( this.filters.testCasedb && this.filters.testCasedb.id){
  307. this.params.casedbId= this.filters.testCasedb.id
  308. }
  309. if(this.cfg && this.cfg.id){
  310. this.params=this.cfg.params
  311. this.title=this.cfg.title
  312. this.remark=this.cfg.remark
  313. }
  314. if(this.showToolBar && !this.title){
  315. this.title="企业工作项每日趋势图"
  316. }
  317. this.searchXmTestCaseToPlanCalcList();
  318. }
  319. },//end method
  320. mounted() {
  321. initSimpleDicts('all',['testStepTcode'] ).then(res=>{
  322. this.dicts=res.data.data;
  323. })
  324. this.initData();
  325. //this.maxTableHeight = util.calcTableMaxHeight(this.$refs.filtersRef.$el)
  326. //this.charts();
  327. this.open();
  328. }//end mounted
  329. }
  330. </script>
  331. <style scoped>
  332. .image {
  333. width: 100%;
  334. display: block;
  335. }
  336. </style>