the_clock.vue 5.7 KB

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