the_leave.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. <template>
  2. <view class="content">
  3. <view class="" v-if="value==0">
  4. <view class='wrap'>
  5. <view class="c-row">
  6. <view class="title">请假类型</view>
  7. <view class="con-list">
  8. <view @click='show=true'>{{detailData.leaveType}} ></view>
  9. <u-picker :range="leaveTypeList" range-key="leaveType" @confirm='ltCheck($event)' v-model="show"
  10. mode="selector">
  11. </u-picker>
  12. </view>
  13. </view>
  14. <view class="c-row">
  15. <view class="title">开始时间</view>
  16. <view class="con-list">
  17. <view @click='show1=true'>{{detailData.startDate}} ></view>
  18. <u-picker v-model="show1" mode="time" @confirm='dateChange($event)' :params="params">
  19. </u-picker>
  20. </view>
  21. </view>
  22. <view class="c-row">
  23. <view class="title">结束时间</view>
  24. <view class="con-list">
  25. <view @click='show2=true'>{{detailData.endDate}} ></view>
  26. <u-picker v-model="show2" mode="time" @confirm='dateChange1($event)' :params="params">
  27. </u-picker>
  28. </view>
  29. </view>
  30. <view class="c-row">
  31. <view class="title">时长</view>
  32. <view class="con-list">
  33. <input v-model='detailData.leaveDuration' placeholder="请输入时长"></input>
  34. </view>
  35. </view>
  36. <view class="c-row">
  37. <view class="left">请假事由</view>
  38. </view>
  39. <view style='position:relative;' class="wrap no-boder">
  40. <u-input class='textarea' v-model="detailData.reasonForLeave" :type="type" :border="border"
  41. :height="height" :auto-height="autoHeight" />
  42. <view style='position:absolute;right:10px;bottom:20px;color:#AFB3BF;'>
  43. {{detailData.reasonForLeave.length}}/100个字
  44. </view>
  45. </view>
  46. <view style='margin:5px 0;'>
  47. <u-button type="primary" class="submit" hover-class="none" @click="submit">提交</u-button>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="" v-else>
  52. <view class='wrap' v-for="(item, index) in tableData" :key="index">
  53. <view class="wenzi audit1" v-if="item.approveStatus == '待人事审核' || item.approveStatus == '待主管审核' ">审核中
  54. </view>
  55. <view class="wenzi audit2" v-if="item.status == '已通过'">已通过</view>
  56. <view class="wenzi audit3" v-if="item.status == '未通过'">未通过</view>
  57. <view class="c-row">
  58. <view class="title">请假类型 : {{item.leaveType}}</view>
  59. </view>
  60. <view class="c-row">
  61. <view class="title">请假事由 : {{item.reasonForLeave}}</view>
  62. </view>
  63. <view class="c-row">
  64. <view class="title">开始时间 : {{item.startDate}}</view>
  65. </view>
  66. <view class="c-row">
  67. <view class="title">结束时间 : {{item.endDate}}</view>
  68. </view>
  69. </view>
  70. <view v-show="isLoadMore">
  71. <uni-load-more :status="loadStatus"></uni-load-more>
  72. </view>
  73. <view class="bottom-btn">
  74. <view>
  75. <view style='width:100%;' class='flex flex-space-between'>
  76. <view @click='clocksubmit' style='width:50%;text-align:center;'>
  77. <image v-if='value==0' class="u-page__item__slot-icon"
  78. src="../../static/img/oa_office/leave/qingjia-check.png"></image>
  79. <image v-else class="u-page__item__slot-icon"
  80. src="../../static/img/oa_office/leave/qingjia.png"></image>
  81. <view :style='{"color":value==0?"#22C572":"#000"}'>请假</view>
  82. </view>
  83. <view @click='clockRecord' style='width:50%;text-align:center;'>
  84. <image v-if='value==1' class="u-page__item__slot-icon"
  85. src="../../static/img/oa_office/leave/jilu-check.png"></image>
  86. <image v-else class="u-page__item__slot-icon"
  87. src="../../static/img/oa_office/leave/jilu.png"></image>
  88. <view :style='{"color":value==1?"#22C572":"#000"}'>记录</view>
  89. </view>
  90. </view>
  91. </view>
  92. <!-- <u-button type="primary" class="submit" hover-class="none" @click="clockRecord">记录</u-button> -->
  93. </view>
  94. </view>
  95. <u-toast ref="uToast" />
  96. <view class="bottom-btn">
  97. <view>
  98. <view style='width:100%;' class='flex flex-space-between'>
  99. <view @click='clocksubmit' style='width:50%;text-align:center;'>
  100. <image v-if='value==0' class="u-page__item__slot-icon"
  101. src="../../static/img/oa_office/leave/qingjia-check.png"></image>
  102. <image v-else class="u-page__item__slot-icon"
  103. src="../../static/img/oa_office/leave/qingjia.png"></image>
  104. <view :style='{"color":value==0?"#22C572":"#000"}'>请假</view>
  105. </view>
  106. <view @click='clockRecord' style='width:50%;text-align:center;'>
  107. <image v-if='value==1' class="u-page__item__slot-icon"
  108. src="../../static/img/oa_office/leave/jilu-check.png"></image>
  109. <image v-else class="u-page__item__slot-icon" src="../../static/img/oa_office/leave/jilu.png">
  110. </image>
  111. <view :style='{"color":value==1?"#22C572":"#000"}'>记录</view>
  112. </view>
  113. </view>
  114. </view>
  115. <!-- <u-button type="primary" class="submit" hover-class="none" @click="clockRecord">记录</u-button> -->
  116. </view>
  117. </view>
  118. </template>
  119. <script>
  120. import dRili from '@/components/d-rili/d-rili.vue';
  121. export default {
  122. components: {
  123. dRili
  124. },
  125. data() {
  126. return {
  127. isLoadMore: false, //是否加载中
  128. loadStatus: 'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  129. pageSize: 10,
  130. currentPage: 1,
  131. show: false,
  132. show1: false,
  133. show2: false,
  134. detailData: {
  135. leaveType: '选择请假类型',
  136. reasonForLeave: "",
  137. startDate: '',
  138. endDate: '选择结束时间',
  139. leaveDuration: '',
  140. },
  141. params: {
  142. year: true,
  143. month: true,
  144. day: true,
  145. hour: true,
  146. minute: true,
  147. },
  148. value: 0,
  149. type: 'textarea',
  150. border: true,
  151. height: 150,
  152. autoHeight: true,
  153. // endDate1:"",
  154. // startDate1: "",
  155. leaveTypeList: [{
  156. leaveType: "事假"
  157. },
  158. {
  159. leaveType: "病假"
  160. },
  161. ],
  162. }
  163. },
  164. onReachBottom() { //上拉触底函数
  165. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  166. this.isLoadMore = true
  167. this.currentPage += 1
  168. this.getList()
  169. }
  170. },
  171. onLoad(options) {
  172. let h
  173. let m
  174. let s
  175. let _day = new Date();
  176. _day.setTime(_day.getTime());
  177. if (_day.getHours() < 10) {
  178. h = "0" + _day.getHours()
  179. } else {
  180. h = _day.getHours()
  181. }
  182. if (_day.getMinutes() < 10) {
  183. m = "0" + _day.getMinutes()
  184. } else {
  185. m = _day.getMinutes()
  186. }
  187. this.detailData.startDate = _day.getFullYear() + "-" + (_day.getMonth() + 1) + "-" + _day.getDate() +
  188. " " + h + ":" + m;
  189. },
  190. onShow() {
  191. this.getList()
  192. },
  193. methods: {
  194. getList() {
  195. this.$api.doRequest('get', '/leaveInfo/selectLeaveInfo', {
  196. pageSize: this.pageSize,
  197. currentPage: this.currentPage,
  198. pcFlag: 0,
  199. compId: uni.getStorageSync('pcUserInfo').compId,
  200. commonId: uni.getStorageSync('pcUserInfo').userId,
  201. }).then(res => {
  202. // if (res.data.code == 200) {
  203. // this.tableData = res.data.data.records
  204. // }
  205. if (res.data.code == 200) {
  206. if (res.data.data.records.length > 0) {
  207. this.isLoadMore = false
  208. this.loadStatus = 'loading'
  209. } else {
  210. this.isLoadMore = true
  211. this.loadStatus = 'nomore'
  212. }
  213. if (this.currentPage == 1) {
  214. this.tableData = res.data.data.records
  215. } else {
  216. this.tableData = this.tableData.concat(res.data.data.records)
  217. }
  218. }
  219. })
  220. },
  221. calculate() {
  222. const query = uni.createSelectorQuery().in(this);
  223. query.selectAll('.left')
  224. console.log(query)
  225. },
  226. ltCheck(e) {
  227. this.detailData.leaveType = this.leaveTypeList[e].leaveType
  228. if (this.detailData.leaveType = "事假") {
  229. this.detailData.leaveTypeKey = "1"
  230. } else {
  231. this.detailData.leaveTypeKey = "3"
  232. }
  233. },
  234. dateChange(e) {
  235. this.detailData.startDate = e.year + "-" + e.month + "-" + e.day + " " + e.hour + ":" + e.minute
  236. // this.startDate1 = e.year + "-" + e.month + "-" + e.day + "-" + e.hour + "-" + e.minute + "-" + e.second
  237. // + ":" + "00"
  238. },
  239. dateChange1(e) {
  240. this.detailData.endDate = e.year + "-" + e.month + "-" + e.day + " " + e.hour + ":" + e.minute
  241. var endtime = new Date(this.detailData.endDate)
  242. var starttime = new Date(this.detailData.startDate)
  243. console.log(endtime - starttime)
  244. this.detailData.leaveDuration = Math.floor((endtime - starttime) / (3600 * 1000))
  245. // this.endDate1 = e.year + "-" + e.month + "-" + e.day + "-" + e.hour + "-" + e.minute + "-" + e.second
  246. },
  247. submit() {
  248. if (!this.detailData.leaveType) {
  249. this.$api.msg('请假类型不能为空')
  250. return
  251. }
  252. if (!this.detailData.startDate) {
  253. this.$api.msg('请选择请假开始时间')
  254. return
  255. }
  256. if (!this.detailData.endDate) {
  257. this.$api.msg('请选择请假结束时间')
  258. return
  259. }
  260. if (!this.detailData.leaveDuration) {
  261. this.$api.msg('请输入请假时长')
  262. return
  263. }
  264. if (!this.detailData.reasonForLeave) {
  265. this.$api.msg('请假事由不能为空')
  266. return
  267. }
  268. var that = this
  269. uni.showModal({
  270. content: "确定提交请假信息?",
  271. showCancel: true,
  272. confirmText: '提交',
  273. success: function(res) {
  274. if (res.confirm) {
  275. that.detailData.compId = uni.getStorageSync('pcUserInfo').compId
  276. that.detailData.commonId = uni.getStorageSync('pcUserInfo').userId
  277. that.detailData.dept = uni.getStorageSync('pcUserInfo').deptName
  278. that.detailData.phone = uni.getStorageSync('pcUserInfo').userMobilePhone
  279. that.detailData.empName = uni.getStorageSync('userInfo').userName
  280. uni.showLoading({
  281. title: '加载中',
  282. mask: true
  283. })
  284. that.$api.doRequest('post', '/leaveInfo/api/addLeave', that.detailData)
  285. .then(res => {
  286. if (res.data.code == 200) {
  287. that.$api.msg('提交成功')
  288. uni.hideLoading()
  289. that.value = 1
  290. // uni.navigateTo({
  291. // url: '/pages/leave/the_leave_record'
  292. // })
  293. } else {
  294. that.$api.msg('提交失败')
  295. }
  296. })
  297. }
  298. }
  299. })
  300. },
  301. clockRecord() {
  302. this.value = 1
  303. uni.setNavigationBarTitle({
  304. title: '请假记录'
  305. });
  306. this.getList()
  307. // uni.navigateTo({
  308. // url: '/pages/leave/the_leave_record'
  309. // })
  310. },
  311. clocksubmit() {
  312. this.value = 0
  313. uni.setNavigationBarTitle({
  314. title: '请假'
  315. });
  316. // uni.navigateTo({
  317. // url: '/pages/leave/the_leave'
  318. // })
  319. },
  320. },
  321. }
  322. </script>
  323. <style lang='scss' scoped>
  324. page {
  325. background: #F5F6FA;
  326. }
  327. .title_b {
  328. margin: 20rpx 20rpx 0rpx 20rpx;
  329. padding: 20rpx 10rpx 20rpx 10rpx;
  330. font-size: 18px;
  331. font-weight: 550;
  332. }
  333. .c-row {
  334. display: -webkit-box;
  335. display: -webkit-flex;
  336. display: flex;
  337. -webkit-box-align: center;
  338. -webkit-align-items: center;
  339. align-items: center;
  340. padding: 20rpx 30rpx;
  341. position: relative;
  342. }
  343. .con-list {
  344. -webkit-box-flex: 1;
  345. -webkit-flex: 1;
  346. flex: 1;
  347. display: -webkit-box;
  348. display: -webkit-flex;
  349. display: flex;
  350. -webkit-box-orient: vertical;
  351. -webkit-box-direction: normal;
  352. -webkit-flex-direction: column;
  353. flex-direction: column;
  354. color: #303133;
  355. line-height: 40rpx;
  356. text-align: right;
  357. padding-right: 20rpx;
  358. }
  359. .wrap {
  360. padding-top: 15px;
  361. padding-bottom: 20px;
  362. font-size: 14px;
  363. background: #fff;
  364. margin: 10px;
  365. border-radius: 10px;
  366. input {
  367. font-size: 14px;
  368. }
  369. >.title {
  370. padding: 10px 16px;
  371. }
  372. .wenzi {
  373. text-align: right;
  374. border-radius: 10rpx;
  375. margin-right: 30rpx;
  376. height: 10rpx;
  377. }
  378. .audit1 {
  379. color: red;
  380. }
  381. .audit2 {
  382. color: #afafe6;
  383. }
  384. .audit3 {
  385. color: red;
  386. }
  387. .c-row {
  388. display: -webkit-box;
  389. display: -webkit-flex;
  390. display: flex;
  391. -webkit-box-align: center;
  392. -webkit-align-items: center;
  393. align-items: center;
  394. padding: 5rpx 30rpx;
  395. position: relative;
  396. }
  397. }
  398. /* .footer {
  399. background: #fff;
  400. position: fixed;
  401. bottom: 0;
  402. width: 100%;
  403. padding: 20px 10px;
  404. z-index: 10;
  405. .button {
  406. background: #22C572;
  407. width: 90%;
  408. margin: 20rpx auto;
  409. padding: 10px;
  410. color: #fff;
  411. text-align: center;
  412. border-radius: 30px;
  413. }
  414. } */
  415. .submit {
  416. width: 40%;
  417. background: #22C572;
  418. border-radius: 10rpx;
  419. }
  420. .bottom-btn {
  421. padding: 30rpx;
  422. background: #FFFFFF;
  423. width: 100%;
  424. position: fixed;
  425. bottom: 0rpx;
  426. z-index: 9999;
  427. }
  428. .buns_item {
  429. display: flex;
  430. padding: 80rpx 0 50rpx 0;
  431. justify-content: space-around;
  432. }
  433. .but_css {
  434. background: #22C572;
  435. width: 40%;
  436. padding: 20rpx;
  437. color: #fff;
  438. text-align: center;
  439. border-radius: 20rpx;
  440. }
  441. /deep/.u-radio-group {
  442. flex-direction: row-reverse;
  443. }
  444. .no-boder {
  445. border: 0;
  446. }
  447. .textarea {
  448. background: #F9F9FA;
  449. border: 1px solid #EEEEEE;
  450. }
  451. .u-page__item__slot-icon {
  452. width: 20px;
  453. height: 20px;
  454. }
  455. .content {
  456. padding-bottom: 150rpx;
  457. overflow: hidden;
  458. }
  459. </style>