the_leave.vue 13 KB

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