the_leave.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <view>
  3. <view class='wrap'>
  4. <view class="c-row">
  5. <view class="title">请假类型</view>
  6. <view class="con-list">
  7. <view @click='show=true'>{{detailData.leaveType}} ></view>
  8. <u-picker :range="leaveTypeList" range-key="leaveType"@confirm='ltCheck($event)' v-model="show" mode="selector">
  9. </u-picker>
  10. </view>
  11. </view>
  12. <view class="c-row">
  13. <view class="title">开始时间</view>
  14. <view class="con-list">
  15. <view @click='show1=true'>{{detailData.startDate}} ></view>
  16. <u-picker v-model="show1" mode="time" @confirm='dateChange($event)' :params="params">
  17. </u-picker>
  18. </view>
  19. </view>
  20. <view class="c-row">
  21. <view class="title">结束时间</view>
  22. <view class="con-list">
  23. <view @click='show2=true'>{{detailData.endDate}} ></view>
  24. <u-picker v-model="show2" mode="time" @confirm='dateChange1($event)' :params="params">
  25. </u-picker>
  26. </view>
  27. </view>
  28. <view class="c-row">
  29. <view class="title">时长</view>
  30. <view class="con-list">
  31. <input v-model='detailData.leaveDuration' placeholder="请输入时长"></input>
  32. </view>
  33. </view>
  34. <view class="c-row">
  35. <view class="left">请假事由</view>
  36. </view>
  37. <view style='position:relative;' class="wrap no-boder">
  38. <u-input class='textarea' v-model="detailData.reasonForLeave" :type="type" :border="border"
  39. :height="height" :auto-height="autoHeight" />
  40. <view style='position:absolute;right:10px;bottom:20px;color:#AFB3BF;'>
  41. {{detailData.reasonForLeave.length}}/100个字
  42. </view>
  43. </view>
  44. </view>
  45. <!-- <view class="footer">
  46. <view @click='clockRecord' class="button">记录</view>
  47. <view @click='submit' class="button">提交</view>
  48. </view> -->
  49. <u-toast ref="uToast" />
  50. <view class="bottom-btn">
  51. <view style='margin:5px 0;'>
  52. <u-button type="primary" class="submit" hover-class="none" @click="submit">提交</u-button>
  53. </view>
  54. <view>
  55. <view style='width:100%;' class='flex flex-space-between'>
  56. <view @click='clocksubmit' style='width:50%;text-align:center;'>
  57. <image
  58. v-if='value==0'
  59. class="u-page__item__slot-icon"
  60. src="../../static/img/oa_office/leave/qingjia-check.png"
  61. ></image>
  62. <image
  63. v-else
  64. class="u-page__item__slot-icon"
  65. src="../../static/img/oa_office/leave/qingjia.png"
  66. ></image>
  67. <view :style='{"color":value==0?"#22C572":"#000"}'>请假</view>
  68. </view>
  69. <view @click='clockRecord' style='width:50%;text-align:center;'>
  70. <image
  71. v-if='value==1'
  72. class="u-page__item__slot-icon"
  73. src="../../static/img/oa_office/leave/jilu-check.png"
  74. ></image>
  75. <image
  76. v-else
  77. class="u-page__item__slot-icon"
  78. src="../../static/img/oa_office/leave/jilu.png"
  79. ></image>
  80. <view :style='{"color":value==1?"#22C572":"#000"}'>记录</view>
  81. </view>
  82. </view>
  83. </view>
  84. <!-- <u-button type="primary" class="submit" hover-class="none" @click="clockRecord">记录</u-button> -->
  85. </view>
  86. </view>
  87. </template>
  88. <script>
  89. export default {
  90. data() {
  91. return {
  92. show: false,
  93. show1: false,
  94. show2: false,
  95. detailData: {
  96. leaveType:'选择请假类型',
  97. reasonForLeave:"",
  98. startDate:'',
  99. endDate:'选择结束时间',
  100. leaveDuration:'',
  101. },
  102. params: {
  103. year: true,
  104. month: true,
  105. day: true,
  106. hour: true,
  107. minute: true,
  108. },
  109. value:0,
  110. type: 'textarea',
  111. border: true,
  112. height: 150,
  113. autoHeight: true,
  114. // endDate1:"",
  115. // startDate1: "",
  116. leaveTypeList: [{
  117. leaveType: "事假"
  118. },
  119. {
  120. leaveType: "病假"
  121. },
  122. ],
  123. }
  124. },
  125. onLoad(options) {
  126. let h
  127. let m
  128. let s
  129. let _day = new Date();
  130. _day.setTime(_day.getTime());
  131. if(_day.getHours() < 10 ){
  132. h = "0" + _day.getHours()
  133. }
  134. else{
  135. h = _day.getHours()
  136. }
  137. if(_day.getMinutes() < 10 ){
  138. m = "0" + _day.getMinutes()
  139. }
  140. else{
  141. m = _day.getMinutes()
  142. }
  143. this.detailData.startDate = _day.getFullYear() + "-" + (_day.getMonth() + 1) + "-" + _day.getDate()
  144. + " " + h + ":" + m;
  145. },
  146. methods: {
  147. calculate() {
  148. const query = uni.createSelectorQuery().in(this);
  149. query.selectAll('.left')
  150. console.log(query)
  151. },
  152. ltCheck(e) {
  153. this.detailData.leaveType = this.leaveTypeList[e].leaveType
  154. if(this.detailData.leaveType = "事假"){
  155. this.detailData.leaveTypeKey = "1"
  156. }
  157. else{
  158. this.detailData.leaveTypeKey = "3"
  159. }
  160. },
  161. dateChange(e) {
  162. this.detailData.startDate = e.year + "-" + e.month + "-" + e.day + " " + e.hour + ":" + e.minute
  163. // this.startDate1 = e.year + "-" + e.month + "-" + e.day + "-" + e.hour + "-" + e.minute + "-" + e.second
  164. // + ":" + "00"
  165. },
  166. dateChange1(e) {
  167. this.detailData.endDate = e.year + "-" + e.month + "-" + e.day + " " + e.hour + ":" + e.minute
  168. var endtime=new Date(this.detailData.endDate)
  169. var starttime=new Date(this.detailData.startDate)
  170. console.log(endtime-starttime)
  171. this.detailData.leaveDuration=Math.floor((endtime-starttime)/(3600*1000))
  172. // this.endDate1 = e.year + "-" + e.month + "-" + e.day + "-" + e.hour + "-" + e.minute + "-" + e.second
  173. },
  174. submit() {
  175. if (!this.detailData.leaveType) {
  176. this.$api.msg('请假类型不能为空')
  177. return
  178. }
  179. if (!this.detailData.startDate) {
  180. this.$api.msg('请选择请假开始时间')
  181. return
  182. }
  183. if (!this.detailData.endDate) {
  184. this.$api.msg('请选择请假结束时间')
  185. return
  186. }
  187. if (!this.detailData.leaveDuration) {
  188. this.$api.msg('请输入请假时长')
  189. return
  190. }
  191. if (!this.detailData.reasonForLeave) {
  192. this.$api.msg('请假事由不能为空')
  193. return
  194. }
  195. var that = this
  196. uni.showModal({
  197. content: "确定提交请假信息?",
  198. showCancel: true,
  199. confirmText: '提交',
  200. success: function(res) {
  201. if (res.confirm) {
  202. that.detailData.compId = uni.getStorageSync('pcUserInfo').compId
  203. that.detailData.commonId = uni.getStorageSync('pcUserInfo').userId
  204. that.detailData.dept = uni.getStorageSync('pcUserInfo').deptName
  205. that.detailData.phone = uni.getStorageSync('pcUserInfo').userMobilePhone
  206. that.detailData.empName = uni.getStorageSync('userInfo').userName
  207. that.$api.doRequest('post', '/leaveInfo/api/addLeave', that.detailData)
  208. .then(res => {
  209. if (res.data.code == 200) {
  210. that.$api.msg('提交成功')
  211. uni.navigateTo({
  212. url: '/pages/leave/the_leave_record'
  213. })
  214. } else {
  215. that.$api.msg('提交失败')
  216. }
  217. })
  218. }
  219. }
  220. })
  221. },
  222. clockRecord() {
  223. uni.navigateTo({
  224. url: '/pages/leave/the_leave_record'
  225. })
  226. },
  227. clocksubmit() {
  228. uni.navigateTo({
  229. url: '/pages/leave/the_leave'
  230. })
  231. },
  232. },
  233. }
  234. </script>
  235. <style lang='scss' scoped>
  236. page {
  237. background: #F5F6FA;
  238. }
  239. .title_b {
  240. margin: 20rpx 20rpx 0rpx 20rpx;
  241. padding: 20rpx 10rpx 20rpx 10rpx;
  242. font-size: 18px;
  243. font-weight: 550;
  244. }
  245. .c-row {
  246. display: -webkit-box;
  247. display: -webkit-flex;
  248. display: flex;
  249. -webkit-box-align: center;
  250. -webkit-align-items: center;
  251. align-items: center;
  252. padding: 20rpx 30rpx;
  253. position: relative;
  254. }
  255. .con-list {
  256. -webkit-box-flex: 1;
  257. -webkit-flex: 1;
  258. flex: 1;
  259. display: -webkit-box;
  260. display: -webkit-flex;
  261. display: flex;
  262. -webkit-box-orient: vertical;
  263. -webkit-box-direction: normal;
  264. -webkit-flex-direction: column;
  265. flex-direction: column;
  266. color: #303133;
  267. line-height: 40rpx;
  268. text-align: right;
  269. padding-right: 20rpx;
  270. }
  271. .wrap {
  272. padding-bottom: 10px;
  273. font-size: 14px;
  274. background: #fff;
  275. margin: 10px;
  276. border-radius: 10px;
  277. input {
  278. font-size: 14px;
  279. }
  280. >.title {
  281. padding: 10px 16px;
  282. }
  283. }
  284. /* .footer {
  285. background: #fff;
  286. position: fixed;
  287. bottom: 0;
  288. width: 100%;
  289. padding: 20px 10px;
  290. z-index: 10;
  291. .button {
  292. background: #22C572;
  293. width: 90%;
  294. margin: 20rpx auto;
  295. padding: 10px;
  296. color: #fff;
  297. text-align: center;
  298. border-radius: 30px;
  299. }
  300. } */
  301. .submit {
  302. width: 40%;
  303. background: #22C572;
  304. border-radius: 10rpx;
  305. }
  306. .bottom-btn {
  307. padding: 30rpx;
  308. background: #FFFFFF;
  309. width: 100%;
  310. position: fixed;
  311. bottom: 0rpx;
  312. z-index: 9999;
  313. }
  314. .buns_item {
  315. display: flex;
  316. padding: 80rpx 0 50rpx 0;
  317. justify-content: space-around;
  318. }
  319. .but_css {
  320. background: #22C572;
  321. width: 40%;
  322. padding: 20rpx;
  323. color: #fff;
  324. text-align: center;
  325. border-radius: 20rpx;
  326. }
  327. /deep/.u-radio-group {
  328. flex-direction: row-reverse;
  329. }
  330. .no-boder {
  331. border: 0;
  332. }
  333. .textarea {
  334. background: #F9F9FA;
  335. border: 1px solid #EEEEEE;
  336. }
  337. .u-page__item__slot-icon{
  338. width:20px;
  339. height:20px;
  340. }
  341. </style>