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
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="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:['id','cfg','category','showToolBar','showParams','isRptCfg','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. titleCpd(){
  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. params:{
  152. },
  153. title:'',//报表配置项
  154. remark:'', //报表配置项
  155. dicts:{testPlanTcode:[]},//下拉选择框的所有静态数据 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]}
  156. load:{ list: false, edit: false, del: false, add: false },//查询中...
  157. dateRanger:[],
  158. maxTableHeight:300,
  159. visible:false,
  160. xmTestPlanCaseUserDists:[],
  161. conditionBtnVisible:false,
  162. }//end return
  163. },//end data
  164. methods: {
  165. formatDict(itemId,val){
  166. var dict=this.dicts[itemId]
  167. if(dict){
  168. var item=dict.find(i=>i.id==val)
  169. if(item){
  170. return item.name
  171. }
  172. }
  173. return val;
  174. },
  175. drawCharts() {
  176. this.myChart = this.$echarts.init(document.getElementById(this.id));
  177. this.myChart.setOption(
  178. {
  179. title: {
  180. text: this.titleCpd,
  181. left: 'center'
  182. },
  183. tooltip: {
  184. trigger: 'item',
  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. legend: {
  199. bottom: 'bottom',
  200. data: ['已执行', '未执行']
  201. },
  202. xAxis: {
  203. type: 'category',
  204. data: this.legendCpd
  205. },
  206. yAxis: {
  207. type: 'value'
  208. },
  209. series: [
  210. {
  211. name: '已执行',
  212. type: 'bar',
  213. data: this.hadExecCpd,
  214. label:{
  215. show: true,
  216. },
  217. },
  218. {
  219. name: '未执行',
  220. type: 'bar',
  221. data: this.notExecCpd,
  222. label:{
  223. show: true,
  224. },
  225. },
  226. ]
  227. }
  228. )
  229. },
  230. searchXmTestPlanCaseUserDist(){
  231. var params={ }
  232. if(this.filters.product && this.filters.product.id){
  233. params.productId=this.filters.product.id
  234. }
  235. if(this.filters.project && this.filters.project.id){
  236. params.projectId=this.filters.project.id
  237. }
  238. if(this.filters.iteration && this.filters.iteration.id){
  239. params.linkIterationId=this.filters.iteration.id
  240. }
  241. if(this.filters.testPlan && this.filters.testPlan.id){
  242. params.planId=this.filters.testPlan.id
  243. }
  244. if(this.filters.testCasedb && this.filters.testCasedb.id){
  245. params.casedbId=this.filters.testCasedb.id
  246. }
  247. getXmTestPlanCaseUserDist(params).then(res=>{
  248. this.xmTestPlanCaseUserDists=res.data.data
  249. })
  250. },
  251. onProjectSelected(project){
  252. this.filters.project=project
  253. },
  254. onProjectClear(){
  255. this.filters.project=null
  256. },
  257. onProductSelected(product){
  258. this.filters.product=product
  259. },
  260. onProductClear(){
  261. this.filters.product=null
  262. },
  263. onIterationSelected(iteration){
  264. this.filters.iteration=iteration
  265. },
  266. onIterationClear(){
  267. this.filters.iteration=null
  268. },
  269. onXmTestPlanSelected(xmTestPlan){
  270. this.filters.testPlan=xmTestPlan
  271. },
  272. onXmTestPlanClear(){
  273. this.filters.testPlan=null
  274. },
  275. initData(){
  276. if(this.xmTestPlan){
  277. this.filters.testPlan=this.xmTestPlan
  278. }
  279. },
  280. sizeAutoChange(){
  281. this.myChart.resize();
  282. },
  283. open(){
  284. this.visible=true;
  285. this.filters.testPlan=this.xmTestPlan
  286. this.filters.product=this.xmProduct
  287. this.filters.project=this.xmProject
  288. this.filters.iteration=this.xmIteration
  289. this.filters.testCasedb=this.xmTestCasedb
  290. if( this.filters.testPlan && this.filters.testPlan.id){
  291. this.params.planId= this.filters.testPlan.id
  292. }
  293. if( this.filters.product && this.filters.product.id){
  294. this.params.productId= this.filters.product.id
  295. }
  296. if( this.filters.project && this.filters.project.id){
  297. this.params.projectId= this.filters.project.id
  298. }
  299. if( this.filters.iteration && this.filters.iteration.id){
  300. this.params.iterationId= this.filters.iteration.id
  301. }
  302. if( this.filters.testCasedb && this.filters.testCasedb.id){
  303. this.params.casedbId= this.filters.testCasedb.id
  304. }
  305. if(this.cfg && this.cfg.id){
  306. this.params=this.cfg.params
  307. this.title=this.cfg.title
  308. this.remark=this.cfg.remark
  309. }
  310. if(this.showToolBar && !this.title){
  311. this.title="企业工作项每日趋势图"
  312. }
  313. this.searchXmTestPlanCaseUserDist();
  314. }
  315. },//end method
  316. mounted() {
  317. initSimpleDicts('all',['testPlanTcode'] ).then(res=>{
  318. this.dicts=res.data.data;
  319. })
  320. this.initData();
  321. this.maxTableHeight = util.calcTableMaxHeight(this.$refs.filtersRef.$el)
  322. //this.charts();
  323. this.open();
  324. }//end mounted
  325. }
  326. </script>
  327. <style scoped>
  328. .image {
  329. width: 100%;
  330. display: block;
  331. }
  332. </style>