the_clock.vue 12 KB

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