index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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_time">时长:
  25. <span v-if="item1.reportTimeType == 0" style="margin-right:10px;">{{fullDayTxt[item1.timeType]}}</span>
  26. <span v-if="item1.reportTimeType == 2" style="margin-right:10px;">{{item1.startTime+'-'+item1.endTime}}</span>{{item1.time}}h
  27. <div class="button" v-if="item1.isOvertime == 1">加班</div>
  28. </div>
  29. <div class="project_content">事项:<span v-html="item1.content"></span></div>
  30. <van-divider />
  31. </div>
  32. </van-panel>
  33. </van-skeleton>
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. export default {
  39. data() {
  40. return {
  41. hasWaiting: false,
  42. state: 0,
  43. user: JSON.parse(localStorage.userInfo),
  44. minDate: new Date(2010, 0, 1),
  45. maxDate: new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate()),
  46. currentDate: new Date(),
  47. nowTime: this.format(new Date(new Date()),"yyyy-MM-dd"),
  48. showPicker: false,
  49. report: [],
  50. fullDayTxt:['全天','上午','下午'],
  51. statusTxt:["待审核", "已通过", "已驳回", "已撤销"],
  52. };
  53. },
  54. created() {
  55. },
  56. methods: {
  57. // 返回
  58. back() {
  59. history.back();
  60. },
  61. // 时间转换
  62. format(date, pattern) {
  63. pattern = pattern || "yyyy-MM-dd";
  64. var _this = this;
  65. return pattern.replace(/([yMdhsm])(\1*)/g, function ($0) {
  66. switch ($0.charAt(0)) {
  67. case 'y': return _this.padding(date.getFullYear(), $0.length);
  68. case 'M': return _this.padding(date.getMonth() + 1, $0.length);
  69. case 'd': return _this.padding(date.getDate(), $0.length);
  70. case 'w': return date.getDay() + 1;
  71. case 'h': return _this.padding(date.getHours(), $0.length);
  72. case 'm': return _this.padding(date.getMinutes(), $0.length);
  73. case 's': return _this.padding(date.getSeconds(), $0.length);
  74. }
  75. });
  76. },
  77. padding(s, len) {
  78. var len = len - (s + '').length;
  79. for (var i = 0; i < len; i++) { s = '0' + s; }
  80. return s;
  81. },
  82. // 改变时间
  83. changeTime(time) {
  84. this.nowTime = this.format(new Date(time),"yyyy-MM-dd");
  85. this.currentDate = time;
  86. this.showPicker = false;
  87. this.getReport();
  88. },
  89. // 获取日报
  90. getReport() {
  91. this.hasWaiting = false;
  92. const toast = this.$toast.loading({
  93. forbidClick: true,
  94. duration: 0
  95. });
  96. this.$axios.post("/report/getReportList", {date: this.nowTime})
  97. .then(res => {
  98. if(res.code == "ok") {
  99. toast.clear();
  100. this.report = res.data;
  101. console.log(this.report);
  102. //计算状态
  103. for (var i=0;i<this.report.length; i++) {
  104. var item = this.report[i];
  105. if (item.state == 0) {
  106. this.hasWaiting = true;
  107. }
  108. }
  109. } else {
  110. toast.clear();
  111. this.$toast.fail('获取失败');
  112. }
  113. }).catch(err=> {toast.clear();});
  114. },
  115. },
  116. mounted() {
  117. this.getReport();
  118. }
  119. };
  120. </script>
  121. <style lang="less" scoped>
  122. .login_form {
  123. margin-top: 46px;
  124. }
  125. .one_report {
  126. margin-bottom: 15px;
  127. font-size:14px;
  128. }
  129. .form_text {
  130. margin: 15px 0 15px;
  131. padding: 0 12px;
  132. }
  133. .form_btn {
  134. text-align: right;
  135. }
  136. .form_btn button {
  137. margin-left: 10px;
  138. }
  139. .one_report_data {
  140. margin-bottom: 10px;
  141. padding: 0 22px;
  142. div {
  143. line-height: 30px;
  144. }
  145. }
  146. </style>
  147. <style lang="less">
  148. .van-nav-bar .van-icon , .van-nav-bar__text {
  149. color: #20a0ff;
  150. }
  151. .button {
  152. float: right;
  153. width: 50px;
  154. height: 25px;
  155. line-height: 25px;
  156. text-align: center;
  157. border: 1px solid red;
  158. color: red;
  159. box-sizing: border-box;
  160. border-radius: 10px;
  161. font-size: 14px;
  162. display: flex;
  163. justify-content: center;
  164. align-items: center;
  165. }
  166. </style>