index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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-for="(item,index) in report" :key="index" title avatar :row="3" :loading="false">
  12. <van-panel class="one_report" :title="item.name" :status="item.state==0?'待审核':item.state==1?'已通过':'已驳回'">
  13. <div class="form_text">
  14. <span style="margin-right:20px;">
  15. <i v-if="parseFloat(item.reportTime)>parseFloat(item.calculateTime)+0.5" style="color:red;margin-right:8px;" class="fa fa-exclamation-triangle"></i>
  16. 总填报:
  17. <span :style="parseFloat(item.reportTime)>parseFloat(item.calculateTime)+0.5?'color:red':''">{{item.reportTime}}h</span>
  18. </span>
  19. <!-- <span>系统智能统计:{{item.calculateTime}}h</span> -->
  20. </div>
  21. <div v-for="(item1,index1) in item.data" :key="index1" class="one_report_data">
  22. <div class="project_title">项目:{{item1.project}}</div>
  23. <div class="project_title" v-if="item1.taskId != null" >任务:{{item1.taskName}}</div>
  24. <div class="project_time">时长:{{item1.time}}h <span class="one_span" v-if="item1.isOvertime === 1">加班</span></div>
  25. <div class="project_content">事项:<span v-html="item1.content"></span></div>
  26. <van-divider />
  27. </div>
  28. <div class="form_btn" slot="footer">
  29. <van-button v-if="(user.role != 0 || user.id == item.data[0].inchargerId) && item.state == 0" size="small" type="info" @click="approve(item.id, item)">通过</van-button>
  30. <van-button v-if="(user.role != 0 || user.id == item.data[0].inchargerId) && item.state == 0" size="small" type="danger" @click="deny(item.id,1, item)">驳回</van-button>
  31. <van-button v-if="(user.role != 0 || user.id == item.data[0].inchargerId) && item.state == 1" size="small" type="danger" @click="deny(item.id,2, item)">撤销</van-button>
  32. </div>
  33. </van-panel>
  34. </van-skeleton>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. export default {
  40. data() {
  41. return {
  42. user: JSON.parse(localStorage.userInfo),
  43. minDate: new Date(2010, 0, 1),
  44. maxDate: new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate()),
  45. currentDate: new Date(),
  46. nowTime: this.format(new Date(new Date()),"yyyy-MM-dd"),
  47. showPicker: false,
  48. report: [],
  49. };
  50. },
  51. created() {
  52. },
  53. methods: {
  54. // 返回
  55. back() {
  56. history.back();
  57. },
  58. // 时间转换
  59. format(date, pattern) {
  60. pattern = pattern || "yyyy-MM-dd";
  61. var _this = this;
  62. return pattern.replace(/([yMdhsm])(\1*)/g, function ($0) {
  63. switch ($0.charAt(0)) {
  64. case 'y': return _this.padding(date.getFullYear(), $0.length);
  65. case 'M': return _this.padding(date.getMonth() + 1, $0.length);
  66. case 'd': return _this.padding(date.getDate(), $0.length);
  67. case 'w': return date.getDay() + 1;
  68. case 'h': return _this.padding(date.getHours(), $0.length);
  69. case 'm': return _this.padding(date.getMinutes(), $0.length);
  70. case 's': return _this.padding(date.getSeconds(), $0.length);
  71. }
  72. });
  73. },
  74. padding(s, len) {
  75. var len = len - (s + '').length;
  76. for (var i = 0; i < len; i++) { s = '0' + s; }
  77. return s;
  78. },
  79. // 改变时间
  80. changeTime(time) {
  81. this.nowTime = this.format(new Date(time),"yyyy-MM-dd");
  82. this.currentDate = time;
  83. this.showPicker = false;
  84. this.getReport();
  85. },
  86. // 获取日报
  87. getReport() {
  88. const toast = this.$toast.loading({
  89. forbidClick: true,
  90. duration: 0
  91. });
  92. this.$axios.post("/report/getReportList", {date: this.nowTime})
  93. .then(res => {
  94. if(res.code == "ok") {
  95. toast.clear();
  96. this.report = res.data;
  97. } else {
  98. toast.clear();
  99. this.$toast.fail('获取失败');
  100. }
  101. }).catch(err=> {toast.clear();});
  102. },
  103. approve(id, item) {
  104. const toast = this.$toast.loading({
  105. forbidClick: true,
  106. duration: 0
  107. });
  108. var ids = '';
  109. var data = item.data;
  110. data.forEach(element => {
  111. if (element.id != null && element.id != '') {
  112. ids +=(element.id+',');
  113. }
  114. });
  115. this.$axios.post("/report/approve", {id: id , date: this.nowTime, reportIds: ids})
  116. .then(res => {
  117. if(res.code == "ok") {
  118. toast.clear();
  119. this.$toast.success('审核成功');
  120. this.getReport();
  121. } else {
  122. toast.clear();
  123. this.$toast.fail('审核失败');
  124. }
  125. }).catch(err=> {toast.clear();});
  126. },
  127. deny(id,i, item) {
  128. const toast = this.$toast.loading({
  129. forbidClick: true,
  130. duration: 0
  131. });
  132. var ids = '';
  133. var data = item.data;
  134. data.forEach(element => {
  135. if (element.id != null && element.id != '') {
  136. ids +=(element.id+',');
  137. }
  138. });
  139. this.$axios.post("/report/deny", {id: id , date: this.nowTime, reportIds: ids})
  140. .then(res => {
  141. if(res.code == "ok") {
  142. toast.clear();
  143. this.$toast.success(i==0?'驳回成功':'撤销成功');
  144. this.getReport();
  145. } else {
  146. toast.clear();
  147. this.$toast.fail(i==0?'驳回失败':'撤销失败');
  148. }
  149. }).catch(err=> {toast.clear();});
  150. }
  151. },
  152. mounted() {
  153. this.getReport();
  154. }
  155. };
  156. </script>
  157. <style lang="less" scoped>
  158. .login_form {
  159. margin-top: 46px;
  160. }
  161. .one_report {
  162. margin-bottom: 15px;
  163. font-size:14px;
  164. }
  165. .form_text {
  166. margin: 15px 0 30px;
  167. padding: 0 12px;
  168. }
  169. .form_btn {
  170. text-align: right;
  171. }
  172. .form_btn button {
  173. margin-left: 10px;
  174. }
  175. .one_report_data {
  176. margin-bottom: 10px;
  177. padding: 0 22px;
  178. div {
  179. line-height: 30px;
  180. }
  181. }
  182. </style>
  183. <style lang="less">
  184. .van-nav-bar .van-icon , .van-nav-bar__text {
  185. color: #20a0ff;
  186. }
  187. // 显示加班样式
  188. .one_span {
  189. width: 40px;
  190. height: 25px;
  191. line-height: 25px;
  192. text-align: center;
  193. box-sizing: border-box;
  194. display: inline-block;
  195. border: 1px solid #fde2e2;
  196. background: #fef0f0;
  197. color: #f56c6c;
  198. font-size: 12px;
  199. border-radius: 5px;
  200. // margin-left: 40px;
  201. float: right;
  202. }
  203. </style>