the_clock.vue 6.9 KB

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