ding.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <view class="ding flex flex-col">
  3. <RadiusSelect title="服务单元名称" placeholder="请选择服务单元" :list="serviceUnit" :value.sync="params.serviceId" :on-change="getSopList"></RadiusSelect>
  4. <RadiusSelect title="SOP" placeholder="请选择SOP" :list="sopList" :value.sync="params.sopNo" :on-change="getDingInfo"></RadiusSelect>
  5. <view class="msg-item">
  6. <view class="m-head flex justify-between">
  7. <view class="m-title flex-col">
  8. <text class="title">签到{{ dingInfo.signInTimeScope ||'' }}</text>
  9. <view class="flex ">
  10. <image src="../../static/icon/ding-success.png" class="ding-success mr2" v-show="dingInfo.signInTime"/>
  11. <view class="sub-title mr2">{{dingInfo.signInTime?dateFormat(dingInfo.signInTime, 'hh:mm')+'已打卡':'未打卡'}}</view>
  12. <a @click="checkDingObj('IN')" class="a-title" v-show="dingInfo.signInTime">更新打卡</a>
  13. </view>
  14. </view>
  15. <view class="m-title flex-col">
  16. <text class="title">签退{{ dingInfo.signOutTimeScope ||'' }}</text>
  17. <view class="flex ">
  18. <image src="../../static/icon/ding-success.png" class="ding-success mr2" v-show="dingInfo.signOutTime"/>
  19. <view class="sub-title mr2">{{dingInfo.signOutTime?dateFormat(dingInfo.signOutTime, 'hh:mm')+'已打卡':'未打卡'}}</view>
  20. <a @click="checkDingObj('OUT')" class="a-title" v-show="dingInfo.signOutTime">更新打卡</a>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="m-body flex items-center" >
  25. <view class="m-box flex flex-col items-center" v-show="dingInfo.sopNo" @click="checkDingObj(signOutEnable?'OUT':(signInEnable?'IN':''))" >
  26. <text class="m-box-1">{{signOutEnable?'签退':(signInEnable?'签到':'')}}打卡</text>
  27. <text class="m-box-2" v-show="dingInfo.faceOpen">(人脸识别)</text>
  28. <text class="m-box-3">{{dateFormat(currentTime, 'hh:mm')}}</text>
  29. </view>
  30. <view class="m-box-disable m-box flex flex-col items-center" v-show="!dingInfo.sopNo">
  31. <text class="m-box-1">无法打卡</text>
  32. <text class="m-box-2" v-show="dingInfo.faceOpen">(人脸识别)</text>
  33. <text class="m-box-3">{{dateFormat(currentTime, 'hh:mm')}}</text>
  34. </view>
  35. <view class="m-box-success flex flex-col items-center" v-show="dingSuccess">
  36. <image src="../../static/icon/ding-success.png" class="image-success"/>
  37. <text class="title-success">打卡成功,打卡时间{{dateFormat(dingObj.signTime, 'hh:mm')}}</text>
  38. </view>
  39. </view>
  40. <view class="m-foot flex">
  41. <u-icon name="map" color="#8C8C8C" size="28"></u-icon>
  42. <text class="sub-title">{{dingObj.signAddress}}</text>
  43. </view>
  44. </view>
  45. <view class="msg-item">
  46. <view class="m-head flex justify-between">
  47. <view class="msg-foot flex flex-col" @click="this.$Router.push({ path: '/pages/ding/ding-abnormal', query: params })">
  48. <u-icon name="error-circle" color="#8C8C8C" size="50"></u-icon>
  49. <text class="sub-title">异常处理</text>
  50. </view>
  51. <view class="msg-separator"></view>
  52. <view class="msg-foot flex flex-col" @click="this.$Router.push({ path: '/pages/ding/ding-statistics', query: params })">
  53. <u-icon name="clock" color="#8C8C8C" size="50"></u-icon>
  54. <text class="sub-title">统计</text>
  55. </view>
  56. </view>
  57. </view>
  58. <u-toast ref="uToast"/>
  59. <u-popup v-model="show" mode="center" border-radius="14">
  60. <view class="popup-main flex flex-col justify-between items-center">
  61. <text class="title">打卡提醒</text>
  62. <text class="sub-title">请选择你是签到还是签退</text>
  63. <u-button type="primary" @click="checkDingObj('IN')">签到</u-button>
  64. <u-button type="primary" plain @click="checkDingObj('OUT')">签退</u-button>
  65. <u-button type="default" @click="show=false">取消</u-button>
  66. </view>
  67. </u-popup>
  68. <u-popup v-if="faceModel" mode="center" border-radius="200" :mask-close-able="false">
  69. <DingFace :on-change="dingFace"></DingFace>
  70. </u-popup>
  71. </view>
  72. </template>
  73. <script>
  74. import {dingFindRunningSop, getDingInfo, dingSave, locAddr} from '@/api/ding'
  75. import {getServiceUnit} from '@/api/common'
  76. import {dateFormat, getAppWxLatLon, timeCompare} from '@/utils/utils'
  77. import RadiusSelect from "@/components/radius-select.vue";
  78. import DingFace from "./ding-face.vue";
  79. export default {
  80. name: 'ding',
  81. components: {RadiusSelect,DingFace},
  82. data() {
  83. return {
  84. dateFormat,
  85. loadingFlag: 0,
  86. serviceUnit: [],
  87. sopList: [],
  88. params: {serviceId: '', sopNo: ''},
  89. show: false,
  90. faceModel: false,
  91. signOutEnable: false,
  92. signInEnable: false,
  93. dingSuccess: false,
  94. dingInfo: {},
  95. setTime:null,
  96. currentTime:null,
  97. dingObj:{
  98. signTime: null,
  99. sopNo:null,
  100. signType: "OUT",
  101. signAddress: "",
  102. axisX: "",
  103. axisY: ""
  104. }
  105. }
  106. },
  107. mounted() {
  108. const _this=this;
  109. getAppWxLatLon(async (res) => {
  110. const loc=await locAddr(res);
  111. _this.dingObj.signAddress=loc.result.address
  112. _this.dingObj.axisX = res.longitude;
  113. _this.dingObj.axisY = res.latitude;
  114. })
  115. getServiceUnit().then((res) => {
  116. this.serviceUnit = (res || []).map((item) => {
  117. return {
  118. value: item.id,
  119. label: item.name
  120. }
  121. })
  122. })
  123. this.setTime = setInterval( ()=> {
  124. this.currentTime = new Date().getTime()
  125. }, 1000)
  126. },
  127. onHide(){
  128. clearInterval(this.setTime)
  129. },
  130. methods: {
  131. getSopList(serviceId) {
  132. if(serviceId)
  133. dingFindRunningSop({serviceUnitId: serviceId}).then((res) => {
  134. this.sopList = (res || []).map((item) => {
  135. return {
  136. value: item.sopNo,
  137. label: item.sopNo + item.customName
  138. }
  139. })
  140. })
  141. },
  142. getDingInfo(sopNo) {
  143. if(sopNo)
  144. getDingInfo({sopNo: sopNo}).then((res) => {
  145. this.dingInfo = res;
  146. if (this.dingInfo.signInTimeScope) {
  147. this.signInEnable=timeCompare(this.dingInfo.signInTimeScope.split("~")[0],this.currentTime,this.dingInfo.signInTimeScope.split("~")[1]);
  148. }
  149. if (this.dingInfo.signOutTimeScope) {
  150. this.signOutEnable=timeCompare(this.dingInfo.signOutTimeScope.split("~")[0],this.currentTime,this.dingInfo.signOutTimeScope.split("~")[1]);
  151. }
  152. if(!this.dingInfo.signInTimeScope||!this.dingInfo.signOutTimeScope){
  153. this.show=true;
  154. }
  155. })
  156. },
  157. checkDingObj(signType) {
  158. if(!signType){
  159. this.show=true;return;
  160. }
  161. this.dingObj.sopNo = this.params.sopNo;
  162. this.dingObj.signType = signType;
  163. this.dingObj.signTime = this.currentTime;
  164. this.dingObj.facePass = false;
  165. if (this.dingInfo.faceOpen) {
  166. this.faceModel=true;
  167. }else{
  168. const _this=this;
  169. getAppWxLatLon(async (res) => {
  170. const loc = await locAddr(res);
  171. _this.dingObj.signAddress = loc.result.address
  172. _this.dingObj.axisX = res.longitude;
  173. _this.dingObj.axisY = res.latitude;
  174. dingSave(_this.dingObj).then((res) => {
  175. _this.dingSuccess = true;
  176. _this.signInEnable = false;
  177. _this.signOutEnable = false;
  178. })
  179. })
  180. }
  181. },
  182. dingFace(facePhotoPath){
  183. const _this=this;
  184. getAppWxLatLon(async (res) => {
  185. const loc = await locAddr(res);
  186. _this.dingObj.signAddress = loc.result.address
  187. _this.dingObj.facePhotoPath = facePhotoPath;
  188. _this.dingObj.axisX = res.longitude;
  189. _this.dingObj.axisY = res.latitude;
  190. dingSave(_this.dingObj).then((res) => {
  191. _this.dingSuccess = true;
  192. _this.signInEnable = false;
  193. _this.signOutEnable = false;
  194. })
  195. })
  196. }
  197. }
  198. }
  199. </script>
  200. <style lang="scss" scoped>
  201. .ding {
  202. height: calc(100% - 80rpx);
  203. padding: 24rpx;
  204. }
  205. .msg-item {
  206. padding: 24rpx;
  207. border-radius: 12rpx;
  208. background: #fff;
  209. margin-bottom: 24rpx;
  210. .m-body {
  211. margin-top: 16rpx;
  212. justify-content: center;
  213. .m-box{
  214. width: 272rpx;
  215. height: 272rpx;
  216. justify-content: center;
  217. background: linear-gradient(180deg, #3196FF 0%, #165DFF 100%);
  218. box-shadow: 0rpx 0rpx 24rpx 0rpx rgba(22,93,255,0.5);
  219. border-radius: 136rpx;
  220. margin-top: 80rpx;
  221. .m-box-1{
  222. height: 56rpx;
  223. font-size: 40rpx;
  224. font-family: PingFangSC-Medium, PingFang SC;
  225. font-weight: 500;
  226. color: #FFFFFF;
  227. line-height: 56rpx;
  228. }
  229. .m-box-2{
  230. height: 44rpx;
  231. font-size: 28rpx;
  232. font-family: PingFangSC-Regular, PingFang SC;
  233. font-weight: 400;
  234. color: rgba(255,255,255,0.5);
  235. line-height: 44rpx;
  236. }
  237. .m-box-3{
  238. height: 48rpx;
  239. font-size: 32rpx;
  240. font-family: PingFangSC-Medium, PingFang SC;
  241. font-weight: 500;
  242. color: #FFFFFF;
  243. line-height: 48rpx;
  244. }
  245. }
  246. .m-box-disable{
  247. width: 272rpx;
  248. height: 272rpx;
  249. justify-content: center;
  250. background: linear-gradient(180deg, #C0C0C0 0%, #8C8C8C 100%);
  251. box-shadow: 0px 0px 12px 0px #BFBFBF;
  252. border-radius: 136rpx;
  253. margin-top: 80rpx;
  254. }
  255. .m-box-success{
  256. margin-top: 80rpx;
  257. .title-success{
  258. width: 188px;
  259. height: 24px;
  260. font-size: 16px;
  261. font-family: PingFangSC-Regular, PingFang SC;
  262. font-weight: 400;
  263. color: #262626;
  264. line-height: 24px;
  265. }
  266. .image-success{
  267. width: 60px;
  268. height: 60px;
  269. }
  270. }
  271. }
  272. .m-foot {
  273. padding-top: 40rpx;
  274. padding-bottom: 70rpx;
  275. justify-content: center;
  276. }
  277. .m-head {
  278. .msg-foot{
  279. min-width: 48%;
  280. align-items: center;
  281. cursor: pointer;
  282. }
  283. .msg-separator{
  284. width: 2rpx;
  285. background: #E5E5E5;
  286. }
  287. .m-title {
  288. min-width: 48%;
  289. background: #f0f0f0;
  290. align-items: center;
  291. border-radius: 12rpx;
  292. padding: 10rpx;
  293. .title {
  294. height: 48rpx;
  295. font-size: 32rpx;
  296. font-family: PingFangSC-Regular, PingFang SC;
  297. font-weight: 400;
  298. color: #262626;
  299. line-height: 48rpx;
  300. }
  301. .ding-success{
  302. margin: 3px 0 3px 0;
  303. width: 14px;
  304. height: 14px;
  305. }
  306. .a-title{
  307. height: 40rpx;
  308. font-size: 24rpx;
  309. font-family: PingFangSC-Regular, PingFang SC;
  310. font-weight: 400;
  311. color: #165DFF;
  312. line-height: 40rpx;
  313. }
  314. .sub-title{
  315. height: 40rpx;
  316. font-size: 24rpx;
  317. font-family: PingFangSC-Regular, PingFang SC;
  318. font-weight: 400;
  319. color: #8C8C8C;
  320. line-height: 40rpx;
  321. }
  322. }
  323. }
  324. }
  325. .popup-main {
  326. min-width: 240px;
  327. min-height: 254px;
  328. padding: 25rpx;
  329. border-radius: 6px;
  330. background: linear-gradient(180deg, #D7EAFF 0%, #FFFFFF 100%);
  331. backdrop-filter: blur(10px);
  332. .title {
  333. width: 160px;
  334. height: 24px;
  335. font-size: 16px;
  336. font-family: PingFangSC-Semibold, PingFang SC;
  337. font-weight: 600;
  338. color: #262626;
  339. line-height: 24px;
  340. text-align: center;
  341. }
  342. .sub-title {
  343. width: 168px;
  344. height: 20px;
  345. font-size: 14px;
  346. font-family: PingFangSC-Regular, PingFang SC;
  347. font-weight: 400;
  348. color: #595959;
  349. line-height: 20px;
  350. text-align: center;
  351. }
  352. u-button{
  353. width: -webkit-fill-available;
  354. }
  355. }
  356. </style>