the_clock.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <view>
  3. <view class="dk" v-if="value==0">
  4. <view class='wrap'>
  5. <view class="c-row">
  6. <view class="title">打卡原因</view>
  7. <view style='padding:0;' class="con-list">
  8. <u-radio-group activeColor="#22C572" v-model="typevalue">
  9. <u-radio key="3" label="下班" name="3">下班</u-radio>
  10. <u-radio key="1" label="上班" name="1">上班</u-radio>
  11. </u-radio-group>
  12. </view>
  13. </view>
  14. <view class="c-row">
  15. <view class="title">目标位置</view>
  16. <view class="con-list">
  17. <view @click='show=true'>{{detailData.targetLocation}}</view>
  18. <u-picker :range="warehouseBaseInfoList" range-key="warehouseName"
  19. @confirm='targetLPicker($event)' v-model="show" mode="selector">
  20. </u-picker>
  21. </view>
  22. </view>
  23. <view class="c-row">
  24. <view class="title">打卡距离</view>
  25. <view class="con-list">
  26. <view>{{clockDistance}}</view>
  27. </view>
  28. </view>
  29. </view>
  30. <view>
  31. <u-button type="primary" class="submit" hover-class="none" @click="submit">打卡</u-button>
  32. </view>
  33. </view>
  34. <view class="jl" v-else>
  35. <view class="uni-container">
  36. <view class="top">
  37. <view class="center">月份</view>
  38. <view @click='show=true'>{{createDate}}</view>
  39. <u-picker v-model="show" mode="time" @confirm='dateChange($event)' :params="params"></u-picker>
  40. </view>
  41. <uni-table border stripe emptyText="暂无更多数据">
  42. <!-- 表头行 -->
  43. <uni-tr>
  44. <uni-th align="center" width="50">日期</uni-th>
  45. <uni-th align="center" width="50">上班时间</uni-th>
  46. <uni-th align="center" width="50">下班时间</uni-th>
  47. </uni-tr>
  48. <!-- 表格数据行 -->
  49. <uni-tr v-for="(item, index) in tableData" :key="index">
  50. <uni-td align="center" style="height: 30px;">{{ item.createDate.split(" ")[0] }}</uni-td>
  51. <uni-td align="center">
  52. <view class="toClockDate" v-if="item.toClockDate">{{ item.toClockDate.split(" ")[1] }}
  53. </view>
  54. <view class="toClockDate" v-else-if="!item.toClockDate">
  55. <button v-if='item.approveStatus ==null && item.status == null' @click='supp(item)'
  56. class="uni-button" size="mini" type="primary" align="center"
  57. style="height: 30px;">补卡</button>
  58. <button v-if='item.approveStatus=="待人事审核"' class='listitemStatus audit Regular'
  59. size="mini" type="primary" align="center" style="height: 30px;">审核中</button>
  60. <button v-if='item.status=="补卡失败"' class='listitemStatus notPass Regular' size="mini"
  61. type="primary" align="center" style="height: 30px;">补卡失败</button>
  62. <button v-if='item.status=="补卡成功"' class='listitemStatus pass Regular' size="mini"
  63. type="primary" align="center" style="height: 30px;">补卡成功</button>
  64. </view>
  65. </uni-td>
  66. <uni-td align="center">
  67. <view class="offClockDate" v-if="item.offClockDate">{{ item.offClockDate.split(" ")[1] }}
  68. </view>
  69. <view class="offClockDate" v-else-if="!item.offClockDate">
  70. <button v-if='item.approveStatus ==null && item.status == null' @click='supp(item)'
  71. class="uni-button" size="mini" type="primary" align="center"
  72. style="height: 30px;">补卡</button>
  73. <button v-if='item.approveStatus=="待人事审核"' class='listitemStatus audit Regular'
  74. size="mini" type="primary" align="center" style="height: 30px;">审核中</button>
  75. <button v-if='item.status=="补卡失败"' class='listitemStatus notPass Regular' size="mini"
  76. type="primary" align="center" style="height: 30px;">补卡失败</button>
  77. <button v-if='item.status=="补卡成功"' class='listitemStatus pass Regular' size="mini"
  78. type="primary" align="center" style="height: 30px;">补卡成功</button>
  79. </view>
  80. </uni-td>
  81. </uni-tr>
  82. </uni-table>
  83. </view>
  84. </view>
  85. <u-toast ref="uToast" />
  86. <view class="bottom-btn">
  87. <view @click='clocksubmit'>
  88. <image v-if='value==0' class="img" src="../../static/img/oa_office/leave/dkc.png" mode="widthFix">
  89. </image>
  90. <image v-else class="img" src="../../static/img/oa_office/leave/dk.png" mode="widthFix">
  91. </image>
  92. <view :style='{"color":value==0?"#22C572":"#000"}'>打卡</view>
  93. </view>
  94. <view @click='clockRecord' style=''>
  95. <image v-if='value==1' class="img" src="../../static/img/oa_office/leave/jilu-check.png"
  96. mode="widthFix">
  97. </image>
  98. <image v-else class="img" src="../../static/img/oa_office/leave/jilu.png" mode="widthFix">
  99. </image>
  100. <view :style='{"color":value==1?"#22C572":"#000"}'>记录</view>
  101. </view>
  102. <!-- <u-button type="primary" class="submit" hover-class="none" @click="clockRecord">记录</u-button> -->
  103. </view>
  104. </view>
  105. </template>
  106. <script>
  107. export default {
  108. data() {
  109. return {
  110. params: {
  111. year: true,
  112. month: true
  113. },
  114. value: 0,
  115. typevalue: '1',
  116. show: false,
  117. detailData: {
  118. compId: '',
  119. clockType: '',
  120. otherReasons: '',
  121. targetLocation: '请选择目标位置',
  122. clockDistance: '重新获取',
  123. },
  124. clockDistance: "",
  125. warehouseType: '1',
  126. warehouseBaseInfoList: [],
  127. }
  128. },
  129. onShow() {
  130. this.getList()
  131. },
  132. onLoad() {
  133. console.log(uni.getStorageSync("clockwerehouse"))
  134. if (!uni.getStorageSync("clockwerehouse")) {
  135. uni.showLoading({
  136. mask: true,
  137. title: '加载中'
  138. })
  139. this.getWarehouse()
  140. } else {
  141. this.detailData.targetLocation = uni.getStorageSync("clockwerehouse")
  142. }
  143. // this.getLocation()
  144. let _day = new Date();
  145. _day.setTime(_day.getTime());
  146. this.createDate = _day.getFullYear() + "-" + (_day.getMonth() + 1);
  147. },
  148. methods: {
  149. dateChange(e) {
  150. console.log(e)
  151. this.createDate = e.year + "-" + e.month
  152. uni.showLoading({
  153. title: "加载中",
  154. mask: true
  155. })
  156. this.getList()
  157. },
  158. clocksubmit() {
  159. this.value = 0
  160. uni.setNavigationBarTitle({
  161. title: '打卡功能'
  162. });
  163. },
  164. calculate() {
  165. const query = uni.createSelectorQuery().in(this);
  166. query.selectAll('.left')
  167. console.log(query)
  168. },
  169. getWarehouse() {
  170. var that = this
  171. this.$api.doRequest('get', '/warehouseBaseInfo/selectWarehouse', {
  172. compId: uni.getStorageSync("pcUserInfo").compId,
  173. warehouseType: '1'
  174. }).then(res => {
  175. uni.hideLoading()
  176. if (res.data.data.length != 0) {
  177. that.warehouseBaseInfoList = res.data.data
  178. that.warehouseBaseInfoList.unshift({
  179. warehouseName: '黑龙江中天昊元贸易有限公司',
  180. warehousePositioning: '40.63070,122.22580'
  181. })
  182. uni.getLocation({
  183. type: 'gcj02',
  184. geocode: true,
  185. success: function(res) {
  186. console.log('获取位置数据:', res);
  187. console.log('当前位置的经度:' + res.longitude);
  188. console.log('当前位置的纬度:' + res.latitude);
  189. that.lat2 = res.latitude
  190. that.lng2 = res.longitude
  191. if (that.warehouseBaseInfoList.length > 0) {
  192. that.clockDistance = that.utils.getDistance(that
  193. .warehouseBaseInfoList[0].warehousePositioning.split(',')[
  194. 0],
  195. that.warehouseBaseInfoList[0].warehousePositioning.split(
  196. ',')[1], that.lat2, that.lng2)
  197. that.detailData.targetLocation = that.warehouseBaseInfoList[0]
  198. .warehouseName
  199. }
  200. },
  201. fail: function(req) {
  202. console.log(req)
  203. }
  204. });
  205. }
  206. })
  207. },
  208. targetLPicker(e) {
  209. uni.setStorageSync("clockwerehouse", this.warehouseBaseInfoList[e[0]].warehouseName)
  210. this.detailData.targetLocation = this.warehouseBaseInfoList[e[0]].warehouseName
  211. this.clockDistance = this.utils.getDistance(this.warehouseBaseInfoList[e[0]].warehousePositioning.split(
  212. ',')[0],
  213. this.warehouseBaseInfoList[e[0]].warehousePositioning.split(',')[1], this.lat2, this.lng2)
  214. },
  215. submit() {
  216. if (!this.typevalue) {
  217. this.$api.msg('打卡原因不能为空')
  218. return
  219. }
  220. if (!this.detailData.targetLocation) {
  221. this.$api.msg('请选择目标位置')
  222. return
  223. }
  224. var that = this
  225. uni.showModal({
  226. content: "确定提交打卡信息?",
  227. showCancel: true,
  228. confirmText: '提交',
  229. success: function(res) {
  230. if (res.confirm) {
  231. that.detailData.compId = uni.getStorageSync('pcUserInfo').compId
  232. that.detailData.commonId = uni.getStorageSync('pcUserInfo').userId
  233. that.detailData.dept = uni.getStorageSync('pcUserInfo').deptName
  234. that.detailData.phone = uni.getStorageSync('pcUserInfo').userMobilePhone
  235. that.detailData.empName = uni.getStorageSync('userInfo').userName
  236. that.detailData.clockType = that.typevalue
  237. if (that.clockDistance.indexOf("km") > -1) {
  238. that.detailData.clockDistance = that.clockDistance.replace("km", "") * 1000
  239. } else {
  240. that.detailData.clockDistance = that.clockDistance.replace("m", "")
  241. }
  242. console.log(that.detailData)
  243. that.$api.doRequest('post', '/clockInfo/api/addClock', that.detailData)
  244. .then(res => {
  245. console.log(res.data)
  246. if (res.data.code == 200) {
  247. that.$api.msg('提交成功')
  248. that.value = 1
  249. } else {
  250. that.$api.msg('提交失败')
  251. }
  252. })
  253. }
  254. }
  255. })
  256. },
  257. clockRecord() {
  258. this.value = 1
  259. uni.setNavigationBarTitle({
  260. title: '记录'
  261. });
  262. uni.showLoading({
  263. title: '加载中',
  264. mask: true
  265. })
  266. this.getList()
  267. // uni.navigateTo({
  268. // url: '/pages/clock/the_clock_record'
  269. // })
  270. },
  271. getList() {
  272. this.$api.doRequest('get', '/clockInfo/selectClockInfo', {
  273. pageSize: 100,
  274. currentPage: 1,
  275. pcFlag: 0,
  276. yearMonth: this.createDate,
  277. compId: uni.getStorageSync('pcUserInfo').compId,
  278. commonId: uni.getStorageSync('pcUserInfo').userId,
  279. }).then(res => {
  280. if (res.data.code == 200) {
  281. uni.hideLoading()
  282. this.tableData = res.data.data.records
  283. this.$forceUpdate() //刷新data数据
  284. }
  285. })
  286. },
  287. }
  288. }
  289. </script>
  290. <style lang='scss' scoped>
  291. page {
  292. background: #F5F6FA;
  293. }
  294. .title_b {
  295. margin: 20rpx 20rpx 0rpx 20rpx;
  296. padding: 20rpx 10rpx 20rpx 10rpx;
  297. font-size: 18px;
  298. font-weight: 550;
  299. }
  300. .c-row {
  301. display: -webkit-box;
  302. display: -webkit-flex;
  303. display: flex;
  304. -webkit-box-align: center;
  305. -webkit-align-items: center;
  306. align-items: center;
  307. padding: 20rpx 30rpx;
  308. position: relative;
  309. }
  310. .con-list {
  311. -webkit-box-flex: 1;
  312. -webkit-flex: 1;
  313. flex: 1;
  314. display: -webkit-box;
  315. display: -webkit-flex;
  316. display: flex;
  317. -webkit-box-orient: vertical;
  318. -webkit-box-direction: normal;
  319. -webkit-flex-direction: column;
  320. flex-direction: column;
  321. color: #303133;
  322. line-height: 40rpx;
  323. text-align: right;
  324. padding-right: 20rpx;
  325. }
  326. .wrap {
  327. padding-bottom: 10px;
  328. font-size: 14px;
  329. background: #fff;
  330. margin: 10px;
  331. border-radius: 10px;
  332. input {
  333. font-size: 14px;
  334. }
  335. >.title {
  336. padding: 10px 16px;
  337. }
  338. }
  339. /* .footer {
  340. background: #fff;
  341. position: fixed;
  342. bottom: 0;
  343. width: 100%;
  344. padding: 20px 10px;
  345. z-index: 10;
  346. .button {
  347. background: #22C572;
  348. width: 90%;
  349. margin: 20rpx auto;
  350. padding: 10px;
  351. color: #fff;
  352. text-align: center;
  353. border-radius: 30px;
  354. }
  355. } */
  356. .submit {
  357. width: 80%;
  358. background: #22C572;
  359. border-radius: 50rpx;
  360. margin-top: 50rpx;
  361. }
  362. .bottom-btn {
  363. padding: 30rpx;
  364. background: #FFFFFF;
  365. width: 100%;
  366. position: fixed;
  367. bottom: 0rpx;
  368. display: flex;
  369. z-index: 9999;
  370. justify-content: space-evenly;
  371. }
  372. .buns_item {
  373. display: flex;
  374. padding: 80rpx 0 50rpx 0;
  375. justify-content: space-around;
  376. }
  377. .but_css {
  378. background: #22C572;
  379. width: 40%;
  380. padding: 20rpx;
  381. color: #fff;
  382. text-align: center;
  383. border-radius: 20rpx;
  384. }
  385. /deep/.u-radio-group {
  386. flex-direction: row-reverse;
  387. }
  388. .img {
  389. width: 50rpx;
  390. }
  391. .uni-container {
  392. padding: 20rpx;
  393. .top {
  394. display: flex;
  395. align-items: center;
  396. margin-bottom: 20rpx;
  397. .center {
  398. margin-right: 20rpx;
  399. }
  400. }
  401. }
  402. </style>