You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

UserAnalysis.vue 22 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <template>
  2. <div class="el-col el-col-21" style="padding-right:10px">
  3. <div style="margin-top: 10px;">
  4. <b class="pro_item">活动分析</b> <span class="update_time">数据更新时间:</span><span style="font-size: 12px;">{{lastUpdatedTime}} &nbsp/&nbsp从{{recordBeginTime}}开始统计</span>
  5. </div>
  6. <div style="margin-top: 20px;">
  7. <span class="sta_iterm">统计周期:</span>
  8. <button type="button" class='btnFirst' id ="yesterday_usr" v-bind:class="{colorChange:1==dynamic}" @click="resetPage(),getUserList('yesterday_usr',1)">昨天</button>
  9. <button type="button" class='btn' id = "current_week_usr" v-bind:class="{colorChange:2==dynamic}" @click="resetPage(),getUserList('current_week_usr',2)">本周</button>
  10. <button type="button" class='btn' id = "current_month_usr" v-bind:class="{colorChange:3==dynamic}" @click="resetPage(),getUserList('current_month_usr',3)">本月</button>
  11. <button type="button" class='btn' id = "last_month_usr" v-bind:class="{colorChange:4==dynamic}" @click="resetPage(),getUserList('last_month_usr',4)">上月</button>
  12. <button type="button" class='btn' id = "monthly_usr" v-bind:class="{colorChange:5==dynamic}" @click="resetPage(),getUserList('monthly_usr',5)">近30天</button>
  13. <button type="button" class='btn' id = "current_year_usr" v-bind:class="{colorChange:6==dynamic}" @click="resetPage(),getUserList('current_year_usr',6)">今年</button>
  14. <button type="button" class='btnLast' id = "all_usr" v-bind:class="{colorChange:7==dynamic}" @click="resetPage(),getUserList('all_usr',7)">所有</button>
  15. <span style="margin-left: 20px;">
  16. <el-date-picker
  17. v-model="value_time"
  18. prefix-icon="el-icon-time"
  19. @change="resetPage(),getUserList('',0)"
  20. type="daterange"
  21. size='small'
  22. unlink-panels
  23. range-separator="至"
  24. start-placeholder="开始日期"
  25. end-placeholder="结束日期">
  26. </el-date-picker>
  27. </span>
  28. <span style="float:right; margin-right: 20px;" >
  29. <a style="display:inline-block;margin-left: 20px; " id = 'download'>
  30. <a class="el-icon-download" v-if="tableData!=''" :href= "this.dataUrl + '?startDate='+this.params.startDate+'&endDate='+this.params.endDate+'&IsReturnFile=true'+'&userName='+this.params.userName" ></a>
  31. <i class="el-icon-download" v-else="tableData=''" href="#" style="color:rgba(187, 187, 187, 100);" @click='popMark()'></i>
  32. <span >
  33. <a v-if="tableData!=''" :href= "this.dataUrl + '?startDate='+this.params.startDate+'&endDate='+this.params.endDate+'&IsReturnFile=true'+'&userName='+this.params.userName" >下载报告</a>
  34. <a v-else="tableData=''" href= "#" style="color:rgba(187, 187, 187, 100);" @click='popMark()'>下载报告</a>
  35. </span>
  36. </a>
  37. <span style="display:inline-block;margin-left: 20px; ">
  38. <el-input size="small" placeholder="输入用户名搜索" v-model="search" class="input-with-select" @keyup.enter.native="searchName() "><i slot="suffix" class="el-input__icon el-icon-search" @click="searchName() "></i>
  39. </el-input>
  40. </span>
  41. </span>
  42. </div>
  43. <div style="margin-top: 30px;">
  44. <el-table
  45. :data="tableData"
  46. style="width: 100%"
  47. :header-cell-style="tableHeaderStyle"
  48. :cell-style='cellStyle'>
  49. <el-table-column
  50. label="ID"
  51. prop="ID"
  52. align="left"
  53. stripe
  54. >
  55. </el-table-column>
  56. <el-table-column
  57. fixed
  58. label="用户名"
  59. align="left"
  60. prop="Name"
  61. width="100px">
  62. <template slot-scope="scope">
  63. <a :href="AppSubUrl +'../../../'+ scope.row.Name">{{scope.row.Name}} </a>
  64. </template>
  65. </el-table-column>
  66. <el-table-column
  67. prop="UserIndex"
  68. label="用户指数"
  69. width="120px"
  70. align="center">
  71. <template slot-scope="scope">
  72. {{scope.row.UserIndex | rounding}}
  73. </template>
  74. </el-table-column>
  75. <el-table-column
  76. prop="CodeMergeCount"
  77. label="PR数"
  78. align="center">
  79. </el-table-column>
  80. <el-table-column
  81. prop="CommitCount"
  82. label="commit数"
  83. align="center">
  84. </el-table-column>
  85. <el-table-column
  86. prop="IssueCount"
  87. label="提出任务数"
  88. align="center">
  89. </el-table-column>
  90. <el-table-column
  91. prop="CommentCount"
  92. label="评论数"
  93. align="center">
  94. </el-table-column>
  95. <el-table-column
  96. prop="FocusRepoCount"
  97. label="关注项目数"
  98. align="center">
  99. </el-table-column>
  100. <el-table-column
  101. prop="StarRepoCount"
  102. label="点赞项目数"
  103. align="center">
  104. </el-table-column>
  105. <el-table-column
  106. prop="LoginCount"
  107. label="登录次数"
  108. align="center">
  109. </el-table-column>
  110. <el-table-column
  111. prop="WatchedCount"
  112. label="关注者数"
  113. align="center">
  114. </el-table-column>
  115. <el-table-column
  116. prop="CommitCodeSize"
  117. label="commit代码行数"
  118. width="115px"
  119. align="center">
  120. </el-table-column>
  121. <el-table-column
  122. prop="SolveIssueCount"
  123. label="已解决任务数"
  124. align="center">
  125. </el-table-column>
  126. <el-table-column
  127. prop="EncyclopediasCount"
  128. label="百科页面贡献次数"
  129. width="130px"
  130. align="center">
  131. </el-table-column>
  132. <el-table-column
  133. prop="CreateRepoCount"
  134. label="创建项目"
  135. align="center">
  136. </el-table-column>
  137. <el-table-column
  138. prop="CloudBrainTaskNum"
  139. label="云脑任务数"
  140. width="120px"
  141. align="center">
  142. </el-table-column>
  143. <el-table-column
  144. prop="CloudBrainRunTime"
  145. label="云脑运行时间(小时)"
  146. width="120px"
  147. align="center">
  148. <template slot-scope="scope">
  149. {{scope.row.CloudBrainRunTime | roundingToHour}}
  150. </template>
  151. </el-table-column>
  152. <el-table-column
  153. prop="CommitDatasetNum"
  154. label="上传(提交)数据集文件数"
  155. width="120px"
  156. align="center">
  157. </el-table-column>
  158. <el-table-column
  159. prop="CommitModelCount"
  160. label="提交模型数"
  161. width="120px"
  162. align="center">
  163. </el-table-column>
  164. <el-table-column
  165. prop="RegistDate"
  166. label="用户注册时间"
  167. width="120px"
  168. align="center">
  169. <template slot-scope="scope">
  170. {{scope.row.RegistDate | transformTimestamp}}
  171. </template>
  172. </el-table-column>
  173. <el-table-column
  174. prop="DataDate"
  175. label="系统统计时间"
  176. width="120px"
  177. align="center">
  178. </el-table-column>
  179. </el-table>
  180. </div>
  181. <div style="margin-top:50px;text-align:center">
  182. <el-pagination
  183. background
  184. @size-change="handleSizeChange"
  185. @current-change="handleCurrentChange"
  186. :current-page="page"
  187. :page-size="pageSize"
  188. :page-sizes="[5,10,20]"
  189. layout="total, sizes, prev, pager, next,jumper"
  190. :total="totalNum">
  191. </el-pagination>
  192. </div>
  193. </div>
  194. </template>
  195. <script>
  196. import { export2Excel } from '../excel/util.js'
  197. export default{
  198. name:'UserAnalysis',
  199. data() {
  200. return {
  201. type_val:'',
  202. recordBeginTime:'',
  203. lastUpdatedTime:'',
  204. page:1,
  205. pageSize:10,
  206. params:{startDate:'',endDate:'',page:1,pageSize:10,userName:''},
  207. tableData: [],
  208. totalNum:0,
  209. dataUrl:'../api/v1/query_user_static_page',
  210. pickerOptions: {
  211. },
  212. value_time: '',
  213. search:'',
  214. data:'',
  215. columns: [{title: 'ID',key: 'ID'},{title: '用户名',key: 'Name'},{title: 'PR数',key: 'CodeMergeCount'},{title: 'commit数',key:'CommitCount'},{title: '提出任务数',key: 'IssueCount'},{title: '评论数',key: 'CommentCount'},{title: '关注项目数',key: 'FocusRepoCount'},{title: '点赞项目数',key: 'StarRepoCount'},{title: '登录次数',key: 'LoginCount'},{title:'关注者数',key:'WatchedCount'},{title:'commit代码行数',key:'CommitCodeSize'},{title:'已解决任务数',key:'SolveIssueCount'},{title:'百科页面贡献次数',key:'EncyclopediasCount'},{title:'创建项目',key:'CreateRepoCount'},{title:'用户注册时间',key:'RegistDate'},{title:'云脑任务数',key:'CloudBrainTaskNum'},{title:'云脑运行时间(小时)',key:'CloudBrainRunTime'},{title:'上传(提交)数据集文件数',key:'CommitDatasetNum'},{title:'提交模型数',key:'CommitModelCount'},{title:'用户指数',key:'UserIndex'},{title:'系统统计时间',key:'CountDate'}],
  216. blob:'',
  217. fileName:'',
  218. dynamic:7,
  219. params_pro:{type:'all',page:1,pagesize:10,beginTime:'',endTime:'',q:'',sort:'openi'},
  220. };
  221. },
  222. methods: {
  223. popMark(){
  224. alert("数据为空时,不能下载!")
  225. },
  226. exportData(){
  227. // this.getUserList('all_usr',7)
  228. var saveFileName = this.getFileName()
  229. export2Excel(this.columns,this.tableData,saveFileName)
  230. },
  231. getFileName(){
  232. var saveFileName=''
  233. var Date=(this.params.startDate).split('-')
  234. var startDate=Date[0]+''+Date[1]+''+Date[2]
  235. Date=(this.params.endDate).split('-')
  236. var endDate=Date[0]+Date[1]+Date[2]
  237. saveFileName = '用户分析_'+this.search+''+startDate+'_'+endDate
  238. if (this.type_val=='all_usr'){
  239. saveFileName = '用户分析_'+this.search+'_all'
  240. }
  241. return saveFileName
  242. },
  243. handleCurrentChange(val){
  244. this.params.page = val
  245. this.page = val
  246. this.getUserList(this.type_val,this.dynamic)
  247. },
  248. handleSizeChange(val){
  249. this.params.pageSize = val
  250. this.resetPage()
  251. this.getUserList(this.type_val,this.dynamic)
  252. },
  253. resetPage(){
  254. this.page=1
  255. this.params.page = 1
  256. },
  257. formatDate(myyear,mymonth,myweekday) {
  258. // var myyear = this.date.getFullYear();
  259. // var mymonth = this.date.getMonth() + 1;
  260. // var myweekday = this.date.getDate();
  261. if (mymonth < 10) {
  262. mymonth = "0" + mymonth;
  263. }
  264. if (myweekday < 10) {
  265. myweekday = "0" + myweekday;
  266. }
  267. return (myyear + "-" + mymonth + "-" + myweekday);
  268. },
  269. // 获得某月的天数
  270. getMonthDays(nowYear,month){
  271. let monthStartDate = new Date(nowYear, month, 1);
  272. let monthEndDate = new Date(nowYear, month + 1, 1);
  273. let days = (monthEndDate - monthStartDate)/(1000 * 60 * 60 * 24);
  274. return days;
  275. },
  276. getUpdateTime(){
  277. this.$axios.get('../api/v1/projectboard/project',{
  278. params:this.params_pro
  279. }).then((res)=>{
  280. this.recordBeginTime=res.data.recordBeginTime
  281. this.lastUpdatedTime=res.data.lastUpdatedTime
  282. })
  283. },
  284. getUserList(type_val,index){
  285. this.type_val = type_val
  286. this.dynamic = index;
  287. var now = new Date(); // 当前日期
  288. var nowDayOfWeek = now.getDay(); // 今天本周的第几天
  289. var nowDay = now.getDate(); // 当前日
  290. var nowMonth = now.getMonth(); // 当前月
  291. var nowYear = now.getFullYear(); // 当前年
  292. var today = this.formatDate(nowYear,nowMonth+1,nowDay);
  293. let lastMonthDate = new Date(); // 上月日期
  294. lastMonthDate.setDate(1);
  295. lastMonthDate.setMonth(lastMonthDate.getMonth()-1);
  296. let lastYear = lastMonthDate.getYear();
  297. let lastMonth = lastMonthDate.getMonth();
  298. this.dataUrl = '../api/v1/query_user_static_page';
  299. if (typeof type_val=="undefined" || type_val=="null" || type_val==""){
  300. this.params.startDate= this.formatDate(this.value_time[0].getFullYear(),this.value_time[0].getMonth() + 1,this.value_time[0].getDate());
  301. this.params.endDate = this.formatDate(this.value_time[1].getFullYear(),this.value_time[1].getMonth() + 1,this.value_time[1].getDate());
  302. }else{
  303. switch(type_val){
  304. case "yesterday_usr":{
  305. this.value_time=[]
  306. this.dataUrl = '../api/v1/query_user_yesterday';
  307. break
  308. }
  309. case "current_week_usr":{
  310. this.value_time=[]
  311. this.dataUrl = '../api/v1/query_user_current_week';
  312. break
  313. }
  314. case "current_month_usr":{
  315. this.value_time=[]
  316. this.dataUrl = '../api/v1/query_user_current_month';
  317. break
  318. }
  319. case "last_month_usr":{
  320. this.value_time=[]
  321. this.dataUrl = '../api/v1/query_user_last_month';
  322. break
  323. }
  324. case "monthly_usr":{
  325. this.value_time=[]
  326. this.dataUrl = '../api/v1/query_user_last30_day';
  327. break
  328. }
  329. case "current_year_usr":{
  330. this.value_time=[]
  331. this.dataUrl = '../api/v1/query_user_current_year';
  332. break
  333. }
  334. case "all_usr":{
  335. this.value_time=[]
  336. this.dataUrl = '../api/v1/query_user_all';
  337. break
  338. }
  339. }
  340. };
  341. this.$axios.get(this.dataUrl,{
  342. params:this.params
  343. }).then((res)=>{
  344. this.tableData = res.data.data
  345. // console.log("res.data:"+res.data.data)
  346. this.totalNum = res.data.count
  347. })
  348. },
  349. searchName(){
  350. this.params.userName = this.search
  351. this.params.page = 1
  352. this.page=1
  353. this.getUserList(this.type_val, this.dynamic)
  354. },
  355. tableHeaderStyle({row,column,rowIndex,columnIndex}){
  356. if(rowIndex===0){
  357. return 'background:#f5f5f6;color:#606266'
  358. }
  359. },
  360. cellStyle({row,column,rowIndex,columnIndex}){
  361. if(rowIndex%2 === 1){
  362. return 'background:#f5f5f6;color:#606266'
  363. }
  364. },
  365. },
  366. filters:{
  367. rounding (value) {
  368. return Number(value).toFixed(2)
  369. },
  370. roundingToHour (value) {
  371. return (Number(value)/3600).toFixed(2)
  372. },
  373. transformTimestamp(timestamp){
  374. let a = new Date(timestamp*1000);
  375. const date = new Date(a);
  376. const Y = date.getFullYear() + '/';
  377. const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '/';
  378. const D = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate()) + ' ';
  379. const h = (date.getHours() < 10 ? '0'+date.getHours() : date.getHours()) + ':';
  380. const m = (date.getMinutes() <10 ? '0'+date.getMinutes() : date.getMinutes());// + ':' ;
  381. // const s = (date.getSeconds() <10 ? '0'+date.getSeconds() : date.getSeconds()) ; // 秒
  382. const dateString = Y + M + D + h + m ;//+ s;
  383. return dateString;
  384. },
  385. },
  386. mounted() {
  387. // document.getElementById("all_usr").style.outline="none"
  388. // document.getElementById("all_usr").focus()
  389. this.getUpdateTime()
  390. this.getUserList("all_usr",7)
  391. },
  392. created() {
  393. },
  394. watch:{
  395. search(val){
  396. if(!val){
  397. this.params.userName = this.search
  398. this.params.page = 1
  399. this.page=1
  400. this.getUserList(this.type_val, this.dynamic)
  401. }
  402. }
  403. },
  404. }
  405. </script>
  406. <style scoped>
  407. .pro_item{
  408. font-size: 16px;
  409. color: rgba(16, 16, 16, 100);
  410. font-family: SourceHanSansSC-bold;
  411. }
  412. .sta_item{
  413. font-size: 14px;
  414. color: rgb(0 0 0);
  415. font-family: SourceHanSansSC-bold;
  416. }
  417. .update_time{
  418. line-height: 17px;
  419. font-size: 12px;
  420. color:rgba(187, 187, 187, 100);
  421. margin-left: 10px;
  422. }
  423. /* .btn{
  424. line-height: 1.5;
  425. margin: -3px;
  426. border: 1px solid #409effd6;
  427. background: #FFFF;
  428. color: #409eff;
  429. width: 60px;
  430. height: 30px;
  431. border-radius:4px ;
  432. } */
  433. .btnFirst{
  434. line-height: 1.5;
  435. margin: -3.5px;
  436. border: 1px solid rgba(22, 132, 252, 100);
  437. border-right: none;
  438. background: #FFFF;
  439. color: #1684FC;
  440. width: 60px;
  441. height: 30px;
  442. border-radius:4px 0px 0px 4px;
  443. }
  444. .btn{
  445. line-height: 1.5;
  446. margin: -3.5px;
  447. border: 1px solid rgba(22, 132, 252, 100);
  448. border-right: none;
  449. background: #FFFF;
  450. color: #1684FC;
  451. width: 60px;
  452. height: 30px;
  453. }
  454. .btnLast{
  455. line-height: 1.5;
  456. margin: -3.5px;
  457. border: 1px solid rgba(22, 132, 252, 100);
  458. /* border-right: none; */
  459. background: #FFFF;
  460. color: #1684FC;
  461. width: 60px;
  462. height: 30px;
  463. border-radius:0px 4px 4px 0px;
  464. }
  465. .btnFirst,.btn,.btnLast {
  466. cursor: pointer;
  467. }
  468. /* .btn:focus,
  469. .btn:active{
  470. background-color:#409effd6 ;
  471. } */
  472. /* /deep/ .el-date-picker {
  473. width: 220px;
  474. } */
  475. /deep/ .el-table {
  476. font-size: 12px;
  477. }
  478. /deep/ .el-table tbody tr:hover>td {
  479. background-color:#D3D3D3!important;
  480. opacity:1
  481. }
  482. /deep/ .el-range-separator{
  483. width: 20% !important;
  484. }
  485. /deep/ .el-pagination {
  486. padding-bottom: 30px;
  487. }
  488. .colorChange {
  489. background-color: #1684FC;
  490. color: #FFFF;
  491. cursor: default;
  492. }
  493. </style>