the_clock.vue 6.7 KB

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