the_clock.vue 7.3 KB

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