index.vue 8.3 KB

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