the_clock.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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. <view v-if='item.approveStatus ==null && item.status == null' @click='supp(item)'
  56. class="bk-button">补卡</view>
  57. <view v-if='item.approveStatus=="待人事审核"' class='listitemStatus audit Regular'>待人事审核
  58. </view>
  59. <view v-if='item.approveStatus=="待主管审核"' class='listitemStatus audit Regular'>待主管审核
  60. </view>
  61. <button v-if='item.status=="补卡失败"' class='listitemStatus notPass Regular' size="mini"
  62. type="primary" align="center" style="height: 30px;">补卡失败</button>
  63. <button v-if='item.status=="补卡成功"' class='listitemStatus pass Regular' size="mini"
  64. type="primary" align="center" style="height: 30px;">补卡成功</button>
  65. </view>
  66. </uni-td>
  67. <uni-td align="center">
  68. <view class="offClockDate" v-if="item.offClockDate">{{ item.offClockDate.split(" ")[1] }}
  69. </view>
  70. <view class="offClockDate" v-else-if="!item.offClockDate">
  71. <view v-if='item.approveStatus ==null && item.status == null' @click='supp(item)'
  72. class="bk-button">补卡</view>
  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(options) {
  133. if (options.value) {
  134. this.value = 1
  135. }
  136. console.log(uni.getStorageSync("clockwerehouse"))
  137. if (!uni.getStorageSync("clockwerehouse")) {
  138. uni.showLoading({
  139. mask: true,
  140. title: '加载中'
  141. })
  142. this.getWarehouse()
  143. } else {
  144. this.detailData.targetLocation = uni.getStorageSync("clockwerehouse")
  145. }
  146. // this.getLocation()
  147. let _day = new Date();
  148. _day.setTime(_day.getTime());
  149. this.createDate = _day.getFullYear() + "-" + (_day.getMonth() + 1);
  150. },
  151. methods: {
  152. supp(item) {
  153. uni.navigateTo({
  154. url: '/pages/clock/supp_clock' + `?id=${item.id}`,
  155. })
  156. },
  157. dateChange(e) {
  158. console.log(e)
  159. this.createDate = e.year + "-" + e.month
  160. uni.showLoading({
  161. title: "加载中",
  162. mask: true
  163. })
  164. this.getList()
  165. },
  166. clocksubmit() {
  167. this.value = 0
  168. uni.setNavigationBarTitle({
  169. title: '打卡功能'
  170. });
  171. },
  172. calculate() {
  173. const query = uni.createSelectorQuery().in(this);
  174. query.selectAll('.left')
  175. console.log(query)
  176. },
  177. getWarehouse() {
  178. var that = this
  179. this.$api.doRequest('get', '/warehouseBaseInfo/selectWarehouse', {
  180. compId: uni.getStorageSync("pcUserInfo").compId,
  181. warehouseType: '1'
  182. }).then(res => {
  183. uni.hideLoading()
  184. if (res.data.data.length != 0) {
  185. that.warehouseBaseInfoList = res.data.data
  186. that.warehouseBaseInfoList.unshift({
  187. warehouseName: '黑龙江中天昊元贸易有限公司',
  188. warehousePositioning: '40.63070,122.22580'
  189. })
  190. uni.getLocation({
  191. type: 'gcj02',
  192. geocode: true,
  193. success: function(res) {
  194. console.log('获取位置数据:', res);
  195. console.log('当前位置的经度:' + res.longitude);
  196. console.log('当前位置的纬度:' + res.latitude);
  197. that.lat2 = res.latitude
  198. that.lng2 = res.longitude
  199. if (that.warehouseBaseInfoList.length > 0) {
  200. that.clockDistance = that.utils.getDistance(that
  201. .warehouseBaseInfoList[0].warehousePositioning.split(',')[
  202. 0],
  203. that.warehouseBaseInfoList[0].warehousePositioning.split(
  204. ',')[1], that.lat2, that.lng2)
  205. that.detailData.targetLocation = that.warehouseBaseInfoList[0]
  206. .warehouseName
  207. }
  208. },
  209. fail: function(req) {
  210. console.log(req)
  211. }
  212. });
  213. }
  214. })
  215. },
  216. targetLPicker(e) {
  217. uni.setStorageSync("clockwerehouse", this.warehouseBaseInfoList[e[0]].warehouseName)
  218. this.detailData.targetLocation = this.warehouseBaseInfoList[e[0]].warehouseName
  219. this.clockDistance = this.utils.getDistance(this.warehouseBaseInfoList[e[0]].warehousePositioning.split(
  220. ',')[0],
  221. this.warehouseBaseInfoList[e[0]].warehousePositioning.split(',')[1], this.lat2, this.lng2)
  222. },
  223. submit() {
  224. if (!this.typevalue) {
  225. this.$api.msg('打卡原因不能为空')
  226. return
  227. }
  228. if (!this.detailData.targetLocation) {
  229. this.$api.msg('请选择目标位置')
  230. return
  231. }
  232. var that = this
  233. uni.showModal({
  234. content: "确定提交打卡信息?",
  235. showCancel: true,
  236. confirmText: '提交',
  237. success: function(res) {
  238. if (res.confirm) {
  239. that.detailData.compId = uni.getStorageSync('pcUserInfo').compId
  240. that.detailData.commonId = uni.getStorageSync('pcUserInfo').userId
  241. that.detailData.dept = uni.getStorageSync('pcUserInfo').deptName
  242. that.detailData.phone = uni.getStorageSync('pcUserInfo').userMobilePhone
  243. that.detailData.empName = uni.getStorageSync('userInfo').userName
  244. that.detailData.clockType = that.typevalue
  245. if (that.clockDistance.indexOf("km") > -1) {
  246. that.detailData.clockDistance = that.clockDistance.replace("km", "") * 1000
  247. } else {
  248. that.detailData.clockDistance = that.clockDistance.replace("m", "")
  249. }
  250. console.log(that.detailData)
  251. that.$api.doRequest('post', '/clockInfo/api/addClock', that.detailData)
  252. .then(res => {
  253. console.log(res.data)
  254. if (res.data.code == 200) {
  255. that.$api.msg('提交成功')
  256. that.value = 1
  257. } else {
  258. that.$api.msg('提交失败')
  259. }
  260. })
  261. }
  262. }
  263. })
  264. },
  265. clockRecord() {
  266. this.value = 1
  267. uni.setNavigationBarTitle({
  268. title: '记录'
  269. });
  270. uni.showLoading({
  271. title: '加载中',
  272. mask: true
  273. })
  274. this.getList()
  275. // uni.navigateTo({
  276. // url: '/pages/clock/the_clock_record'
  277. // })
  278. },
  279. getList() {
  280. this.$api.doRequest('get', '/clockInfo/selectClockInfo', {
  281. pageSize: 100,
  282. currentPage: 1,
  283. pcFlag: 0,
  284. yearMonth: this.createDate,
  285. compId: uni.getStorageSync('pcUserInfo').compId,
  286. commonId: uni.getStorageSync('pcUserInfo').userId,
  287. }).then(res => {
  288. if (res.data.code == 200) {
  289. uni.hideLoading()
  290. this.tableData = res.data.data.records
  291. this.$forceUpdate() //刷新data数据
  292. }
  293. })
  294. },
  295. }
  296. }
  297. </script>
  298. <style lang='scss' scoped>
  299. page {
  300. background: #F5F6FA;
  301. }
  302. .title_b {
  303. margin: 20rpx 20rpx 0rpx 20rpx;
  304. padding: 20rpx 10rpx 20rpx 10rpx;
  305. font-size: 18px;
  306. font-weight: 550;
  307. }
  308. .c-row {
  309. display: -webkit-box;
  310. display: -webkit-flex;
  311. display: flex;
  312. -webkit-box-align: center;
  313. -webkit-align-items: center;
  314. align-items: center;
  315. padding: 20rpx 30rpx;
  316. position: relative;
  317. }
  318. .con-list {
  319. -webkit-box-flex: 1;
  320. -webkit-flex: 1;
  321. flex: 1;
  322. display: -webkit-box;
  323. display: -webkit-flex;
  324. display: flex;
  325. -webkit-box-orient: vertical;
  326. -webkit-box-direction: normal;
  327. -webkit-flex-direction: column;
  328. flex-direction: column;
  329. color: #303133;
  330. line-height: 40rpx;
  331. text-align: right;
  332. padding-right: 20rpx;
  333. }
  334. .wrap {
  335. padding-bottom: 10px;
  336. font-size: 14px;
  337. background: #fff;
  338. margin: 10px;
  339. border-radius: 10px;
  340. input {
  341. font-size: 14px;
  342. }
  343. >.title {
  344. padding: 10px 16px;
  345. }
  346. }
  347. /* .footer {
  348. background: #fff;
  349. position: fixed;
  350. bottom: 0;
  351. width: 100%;
  352. padding: 20px 10px;
  353. z-index: 10;
  354. .button {
  355. background: #22C572;
  356. width: 90%;
  357. margin: 20rpx auto;
  358. padding: 10px;
  359. color: #fff;
  360. text-align: center;
  361. border-radius: 30px;
  362. }
  363. } */
  364. .submit {
  365. width: 80%;
  366. background: #22C572;
  367. border-radius: 50rpx;
  368. margin-top: 50rpx;
  369. }
  370. .bottom-btn {
  371. padding: 30rpx;
  372. background: #FFFFFF;
  373. width: 100%;
  374. position: fixed;
  375. bottom: 0rpx;
  376. display: flex;
  377. z-index: 9999;
  378. justify-content: space-evenly;
  379. }
  380. .buns_item {
  381. display: flex;
  382. padding: 80rpx 0 50rpx 0;
  383. justify-content: space-around;
  384. }
  385. .but_css {
  386. background: #22C572;
  387. width: 40%;
  388. padding: 20rpx;
  389. color: #fff;
  390. text-align: center;
  391. border-radius: 20rpx;
  392. }
  393. /deep/.u-radio-group {
  394. flex-direction: row-reverse;
  395. }
  396. .img {
  397. width: 50rpx;
  398. }
  399. .uni-container {
  400. padding: 20rpx;
  401. .top {
  402. display: flex;
  403. align-items: center;
  404. margin-bottom: 20rpx;
  405. .center {
  406. margin-right: 20rpx;
  407. }
  408. }
  409. }
  410. .listitemStatus {
  411. color: red;
  412. }
  413. .bk-button {
  414. background: #22C572;
  415. color: white;
  416. width: 100rpx;
  417. padding: 10rpx;
  418. box-sizing: border-box;
  419. border-radius: 50rpx;
  420. }
  421. .offClockDate {
  422. display: flex;
  423. justify-content: center;
  424. }
  425. </style>