the_clock.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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 @change="groupChange" 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" v-if='show1'>
  14. <view class="title">其他原因</view>
  15. <view class="con-list">
  16. <input type="digit" @input='calculate' name="otherReasons" v-model='detailData.otherReasons'
  17. placeholder="请输入其他原因"></input>
  18. </view>
  19. </view>
  20. <view class="c-row">
  21. <view class="title">目标位置</view>
  22. <view class="con-list">
  23. <view @click='show=true'>{{detailData.targetLocation}}</view>
  24. <u-picker :range="warehouseBaseInfoList" range-key="warehouseName" @confirm='targetLPicker($event)'
  25. v-model="show" mode="selector">
  26. </u-picker>
  27. </view>
  28. </view>
  29. <view class="c-row">
  30. <view class="title">打卡距离</view>
  31. <view class="con-list">
  32. <input type="number" v-model='clockDistance' placeholder="重新获取" :disabled="true"></input>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="footer">
  37. <view @click='submit' class="button">提交</view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. export default {
  43. data() {
  44. return {
  45. typevalue: '1',
  46. show: false,
  47. show1: false,
  48. detailData: {
  49. clockType: '',
  50. otherReasons: '',
  51. targetLocation: '请选择目标位置',
  52. clockDistance: '重新获取',
  53. },
  54. clockDistance:"",
  55. warehouseType:'1',
  56. warehouseBaseInfoList:[],
  57. }
  58. },
  59. onLoad() {
  60. this.getWarehouse()
  61. // this.getLocation()
  62. },
  63. methods: {
  64. calculate() {
  65. const query = uni.createSelectorQuery().in(this);
  66. query.selectAll('.left')
  67. console.log(query)
  68. },
  69. groupChange(e) {
  70. console.log(e)
  71. this.detailData.clockType = e
  72. if (e == 1 || e == null) {
  73. this.show1 = false
  74. }
  75. else{
  76. this.show1 = true
  77. }
  78. },
  79. getWarehouse() {
  80. this.$api.doRequest('get', '/warehouseBaseInfo/selectWarehouse', {
  81. compId: uni.getStorageSync("pcUserInfo").compId,
  82. warehouseType: '1'
  83. }).then(res => {
  84. if (res.data.data.length != 0) {
  85. this.warehouseBaseInfoList = res.data.data
  86. uni.getLocation({
  87. type: 'gcj02',
  88. geocode: true,
  89. success: function(res) {
  90. console.log('获取位置数据:', res);
  91. console.log('当前位置的经度:' + res.longitude);
  92. console.log('当前位置的纬度:' + res.latitude);
  93. this.lat2 = res.latitude
  94. this.lng2 = res.longitude
  95. if(this.warehouseBaseInfoList.length > 0){
  96. this.clockDistance = this.utils.getDistance(this.warehouseBaseInfoList[0].warehousePositioning.split(',')[1],
  97. this.warehouseBaseInfoList[0].warehousePositioning.split(',')[0], this.lat2, this.lng2)
  98. }
  99. },
  100. fail:function(req){
  101. console.log(req)
  102. }
  103. });
  104. }
  105. })
  106. },
  107. targetLPicker(e) {
  108. this.detailData.targetLocation = this.warehouseBaseInfoList[e[0]].warehouseName
  109. this.clockDistance = this.utils.getDistance(this.warehouseBaseInfoList[e[0]].warehousePositioning.split(',')[1],
  110. this.warehouseBaseInfoList[e[0]].warehousePositioning.split(',')[0], this.lat2, this.lng2)
  111. },
  112. submit() {
  113. // if (!this.detailData.clockType) {
  114. // this.$api.msg('打卡原因不能为空')
  115. // return
  116. // }
  117. // if (this.typevalue == 3) {
  118. // if (!this.detailData.otherReasons) {
  119. // this.$api.msg('其他原因不能为空')
  120. // return
  121. // }
  122. // }
  123. // if (!this.detailData.targetLocation) {
  124. // this.$api.msg('目标位置不能为空')
  125. // return
  126. // }
  127. uni.showModal({
  128. content: "确定提交打卡信息?",
  129. showCancel: true,
  130. confirmText: '提交',
  131. success: function(res) {
  132. if (res.confirm) {
  133. }
  134. }
  135. })
  136. },
  137. }
  138. }
  139. </script>
  140. <style lang='scss' scoped>
  141. page {
  142. background: #F5F6FA;
  143. }
  144. .title_b {
  145. margin: 20rpx 20rpx 0rpx 20rpx;
  146. padding: 20rpx 10rpx 20rpx 10rpx;
  147. font-size: 18px;
  148. font-weight: 550;
  149. }
  150. .c-row {
  151. display: -webkit-box;
  152. display: -webkit-flex;
  153. display: flex;
  154. -webkit-box-align: center;
  155. -webkit-align-items: center;
  156. align-items: center;
  157. padding: 20rpx 30rpx;
  158. position: relative;
  159. }
  160. .con-list {
  161. -webkit-box-flex: 1;
  162. -webkit-flex: 1;
  163. flex: 1;
  164. display: -webkit-box;
  165. display: -webkit-flex;
  166. display: flex;
  167. -webkit-box-orient: vertical;
  168. -webkit-box-direction: normal;
  169. -webkit-flex-direction: column;
  170. flex-direction: column;
  171. color: #303133;
  172. line-height: 40rpx;
  173. text-align: right;
  174. padding-right: 20rpx;
  175. }
  176. .wrap {
  177. padding-bottom: 10px;
  178. font-size: 14px;
  179. background: #fff;
  180. margin: 10px;
  181. border-radius: 10px;
  182. input {
  183. font-size: 14px;
  184. }
  185. >.title {
  186. padding: 10px 16px;
  187. }
  188. }
  189. .footer {
  190. background: #fff;
  191. position: fixed;
  192. bottom: 0;
  193. width: 100%;
  194. padding: 20px 10px;
  195. z-index: 10;
  196. .button {
  197. background: #22C572;
  198. width: 90%;
  199. margin: 20rpx auto;
  200. padding: 10px;
  201. color: #fff;
  202. text-align: center;
  203. border-radius: 30px;
  204. }
  205. }
  206. .buns_item {
  207. display: flex;
  208. padding: 80rpx 0 50rpx 0;
  209. justify-content: space-around;
  210. }
  211. .but_css {
  212. background: #22C572;
  213. width: 40%;
  214. padding: 20rpx;
  215. color: #fff;
  216. text-align: center;
  217. border-radius: 20rpx;
  218. }
  219. /deep/.u-radio-group {
  220. flex-direction: row-reverse;
  221. }
  222. </style>