index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. <template>
  2. <view>
  3. <view>
  4. <view class="topTwo">
  5. <!-- 头部导航 -->
  6. <view class="tesx">
  7. <view :class="tobu == 1 ? 'con' : ''" @click="to(1)" style="margin-right: 20rpx;">需要观察</view>
  8. <view :class="tobu == 2 ? 'con' : ''" @click="to(2)">处置记录</view>
  9. </view>
  10. <!-- 搜索框 -->
  11. <view class="sou">
  12. <input class="inp" confirm-type="search" @confirm="search" @input="search" v-model="key"
  13. placeholder="学生姓名" />
  14. <u-icon class="inp-img" name="search" color="#8C8C8C" size="49rpx"></u-icon>
  15. </view>
  16. </view>
  17. </view>
  18. <view style="height: 256rpx;"></view>
  19. <!-- <view class="noData" v-if="listData.length == 0">
  20. 暂无数据
  21. </view> -->
  22. <view v-if="tobu == 1">
  23. <u-swipe-action>
  24. <u-swipe-action-item :threshold="60" style="margin-bottom: 32rpx;" v-for="(item, index) in listData" :options="swipe"
  25. :disabled="swipeShow" @click="cancelT(item)" :key="index">
  26. <!-- 任务分块部分 -->
  27. <view class="chunking">
  28. <view @click="toDetails(item.id)">
  29. <view style="overflow: hidden;">
  30. <view class="img-no">
  31. <image :src="item.headUrl"></image>
  32. </view>
  33. <!-- 图片替代 -->
  34. <!-- 基本信息 -->
  35. <view class="chunking-text">
  36. <view class="top">
  37. <text
  38. style="font-size: 32rpx; font-weight: 600 ; margin-right: 10rpx;">{{item.studentName}}</text>
  39. ·
  40. <!-- 这里有个点 -->
  41. <text style="margin-left: 10rpx;">{{item.sex == 1 ? '男' : '女'}}</text>
  42. </view>
  43. <view class="bottom">{{item.age}}岁 <text
  44. style="margin-left: 10rpx;">{{item.grade}}</text></view>
  45. </view>
  46. <!-- 时间 -->
  47. <view class="chunking-time">{{item.createTime}}</view>
  48. </view>
  49. <!-- 简略信息 -->
  50. <view class="brief">
  51. <view style="color: #6241D5; font-weight: 600; margin-bottom: 10rpx;">伤情:</view>
  52. {{item.symptom}}
  53. </view>
  54. <!-- 底部 -->
  55. <view class="block-end">
  56. <!-- 处理人信息 -->
  57. <view class="handle">
  58. 处理人: {{item.disposeUserName}}
  59. </view>
  60. <!-- 跟踪处置 - 按钮 -->
  61. <!-- <view class="ann" style="float: right;" @click="track(1)">
  62. 跟踪处置
  63. </view> -->
  64. </view>
  65. </view>
  66. <!-- 跟踪处置 - 按钮 -->
  67. <view class="ann" style="float: right;" @click="track(item)">
  68. 跟踪处置
  69. </view>
  70. </view>
  71. </u-swipe-action-item>
  72. </u-swipe-action>
  73. </view>
  74. <view v-else>
  75. <!-- 任务分块部分 -->
  76. <view class="chunking" style="margin-bottom: 32rpx;" v-for="(item, id) in listData" :key="id">
  77. <view @click="toDetails(item.id)">
  78. <view style="overflow: hidden;">
  79. <view class="img-no">
  80. <image :src="item.headUrl"></image>
  81. </view>
  82. <!-- 图片替代 -->
  83. <!-- 基本信息 -->
  84. <view class="chunking-text">
  85. <view class="top">
  86. <text
  87. style="font-size: 32rpx; font-weight: 600 ; margin-right: 10rpx;">{{item.studentName}}</text>
  88. ·
  89. <!-- 这里有个点 -->
  90. <text style="margin-left: 10rpx;">{{item.sex == 1 ? '男' : '女'}}</text>
  91. </view>
  92. <view class="bottom">{{item.age}}岁 <text style="margin-left: 10rpx;">{{item.grade}}</text>
  93. </view>
  94. </view>
  95. <!-- 时间 -->
  96. <view class="chunking-time">{{item.createTime}}</view>
  97. </view>
  98. <!-- 简略信息 -->
  99. <view class="brief">
  100. <view style="color: #6241D5; font-weight: 600; margin-bottom: 10rpx;">伤情:</view>
  101. {{item.symptom}}
  102. </view>
  103. <!-- 底部 -->
  104. <view class="block-end">
  105. <!-- 处理人信息 -->
  106. <view class="handle">
  107. 处理人: {{item.disposeUserName}}
  108. </view>
  109. <!-- 跟踪处置 - 按钮 -->
  110. <!-- <view class="ann" style="float: right;" @click="track(1)">
  111. 跟踪处置
  112. </view> -->
  113. </view>
  114. </view>
  115. <!-- 跟踪处置 - 按钮 -->
  116. <!-- <view class="ann" style="float: right;" @click="track(item)">
  117. 跟踪处置
  118. </view> -->
  119. </view>
  120. </view>
  121. <!-- 功能不明确,暂时 -->
  122. <!-- <view @click="signIn">
  123. 登录跳转
  124. </view> -->
  125. <!-- 悬浮按钮 -->
  126. <view class="suspension" @click="toFace">
  127. <image src="../../static/icon.svg"></image>
  128. </view>
  129. <!-- 跟踪处置 -->
  130. <u-action-sheet :closeOnClickOverlay="true" @close="cancel" @select="selectClick" :show="show">
  131. <template>
  132. <view style="padding: 32rpx; text-align: left;">
  133. <RedDot text="处理措施" :required="true"></RedDot>
  134. <u--textarea border="none" v-model="disposeText" style="margin: 32rpx 0 72rpx 0; padding: 0;"
  135. placeholder="请输入" autoHeight />
  136. </view>
  137. <view class="handle-time">
  138. 处理时间:{{time}}
  139. </view>
  140. <view class="behavior" @click="addBehavior" style="color: #7B5DF0; border: 1rpx solid #F5F6F7;">确认
  141. </view>
  142. <view class="behavior" @click="cancel">取消</view>
  143. </template>
  144. </u-action-sheet>
  145. <u-loadmore :status="status" :loading-text="loadingText" :nomore-text="nomoreText" />
  146. </view>
  147. </template>
  148. <script>
  149. import RedDot from '../../conponents/red-dot.vue'
  150. export default {
  151. components: {
  152. RedDot,
  153. },
  154. data() {
  155. return {
  156. providerList: [],
  157. version: '',
  158. tobu: '1',
  159. swipe: [{
  160. text: '取消跟踪',
  161. style: {
  162. backgroundColor: '#FA541C',
  163. }
  164. }],
  165. swipeShow: false,
  166. listData: [], // 列表数据
  167. page: 1, // 分页
  168. tobel: '', // 总数
  169. key: '', // 学生姓名关键字
  170. id: '',
  171. show: false,
  172. disposeText: '',
  173. Record: '', // 添加应急处理数据
  174. time: '', // 跟踪处理时间
  175. status: 'loading',
  176. loadingText: '努力加载中',
  177. nomoreText: '实在没有了',
  178. setTime: null,
  179. img: '',
  180. }
  181. },
  182. onShow() {
  183. // this.tobu = '1'
  184. this.page = 1, // 分页
  185. this.listData = []
  186. this.getList()
  187. },
  188. watch:{
  189. listData(newName, oldName){
  190. let time = 1000
  191. },
  192. },
  193. methods: {
  194. // 跳转登录页面
  195. signIn() {
  196. uni.navigateTo({
  197. url: `/pages/signIn/signIn`
  198. })
  199. },
  200. // 列表数据请求
  201. getList() {
  202. let data = {
  203. pageNum: this.page,
  204. pageSize: 5,
  205. type: this.tobu,
  206. }
  207. if(this.key){
  208. data.search = this.key
  209. }
  210. this.$request({
  211. url: this.$api.index.emergencyList,
  212. data: data
  213. }).then( res => {
  214. if (res.code == 200) {
  215. for (let item of res.data.list) {
  216. item.createTime = item.createTime.replace('T', ' ')
  217. item.createTime = item.createTime.slice(0, item.createTime.length - 3)
  218. }
  219. this.listData.push(...res.data.list)
  220. this.total = res.data.total
  221. if (res.data.total > 5) {
  222. this.status = 'loadmore'
  223. } else {
  224. this.status = 'nomore'
  225. }
  226. this.getChildHead()
  227. } else {
  228. this.$u.toast(err.message)
  229. this.status = 'nomore'
  230. this.listData = []
  231. }
  232. }).catch(err => {
  233. this.$u.toast(err.message)
  234. this.status = 'nomore'
  235. this.listData = []
  236. })
  237. },
  238. getChildHead(){
  239. for(let index = 0 ;index< this.listData.length ;index++){
  240. let item = this.listData[index]
  241. if(item.headUrl) continue;
  242. let existIndex = this.listData.findIndex(s=>s.studentId == item.studentId && s.headUrl)
  243. if(existIndex > -1) {
  244. item.headUrl = this.listData[existIndex].headUrl
  245. continue;
  246. }
  247. this.$request({
  248. url: this.$api.index.getPortrait,
  249. data: {
  250. id: item.studentId,
  251. studentId: item.studentId,
  252. }
  253. }).then((headRes)=>{
  254. this.listData[index].headUrl = headRes.data
  255. this.$set(this.listData,index,this.listData[index])
  256. })
  257. }
  258. },
  259. // 请求头像
  260. getPortrait(id){
  261. this.$request({
  262. url: this.$api.index.getPortrait,
  263. data: {
  264. id: id,
  265. studentId: id,
  266. }
  267. }).then(res => {
  268. // var arr = res.data
  269. // this.img = res.data
  270. this.getImg(res.data)
  271. console.log(this.getImg(res.data), 'img')
  272. })
  273. },
  274. // 搜索
  275. search() {
  276. // 防抖
  277. if (this.setTime !== null) {
  278. clearTimeout(this.setTime);
  279. }
  280. this.setTime = setTimeout(() => {
  281. this.listData = []
  282. this.getList()
  283. }, 500)
  284. },
  285. // 点击改变是否观察或者处理记录
  286. to(data) {
  287. if (this.status == 'loading') {
  288. return
  289. }
  290. this.key = ''
  291. this.page = 1
  292. this.tobu = data
  293. this.listData = []
  294. this.status = 'loading'
  295. setTimeout(() => {
  296. this.getList()
  297. }, 1000)
  298. },
  299. cancelT(data) {
  300. console.log(data)
  301. // return
  302. this.$request({
  303. url: this.$api.index.cancelWatch,
  304. header: {
  305. contentType: "application/json"
  306. },
  307. method: 'POST',
  308. data: {
  309. id: data.id
  310. }
  311. }).then(res => {
  312. this.$u.toast(res.msg)
  313. if (res.code == 200) {
  314. this.listData = []
  315. this.status = 'loading'
  316. this.getList()
  317. }
  318. })
  319. },
  320. // 跟踪处置
  321. track(data) {
  322. console.log(data)
  323. this.time = this.dateFormat("YYYY.mm.dd HH:MM", new Date())
  324. this.Record = data
  325. this.show = true
  326. },
  327. //跳转详情
  328. toDetails(id) {
  329. console.log(id)
  330. uni.navigateTo({
  331. url: `/pages/details/index?id=${id}`
  332. })
  333. },
  334. toFace() {
  335. uni.navigateTo({
  336. url: '/pages/face/index'
  337. })
  338. },
  339. addBehavior() {
  340. if (this.disposeText == '') {
  341. this.$u.toast('处理措施未填写')
  342. return
  343. }
  344. this.$request({
  345. url: this.$api.index.addDisposeRecord,
  346. header: {
  347. contentType: "application/json"
  348. },
  349. method: 'POST',
  350. data: {
  351. id: this.Record.id,
  352. disposeText: this.disposeText,
  353. }
  354. }).then(res => {
  355. this.$u.toast(res.msg)
  356. this.cancel()
  357. }).catch(err => {
  358. this.$u.toast(err.msg)
  359. this.cancel()
  360. })
  361. },
  362. cancel() {
  363. this.show = false
  364. this.disposeText = ''
  365. },
  366. // 获取时间
  367. dateFormat(fmt, date) {
  368. let ret;
  369. const opt = {
  370. "Y+": date.getFullYear().toString(), // 年
  371. "m+": (date.getMonth() + 1).toString(), // 月
  372. "d+": date.getDate().toString(), // 日
  373. "H+": date.getHours().toString(), // 时
  374. "M+": date.getMinutes().toString(), // 分
  375. "S+": date.getSeconds().toString() // 秒
  376. // 有其他格式化字符需求可以继续添加,必须转化成字符串
  377. };
  378. for (let k in opt) {
  379. ret = new RegExp("(" + k + ")").exec(fmt);
  380. if (ret) {
  381. fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
  382. };
  383. };
  384. return fmt;
  385. },
  386. onReachBottom() {
  387. // console.log(this.page, this.total)
  388. setTimeout(() => {
  389. if (this.total - this.page * 5 <= 0) {
  390. this.status = 'nomore'
  391. // console.log('ww')
  392. } else {
  393. // console.log('w')
  394. this.status = 'loading';
  395. this.page++
  396. this.getList()
  397. }
  398. }, 100)
  399. }
  400. }
  401. }
  402. </script>
  403. <style lang="scss" scoped>
  404. page {
  405. padding: 0 32rpx;
  406. /* background-color: #D9D9D9; */
  407. background-color: #F5F5F5 !important;
  408. }
  409. .topTwo {
  410. position: fixed;
  411. top: -2rpx;
  412. background-color: #f5f5f5;
  413. padding-bottom: 10rpx;
  414. z-index: 999;
  415. width: 100%;
  416. box-sizing: border-box;
  417. padding-right: 65rpx;
  418. }
  419. .tesx {
  420. display: flex;
  421. align-items: center;
  422. font-size: 32rpx;
  423. color: rgba(0, 0, 0, 0.60);
  424. height: 128rpx;
  425. margin-bottom: 16rpx;
  426. }
  427. .con {
  428. font-size: 40rpx;
  429. font-weight: 600;
  430. color: #000;
  431. }
  432. .sou {
  433. margin-bottom: 30rpx;
  434. position: relative;
  435. overflow: hidden;
  436. }
  437. .inp {
  438. height: 72rpx;
  439. border: 2rpx solid #D9D9D9;
  440. border-radius: 50px;
  441. box-sizing: border-box;
  442. padding-left: 60rpx;
  443. }
  444. .inp-img {
  445. position: absolute;
  446. top: 10rpx;
  447. left: 10rpx;
  448. }
  449. .chunking {
  450. height: 400rpx;
  451. border-radius: 32rpx;
  452. background-color: #fff;
  453. box-sizing: border-box;
  454. padding: 32rpx;
  455. position: relative;
  456. }
  457. .img-no {
  458. width: 83rpx;
  459. height: 83rpx;
  460. background-color: #D9D9D9;
  461. border-radius: 50rpx;
  462. margin-right: 15rpx;
  463. float: left;
  464. overflow: hidden;
  465. image{
  466. width: 100%;
  467. height: 100%;
  468. }
  469. }
  470. .chunking-text {
  471. float: left;
  472. font-size: 25rpx;
  473. display: flex;
  474. flex-direction: column;
  475. justify-content: center;
  476. }
  477. .chunking-text .top {
  478. margin: 5rpx 0;
  479. }
  480. .chunking-text .buttom {}
  481. .chunking-time {
  482. float: right;
  483. font-size: 28rpx;
  484. color: rgba(0, 0, 0, 0.60);
  485. height: 83rpx;
  486. line-height: 83rpx;
  487. }
  488. .brief {
  489. width: 622rpx;
  490. height: 136rpx;
  491. background: #fafafa;
  492. border-radius: 16rpx;
  493. margin-top: 33rpx;
  494. box-sizing: border-box;
  495. padding: 16rpx 23rpx;
  496. font-size: 28rpx;
  497. color: rgba(0, 0, 0, 0.60);
  498. font-weight: 500;
  499. overflow:hidden;
  500. white-space:nowrap;
  501. text-overflow:ellipsis;
  502. }
  503. .block-end {
  504. height: 56rpx;
  505. font-size: 28rpx;
  506. color: #000;
  507. font-weight: 500;
  508. margin-top: 32rpx;
  509. }
  510. .handle {
  511. float: left;
  512. line-height: 58rpx;
  513. }
  514. .ann {
  515. float: right;
  516. border: 1px solid #fa8c16;
  517. box-sizing: border-box;
  518. padding: 9rpx 25rpx;
  519. color: #FA8C16;
  520. border-radius: 40rpx;
  521. position: relative;
  522. bottom: 56rpx;
  523. z-index: 9;
  524. font-size: 28rpx;
  525. }
  526. .suspension {
  527. width: 96rpx;
  528. height: 96rpx;
  529. border-radius: 50px;
  530. background-color: #7b5df0;
  531. position: fixed;
  532. right: 32rpx;
  533. bottom: 168rpx;
  534. z-index: 999;
  535. }
  536. .suspension image {
  537. width: 100%;
  538. height: 100%;
  539. }
  540. /* 滑块单元格样式 */
  541. .u-swipe-action-item {
  542. border-radius: 32rpx;
  543. }
  544. .swipe-action {
  545. &__content {
  546. padding: 25rpx 0;
  547. &__text {
  548. font-size: 28rpx;
  549. color: #fff;
  550. padding-left: 30rpx;
  551. }
  552. }
  553. }
  554. .handle-time {
  555. height: 80rpx;
  556. line-height: 80rpx;
  557. background: #f5f6f7;
  558. margin-top: 18rpx;
  559. box-sizing: border-box;
  560. padding-left: 32rpx;
  561. color: rgba(0, 0, 0, 0.60);
  562. font-size: 23rpx;
  563. text-align: left;
  564. }
  565. .behavior {
  566. height: 112rpx;
  567. line-height: 112rpx;
  568. font-size: 33rpx;
  569. color: #000;
  570. }
  571. // 暂无数据
  572. .noData {
  573. text-align: center;
  574. }
  575. </style>