daily_report_statistics.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. <template>
  2. <view class="content">
  3. <view class="head-box-date" style="border: none;">
  4. <uni-nav-bar class="header-nav-box" id="header_nav" left-icon="arrowleft" type="line" title="日报统计" @clickLeft="back" />
  5. <label class="head-right-box iconfont icon-switch switch_color" @click="btnclick">切换月评</label>
  6. <!--
  7. <button class="head-right-box iconfont icon-switch switch_color" @click="btnclick">切换月评</button>
  8. -->
  9. <view class="heax-date-box">
  10. <view :class="{pre: !is_future_month(-1),
  11. pre_unable: is_future_month(-1)}" @click="changeMonth('pre')">
  12. <label class="font_smaller iconfont icon-left-circle">上月</label>
  13. </view>
  14. <view>
  15. <label class="font_smaller">{{year}}年{{month}}月</label>
  16. </view>
  17. <view :class="{next: !is_future_month(1),
  18. next_unable: is_future_month(1)}" @click="changeMonth('next')">
  19. <label class="font_smaller">下月</label>
  20. <label class="font_smaller iconfont icon-right-circle"></label>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="content-box_with_date_none_footer" style="background-color: #EEEEEE;" >
  25. <view class="daily_report_statistics">
  26. <daily-report-statistics-card v-for="(item,index) in daily_report_statistics" :key="index"
  27. :onDuty="item.on_duty" :submitted="item.submitted" :unsubmitted="item.unsubmitted" :date="item.date_str"
  28. @onCardClick="onCardClick"
  29. >
  30. </daily-report-statistics-card>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import utils from '../../utils/common.js'
  37. import store from '../../utils/store.js'
  38. //Vue.component('uni-collapse-item',uniCollapseItem)
  39. //Vue.component('uni-collapse',uniCollapse)
  40. import dailyReportStatisticsCard from '@/components/daily_report_statistics_card/daily_report_statistics_card.vue'
  41. var _self;
  42. export default {
  43. components:{
  44. dailyReportStatisticsCard
  45. },
  46. data() {
  47. return {
  48. kpi_url:'',
  49. employeeID:'',
  50. workMonth:'',
  51. date:'09-01 2021',
  52. year:new Date().getFullYear(),
  53. month:new Date().getMonth()+1,
  54. day:new Date().getDate(),
  55. // holidays:[],
  56. workTags:[],
  57. daily_report_statistics:[
  58. {on_duty:true,date_str:'2021-09-29',submitted:5,unsubmitted:1},
  59. {on_duty:true,date_str:'2021-09-28',submitted:2,unsubmitted:4},
  60. {on_duty:true,date_str:'2021-09-27',submitted:3,unsubmitted:3},
  61. {on_duty:false,date_str:'2021-09-26',submitted:0,unsubmitted:0},
  62. {on_duty:true,date_str:'2021-09-25',submitted:5,unsubmitted:1},
  63. {on_duty:true,date_str:'2021-09-24',submitted:5,unsubmitted:1},
  64. {on_duty:true,date_str:'2021-09-23',submitted:5,unsubmitted:1},
  65. {on_duty:true,date_str:'2021-09-22',submitted:5,unsubmitted:1},
  66. {on_duty:true,date_str:'2021-09-21',submitted:5,unsubmitted:1},
  67. {on_duty:true,date_str:'2021-09-20',submitted:5,unsubmitted:1},
  68. {on_duty:false,date_str:'2021-09-19',submitted:5,unsubmitted:1},
  69. {on_duty:true,date_str:'2021-09-18',submitted:5,unsubmitted:1},
  70. {on_duty:true,date_str:'2021-09-17',submitted:5,unsubmitted:1},
  71. {on_duty:true,date_str:'2021-09-16',submitted:5,unsubmitted:1},
  72. {on_duty:true,date_str:'2021-09-15',submitted:5,unsubmitted:1},
  73. {on_duty:true,date_str:'2021-09-14',submitted:5,unsubmitted:1},
  74. {on_duty:true,date_str:'2021-09-13',submitted:5,unsubmitted:1},
  75. ]
  76. }
  77. },
  78. onLoad(options)
  79. {
  80. //console.log('data stattistics'+JSON.stringify(options));
  81. _self = this;
  82. if(options.date)
  83. {
  84. const date1 = JSON.parse(decodeURIComponent(options.date));
  85. //console.log('data'+JSON.stringify(date1));
  86. if(date1)
  87. {
  88. this.year = date1.year;
  89. this.month = date1.month;
  90. }
  91. //
  92. }
  93. this.kpi_url= uni.getStorageSync('kpi-url');
  94. this.employeeID = uni.getStorageSync('usId');
  95. },
  96. /** onUnload() {
  97. uni.navigateBack({
  98. delta: 10
  99. })
  100. },*/
  101. onReady() {
  102. if(this.year<2000)
  103. {
  104. let date = new Date();
  105. this.year = date.getFullYear();
  106. this.month = date.getMonth()+1;
  107. }
  108. this.refreshEmployeeList();
  109. // #ifdef APP-NVUE
  110. const eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
  111. // #endif
  112. // #ifndef APP-NVUE
  113. const eventChannel = this.getOpenerEventChannel();
  114. // #endif
  115. eventChannel.on('acceptDataFromOpenerPage', function(data) {
  116. if(data)
  117. {
  118. let param = data.data;
  119. if(param)
  120. {
  121. console.log('employee_list activated'+JSON.stringify(data));
  122. if(param.action && param.action=='employee_list')//employee_daily_report
  123. {
  124. if(param.year && param.month)
  125. {
  126. _self.year = param.year;
  127. _self.month =param.month;
  128. _self.refreshEmployeeList();
  129. }
  130. }
  131. }
  132. }
  133. });
  134. },
  135. methods: {
  136. onCardClick(data)
  137. {
  138. uni.navigateTo({
  139. url:'../daily_report_detail/daily_report_detail', //?date='+encodeURIComponent(JSON.stringify(data.date))
  140. success: function(res) {
  141. // 通过eventChannel向被打开页面传送数据
  142. //console.log('fill xxxx')
  143. res.eventChannel.emit('acceptDataFromOpenerPage', { data: data })
  144. }
  145. })
  146. //console.log('index:'+JSON.stringify(data));
  147. },
  148. btnclick()
  149. {
  150. //uni.navigateTo({
  151. let date = {year:_self.year,month:_self.month};//new Date(_self.year,_self.month,_self.day);
  152. //console.log('daily date'+ JSON.stringify(date));
  153. uni.redirectTo({
  154. url:'../employee_list/employee_list?date='+encodeURIComponent(JSON.stringify(date))
  155. // url:'../employee_list/employee_list', //?date='+encodeURIComponent(JSON.stringify(data.date))
  156. /// success: function(res) {
  157. // 通过eventChannel向被打开页面传送数据
  158. //console.log('fill xxxx')
  159. // res.eventChannel.emit('acceptDataFromOpenerPage', { data:
  160. // {action:'daily_report_statistics',year:_self.year,month:_self.month} })
  161. // }
  162. })
  163. },
  164. /*
  165. _holidays(_year,_month)
  166. {
  167. //console.log('xxx'+_year+'xxx');
  168. let monthstr = _year.toString() + this.formatNum(_month);
  169. let yearstr = _year.toString();
  170. let keystr = 'holidays_'+yearstr+monthstr;
  171. //console.log('xx'+keystr+'xx');
  172. let valuestr = uni.getStorageSync(keystr);
  173. if(valuestr)
  174. {
  175. this.holidays = valuestr;
  176. return;
  177. }
  178. //let urlStr = 'https://api.apihubs.cn/holiday/get?field=year,month,date&year=' + _year.toString() + '&' + 'month=' +monthstr + '&holiday_recess=1&cn=1&size=31';
  179. //console.log(urlStr);
  180. uni.request({
  181. url:'https://api.apihubs.cn/holiday/get',
  182. data:
  183. {
  184. field:'year,month,date',
  185. year:yearstr,
  186. month:monthstr,
  187. holiday_recess:1,
  188. cn:1,
  189. size:31
  190. },
  191. method:'GET',
  192. sslVerify:false,
  193. timeout:2000,
  194. success:(res)=>{
  195. //console.log('res success'+JSON.stringify(res.data));
  196. if(res.data)
  197. {
  198. if(res.data.msg =='ok')
  199. {
  200. if(res.data.data)
  201. {
  202. if(res.data.data.list)
  203. {
  204. uni.setStorageSync(keystr,res.data.data.list);
  205. this.holidays = res.data.data.list;
  206. }
  207. }
  208. }
  209. }
  210. },
  211. fail:(res)=>{
  212. console.log('res failed'+JSON.stringify(res.data));
  213. }
  214. });
  215. },*/
  216. isHoliday(_date)
  217. {
  218. //console.log('date' + JSON.stringify(_date) +'tag'+ JSON.stringify(this.workTags));
  219. //return false;
  220. for(let i = 0;i< this.workTags.length;i++)
  221. {
  222. if(_date == this.workTags[i].date)
  223. {
  224. if(this.workTags[i].flag ==0)
  225. {
  226. //console.log('假期 ' + this.workTags[i].date);
  227. //console.log('xxxx' + this.holidays[i].date.toString());
  228. return true;
  229. }
  230. }
  231. }
  232. /* let date = _date.replace(new RegExp(/-/g), "");
  233. //console.log('date:'+date);
  234. for(let i = 0;i< this.holidays.length;i++)
  235. {
  236. if(date == this.holidays[i].date.toString())
  237. {
  238. //console.log('xxxx' + this.holidays[i].date.toString());
  239. return true;
  240. }
  241. }*/
  242. return false;
  243. },
  244. isWorkDay(ymd) {
  245. //是否工作日
  246. //let ymd = `${y}/${m}/${d}`;
  247. let formatDY = new Date(ymd.replace(/-/g, '/'));
  248. let week = formatDY.getDay();
  249. if (week == 0 ) {//|| week == 6
  250. return false;
  251. } else {
  252. return true;
  253. }
  254. },
  255. refreshEmployeeList()
  256. {
  257. this.daily_report_statistics = [];
  258. //this._holidays(this.year,this.month);
  259. let today = new Date();
  260. let todaystr = this.year + '-' + this.formatNum(today.getMonth()+1) +'-' + this.formatNum(today.getDate());
  261. this.workMonth= this.year +'-'+ this.formatNum(this.month);
  262. //console.log('日报统计 ID:'+this.employeeID+'month:'+this.workMonth);
  263. uni.request({
  264. url: this.kpi_url+ '/api/rptDailySubmitData.do',//'http://192.168.77.99:8080/api/loadMonthWorkSummary.do',//?workNum='+this.employeeNumber+'&workMonth='+this.workMonth, //仅为示例,并非真实接口地址。
  265. data:{usId:this.employeeID,workMonth:this.workMonth},
  266. method:'GET',
  267. timeout:20000,
  268. success: (res) => {
  269. //console.log('res'+JSON.stringify(res.data));
  270. if(res.data.success){
  271. if(res.data.data)
  272. {
  273. let total = 0;
  274. if(res.data.data.total)
  275. {
  276. total = res.data.data.total;
  277. //console.log('total'+total);
  278. }
  279. let daily_report_statistics = res.data.data.rpt;
  280. //this.$refs.ren.set_status(year,month);
  281. let workTags = res.data.data.workTags;
  282. for(let i = 0;i< workTags.length;i++)
  283. {
  284. let workTag = {date:this.year.toString()+'-' + utils.formatNum(this.month)+'-' +utils.formatNum(i+1),flag:Number(workTags[i])};
  285. this.workTags.push(workTag);
  286. }
  287. //console.log('data '+JSON.stringify(this.workTags));
  288. //return;
  289. if(daily_report_statistics)
  290. {
  291. //console.log('res'+JSON.stringify(daily_report_statistics));
  292. this.daily_report_statistics = [];
  293. for(let i = 0;i< daily_report_statistics.length;i++)
  294. {
  295. //console.log('xxxx')
  296. let statistics = daily_report_statistics[i];
  297. if(statistics.submitDate>todaystr)
  298. continue;
  299. let _unsubmitted = total-statistics.submitCount;
  300. let _onDuty = true;
  301. //if(!statistics.submitCount)
  302. //{
  303. if(this.isHoliday(statistics.submitDate))
  304. _onDuty=false;
  305. // if(!this.isWorkDay(statistics.submitDate))
  306. // _onDuty = false;
  307. //}
  308. this.daily_report_statistics.push({on_duty:_onDuty,date_str:statistics.submitDate,submitted:statistics.submitCount,unsubmitted:_unsubmitted})
  309. //console.log('Date: '+statistics.submitDate);
  310. }
  311. }
  312. }
  313. }
  314. else{
  315. console.log('fail')
  316. uni.showToast({
  317. title: res.data.exception,
  318. icon: 'error',
  319. duration: 2000
  320. });
  321. }
  322. },
  323. fail:(res)=>{
  324. console.log('requrest failed')
  325. console.log(res);
  326. uni.showModal({
  327. title:'提示',
  328. content:'请求服务失败,请检查网络!',
  329. showCancel:false
  330. })
  331. },
  332. complete:()=>{
  333. //uni.hideLoading();
  334. }
  335. });
  336. },
  337. back() {
  338. console.log('test')
  339. uni.navigateBack({
  340. delta: 10
  341. })
  342. },
  343. formatNum(num) {
  344. let res = Number(num);
  345. return res < 10 ? '0' + res : res;
  346. },
  347. addMonth(date, months) {
  348. let y = date.getFullYear();
  349. let m = date.getMonth();
  350. var d = date.getDate();
  351. // console.log('add month y' + y + ' m:' + m + ' d: ' + d + ' month: ' + months);
  352. y += Math.floor((m + 1 + months) / 12); //计算年
  353. m = Math.floor((m + 1 + months) % 12) - 1; //计算月
  354. let _date = new Date(y,m,d);
  355. // console.log('result y:' + y + ' m: ' + m + '_date:' + _date);
  356. return _date;
  357. },
  358. is_future_month(increment)
  359. {
  360. let date = new Date();
  361. let page_date = new Date(this.year,this.month-1,1);
  362. page_date = this.addMonth(page_date,increment)
  363. let _y = date.getFullYear();//当前年
  364. let _m = date.getMonth();//当前月
  365. let _y1 = page_date.getFullYear();
  366. let _m1 = page_date.getMonth();
  367. if(_y1>_y)
  368. return true;
  369. if(_y1<_y)
  370. return false;
  371. if(_m1 > _m)
  372. return true;
  373. return false;
  374. },
  375. changeMonth(type){
  376. if(type=='pre'){
  377. if (this.month + 1 == 2) {
  378. this.month = 12;
  379. this.year = this.year - 1;
  380. } else {
  381. this.month = this.month - 1;
  382. }
  383. }else{
  384. if (this.month + 1 == 13) {
  385. this.month = 1;
  386. this.year = this.year + 1;
  387. } else {
  388. this.month = this.month + 1;
  389. }
  390. }
  391. this.refreshEmployeeList();
  392. }
  393. }
  394. }
  395. </script>
  396. <style lang="scss">
  397. @import url("/static/font/iconfont.css");
  398. @import "@/common/pa_main.scss";
  399. button::after { border: none }
  400. #header_nav {
  401. color: #007AFF;
  402. box-shadow: 0 0px 0px #FFFFFF;
  403. border-bottom-width: 10rpx;
  404. border-bottom-style: solid;
  405. border-bottom-color: #FFFFFF;
  406. }
  407. .pre,.next{
  408. color: #4d7df9;
  409. font-size: 28rpx;
  410. font-weight: normal;
  411. padding: 8rpx 15rpx;
  412. //border-radius: 10rpx;
  413. //border: 2rpx solid #dcdfe6;
  414. }
  415. .pre_unable,.next_unable
  416. {
  417. color: #B5B5B5;
  418. font-size: 28rpx;
  419. font-weight: normal;
  420. padding: 8rpx 15rpx;
  421. }
  422. .pre{
  423. margin-right: 30rpx;
  424. }
  425. .next{
  426. margin-left: 30rpx;
  427. }
  428. .daily_report_statistics
  429. {
  430. padding-top: 10rpx;
  431. padding-left: 0rpx;
  432. padding-right: 0rpx;
  433. height: auto;
  434. background-color: #EEEEEE!important;
  435. }
  436. ::-webkit-scrollbar {
  437. display: none;
  438. width: 0 !important;
  439. height: 0 !important;
  440. -webkit-appearance: none;
  441. background: transparent;
  442. }
  443. </style>