the_clock.vue 6.4 KB

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