the_leave.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. <u-button type="primary" class="submit" hover-class="none" @click="clockRecord">记录</u-button>
  52. <u-button type="primary" class="submit" hover-class="none" @click="submit">提交</u-button>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. export default {
  58. data() {
  59. return {
  60. show: false,
  61. show1: false,
  62. show2: false,
  63. detailData: {
  64. leaveType:'选择请假类型',
  65. reasonForLeave:"",
  66. startDate:'',
  67. endDate:'选择结束时间',
  68. leaveDuration:'',
  69. },
  70. params: {
  71. year: true,
  72. month: true,
  73. day: true,
  74. hour: true,
  75. minute: true,
  76. },
  77. type: 'textarea',
  78. border: true,
  79. height: 150,
  80. autoHeight: true,
  81. // endDate1:"",
  82. // startDate1: "",
  83. leaveTypeList: [{
  84. leaveType: "事假"
  85. },
  86. {
  87. leaveType: "病假"
  88. },
  89. ],
  90. }
  91. },
  92. onLoad(options) {
  93. let h
  94. let m
  95. let s
  96. let _day = new Date();
  97. _day.setTime(_day.getTime());
  98. if(_day.getHours() < 10 ){
  99. h = "0" + _day.getHours()
  100. }
  101. else{
  102. h = _day.getHours()
  103. }
  104. if(_day.getMinutes() < 10 ){
  105. m = "0" + _day.getMinutes()
  106. }
  107. else{
  108. m = _day.getMinutes()
  109. }
  110. this.detailData.startDate = _day.getFullYear() + "-" + (_day.getMonth() + 1) + "-" + _day.getDate()
  111. + " " + h + ":" + m;
  112. },
  113. methods: {
  114. calculate() {
  115. const query = uni.createSelectorQuery().in(this);
  116. query.selectAll('.left')
  117. console.log(query)
  118. },
  119. ltCheck(e) {
  120. this.detailData.leaveType = this.leaveTypeList[e].leaveType
  121. if(this.detailData.leaveType = "事假"){
  122. this.detailData.leaveTypeKey = "1"
  123. }
  124. else{
  125. this.detailData.leaveTypeKey = "3"
  126. }
  127. },
  128. dateChange(e) {
  129. this.detailData.startDate = e.year + "-" + e.month + "-" + e.day + " " + e.hour + ":" + e.minute
  130. // this.startDate1 = e.year + "-" + e.month + "-" + e.day + "-" + e.hour + "-" + e.minute + "-" + e.second
  131. // + ":" + "00"
  132. },
  133. dateChange1(e) {
  134. this.detailData.endDate = e.year + "-" + e.month + "-" + e.day + " " + e.hour + ":" + e.minute
  135. // this.endDate1 = e.year + "-" + e.month + "-" + e.day + "-" + e.hour + "-" + e.minute + "-" + e.second
  136. },
  137. submit() {
  138. if (!this.detailData.leaveType) {
  139. this.$api.msg('请假类型不能为空')
  140. return
  141. }
  142. if (!this.detailData.startDate) {
  143. this.$api.msg('请选择请假开始时间')
  144. return
  145. }
  146. if (!this.detailData.endDate) {
  147. this.$api.msg('请选择请假结束时间')
  148. return
  149. }
  150. if (!this.detailData.leaveDuration) {
  151. this.$api.msg('请输入请假时长')
  152. return
  153. }
  154. if (!this.detailData.reasonForLeave) {
  155. this.$api.msg('请假事由不能为空')
  156. return
  157. }
  158. var that = this
  159. uni.showModal({
  160. content: "确定提交请假信息?",
  161. showCancel: true,
  162. confirmText: '提交',
  163. success: function(res) {
  164. if (res.confirm) {
  165. that.detailData.compId = uni.getStorageSync('pcUserInfo').compId
  166. that.detailData.commonId = uni.getStorageSync('pcUserInfo').userId
  167. that.detailData.dept = uni.getStorageSync('pcUserInfo').deptName
  168. that.detailData.phone = uni.getStorageSync('pcUserInfo').userMobilePhone
  169. that.detailData.empName = uni.getStorageSync('userInfo').userName
  170. that.$api.doRequest('post', '/leaveInfo/api/addLeave', that.detailData)
  171. .then(res => {
  172. if (res.data.code == 200) {
  173. that.$api.msg('提交成功')
  174. uni.navigateTo({
  175. url: '/pages/leave/the_leave_record'
  176. })
  177. } else {
  178. that.$api.msg('提交失败')
  179. }
  180. })
  181. }
  182. }
  183. })
  184. },
  185. clockRecord() {
  186. uni.navigateTo({
  187. url: '/pages/leave/the_leave_record'
  188. })
  189. },
  190. },
  191. }
  192. </script>
  193. <style lang='scss' scoped>
  194. page {
  195. background: #F5F6FA;
  196. }
  197. .title_b {
  198. margin: 20rpx 20rpx 0rpx 20rpx;
  199. padding: 20rpx 10rpx 20rpx 10rpx;
  200. font-size: 18px;
  201. font-weight: 550;
  202. }
  203. .c-row {
  204. display: -webkit-box;
  205. display: -webkit-flex;
  206. display: flex;
  207. -webkit-box-align: center;
  208. -webkit-align-items: center;
  209. align-items: center;
  210. padding: 20rpx 30rpx;
  211. position: relative;
  212. }
  213. .con-list {
  214. -webkit-box-flex: 1;
  215. -webkit-flex: 1;
  216. flex: 1;
  217. display: -webkit-box;
  218. display: -webkit-flex;
  219. display: flex;
  220. -webkit-box-orient: vertical;
  221. -webkit-box-direction: normal;
  222. -webkit-flex-direction: column;
  223. flex-direction: column;
  224. color: #303133;
  225. line-height: 40rpx;
  226. text-align: right;
  227. padding-right: 20rpx;
  228. }
  229. .wrap {
  230. padding-bottom: 10px;
  231. font-size: 14px;
  232. background: #fff;
  233. margin: 10px;
  234. border-radius: 10px;
  235. input {
  236. font-size: 14px;
  237. }
  238. >.title {
  239. padding: 10px 16px;
  240. }
  241. }
  242. /* .footer {
  243. background: #fff;
  244. position: fixed;
  245. bottom: 0;
  246. width: 100%;
  247. padding: 20px 10px;
  248. z-index: 10;
  249. .button {
  250. background: #22C572;
  251. width: 90%;
  252. margin: 20rpx auto;
  253. padding: 10px;
  254. color: #fff;
  255. text-align: center;
  256. border-radius: 30px;
  257. }
  258. } */
  259. .submit {
  260. width: 40%;
  261. background: #22C572;
  262. border-radius: 10rpx;
  263. }
  264. .bottom-btn {
  265. padding: 30rpx;
  266. background: #FFFFFF;
  267. width: 100%;
  268. position: fixed;
  269. bottom: 0rpx;
  270. display: flex;
  271. z-index: 9999;
  272. }
  273. .buns_item {
  274. display: flex;
  275. padding: 80rpx 0 50rpx 0;
  276. justify-content: space-around;
  277. }
  278. .but_css {
  279. background: #22C572;
  280. width: 40%;
  281. padding: 20rpx;
  282. color: #fff;
  283. text-align: center;
  284. border-radius: 20rpx;
  285. }
  286. /deep/.u-radio-group {
  287. flex-direction: row-reverse;
  288. }
  289. .no-boder {
  290. border: 0;
  291. }
  292. .textarea {
  293. background: #F9F9FA;
  294. border: 1px solid #EEEEEE;
  295. }
  296. </style>