dayreportform.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view style="width: 100%;height: 100%;">
  3. <view id="header">
  4. <u-row customStyle="border-bottom:1rpx solid lightgrey;height:80rpx">
  5. <u-col span="3">
  6. <picker mode="date" fields="year" @change="(e)=>{year=e.target.value;getdata()}">
  7. <text>{{year}}年</text>
  8. </picker>
  9. </u-col>
  10. <u-col span="2">
  11. <picker mode="selector" :range="months" :value="index"
  12. @change="(e)=>{index= e.target.value ;month=months[e.target.value];getdata()}">
  13. <text>{{months[index]}}月</text>
  14. </picker>
  15. </u-col>
  16. <u-col span="3" @click="showChooseUser">
  17. <text>{{user.name}}</text>
  18. </u-col>
  19. <u-col span="2">
  20. <view style="display: flex;">
  21. <u-tag :text="leaveTime" borderColor = "#DA2424" bgColor="#DA2424"></u-tag>
  22. </view>
  23. </u-col>
  24. <u-col span="2" style="display: flex;">
  25. <view>
  26. <u-tag :text="overTime" bgColor="#62D557" borderColor="#62D557"></u-tag>
  27. </view>
  28. </u-col>
  29. </u-row>
  30. </view>
  31. <scroll-view :style="{height:s_height+'px'}" scroll-y="true">
  32. <uni-card v-for="(item,index) in reports">
  33. <view slot="title">
  34. <view class="title">
  35. <text>{{item.reportDate}}</text>
  36. <u-tag :text="item.sumHours" :bgColor="calcColor(item)" :borderColor="calcColor(item)"></u-tag>
  37. </view>
  38. </view>
  39. <u-row v-for="(child,index1) in item.reportDetails" customStyle="border-bottom:1rpx solid lightgrey;min-height:60rpx">
  40. <!-- <u-col span="3">
  41. <text>{{child.taskName}}</text>
  42. </u-col> -->
  43. <u-col span="10">
  44. <text>{{child.content}}</text>
  45. </u-col>
  46. <u-col span="2">
  47. <view style="display: flex;justify-content:flex-end">
  48. <u-tag :text="child.workHours" size="mini" borderColor="lightgrey" bgColor="lightgrey"></u-tag>
  49. </view>
  50. </u-col>
  51. </u-row>
  52. </uni-card>
  53. </scroll-view>
  54. <u-popup :show="isShowUser">
  55. <scroll-view style="height: 90vh;" scroll-y="true">
  56. <view class="item" v-for="dept in users">
  57. <view class="content" @click="chooseUser(dept)">
  58. <text>{{dept.title}}</text>
  59. </view>
  60. <view class="item" v-for="cs in dept.children">
  61. <view class="content" @click="chooseUser(cs)">
  62. <text>{{cs.title}}</text>
  63. </view>
  64. <view class="item" v-for="user in cs.children">
  65. <view class="content" @click="chooseUser(user)">
  66. <text>{{user.title}}</text>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </scroll-view>
  72. </u-popup>
  73. </view>
  74. </template>
  75. <script>
  76. import taskReport from '../../api/taskReport.js'
  77. import auth from "../../utils/js/auth.js"
  78. export default {
  79. data() {
  80. return {
  81. s_height: 0,
  82. year: "",
  83. month: "",
  84. index: 0,
  85. months: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
  86. user: {
  87. "id": "",
  88. "name": ""
  89. },
  90. isShowUser: false,
  91. users: [],
  92. reports: [],
  93. overTime: 0,
  94. leaveTime: 0
  95. }
  96. },
  97. onReady() {
  98. let that = this
  99. uni.getSystemInfo({
  100. success(res) {
  101. const w_height = res.windowHeight;
  102. var query = uni.createSelectorQuery();
  103. query.select('#header').boundingClientRect();
  104. query.exec(function(res) {
  105. that.s_height = w_height - res[0].height;
  106. })
  107. }
  108. })
  109. },
  110. onLoad() {
  111. this.user.id = auth.getId()
  112. this.user.name = auth.getName()
  113. let date = new Date();
  114. this.year = date.getFullYear()
  115. let mon = date.getMonth() + 1
  116. let day = date.getDate()
  117. if(day>26){
  118. mon+=1
  119. }
  120. this.month = mon.toString()
  121. this.index = this.months.indexOf(this.month)
  122. this.getUser()
  123. this.getdata()
  124. },
  125. methods: {
  126. getUser() {
  127. taskReport.getEmpTree().then(res => {
  128. if (res.data.success) {
  129. this.users = res.data.data
  130. }
  131. })
  132. },
  133. getdata() {
  134. let param = {
  135. "year": this.year,
  136. "month": this.month,
  137. "userId": this.user.id
  138. }
  139. taskReport.getPersonReportDetail(param).then(res => {
  140. if (res.data.success) {
  141. this.reports = res.data.data
  142. }
  143. })
  144. taskReport.getLeaveTime(param).then(res => {
  145. if (res.data.success) {
  146. this.leaveTime = res.data.data
  147. }
  148. })
  149. taskReport.getOverTime(param).then(res => {
  150. if (res.data.success) {
  151. this.overTime = res.data.data
  152. }
  153. })
  154. },
  155. showChooseUser() {
  156. this.isShowUser = true
  157. },
  158. chooseUser(e) {
  159. if (e.children.length == 0) {
  160. this.user.id = e.id
  161. this.user.name = e.title
  162. this.isShowUser = false
  163. this.getdata()
  164. }
  165. },
  166. calcColor(item) {
  167. if (item.isWork == 0) {
  168. return item.sumHours >= 8 ? '#62D557' : '#DA2424'
  169. } else if (item.isWork == 1) {
  170. return item.sumHours >= 4 ? '#62D557' : '#DA2424'
  171. } else if (item.isWork == 2) {
  172. return '#62D557'
  173. }
  174. }
  175. }
  176. }
  177. </script>
  178. <style>
  179. .item {
  180. margin-top: 12rpx;
  181. margin-left: 12px;
  182. width: calc(100%-12px);
  183. }
  184. .content {
  185. height: 60rpx;
  186. line-height: 60rpx;
  187. }
  188. .title {
  189. height: 60rpx;
  190. line-height: 60rpx;
  191. display: flex;
  192. justify-content:space-between;
  193. align-items: center;
  194. }
  195. </style>