the_clock.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <view>
  3. <view class='wrap'>
  4. <view class="c-row">
  5. <view class="title">打卡原因</view>
  6. <view class="con-list">
  7. <u-radio-group v-model="typevalue">
  8. <u-radio key="3" label="下班" name="3">下班</u-radio>
  9. <u-radio key="1" label="上班" name="1">上班</u-radio>
  10. </u-radio-group>
  11. </view>
  12. </view>
  13. <view class="c-row">
  14. <view class="title">目标位置</view>
  15. <view class="con-list">
  16. <view @click='show=true'>{{detailData.targetLocation}}</view>
  17. <u-picker :range="warehouseBaseInfoList" range-key="warehouseName" @confirm='targetLPicker($event)'
  18. v-model="show" mode="selector">
  19. </u-picker>
  20. </view>
  21. </view>
  22. <view class="c-row">
  23. <view class="title">打卡距离</view>
  24. <view class="con-list">
  25. <view>{{clockDistance}}</view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="footer">
  30. <view @click='clockRecord' class="button">记录</view>
  31. <view @click='submit' class="button">提交</view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. typevalue: '1',
  40. show: false,
  41. detailData: {
  42. compId: '',
  43. clockType: '',
  44. otherReasons: '',
  45. targetLocation: '请选择目标位置',
  46. clockDistance: '重新获取',
  47. },
  48. clockDistance: "",
  49. warehouseType: '1',
  50. warehouseBaseInfoList: [],
  51. }
  52. },
  53. onLoad() {
  54. this.getWarehouse()
  55. // this.getLocation()
  56. },
  57. methods: {
  58. calculate() {
  59. const query = uni.createSelectorQuery().in(this);
  60. query.selectAll('.left')
  61. console.log(query)
  62. },
  63. getWarehouse() {
  64. var that = this
  65. this.$api.doRequest('get', '/warehouseBaseInfo/selectWarehouse', {
  66. compId: uni.getStorageSync("pcUserInfo").compId,
  67. warehouseType: '1'
  68. }).then(res => {
  69. if (res.data.data.length != 0) {
  70. that.warehouseBaseInfoList = res.data.data
  71. uni.getLocation({
  72. type: 'gcj02',
  73. geocode: true,
  74. success: function(res) {
  75. console.log('获取位置数据:', res);
  76. console.log('当前位置的经度:' + res.longitude);
  77. console.log('当前位置的纬度:' + res.latitude);
  78. that.lat2 = res.latitude
  79. that.lng2 = res.longitude
  80. if (that.warehouseBaseInfoList.length > 0) {
  81. that.clockDistance = that.utils.getDistance(that
  82. .warehouseBaseInfoList[0].warehousePositioning.split(',')[
  83. 0],
  84. that.warehouseBaseInfoList[0].warehousePositioning.split(
  85. ',')[1], that.lat2, that.lng2)
  86. that.detailData.targetLocation = that.warehouseBaseInfoList[0].warehouseName
  87. }
  88. },
  89. fail: function(req) {
  90. console.log(req)
  91. }
  92. });
  93. }
  94. })
  95. },
  96. targetLPicker(e) {
  97. this.detailData.targetLocation = this.warehouseBaseInfoList[e[0]].warehouseName
  98. this.clockDistance = this.utils.getDistance(this.warehouseBaseInfoList[e[0]].warehousePositioning.split(
  99. ',')[0],
  100. this.warehouseBaseInfoList[e[0]].warehousePositioning.split(',')[1], this.lat2, this.lng2)
  101. },
  102. submit() {
  103. if (!this.typevalue) {
  104. this.$api.msg('打卡原因不能为空')
  105. return
  106. }
  107. if (!this.detailData.targetLocation) {
  108. this.$api.msg('请选择目标位置')
  109. return
  110. }
  111. var that = this
  112. uni.showModal({
  113. content: "确定提交打卡信息?",
  114. showCancel: true,
  115. confirmText: '提交',
  116. success: function(res) {
  117. if (res.confirm) {
  118. that.detailData.compId = uni.getStorageSync('pcUserInfo').compId
  119. that.detailData.commonId = uni.getStorageSync('pcUserInfo').userId
  120. that.detailData.dept = uni.getStorageSync('pcUserInfo').deptName
  121. that.detailData.phone = uni.getStorageSync('pcUserInfo').userMobilePhone
  122. that.detailData.empName = uni.getStorageSync('userInfo').userName
  123. that.detailData.clockType = that.typevalue
  124. if(that.clockDistance.indexOf("km") > -1){
  125. that.detailData.clockDistance = that.clockDistance.replace("km","")*1000
  126. }else{
  127. that.detailData.clockDistance = that.clockDistance.replace("m","")
  128. }
  129. console.log(that.detailData)
  130. that.$api.doRequest('post', '/clockInfo/api/addClock', that.detailData)
  131. .then(res => {
  132. console.log(res.data)
  133. if (res.data.code == 200) {
  134. that.$api.msg('提交成功')
  135. } else {
  136. that.$api.msg('提交失败')
  137. }
  138. })
  139. }
  140. }
  141. })
  142. },
  143. clockRecord() {
  144. uni.navigateTo({
  145. url: '/pages/clock/the_clock_record'
  146. })
  147. },
  148. },
  149. }
  150. </script>
  151. <style lang='scss' scoped>
  152. page {
  153. background: #F5F6FA;
  154. }
  155. .title_b {
  156. margin: 20rpx 20rpx 0rpx 20rpx;
  157. padding: 20rpx 10rpx 20rpx 10rpx;
  158. font-size: 18px;
  159. font-weight: 550;
  160. }
  161. .c-row {
  162. display: -webkit-box;
  163. display: -webkit-flex;
  164. display: flex;
  165. -webkit-box-align: center;
  166. -webkit-align-items: center;
  167. align-items: center;
  168. padding: 20rpx 30rpx;
  169. position: relative;
  170. }
  171. .con-list {
  172. -webkit-box-flex: 1;
  173. -webkit-flex: 1;
  174. flex: 1;
  175. display: -webkit-box;
  176. display: -webkit-flex;
  177. display: flex;
  178. -webkit-box-orient: vertical;
  179. -webkit-box-direction: normal;
  180. -webkit-flex-direction: column;
  181. flex-direction: column;
  182. color: #303133;
  183. line-height: 40rpx;
  184. text-align: right;
  185. padding-right: 20rpx;
  186. }
  187. .wrap {
  188. padding-bottom: 10px;
  189. font-size: 14px;
  190. background: #fff;
  191. margin: 10px;
  192. border-radius: 10px;
  193. input {
  194. font-size: 14px;
  195. }
  196. >.title {
  197. padding: 10px 16px;
  198. }
  199. }
  200. .footer {
  201. background: #fff;
  202. position: fixed;
  203. bottom: 0;
  204. width: 100%;
  205. padding: 20px 10px;
  206. z-index: 10;
  207. .button {
  208. background: #22C572;
  209. width: 90%;
  210. margin: 20rpx auto;
  211. padding: 10px;
  212. color: #fff;
  213. text-align: center;
  214. border-radius: 30px;
  215. }
  216. }
  217. .buns_item {
  218. display: flex;
  219. padding: 80rpx 0 50rpx 0;
  220. justify-content: space-around;
  221. }
  222. .but_css {
  223. background: #22C572;
  224. width: 40%;
  225. padding: 20rpx;
  226. color: #fff;
  227. text-align: center;
  228. border-radius: 20rpx;
  229. }
  230. /deep/.u-radio-group {
  231. flex-direction: row-reverse;
  232. }
  233. </style>