teacher-attendDetail.tsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. import { defineComponent, reactive, ref, onMounted } from 'vue'
  2. import styles from './teacher-attendDetail.module.less'
  3. import clockIcon from '../images/clock-icon.png'
  4. import errorIcon from '../images/error-icon.png'
  5. import successIcon from '../images/success-icon.png'
  6. import defaultIcon from '@/school/images/default-icon.png'
  7. import sendmsgIcon from '@/school/images/sendmsg-icon.png'
  8. import phoneIcon from '@/school/images/phone-icon.png'
  9. import OHeader from '@/components/o-header'
  10. import msgIcon from '@/school/images/msg-icon.png'
  11. import { Icon, ActionSheet, showToast } from 'vant'
  12. import dayjs from 'dayjs'
  13. import { useRoute, useRouter } from 'vue-router'
  14. import { state as globalState } from '@/state'
  15. import request from '@/helpers/request'
  16. import { postMessage } from '@/helpers/native-message'
  17. import { teacherAttType } from '@/constant/index'
  18. export default defineComponent({
  19. props: ['item'],
  20. name: 'teacher-attendDetail',
  21. setup(props) {
  22. const router = useRouter()
  23. const route = useRoute()
  24. const gotoStudentDetail = () => {
  25. // router.push({ path: '/student-att-day', query: { time: teacherAttInfo.value.time } })
  26. }
  27. const attendanceScope = ref(0)
  28. const teacherAttInfo = ref({} as any)
  29. const platformApi = ref(globalState.platformApi)
  30. console.log(platformApi.value)
  31. const showContact = ref(false)
  32. const startContact = () => {
  33. showContact.value = true
  34. }
  35. const closeSheet = () => {
  36. showContact.value = false
  37. }
  38. const postMsg = async () => {
  39. try {
  40. await postMessage({
  41. api: 'joinChatGroup',
  42. content: {
  43. type: 'single', // single 单人 multi 多人
  44. id: teacherAttInfo.value.imUserId
  45. }
  46. })
  47. closeSheet()
  48. } catch (e) {
  49. showToast('发起聊天失败')
  50. closeSheet()
  51. }
  52. }
  53. const callPhone = async () => {
  54. try {
  55. await postMessage({
  56. api: 'callPhone',
  57. content: {
  58. phone: teacherAttInfo.value.teacherPhone
  59. }
  60. })
  61. closeSheet()
  62. } catch (e) {
  63. showToast('拨号失败')
  64. closeSheet()
  65. }
  66. }
  67. const getCourseAtt = async () => {
  68. try {
  69. const res = await request.post(
  70. `${platformApi.value}/courseSchedule/teacherAttendance/course/${route.query.courseScheduleId}`,
  71. {}
  72. )
  73. teacherAttInfo.value = res.data
  74. // res.data.sysParamConfigs.forEach((item: any) => {
  75. // if (item.paramName == 'scope_of_attendance') {
  76. // attendanceScope.value = item.paramValue
  77. // }
  78. // })
  79. } catch (e) {
  80. console.log(e)
  81. }
  82. }
  83. onMounted(() => {
  84. getCourseAtt()
  85. })
  86. const setAddress = async (myPoint: string) => {
  87. if (!myPoint) {
  88. // showToast('当前暂无定位')
  89. return
  90. }
  91. try {
  92. await postMessage({
  93. api: 'sourseMapApi',
  94. content: {
  95. type: 'display',
  96. orginPoint: teacherAttInfo.value.schoolLongitudeLatitude,
  97. myPoint: myPoint,
  98. limitDistance: teacherAttInfo.value.scopeOfAttendance
  99. }
  100. })
  101. } catch (e) {
  102. console.log(e)
  103. }
  104. }
  105. return () => (
  106. <>
  107. <OHeader></OHeader>
  108. <div class={styles.itemWrap} onClick={gotoStudentDetail}>
  109. <div class={styles.itemWrapTopCard}>
  110. <div class={styles.itemWrapTop}>
  111. <div class={styles.itemWrapTopLeft}>
  112. <div class={styles.clockWrap}>
  113. <img src={clockIcon} alt="" />
  114. </div>
  115. <p class={styles.leftTimer}>
  116. {dayjs(teacherAttInfo.value?.startTime).format('YYYY-MM-DD HH:mm')}
  117. {'~'}
  118. {dayjs(teacherAttInfo.value?.endTime).format('HH:mm')}
  119. </p>
  120. </div>
  121. <div class={styles.itemWrapTopRight}>{/* <Icon name="arrow"></Icon> */}</div>
  122. </div>
  123. <div class={styles.itemWrapBottom}>
  124. <div class={styles.courseInfo}>
  125. <img
  126. class={styles.headImgs}
  127. src={
  128. teacherAttInfo.value.teacherAvatar
  129. ? teacherAttInfo.value.teacherAvatar
  130. : defaultIcon
  131. }
  132. alt=""
  133. />
  134. <div class={styles.infoMsg}>
  135. <p class={styles.infoMsgMain}>
  136. {teacherAttInfo.value?.classGroupName}-{teacherAttInfo.value?.teacherName}
  137. </p>
  138. <p
  139. class={[
  140. styles.infoMsgSub,
  141. platformApi.value == '/api-teacher' ? styles.infoMsgSubTeacher : ''
  142. ]}
  143. >
  144. {teacherAttInfo.value?.orchestraName}
  145. </p>
  146. </div>
  147. </div>
  148. {platformApi.value == '/api-teacher' ? null : (
  149. <div
  150. class={styles.msgIcon}
  151. onClick={(e: any) => {
  152. e.stopPropagation()
  153. e.preventDefault()
  154. startContact()
  155. }}
  156. >
  157. <img src={msgIcon} alt="" />
  158. </div>
  159. )}
  160. </div>
  161. </div>
  162. <div class={styles.attInfo}>
  163. <div
  164. class={
  165. teacherAttInfo.value?.signInStatus === 'NORMAL' ? styles.passWrap : styles.goWrap
  166. }
  167. >
  168. <div class={styles.attInfoDot}>
  169. <div class={styles.attInfoDotTitle}>
  170. <span>
  171. 上课时间 <span>{dayjs(teacherAttInfo.value?.startTime).format('HH:mm')}</span>
  172. </span>
  173. <img
  174. src={teacherAttInfo.value?.signInStatus === 'NORMAL' ? successIcon : errorIcon}
  175. alt=""
  176. />
  177. </div>
  178. <p class={styles.signTime}>
  179. {teacherAttInfo.value?.signInTime ? (
  180. <div class={styles.textWidth}>
  181. {teacherAttInfo.value?.signInStatus === 'NORMAL'
  182. ? '签到时间'
  183. : teacherAttType[teacherAttInfo.value?.signInStatus]}
  184. </div>
  185. ) : (
  186. ''
  187. )}
  188. {teacherAttInfo.value?.signInTime ? (
  189. <span>{dayjs(teacherAttInfo.value?.signInTime).format('HH:mm:ss')}</span>
  190. ) : (
  191. '未签到'
  192. )}
  193. </p>
  194. </div>
  195. </div>
  196. <div
  197. class={
  198. teacherAttInfo.value?.signInLongitudeLatitudeStatus === 'NORMAL'
  199. ? styles.passWrap
  200. : styles.goWrap
  201. }
  202. >
  203. <div class={styles.attInfoDot}>
  204. <div class={styles.attInfoDotTitle}>
  205. <span>签到定位</span>
  206. <img
  207. src={
  208. teacherAttInfo.value?.signInLongitudeLatitudeStatus === 'NORMAL'
  209. ? successIcon
  210. : errorIcon
  211. }
  212. alt=""
  213. />
  214. </div>
  215. <div
  216. class={styles.attRang}
  217. onClick={() => {
  218. setAddress(teacherAttInfo.value.signInLongitudeLatitude)
  219. }}
  220. >
  221. {teacherAttInfo.value.signInLongitudeLatitude ? (
  222. <p>
  223. {teacherAttInfo.value?.signInLongitudeLatitudeStatus === 'NORMAL'
  224. ? '考勤范围内'
  225. : '考勤范围外'}
  226. </p>
  227. ) : (
  228. <p>暂无定位</p>
  229. )}
  230. {teacherAttInfo.value.signInLongitudeLatitude ? (
  231. <p
  232. class={[
  233. styles.locP,
  234. teacherAttInfo.value?.signInLongitudeLatitudeStatus === 'NORMAL'
  235. ? styles.pass
  236. : styles.error
  237. ]}
  238. >
  239. 查看定位<Icon name="arrow" class={styles.arrow}></Icon>
  240. </p>
  241. ) : null}
  242. </div>
  243. </div>
  244. </div>
  245. </div>
  246. <div class={[styles.attInfo, styles.attBackInfo]}>
  247. <div
  248. class={
  249. teacherAttInfo.value?.signOutStatus === 'NORMAL' ? styles.passWrap : styles.goWrap
  250. }
  251. >
  252. <div class={styles.attInfoDot}>
  253. <div class={styles.attInfoDotTitle}>
  254. <p>
  255. 下课时间 <span>{dayjs(teacherAttInfo.value?.endTime).format('HH:mm')}</span>
  256. </p>
  257. <img
  258. src={teacherAttInfo.value?.signOutStatus === 'NORMAL' ? successIcon : errorIcon}
  259. alt=""
  260. />
  261. </div>
  262. <p class={styles.signTime}>
  263. {teacherAttInfo.value?.signOutTime ? (
  264. <>
  265. <div class={styles.textWidth}>
  266. {teacherAttInfo.value?.signOutStatus === 'NORMAL'
  267. ? '签退时间'
  268. : teacherAttType[teacherAttInfo.value?.signOutStatus]}
  269. </div>
  270. <span>{dayjs(teacherAttInfo.value?.signOutTime).format('HH:mm:ss')}</span>
  271. </>
  272. ) : (
  273. '未签退'
  274. )}
  275. </p>
  276. </div>
  277. </div>
  278. <div
  279. class={
  280. teacherAttInfo.value?.signOutLongitudeLatitudeStatus === 'NORMAL'
  281. ? styles.passWrap
  282. : styles.goWrap
  283. }
  284. >
  285. <div class={styles.attInfoDot}>
  286. <div class={styles.attInfoDotTitle}>
  287. <span>签退定位</span>
  288. <img
  289. src={
  290. teacherAttInfo.value?.signOutLongitudeLatitudeStatus === 'NORMAL'
  291. ? successIcon
  292. : errorIcon
  293. }
  294. alt=""
  295. />
  296. </div>
  297. <div
  298. class={styles.attRang}
  299. onClick={() => {
  300. setAddress(teacherAttInfo.value.signOutLongitudeLatitude)
  301. }}
  302. >
  303. {teacherAttInfo.value.signOutLongitudeLatitude ? (
  304. <>
  305. <p>
  306. {' '}
  307. {teacherAttInfo.value?.signOutLongitudeLatitudeStatus === 'NORMAL'
  308. ? '考勤范围内'
  309. : '考勤范围外'}
  310. </p>
  311. <p
  312. class={[
  313. styles.locP,
  314. teacherAttInfo.value?.signOutLongitudeLatitudeStatus === 'NORMAL'
  315. ? styles.pass
  316. : styles.error
  317. ]}
  318. >
  319. 查看定位<Icon name="arrow" class={styles.arrow}></Icon>
  320. </p>
  321. </>
  322. ) : (
  323. <>
  324. <p>暂无定位</p>
  325. <p></p>
  326. </>
  327. )}
  328. </div>
  329. </div>
  330. </div>
  331. </div>
  332. <ActionSheet
  333. class="bottomSheet"
  334. v-model:show={showContact.value}
  335. v-slots={{
  336. description: () => (
  337. <div class={styles.bottomTitle}>
  338. <div class={styles.bottomTitleLeft}>
  339. <span></span>
  340. <p>联系方式</p>
  341. </div>
  342. <div
  343. class={styles.bottomTitleRight}
  344. onClick={(e: any) => {
  345. e.stopPropagation()
  346. e.preventDefault()
  347. closeSheet()
  348. }}
  349. >
  350. <Icon class={styles.cross} name="cross"></Icon>
  351. </div>
  352. </div>
  353. )
  354. }}
  355. >
  356. <div class={styles.bottomConent}>
  357. <div
  358. class={styles.bottomConentLeft}
  359. onClick={(e: any) => {
  360. e.stopPropagation()
  361. e.preventDefault()
  362. postMsg()
  363. }}
  364. >
  365. <div class={styles.bottomImgWrap}>
  366. <img src={sendmsgIcon} alt="" />
  367. </div>
  368. <p>发送消息</p>
  369. </div>
  370. <div
  371. class={styles.bottomConentRight}
  372. onClick={(e: any) => {
  373. e.stopPropagation()
  374. e.preventDefault()
  375. callPhone()
  376. }}
  377. >
  378. <div class={styles.bottomImgWrap}>
  379. <img src={phoneIcon} alt="" />
  380. </div>
  381. <p>拨打电话</p>
  382. </div>
  383. </div>
  384. </ActionSheet>
  385. </div>
  386. </>
  387. )
  388. }
  389. })