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 21 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <div>
  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='btn' 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='btn' 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. <i class="el-icon-download"></i>
  31. <span ><a :href= "'../tool/query_user_static_page/?startDate='+this.params.startDate+'&endDate='+this.params.endDate+'&IsReturnFile=true'+'&userName='+this.params.userName" >下载报告</a> </span>
  32. </a>
  33. <span style="display:inline-block;margin-left: 20px; ">
  34. <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>
  35. </el-input>
  36. </span>
  37. </span>
  38. </div>
  39. <div style="margin-top: 30px;">
  40. <el-table
  41. :data="tableData"
  42. style="width: 100%"
  43. :header-cell-style="tableHeaderStyle"
  44. :cell-style='cellStyle'>
  45. <el-table-column
  46. label="ID"
  47. prop="ID"
  48. align="center"
  49. stripe
  50. >
  51. </el-table-column>
  52. <el-table-column
  53. label="用户名"
  54. align="center"
  55. prop="Name"
  56. width="100px">
  57. </el-table-column>
  58. <el-table-column
  59. prop="CodeMergeCount"
  60. label="PR数"
  61. align="center">
  62. </el-table-column>
  63. <el-table-column
  64. prop="CommitCount"
  65. label="commit数"
  66. align="center">
  67. </el-table-column>
  68. <el-table-column
  69. prop="IssueCount"
  70. label="提出任务数"
  71. align="center">
  72. </el-table-column>
  73. <el-table-column
  74. prop="CommentCount"
  75. label="评论数"
  76. align="center">
  77. </el-table-column>
  78. <el-table-column
  79. prop="FocusRepoCount"
  80. label="关注项目数"
  81. align="center">
  82. </el-table-column>
  83. <el-table-column
  84. prop="StarRepoCount"
  85. label="点赞项目数"
  86. align="center">
  87. </el-table-column>
  88. <el-table-column
  89. prop="LoginCount"
  90. label="登录次数"
  91. align="center">
  92. </el-table-column>
  93. <el-table-column
  94. prop="WatchedCount"
  95. label="关注者数"
  96. align="center">
  97. </el-table-column>
  98. <el-table-column
  99. prop="CommitCodeSize"
  100. label="commit代码行数"
  101. width="115px"
  102. align="center">
  103. </el-table-column>
  104. <el-table-column
  105. prop="SolveIssueCount"
  106. label="已解决任务数"
  107. align="center">
  108. </el-table-column>
  109. <el-table-column
  110. prop="EncyclopediasCount"
  111. label="百科页面贡献次数"
  112. width="130px"
  113. align="center">
  114. </el-table-column>
  115. <el-table-column
  116. prop="CreateRepoCount"
  117. label="创建项目"
  118. align="center">
  119. </el-table-column>
  120. <el-table-column
  121. prop="RegistDate"
  122. label="用户注册时间"
  123. width="120px"
  124. align="center">
  125. <template slot-scope="scope">
  126. {{scope.row.RegistDate | transformTimestamp}}
  127. </template>
  128. </el-table-column>
  129. <el-table-column
  130. prop="CountDate"
  131. label="系统统计时间"
  132. width="120px"
  133. align="center">
  134. <template slot-scope="scope">
  135. {{scope.row.CountDate | transformTimestamp}}
  136. </template>
  137. </el-table-column>
  138. </el-table>
  139. </div>
  140. <div style="margin-top:50px;text-align:center">
  141. <el-pagination
  142. background
  143. @size-change="handleSizeChange"
  144. @current-change="handleCurrentChange"
  145. :current-page="page"
  146. :page-size="pageSize"
  147. :page-sizes="[2,5,10,20]"
  148. layout="total, sizes, prev, pager, next,jumper"
  149. :total="totalNum">
  150. </el-pagination>
  151. </div>
  152. </div>
  153. </template>
  154. <script>
  155. import { export2Excel } from '../excel/util.js'
  156. export default{
  157. name:'UserAnalysis',
  158. data() {
  159. return {
  160. type_val:'',
  161. recordBeginTime:'',
  162. lastUpdatedTime:'',
  163. page:1,
  164. pageSize:10,
  165. params:{startDate:'',endDate:'',page:1,pageSize:10,userName:''},
  166. tableData: [],
  167. totalNum:0,
  168. pickerOptions: {
  169. },
  170. value_time: '',
  171. search:'',
  172. data:'',
  173. 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:'CountDate'}],
  174. blob:'',
  175. fileName:'',
  176. dynamic:7,
  177. params_pro:{type:'all',page:1,pagesize:10,beginTime:'',endTime:'',q:'',sort:'openi'},
  178. };
  179. },
  180. methods: {
  181. exportData(){
  182. // this.getUserList('all_usr',7)
  183. var saveFileName = this.getFileName()
  184. export2Excel(this.columns,this.tableData,saveFileName)
  185. },
  186. getFileName(){
  187. var saveFileName=''
  188. var Date=(this.params.startDate).split('-')
  189. var startDate=Date[0]+''+Date[1]+''+Date[2]
  190. console.log(startDate)
  191. Date=(this.params.endDate).split('-')
  192. var endDate=Date[0]+Date[1]+Date[2]
  193. saveFileName = '用户分析_'+this.search+''+startDate+'_'+endDate
  194. if (this.type_val=='all_usr'){
  195. saveFileName = '用户分析_'+this.search+'_all'
  196. }
  197. return saveFileName
  198. },
  199. handleCurrentChange(val){
  200. this.params.page = val
  201. this.page = val
  202. this.getUserList(this.type_val,this.dynamic)
  203. },
  204. handleSizeChange(val){
  205. this.params.pageSize = val
  206. this.resetPage()
  207. this.getUserList(this.type_val,this.dynamic)
  208. },
  209. resetPage(){
  210. this.page=1
  211. this.params.page = 1
  212. },
  213. formatDate(myyear,mymonth,myweekday) {
  214. // var myyear = this.date.getFullYear();
  215. // var mymonth = this.date.getMonth() + 1;
  216. // var myweekday = this.date.getDate();
  217. if (mymonth < 10) {
  218. mymonth = "0" + mymonth;
  219. }
  220. if (myweekday < 10) {
  221. myweekday = "0" + myweekday;
  222. }
  223. return (myyear + "-" + mymonth + "-" + myweekday);
  224. },
  225. // 获得某月的天数
  226. getMonthDays(nowYear,month){
  227. let monthStartDate = new Date(nowYear, month, 1);
  228. let monthEndDate = new Date(nowYear, month + 1, 1);
  229. let days = (monthEndDate - monthStartDate)/(1000 * 60 * 60 * 24);
  230. return days;
  231. },
  232. getUpdateTime(){
  233. this.$axios.get('../api/v1/projectboard/project',{
  234. params:this.params_pro
  235. }).then((res)=>{
  236. this.recordBeginTime=res.data.recordBeginTime
  237. this.lastUpdatedTime=res.data.lastUpdatedTime
  238. })
  239. },
  240. getUserList(type_val,index){
  241. this.type_val = type_val
  242. this.dynamic = index;
  243. console.log("dj:"+type_val)
  244. var now = new Date(); // 当前日期
  245. var nowDayOfWeek = now.getDay(); // 今天本周的第几天
  246. var nowDay = now.getDate(); // 当前日
  247. var nowMonth = now.getMonth(); // 当前月
  248. var nowYear = now.getFullYear(); // 当前年
  249. var today = this.formatDate(nowYear,nowMonth+1,nowDay);
  250. let lastMonthDate = new Date(); // 上月日期
  251. lastMonthDate.setDate(1);
  252. lastMonthDate.setMonth(lastMonthDate.getMonth()-1);
  253. let lastYear = lastMonthDate.getYear();
  254. let lastMonth = lastMonthDate.getMonth();
  255. if (typeof type_val=="undefined" || type_val=="null" || type_val==""){
  256. this.params.startDate= this.formatDate(this.value_time[0].getFullYear(),this.value_time[0].getMonth() + 1,this.value_time[0].getDate());
  257. this.params.endDate = this.formatDate(this.value_time[1].getFullYear(),this.value_time[1].getMonth() + 1,this.value_time[1].getDate());
  258. }else{
  259. switch(type_val){
  260. case "yesterday_usr":{
  261. var now = new Date();
  262. var tmp = new Date(now.setTime(now.getTime()-24*60*60*1000));
  263. var yesterday = this.formatDate(tmp.getFullYear(),tmp.getMonth()+1,tmp.getDate());
  264. this.params.startDate = yesterday
  265. this.params.endDate = yesterday
  266. this.value_time=[]
  267. // document.getElementById("yesterday_usr").style.backgroundColor="409effd6"
  268. // document.getElementById("current_week_usr")
  269. break
  270. }
  271. case "current_week_usr":{
  272. var now = new Date(); // 当前日期
  273. var nowDayOfWeek = now.getDay(); // 今天本周的第几天
  274. var day = nowDayOfWeek || 7;
  275. this.params.startDate = this.formatDate(now.getFullYear(), nowMonth+1, nowDay + 1 - day);
  276. this.params.endDate = today
  277. this.value_time=[]
  278. break
  279. }
  280. case "current_month_usr":{
  281. this.params.startDate = this.formatDate(nowYear,nowMonth+1,1);
  282. this.params.endDate = today
  283. this.value_time=[]
  284. break
  285. }
  286. case "last_month_usr":{
  287. this.params.startDate=this.formatDate(nowYear, lastMonth+1, 1);
  288. this.params.endDate=this.formatDate(nowYear, lastMonth+1, this.getMonthDays(nowYear,lastMonth));
  289. this.value_time=[]
  290. break
  291. }
  292. case "monthly_usr":{
  293. var temp=new Date(now - 1000 * 60 * 60 * 24 * 30)
  294. this.params.startDate = this.formatDate(temp.getFullYear(),temp.getMonth()+1,temp.getDate());
  295. this.params.endDate = today
  296. this.value_time=[]
  297. break
  298. }
  299. case "current_year_usr":{
  300. this.params.startDate = this.formatDate(now.getFullYear(), 1, 1);
  301. this.params.endDate = today
  302. this.value_time=[]
  303. break
  304. }
  305. case "all_usr":{
  306. console.log("e:"+today)
  307. this.params.startDate = 'all'//this.formatDate(2000, 1, 1); //this.recordBeginTime//
  308. this.params.endDate = today
  309. this.value_time=[]
  310. break
  311. }
  312. }
  313. };
  314. this.$axios.get('../tool/query_user_static_page',{
  315. params:this.params
  316. }).then((res)=>{
  317. this.tableData = res.data.data
  318. // console.log("res.data:"+res.data.data)
  319. this.totalNum = res.data.count
  320. console.log("res.count:"+res.data.count)
  321. })
  322. // this.$axios.get('../tool/query_user_static',{
  323. // params:this.params
  324. // }).then((res)=>{
  325. // this.currentPage = 1
  326. // this.tableData = res.data
  327. // console.log(" this.tableData:", this.tableData.length)
  328. // for(var i=0;i<this.tableData.length;i++){
  329. // this.tableData[i].RegistDate = this.transformTimestamp(this.tableData[i].RegistDate)
  330. // this.tableData[i].CountDate = this.transformTimestamp(this.tableData[i].CountDate)
  331. // console.log(" this.tableData:", this.tableData[i].RegistDate)
  332. // }
  333. // })
  334. },
  335. searchName(){
  336. // this.params.q = this.search
  337. // this.params.page = 1
  338. // this.getUserList("all_usr")
  339. // var search = this.search;
  340. // this.getUserList("all_usr",7)
  341. // this.tableData = this.tableData.filter(data => !search || data.Name.toLowerCase().includes(search.toLowerCase()))
  342. this.params.userName = this.search
  343. this.params.page = 1
  344. this.page=1
  345. this.getUserList(this.type_val, this.dynamic)
  346. },
  347. // goToDetailPage(pro_id,pro_name){
  348. // sessionStorage.setItem("pro_id",pro_id);
  349. // sessionStorage.setItem("pro_name",pro_name);
  350. // document.getElementById("pro_main").style.display="none";
  351. // document.getElementById("pro_detail").style.display="block";
  352. // },
  353. tableHeaderStyle({row,column,rowIndex,columnIndex}){
  354. if(rowIndex===0){
  355. return 'background:#f5f5f6;color:#606266'
  356. }
  357. },
  358. cellStyle({row,column,rowIndex,columnIndex}){
  359. if(rowIndex%2 === 1){
  360. return 'background:#f5f5f6;color:#606266'
  361. }
  362. },
  363. },
  364. filters:{
  365. transformTimestamp(timestamp){
  366. console.log("timestamp",timestamp)
  367. let a = new Date(timestamp*1000);
  368. const date = new Date(a);
  369. const Y = date.getFullYear() + '/';
  370. const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '/';
  371. const D = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate()) + ' ';
  372. const h = (date.getHours() < 10 ? '0'+date.getHours() : date.getHours()) + ':';
  373. const m = (date.getMinutes() <10 ? '0'+date.getMinutes() : date.getMinutes());// + ':' ;
  374. // const s = (date.getSeconds() <10 ? '0'+date.getSeconds() : date.getSeconds()) ; // 秒
  375. const dateString = Y + M + D + h + m ;//+ s;
  376. console.log('dateString', dateString); // > dateString 2021-07-06 14:23
  377. return dateString;
  378. },
  379. // transformTimestamp(timestamp){
  380. // var dateString= new Date(timestamp);
  381. // return dateString.toLocaleDateString().replace(/\//g, "-") + " " + dateString.toTimeString().substr(0, 8);
  382. // },
  383. },
  384. mounted() {
  385. // document.getElementById("all_usr").style.outline="none"
  386. // document.getElementById("all_usr").focus()
  387. this.getUserList("all_usr",7)
  388. },
  389. created() {
  390. },
  391. watch:{
  392. search(val){
  393. // if(!val){
  394. // this.getUserList("all_usr",7)
  395. // }
  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. /* .btn:focus,
  434. .btn:active{
  435. background-color:#409effd6 ;
  436. } */
  437. /* /deep/ .el-date-picker {
  438. width: 220px;
  439. } */
  440. /deep/ .el-table {
  441. font-size: 12px;
  442. }
  443. /deep/ .el-table tbody tr:hover>td {
  444. background-color:#D3D3D3!important;
  445. opacity:1
  446. }
  447. /deep/ .el-range-separator{
  448. width: 20% !important;
  449. }
  450. .colorChange {
  451. background-color: #409effd6;
  452. color: #FFFF;
  453. }
  454. </style>