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.

377 lines
12 KiB

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
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
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 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
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
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
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
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
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
2 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
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
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
3 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
2 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
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
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 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>
  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 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>
  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 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>
  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 { getXmTestPlanCaseUserDist } 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. hadExecCpd(){
  84. if(!this.rawDatas ||this.rawDatas.length==0){
  85. return []
  86. }else{
  87. return this.rawDatas.map(i=>i.hadExec)
  88. }
  89. },
  90. notExecCpd(){
  91. if(!this.rawDatas ||this.rawDatas.length==0){
  92. return []
  93. }else{
  94. return this.rawDatas.map(i=>i.notExec)
  95. }
  96. },
  97. legendCpd(){
  98. if(!this.rawDatas ||this.rawDatas.length==0){
  99. return []
  100. }else{
  101. return this.rawDatas.map(i=>i.execUsername)
  102. }
  103. },
  104. rawDatasCpd(){
  105. if(!this.rawDatas || this.rawDatas.length==0){
  106. return []
  107. }else{
  108. var datas=[]
  109. this.rawDatas.forEach(i=>{
  110. var data={}
  111. var itemId="testPlanTcode";
  112. data.name=this.formatDict(itemId,i.execStatus)
  113. data.value=i.totalCnt
  114. datas.push(data)
  115. })
  116. return datas;
  117. }
  118. },
  119. titleCpd(){
  120. var preName=""
  121. if(this.filters.testPlan && this.filters.testPlan.id){
  122. preName=`测试计划【${this.filters.testPlan.name}`
  123. }else if(this.filters.testCasedb && this.filters.testCasedb.id){
  124. preName=`测试库【${this.filters.testCasedb.name}`
  125. }else if(this.filters.iteration && this.filters.iteration.id){
  126. preName=`迭代【${this.filters.iteration.iterationName}`
  127. }else if(this.filters.product && this.filters.product.id){
  128. if(this.filters.product.productName){
  129. preName=`产品【${this.filters.product.productName}`
  130. }else{
  131. preName=`产品【${this.filters.product.id}`
  132. }
  133. }else if(this.filters.project && this.filters.project.id){
  134. if(this.filters.project.name){
  135. preName=`项目【${this.filters.project.name}`
  136. }else{
  137. preName=`项目【${this.filters.project.id}`
  138. }
  139. }
  140. return preName+ '测试用例执行结果数量分布'
  141. },
  142. xmProductCpd(){
  143. if(this.xmTestPlan && this.xmTestPlan.id){
  144. return {id:this.xmTestPlan.productId,productName:this.xmTestPlan.productName}
  145. }
  146. if(this.xmProduct && this.xmProduct.id){
  147. return this.xmProduct
  148. }
  149. return null;
  150. }
  151. },
  152. watch: {
  153. rawDatasCpd(){
  154. this.drawCharts();
  155. }
  156. },
  157. data() {
  158. return {
  159. filterVisible:false,
  160. filters:{
  161. product:null,
  162. project:null,
  163. testPlan:null,
  164. iteration:null,
  165. testCasedb:null,
  166. },
  167. params:{
  168. },
  169. title:'',//报表配置项
  170. remark:'', //报表配置项
  171. dicts:{testPlanTcode:[]},//下拉选择框的所有静态数据 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]}
  172. load:{ list: false, edit: false, del: false, add: false },//查询中...
  173. dateRanger:[],
  174. maxTableHeight:300,
  175. visible:false,
  176. rawDatas:[],
  177. conditionBtnVisible:false,
  178. }//end return
  179. },//end data
  180. methods: {
  181. formatDict(itemId,val){
  182. var dict=this.dicts[itemId]
  183. if(dict){
  184. var item=dict.find(i=>i.id==val)
  185. if(item){
  186. return item.name
  187. }
  188. }
  189. return val;
  190. },
  191. drawCharts() {
  192. this.myChart = this.$echarts.init(document.getElementById(this.id));
  193. this.myChart.setOption(
  194. {
  195. title: {
  196. text: this.titleCpd,
  197. left: 'center'
  198. },
  199. tooltip: {
  200. trigger: 'item',
  201. },
  202. barMaxWidth: 100,
  203. toolbox: {
  204. show: true,
  205. top:"5%",
  206. right:"10px",
  207. feature: {
  208. dataView: { show: true, readOnly: false },
  209. magicType: { show: true, type: ['line', 'bar'] },
  210. saveAsImage: { show: true }
  211. }
  212. },
  213. calculable: true,
  214. legend: {
  215. bottom: 'bottom',
  216. data: ['已执行', '未执行']
  217. },
  218. xAxis: {
  219. type: 'category',
  220. data: this.legendCpd
  221. },
  222. yAxis: {
  223. type: 'value'
  224. },
  225. series: [
  226. {
  227. name: '已执行',
  228. type: 'bar',
  229. data: this.hadExecCpd,
  230. label:{
  231. show: true,
  232. },
  233. },
  234. {
  235. name: '未执行',
  236. type: 'bar',
  237. data: this.notExecCpd,
  238. label:{
  239. show: true,
  240. },
  241. },
  242. ]
  243. }
  244. )
  245. },
  246. searchXmTestPlanCaseUserDist(){
  247. if(this.rptDatas){
  248. this.rawDatas=this.rptDatas
  249. return;
  250. }
  251. var params={...this.params }
  252. getXmTestPlanCaseUserDist(params).then(res=>{
  253. this.rawDatas=res.data.data
  254. })
  255. },
  256. onProjectSelected(project){
  257. this.filters.project=project
  258. },
  259. onProjectClear(){
  260. this.filters.project=null
  261. },
  262. onProductSelected(product){
  263. this.filters.product=product
  264. },
  265. onProductClear(){
  266. this.filters.product=null
  267. },
  268. onIterationSelected(iteration){
  269. this.filters.iteration=iteration
  270. },
  271. onIterationClear(){
  272. this.filters.iteration=null
  273. },
  274. onXmTestPlanSelected(xmTestPlan){
  275. this.filters.testPlan=xmTestPlan
  276. },
  277. onXmTestPlanClear(){
  278. this.filters.testPlan=null
  279. },
  280. initData(){
  281. if(this.xmTestPlan){
  282. this.filters.testPlan=this.xmTestPlan
  283. }
  284. },
  285. sizeAutoChange(){
  286. this.myChart.resize();
  287. },
  288. open(){
  289. this.visible=true;
  290. this.filters.testPlan=this.xmTestPlan
  291. this.filters.product=this.xmProduct
  292. this.filters.project=this.xmProject
  293. this.filters.iteration=this.xmIteration
  294. this.filters.testCasedb=this.xmTestCasedb
  295. if( this.filters.testPlan && this.filters.testPlan.id){
  296. this.params.planId= this.filters.testPlan.id
  297. }
  298. if( this.filters.product && this.filters.product.id){
  299. this.params.productId= this.filters.product.id
  300. }
  301. if( this.filters.project && this.filters.project.id){
  302. this.params.projectId= this.filters.project.id
  303. }
  304. if( this.filters.iteration && this.filters.iteration.id){
  305. this.params.iterationId= this.filters.iteration.id
  306. }
  307. if( this.filters.testCasedb && this.filters.testCasedb.id){
  308. this.params.casedbId= this.filters.testCasedb.id
  309. }
  310. if(this.cfg && this.cfg.id){
  311. this.params=this.cfg.params
  312. this.title=this.cfg.title
  313. this.remark=this.cfg.remark
  314. }
  315. if(this.showToolBar && !this.title){
  316. this.title="企业工作项每日趋势图"
  317. }
  318. this.searchXmTestPlanCaseUserDist();
  319. }
  320. },//end method
  321. mounted() {
  322. this.initData();
  323. this.$mdp.ajaxGetDictOptions('testPlanTcode').then(res=>{
  324. this.dicts['testPlanTcode']=res.data.options
  325. })
  326. this.open();
  327. }//end mounted
  328. }
  329. </script>
  330. <style scoped>
  331. .image {
  332. width: 100%;
  333. display: block;
  334. }
  335. </style>