index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <div class="boxswai">
  3. <div class="boxnei flex flex-d-c">
  4. <el-menu :default-active="activeIndex"
  5. class="el-menu-demo"
  6. mode="horizontal"
  7. text-color='black'
  8. active-text-color='#1684FC'
  9. @select="handleSelect"
  10. >
  11. <el-menu-item index="1" v-model="activeIndex">我的待办工单</el-menu-item>
  12. <el-menu-item index="2" v-model="activeIndex">所有代办工单</el-menu-item>
  13. </el-menu>
  14. <div class="information flex1">
  15. <el-collapse v-show="activeIndex == 1">
  16. <el-collapse-item
  17. :name="item.title"
  18. v-for="(item,key) in collapseData1"
  19. :key="key"
  20. >
  21. <template slot="title">
  22. <i
  23. class="el-icon-chat-dot-round"
  24. style="fontSize:18px;margin-right:10px;"
  25. > </i>{{item.title}}
  26. </template>
  27. <div>
  28. <el-button
  29. type="text"
  30. style="color:rgb(65, 80, 88);"
  31. >立即处理</el-button>
  32. </div>
  33. <div>
  34. <el-button
  35. type="text"
  36. @click="ignore(key)"
  37. v-throttle="3000"
  38. style="color:rgb(65, 80, 88);"
  39. >忽略</el-button>
  40. </div>
  41. </el-collapse-item>
  42. </el-collapse>
  43. <el-collapse v-show="activeIndex==2">
  44. <el-collapse-item
  45. :name="item.title"
  46. v-for="(item,key) in collapseData2"
  47. :key="key"
  48. >
  49. <template slot="title">
  50. <i
  51. class="el-icon-chat-dot-round"
  52. style="fontSize:18px;margin-right:10px;"
  53. > </i>{{item.title}}
  54. </template>
  55. <div v-show="item.operation">
  56. <div>
  57. <el-button
  58. type="text"
  59. style="color:rgb(65, 80, 88);"
  60. >立即处理</el-button>
  61. </div>
  62. <div>
  63. <el-button
  64. type="text"
  65. v-throttle="3000"
  66. @click="ignore2(key)"
  67. style="color:rgb(65, 80, 88);"
  68. >忽略</el-button>
  69. </div>
  70. </div>
  71. </el-collapse-item>
  72. </el-collapse>
  73. </div>
  74. <el-row :gutter="20" class="mg-t-20">
  75. <el-col :span="8">
  76. <div class="chart-title">证书统计(总计XXXXX个)</div>
  77. <div id="container"></div>
  78. </el-col>
  79. <el-col :span="8">
  80. <div class="chart-title">人员账户统计(总计{{personAmount}}位)</div>
  81. <div id="container2"></div>
  82. </el-col>
  83. <el-col :span="8">
  84. <div class="chart-title">
  85. <span>维护类型统计汇总</span>
  86. <el-select v-model="projectId" placeholder="请选择项目" size="small" @change="selectProjectOpinion">
  87. <el-option
  88. v-for="item in projectList"
  89. :key="item.id"
  90. :label="item.projectName"
  91. :value="item.id"
  92. ></el-option>
  93. </el-select>
  94. </div>
  95. <div id="container3"></div>
  96. </el-col>
  97. </el-row>
  98. </div>
  99. </div>
  100. </template>
  101. <script>
  102. // 引入统计图
  103. import { Area, Column, Pie } from '@antv/g2plot';
  104. import { queryBusinessUserOpinion, queryBusinessUserOpinionAll, queryProjectUserAmount, queryProjectPfx, queryOpinionTypeAmount } from '@/api/news/news.js';
  105. export default {
  106. data () {
  107. return {
  108. LineData: [],//折线统计图数据
  109. ColumnData: [],//条形统计图数据
  110. personAmount: 0,
  111. PieData: [],//饼图统计图数据
  112. activeIndex: '1',
  113. collapseData1: [],//
  114. collapseData2: [],//
  115. userOpinionTypeList:[],
  116. projectList:[],
  117. projectId:'',
  118. }
  119. },
  120. methods: {
  121. selectProjectOpinion(){
  122. let _this = this;
  123. this.userOpinionTypeList.forEach(vo => {
  124. if(vo.projectId === _this.projectId){
  125. _this.PieData = [];
  126. let problemType = vo.problemType;
  127. let problemTypeAmount = vo.problemTypeAmount;
  128. _this.projectId = vo.projectId;
  129. problemType.forEach((name, index) => {
  130. _this.PieData.push({type : name, value : Number(problemTypeAmount[index])});
  131. });
  132. }
  133. })
  134. },
  135. async handleSelect (key) {
  136. if (key == 2) {
  137. if (this.collapseData2.length <= 0) {
  138. await this.queryBusinessUserOpinionAll()
  139. this.collapseData = this.collapseData2;
  140. } else {
  141. this.collapseData = this.collapseData2;
  142. }
  143. } else {
  144. if (this.collapseData1.length > 0) {
  145. this.collapseData = this.collapseData1;
  146. }
  147. }
  148. this.activeIndex = key
  149. },
  150. async queryBusinessUserOpinion () {//获取我的消息
  151. const { data: res } = await queryBusinessUserOpinion({
  152. current: 1,
  153. size: 999999
  154. })
  155. if (res.code == 200) {
  156. this.collapseData1 = res.data.userOpinionFlowList
  157. this.menuTag = res.data.operation
  158. }
  159. },
  160. async queryBusinessUserOpinionAll () {
  161. const { data: res } = await queryBusinessUserOpinionAll({
  162. current: 1,
  163. size: 999999
  164. })
  165. if (res.code == 200) {
  166. this.collapseData2 = res.data.userOpinionFlowList;
  167. }
  168. },
  169. ignore (key) {
  170. this.collapseData1.splice(this.collapseData1.indexOf(this.collapseData1[key]), 1)
  171. },
  172. ignore2 (key) {
  173. this.collapseData2.splice(this.collapseData2.indexOf(this.collapseData2[key]), 1)
  174. },
  175. async LineV () {
  176. await this.queryProjectPfx();
  177. const line = new Area('container', {
  178. data: this.LineData,
  179. xField: 'project',
  180. yField: 'value',
  181. seriesField: 'category',
  182. isStack:false,
  183. legend: {
  184. position: 'bottom',
  185. },
  186. autoFit:true
  187. });
  188. line.render();
  189. },
  190. async ColumnV () {
  191. await this.queryProjectUserAmount();
  192. const columnPlot = new Column('container2', {
  193. data: this.ColumnData,
  194. isGroup: true,
  195. xField: 'project',
  196. yField: 'value',
  197. seriesField: 'category',
  198. /** 设置颜色 */
  199. //color: ['#1ca9e6', '#f88c24'],
  200. /** 设置间距 */
  201. // marginRatio: 0.1,
  202. label: {
  203. // 可手动配置 label 数据标签位置
  204. position: 'middle', // 'top', 'middle', 'bottom'
  205. // 可配置附加的布局方法
  206. layout: [
  207. // 柱形图数据标签位置自动调整
  208. { type: 'interval-adjust-position' },
  209. // 数据标签防遮挡
  210. { type: 'interval-hide-overlap' },
  211. // 数据标签文颜色自动调整
  212. { type: 'adjust-color' },
  213. ],
  214. },
  215. legend: {
  216. position: 'bottom',
  217. },
  218. });
  219. columnPlot.render();
  220. },
  221. async PieV () {
  222. await this.queryOpinionTypeAmount();
  223. const piePlot = new Pie('container3', {
  224. appendPadding: 10,
  225. data: this.PieData,
  226. angleField: 'value',
  227. colorField: 'type',
  228. radius: 0.75,
  229. label: {
  230. type: 'spider',
  231. labelHeight: 28,
  232. content: '{name}\n{value}',
  233. },
  234. interactions: [{ type: 'element-selected' }, { type: 'element-active' }],
  235. legend: {
  236. position: 'bottom',
  237. },
  238. });
  239. piePlot.render();
  240. },
  241. //获取人员账户
  242. async queryProjectUserAmount(){
  243. const {data : res} = await queryProjectUserAmount();
  244. let records = res.data.projectUserAmountVOList;
  245. records.forEach(vo => {
  246. this.ColumnData.push({"category": "施工方","project": vo.projectName,"value": vo.contractor});
  247. this.ColumnData.push({"category": "监理方","project": vo.projectName,"value": vo.supervision});
  248. this.ColumnData.push({"category": "指挥部","project": vo.projectName,"value": vo.owner});
  249. });
  250. this.personAmount = res.data.projectUserAmount;
  251. },
  252. //证书统计
  253. async queryProjectPfx(){
  254. let _this = this;
  255. const {data : res} = await queryProjectPfx();
  256. let pfxList = res.data.pfxList;
  257. pfxList.forEach(vo => {
  258. _this.LineData.push({"category": "个人证书","project": vo.projectName,"value": Number(vo.personalCount)});
  259. _this.LineData.push({"category": "企业证书","project": vo.projectName,"value": Number(vo.enterpriseCount)});
  260. });
  261. },
  262. //维护类型统计汇总
  263. async queryOpinionTypeAmount(){
  264. let _this = this;
  265. const {data : res} = await queryOpinionTypeAmount();
  266. this.userOpinionTypeList = res.data.userOpinionList;
  267. let problemType = this.userOpinionTypeList[0].problemType;
  268. let problemTypeAmount = this.userOpinionTypeList[0].problemTypeAmount;
  269. this.projectId = this.userOpinionTypeList[0].projectId;
  270. problemType.forEach((name, index) => {
  271. _this.PieData.push({type : name, value : Number(problemTypeAmount[index])});
  272. });
  273. this.projectList = res.data.projectInfos;
  274. }
  275. },
  276. created () {
  277. this.queryBusinessUserOpinion();
  278. },
  279. mounted () {
  280. this.LineV()
  281. this.ColumnV()
  282. this.PieV()
  283. }
  284. }
  285. </script>
  286. <style lang="scss" scoped>
  287. .el-menu.el-menu--horizontal {
  288. display: flex;
  289. justify-content: center;
  290. }
  291. .el-menu-item,
  292. .el-submenu__title {
  293. line-height: 40px;
  294. height: 40px;
  295. }
  296. .el-menu-item {
  297. padding: 0px;
  298. margin: 0 20px;
  299. }
  300. .information {
  301. margin-top: 20px;
  302. background-color: #faf8fd;
  303. box-sizing: border-box;
  304. border-radius: 4px;
  305. overflow: auto;
  306. }
  307. .el-collapse {
  308. border: none;
  309. }
  310. /deep/.el-collapse-item__header {
  311. background-color: #faf8fd;
  312. border-bottom: none;
  313. box-sizing: border-box;
  314. padding-left: 20px;
  315. color: red;
  316. }
  317. /deep/.el-collapse-item__content {
  318. background-color: #f7f7f7;
  319. box-sizing: border-box;
  320. padding-left: 20px;
  321. padding-bottom: 0px;
  322. }
  323. .visualization {
  324. height: calc(60% - 60px);
  325. }
  326. .chart-title{
  327. margin-bottom: 20px;
  328. font-weight: 700;
  329. font-size: 18px;
  330. color: rgba(119, 40, 245, 0.85);
  331. }
  332. </style>