the_leave.vue 6.6 KB

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