the_clock.vue 12 KB

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