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.

365 lines
11 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
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
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
3 years ago
3 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
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="this.id"></div>
  7. <div class="progress"></div>
  8. </div>
  9. </el-col>
  10. <el-col :span="6" class="border">
  11. <el-form :model="params" 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="params.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="params.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="params.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="params.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="params.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','cfg','category','showToolBar','showParams','isRptCfg','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. params:{
  155. },
  156. title:'',//报表配置项
  157. remark:'', //报表配置项
  158. groupBy:'task_state',
  159. groupBys:[
  160. {id:'task_state', name:'任务状态'},
  161. {id:'task_type', name:'任务类型'},
  162. {id:'plan_type', name:'计划类型'},
  163. {id:'settle_schemel', name:'结算方案'},
  164. {id:'priority', name:'优先级'}
  165. ],
  166. dicts:{},//下拉选择框的所有静态数据 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]}
  167. load:{ list: false, edit: false, del: false, add: false },//查询中...
  168. dateRanger:[],
  169. maxTableHeight:300,
  170. visible:false,
  171. xmTaskAttDists:[],
  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. findMax( list ) {
  186. var i, max = list[0];
  187. if(list.length < 2) return max;
  188. for (i = 0; i < list.length; i++) {
  189. if (list[i].distBudgetWorkload > max.distBudgetWorkload) {
  190. max = list[i];
  191. }
  192. }
  193. return max;
  194. },
  195. open(){
  196. this.visible=true;
  197. this.filters.testPlan=this.xmTestPlan
  198. this.filters.product=this.xmProduct
  199. this.filters.project=this.xmProject
  200. this.filters.iteration=this.xmIteration
  201. this.filters.testCasedb=this.xmTestCasedb
  202. if( this.filters.testPlan && this.filters.testPlan.id){
  203. this.params.planId= this.filters.testPlan.id
  204. }
  205. if( this.filters.product && this.filters.product.id){
  206. this.params.productId= this.filters.product.id
  207. }
  208. if( this.filters.project && this.filters.project.id){
  209. this.params.projectId= this.filters.project.id
  210. }
  211. if( this.filters.iteration && this.filters.iteration.id){
  212. this.params.iterationId= this.filters.iteration.id
  213. }
  214. if( this.filters.testCasedb && this.filters.testCasedb.id){
  215. this.params.casedbId= this.filters.testCasedb.id
  216. }
  217. if(this.cfg && this.cfg.id){
  218. this.params=this.cfg.params
  219. this.title=this.cfg.title
  220. this.remark=this.cfg.remark
  221. }
  222. if(this.showToolBar && !this.title){
  223. this.title="企业工作项每日趋势图"
  224. }
  225. this.searchXmTaskAttDist()
  226. },
  227. drawCharts() {
  228. this.myChart = this.$echarts.init(document.getElementById(this.id));
  229. this.myChart.setOption(
  230. {
  231. title: {
  232. text: this.titleCpd,
  233. left: 'center'
  234. },
  235. tooltip: {
  236. trigger: 'item',
  237. },
  238. toolbox: {
  239. show: true,
  240. top:"5%",
  241. right:"10px",
  242. feature: {
  243. dataView: { show: true, readOnly: false },
  244. saveAsImage: { show: true },
  245. }
  246. },
  247. calculable: true,
  248. legend:{
  249. bottom: 'bottom',
  250. data:this.legendCpd,
  251. },
  252. graphic: {
  253. type: 'text',
  254. left: 'center',
  255. top: 'center',
  256. style: {
  257. // text: '总数',
  258. text:
  259. '任务数'+this.total ,
  260. textAlign: 'center',
  261. fill: '#333',
  262. width: 30,
  263. height: 30,
  264. fontSize: 14
  265. }
  266. },
  267. series: [
  268. {
  269. type: 'pie',
  270. radius: ['50%','70%'],
  271. data: this.xmTaskAttDistsCpd,
  272. emphasis: {
  273. itemStyle: {
  274. shadowBlur: 10,
  275. shadowOffsetX: 0,
  276. shadowColor: 'rgba(0, 0, 0, 0.5)'
  277. }
  278. },
  279. label: {
  280. show: true,
  281. formatter:'{b}: {c}  ({d}%)'
  282. },
  283. }
  284. ]
  285. }
  286. )
  287. },
  288. onXmTaskSomeFieldsChange(fieldName,$event){
  289. this.xmTaskAttDists=[]
  290. },
  291. searchXmTaskAttDist(){
  292. if(!this.groupBy){
  293. this.$notify({position:'bottom-left',showClose:true,message:'请选中分组属性',type:'warning'})
  294. return
  295. }
  296. var params={...this.params}
  297. params.ntype='0'
  298. getXmTaskAttDist(params).then(res=>{
  299. this.xmTaskAttDists=res.data.data
  300. })
  301. },
  302. onProjectSelected(project){
  303. this.filters.project=project
  304. },
  305. onProjectClear(){
  306. this.filters.project=null
  307. },
  308. onIterationSelected(iteration){
  309. this.filters.iteration=iteration
  310. },
  311. onIterationClear(){
  312. this.filters.iteration=null
  313. }
  314. },//end method
  315. mounted() {
  316. initSimpleDicts('all',['planType','xmTaskSettleSchemel','taskType','priority','taskState'] ).then(res=>{
  317. this.dicts=res.data.data;
  318. })
  319. this.maxTableHeight = util.calcTableMaxHeight(this.$refs.filtersRef.$el)
  320. //this.charts();
  321. this.open();
  322. }//end mounted
  323. }
  324. </script>
  325. <style scoped>
  326. .image {
  327. width: 100%;
  328. display: block;
  329. }
  330. </style>