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.

380 lines
12 KiB

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