teacher-attendDetail.tsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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. ? teacherAttType[teacherAttInfo.value?.signInStatus]
  181. : ''}
  182. {teacherAttInfo.value?.signInTime ? (
  183. <span>{dayjs(teacherAttInfo.value?.signInTime).format('HH:mm:ss')}</span>
  184. ) : (
  185. <span>未签到</span>
  186. )}
  187. </p>
  188. </div>
  189. </div>
  190. <div
  191. class={
  192. teacherAttInfo.value?.signInLongitudeLatitudeStatus === 'NORMAL'
  193. ? styles.passWrap
  194. : styles.goWrap
  195. }
  196. >
  197. <div class={styles.attInfoDot}>
  198. <div class={styles.attInfoDotTitle}>
  199. <span>签到定位</span>
  200. <img
  201. src={
  202. teacherAttInfo.value?.signInLongitudeLatitudeStatus === 'NORMAL'
  203. ? successIcon
  204. : errorIcon
  205. }
  206. alt=""
  207. />
  208. </div>
  209. <div
  210. class={styles.attRang}
  211. onClick={() => {
  212. setAddress(teacherAttInfo.value.signInLongitudeLatitude)
  213. }}
  214. >
  215. {teacherAttInfo.value.signInLongitudeLatitude ? (
  216. <p>
  217. {teacherAttInfo.value?.signInLongitudeLatitudeStatus === 'NORMAL'
  218. ? '考勤范围内'
  219. : '考勤范围外'}
  220. </p>
  221. ) : (
  222. <p>暂无定位</p>
  223. )}
  224. {teacherAttInfo.value.signInLongitudeLatitude ? (
  225. <p
  226. class={[
  227. styles.locP,
  228. teacherAttInfo.value?.signInLongitudeLatitudeStatus === 'NORMAL'
  229. ? styles.pass
  230. : styles.error
  231. ]}
  232. >
  233. 查看定位 <Icon name="arrow" class={styles.arrow}></Icon>
  234. </p>
  235. ) : null}
  236. </div>
  237. </div>
  238. </div>
  239. </div>
  240. <div class={[styles.attInfo, styles.attBackInfo]}>
  241. <div
  242. class={
  243. teacherAttInfo.value?.signOutStatus === 'NORMAL' ? styles.passWrap : styles.goWrap
  244. }
  245. >
  246. <div class={styles.attInfoDot}>
  247. <div class={styles.attInfoDotTitle}>
  248. <p>
  249. 下课时间<span>{dayjs(teacherAttInfo.value?.endTime).format('HH:mm')}</span>
  250. </p>
  251. <img
  252. src={teacherAttInfo.value?.signOutStatus === 'NORMAL' ? successIcon : errorIcon}
  253. alt=""
  254. />
  255. </div>
  256. <p class={styles.signTime}>
  257. {teacherAttInfo.value?.signOutTime
  258. ? teacherAttType[teacherAttInfo.value?.signOutStatus]
  259. : ''}
  260. {teacherAttInfo.value?.signOutTime ? (
  261. <span>{dayjs(teacherAttInfo.value?.signOutTime).format('HH:mm:ss')}</span>
  262. ) : (
  263. '未签退'
  264. )}
  265. </p>
  266. </div>
  267. </div>
  268. <div
  269. class={
  270. teacherAttInfo.value?.signOutLongitudeLatitudeStatus === 'NORMAL'
  271. ? styles.passWrap
  272. : styles.goWrap
  273. }
  274. >
  275. <div class={styles.attInfoDot}>
  276. <div class={styles.attInfoDotTitle}>
  277. <span>签退定位</span>
  278. <img
  279. src={
  280. teacherAttInfo.value?.signOutLongitudeLatitudeStatus === 'NORMAL'
  281. ? successIcon
  282. : errorIcon
  283. }
  284. alt=""
  285. />
  286. </div>
  287. <div
  288. class={styles.attRang}
  289. onClick={() => {
  290. setAddress(teacherAttInfo.value.signOutLongitudeLatitude)
  291. }}
  292. >
  293. {teacherAttInfo.value.signOutLongitudeLatitude ? (
  294. <>
  295. <p>
  296. {' '}
  297. {teacherAttInfo.value?.signOutLongitudeLatitudeStatus === 'NORMAL'
  298. ? '考勤范围内'
  299. : '考勤范围外'}
  300. </p>
  301. <p
  302. class={[
  303. styles.locP,
  304. teacherAttInfo.value?.signOutLongitudeLatitudeStatus === 'NORMAL'
  305. ? styles.pass
  306. : styles.error
  307. ]}
  308. >
  309. 查看定位 <Icon name="arrow" class={styles.arrow}></Icon>
  310. </p>
  311. </>
  312. ) : (
  313. <p>暂无定位</p>
  314. )}
  315. </div>
  316. </div>
  317. </div>
  318. </div>
  319. <ActionSheet
  320. class="bottomSheet"
  321. v-model:show={showContact.value}
  322. v-slots={{
  323. description: () => (
  324. <div class={styles.bottomTitle}>
  325. <div class={styles.bottomTitleLeft}>
  326. <span></span>
  327. <p>联系方式</p>
  328. </div>
  329. <div
  330. class={styles.bottomTitleRight}
  331. onClick={(e: any) => {
  332. e.stopPropagation()
  333. e.preventDefault()
  334. closeSheet()
  335. }}
  336. >
  337. <Icon class={styles.cross} name="cross"></Icon>
  338. </div>
  339. </div>
  340. )
  341. }}
  342. >
  343. <div class={styles.bottomConent}>
  344. <div
  345. class={styles.bottomConentLeft}
  346. onClick={(e: any) => {
  347. e.stopPropagation()
  348. e.preventDefault()
  349. postMsg()
  350. }}
  351. >
  352. <div class={styles.bottomImgWrap}>
  353. <img src={sendmsgIcon} alt="" />
  354. </div>
  355. <p>发送消息</p>
  356. </div>
  357. <div
  358. class={styles.bottomConentRight}
  359. onClick={(e: any) => {
  360. e.stopPropagation()
  361. e.preventDefault()
  362. callPhone()
  363. }}
  364. >
  365. <div class={styles.bottomImgWrap}>
  366. <img src={phoneIcon} alt="" />
  367. </div>
  368. <p>拨打电话</p>
  369. </div>
  370. </div>
  371. </ActionSheet>
  372. </div>
  373. </>
  374. )
  375. }
  376. })