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