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.

352 lines
10 KiB

4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
  1. <template>
  2. <section>
  3. <el-row :gutter="5" >
  4. <el-col :span="18">
  5. <div>
  6. <div class="echart-box" id="xmTaskAttDist"></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="分组属性">
  13. <el-select v-model="groupBy" @change="onXmTaskSomeFieldsChange('groupBy',$event)" clearable>
  14. <el-option v-for="i in this.groupBys" :label="i.name" :key="i.id" :value="i.id"></el-option>
  15. </el-select>
  16. </el-form-item>
  17. <el-form-item label="归属项目" >
  18. <xm-project-select v-if="!xmProject || !xmProject.id" ref="xmProjectSelect" style="display:inline;" :auto-select="false" :link-project-id="xmProject?xmProject.id:null" @row-click="onProjectSelected" @clear="onProjectClear"></xm-project-select>
  19. <span v-else>{{xmProject.id}} <span v-if="xmProject.name"><br/>{{ xmProject.name }} </span> </span>
  20. </el-form-item>
  21. <el-form-item label="任务状态" prop="taskState">
  22. <el-select v-model="filters.taskState" @change="onXmTaskSomeFieldsChange('taskState',$event)" clearable>
  23. <el-option v-for="i in this.dicts.taskState" :label="i.name" :key="i.id" :value="i.id"></el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item label="任务类型" prop="taskType" >
  27. <el-select v-model="filters.taskType" @change="onXmTaskSomeFieldsChange('taskType',$event)" clearable>
  28. <el-option v-for="i in this.dicts.taskType" :label="i.name" :key="i.id" :value="i.id"></el-option>
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item label="计划类型" prop="planType">
  32. <el-select v-model="filters.planType" @change="onXmTaskSomeFieldsChange('planType',$event)" clearable>
  33. <el-option v-for="i in this.dicts.planType" :label="i.name" :key="i.id" :value="i.id"></el-option>
  34. </el-select>
  35. </el-form-item>
  36. <el-form-item label="结算方案" prop="settleSchemel" >
  37. <el-select v-model="filters.settleSchemel" @change="onXmTaskSomeFieldsChange('settleSchemel',$event)" clearable>
  38. <el-option v-for="i in this.dicts.xmTaskSettleSchemel" :label="i.name" :key="i.id" :value="i.id"></el-option>
  39. </el-select>
  40. </el-form-item>
  41. <el-form-item label="优先级" prop="priority" >
  42. <el-select v-model="filters.priority" @change="onXmTaskSomeFieldsChange('priority',$event)" clearable>
  43. <el-option v-for="i in dicts.priority" :label="i.name" :key="i.id" :value="i.id"></el-option>
  44. </el-select>
  45. </el-form-item>
  46. <el-form-item>
  47. <el-button type="primary" icon="el-icon-search" @click="searchXmTaskAttDist">查询</el-button>
  48. </el-form-item>
  49. </el-form>
  50. </el-col>
  51. </el-row>
  52. </section>
  53. </template>
  54. <script>
  55. import util from '@/common/js/util';//全局公共库
  56. import { initSimpleDicts } from '@/api/mdp/meta/item';//下拉框数据查询
  57. import { mapGetters } from 'vuex'
  58. import { getXmTaskAttDist } from '@/api/xm/core/xmTask';
  59. import XmProjectSelect from '@/views/xm/core/components/XmProjectSelect';//新增界面
  60. export default {
  61. components: {
  62. XmProjectSelect,
  63. },
  64. props:['id','xmProduct','xmIteration','xmProject'],
  65. computed: {
  66. ...mapGetters([
  67. 'userInfo','roles'
  68. ]),
  69. xmTaskAttDistsCpd(){
  70. if(this.xmTaskAttDists.length==0){
  71. return []
  72. }else{
  73. var itemId="";
  74. if(this.groupBy=='task_state'){
  75. itemId="taskState"
  76. }else if(this.groupBy=='settle_schemel'){
  77. itemId="xmTaskSettleSchemel"
  78. }else if(this.groupBy=='task_type'){
  79. itemId="taskType"
  80. }else if(this.groupBy=='priority'){
  81. itemId="priority"
  82. }else if(this.groupBy=='plan_type'){
  83. itemId="planType"
  84. }
  85. return this.xmTaskAttDists.map(i=>{
  86. var data={...i}
  87. data.name=this.formatDict(itemId,data.name)
  88. return data;
  89. })
  90. }
  91. },
  92. total(){
  93. if(!this.xmTaskAttDists || this.xmTaskAttDists.length==0){
  94. return 0
  95. }else{
  96. return this.xmTaskAttDists.reduce((n, i) => {
  97. return (n += i.value);
  98. }, 0)
  99. }
  100. },
  101. titleCpd(){
  102. var preName=""
  103. if(this.filters.testPlan && this.filters.testPlan.id){
  104. preName=`测试计划【${this.filters.testPlan.name}`
  105. }else if(this.filters.testCasedb && this.filters.testCasedb.id){
  106. preName=`测试库【${this.filters.testCasedb.name}`
  107. }else if(this.filters.iteration && this.filters.iteration.id){
  108. preName=`迭代【${this.filters.iteration.iterationName}`
  109. }else if(this.filters.project && this.filters.project.id){
  110. if(this.filters.project.name){
  111. preName=`项目【${this.filters.project.name}`
  112. }else{
  113. preName=`项目【${this.filters.project.id}`
  114. }
  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. }
  122. return preName+this.groupBys.find(i=>i.id==this.groupBy).name+'数量分布'
  123. },
  124. legendCpd(){
  125. var itemId="";
  126. if(this.groupBy=='task_state'){
  127. itemId="taskState"
  128. }else if(this.groupBy=='settle_schemel'){
  129. itemId="xmTaskSettleSchemel"
  130. }else if(this.groupBy=='task_type'){
  131. itemId="taskType"
  132. }else if(this.groupBy=='priority'){
  133. itemId="priority"
  134. }else if(this.groupBy=='plan_type'){
  135. itemId="planType"
  136. }
  137. return this.dicts[itemId].map(i=>i.name)
  138. }
  139. },
  140. watch: {
  141. xmTaskAttDistsCpd(){
  142. this.drawCharts();
  143. }
  144. },
  145. data() {
  146. return {
  147. filters:{
  148. product:null,
  149. project:null,
  150. testPlan:null,
  151. iteration:null,
  152. testCasedb:null,
  153. },
  154. groupBy:'task_state',
  155. groupBys:[
  156. {id:'task_state', name:'任务状态'},
  157. {id:'task_type', name:'任务类型'},
  158. {id:'plan_type', name:'计划类型'},
  159. {id:'settle_schemel', name:'结算方案'},
  160. {id:'priority', name:'优先级'}
  161. ],
  162. dicts:{},//下拉选择框的所有静态数据 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]}
  163. load:{ list: false, edit: false, del: false, add: false },//查询中...
  164. dateRanger:[],
  165. maxTableHeight:300,
  166. visible:false,
  167. xmTaskAttDists:[],
  168. }//end return
  169. },//end data
  170. methods: {
  171. formatDict(itemId,val){
  172. var dict=this.dicts[itemId]
  173. if(dict){
  174. var item=dict.find(i=>i.id==val)
  175. if(item){
  176. return item.name
  177. }
  178. }
  179. return val;
  180. },
  181. findMax( list ) {
  182. var i, max = list[0];
  183. if(list.length < 2) return max;
  184. for (i = 0; i < list.length; i++) {
  185. if (list[i].distBudgetWorkload > max.distBudgetWorkload) {
  186. max = list[i];
  187. }
  188. }
  189. return max;
  190. },
  191. open(){
  192. this.visible=true;
  193. this.filters.product=this.xmProduct
  194. this.filters.project=this.xmProject
  195. this.filters.iteration=this.xmIteration
  196. this.searchXmTaskAttDist()
  197. },
  198. drawCharts() {
  199. this.myChart = this.$echarts.init(document.getElementById("xmTaskAttDist"));
  200. this.myChart.setOption(
  201. {
  202. title: {
  203. text: this.titleCpd,
  204. left: 'center'
  205. },
  206. tooltip: {
  207. trigger: 'item',
  208. },
  209. toolbox: {
  210. show: true,
  211. top:"5%",
  212. right:"10px",
  213. feature: {
  214. dataView: { show: true, readOnly: false },
  215. saveAsImage: { show: true },
  216. }
  217. },
  218. calculable: true,
  219. legend:{
  220. bottom: 'bottom',
  221. data:this.legendCpd,
  222. },
  223. graphic: {
  224. type: 'text',
  225. left: 'center',
  226. top: 'center',
  227. style: {
  228. // text: '总数',
  229. text:
  230. '任务数'+this.total ,
  231. textAlign: 'center',
  232. fill: '#333',
  233. width: 30,
  234. height: 30,
  235. fontSize: 14
  236. }
  237. },
  238. series: [
  239. {
  240. type: 'pie',
  241. radius: ['50%','70%'],
  242. data: this.xmTaskAttDistsCpd,
  243. emphasis: {
  244. itemStyle: {
  245. shadowBlur: 10,
  246. shadowOffsetX: 0,
  247. shadowColor: 'rgba(0, 0, 0, 0.5)'
  248. }
  249. },
  250. label: {
  251. show: true,
  252. formatter:'{b}: {c}  ({d}%)'
  253. },
  254. }
  255. ]
  256. }
  257. )
  258. },
  259. onXmTaskSomeFieldsChange(fieldName,$event){
  260. this.xmTaskAttDists=[]
  261. },
  262. searchXmTaskAttDist(){
  263. if(!this.groupBy){
  264. this.$notify({position:'bottom-left',showClose:true,message:'请选中分组属性',type:'warning'})
  265. return
  266. }
  267. var params={}
  268. if(this.filters.taskType){
  269. params.taskType=this.filters.taskType
  270. }
  271. if(this.filters.taskState){
  272. params.taskState=this.filters.taskState
  273. }
  274. if(this.filters.planType){
  275. params.planType=this.filters.planType
  276. }
  277. if(this.filters.settleSchemel){
  278. params.settleSchemel=this.filters.settleSchemel
  279. }
  280. if(this.filters.priority){
  281. params.priority=this.filters.priority
  282. }
  283. params.groupBy=this.groupBy
  284. if(this.filters.project){
  285. params.projectId=this.filters.project.id
  286. }
  287. if(this.filters.iteration){
  288. params.iterationId=this.filters.iteration.id
  289. }
  290. params.ntype='0'
  291. getXmTaskAttDist(params).then(res=>{
  292. this.xmTaskAttDists=res.data.data
  293. })
  294. },
  295. onProjectSelected(project){
  296. this.filters.project=project
  297. },
  298. onProjectClear(){
  299. this.filters.project=null
  300. },
  301. onIterationSelected(iteration){
  302. this.filters.iteration=iteration
  303. },
  304. onIterationClear(){
  305. this.filters.iteration=null
  306. }
  307. },//end method
  308. mounted() {
  309. initSimpleDicts('all',['planType','xmTaskSettleSchemel','taskType','priority','taskState'] ).then(res=>{
  310. this.dicts=res.data.data;
  311. })
  312. this.maxTableHeight = util.calcTableMaxHeight(this.$refs.filtersRef.$el)
  313. //this.charts();
  314. this.open();
  315. }//end mounted
  316. }
  317. </script>
  318. <style scoped>
  319. .image {
  320. width: 100%;
  321. display: block;
  322. }
  323. </style>