index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <div>
  3. <van-nav-bar title="查看日报" left-text="返回" @click-left="back" fixed left-arrow/>
  4. <div class="login_form">
  5. <van-sticky :offset-top="46">
  6. <van-field readonly clickable name="datetimePicker" :value="nowTime" label="时间选择" placeholder="点击选择时间" @click="showPicker = true"/>
  7. </van-sticky>
  8. <van-popup v-model="showPicker" position="bottom">
  9. <van-datetime-picker v-model="currentDate" type="date" :min-date="minDate" :max-date="maxDate" @confirm="changeTime" @cancel="showPicker = false"/>
  10. </van-popup>
  11. <van-skeleton :v-if="report.length!=0" v-for="(item,index) in report" title avatar :row="3" :loading="false" :key="index">
  12. <van-panel class="one_report" :title="item.name" :status="statusTxt[item.state]">
  13. <div class="form_text">
  14. <span style="margin-right:20px;margin-left:5px;font-size:14px;">
  15. <!-- <i v-if="parseFloat(item.reportTime)>parseFloat(item.calculateTime)+0.5"
  16. style="color:red;margin-right:8px;" class="fa fa-exclamation-triangle"></i> -->
  17. 总填报:
  18. <span :style="parseFloat(item.reportTime)>parseFloat(item.calculateTime)+0.5?'color:red':''">{{item.reportTime}}h</span>
  19. </span>
  20. <!-- <span>系统智能统计:{{item.calculateTime}}h</span> -->
  21. </div>
  22. <div v-for="(item1,index1) in item.data" class="one_report_data" :key="index1">
  23. <div class="project_title">项目:{{item1.project}}</div>
  24. <div class="project_title" v-if="item1.taskId != null" >任务:{{item1.taskName}}</div>
  25. <div class="project_time">时长:
  26. <span v-if="item1.reportTimeType == 0" style="margin-right:10px;">{{fullDayTxt[item1.timeType]}}</span>
  27. <span v-if="item1.reportTimeType == 2" style="margin-right:10px;">{{item1.startTime+'-'+item1.endTime}}</span>{{item1.time}}h
  28. <div class="button" v-if="item1.isOvertime == 1">加班</div>
  29. </div>
  30. <div class="project_content">事项:<span v-html="item1.content"></span></div>
  31. <van-divider />
  32. </div>
  33. </van-panel>
  34. </van-skeleton>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. export default {
  40. data() {
  41. return {
  42. hasWaiting: false,
  43. state: 0,
  44. user: JSON.parse(localStorage.userInfo),
  45. minDate: new Date(2010, 0, 1),
  46. maxDate: new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate()),
  47. currentDate: new Date(),
  48. nowTime: this.format(new Date(new Date()),"yyyy-MM-dd"),
  49. showPicker: false,
  50. report: [],
  51. fullDayTxt:['全天','上午','下午'],
  52. statusTxt:["待审核", "已通过", "已驳回", "已撤销"],
  53. };
  54. },
  55. created() {
  56. },
  57. methods: {
  58. // 返回
  59. back() {
  60. history.back();
  61. },
  62. // 时间转换
  63. format(date, pattern) {
  64. pattern = pattern || "yyyy-MM-dd";
  65. var _this = this;
  66. return pattern.replace(/([yMdhsm])(\1*)/g, function ($0) {
  67. switch ($0.charAt(0)) {
  68. case 'y': return _this.padding(date.getFullYear(), $0.length);
  69. case 'M': return _this.padding(date.getMonth() + 1, $0.length);
  70. case 'd': return _this.padding(date.getDate(), $0.length);
  71. case 'w': return date.getDay() + 1;
  72. case 'h': return _this.padding(date.getHours(), $0.length);
  73. case 'm': return _this.padding(date.getMinutes(), $0.length);
  74. case 's': return _this.padding(date.getSeconds(), $0.length);
  75. }
  76. });
  77. },
  78. padding(s, len) {
  79. var len = len - (s + '').length;
  80. for (var i = 0; i < len; i++) { s = '0' + s; }
  81. return s;
  82. },
  83. // 改变时间
  84. changeTime(time) {
  85. this.nowTime = this.format(new Date(time),"yyyy-MM-dd");
  86. this.currentDate = time;
  87. this.showPicker = false;
  88. this.getReport();
  89. },
  90. // 获取日报
  91. getReport() {
  92. this.hasWaiting = false;
  93. const toast = this.$toast.loading({
  94. forbidClick: true,
  95. duration: 0
  96. });
  97. this.$axios.post("/report/getReportList", {date: this.nowTime})
  98. .then(res => {
  99. if(res.code == "ok") {
  100. toast.clear();
  101. this.report = res.data;
  102. console.log(this.report);
  103. //计算状态
  104. for (var i=0;i<this.report.length; i++) {
  105. var item = this.report[i];
  106. if (item.state == 0) {
  107. this.hasWaiting = true;
  108. }
  109. }
  110. } else {
  111. toast.clear();
  112. this.$toast.fail('获取失败:'+res.msg);
  113. }
  114. }).catch(err=> {toast.clear();});
  115. },
  116. },
  117. mounted() {
  118. if (sessionStorage.targetDate != null) {
  119. this.nowTime = sessionStorage.targetDate;
  120. sessionStorage.removeItem('targetDate');
  121. }
  122. this.getReport();
  123. }
  124. };
  125. </script>
  126. <style lang="less" scoped>
  127. .login_form {
  128. margin-top: 46px;
  129. }
  130. .one_report {
  131. margin-bottom: 15px;
  132. font-size:14px;
  133. }
  134. .form_text {
  135. margin: 15px 0 15px;
  136. padding: 0 12px;
  137. }
  138. .form_btn {
  139. text-align: right;
  140. }
  141. .form_btn button {
  142. margin-left: 10px;
  143. }
  144. .one_report_data {
  145. margin-bottom: 10px;
  146. padding: 0 22px;
  147. div {
  148. line-height: 30px;
  149. }
  150. }
  151. </style>
  152. <style lang="less">
  153. .van-nav-bar .van-icon , .van-nav-bar__text {
  154. color: #20a0ff;
  155. }
  156. .button {
  157. float: right;
  158. width: 50px;
  159. height: 25px;
  160. line-height: 25px;
  161. text-align: center;
  162. border: 1px solid red;
  163. color: red;
  164. box-sizing: border-box;
  165. border-radius: 10px;
  166. font-size: 14px;
  167. display: flex;
  168. justify-content: center;
  169. align-items: center;
  170. }
  171. </style>