index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. <template>
  2. <view>
  3. <!-- 基本信息 -->
  4. <template>
  5. <view class="content">
  6. <u-cell isLink @click="show=true">
  7. <view slot="title" class="u-slot-title">
  8. <text class="u-cell-text">
  9. <RedDot text="班级" :required="true"></RedDot>
  10. </text>
  11. </view>
  12. <view slot="right-icon" isLink class="cell-right">{{classCheck.label || '请选择'}}</view>
  13. </u-cell>
  14. <u-picker v-if="type != 2" :closeOnClickOverlay="true" @close="show=false" :show="show" :columns="classData"
  15. keyName="label" @cancel="show=false" @confirm="choiceUser"></u-picker>
  16. </view>
  17. <view class="content">
  18. <u-cell isLink @click="nameshow">
  19. <view slot="title" class="u-slot-title">
  20. <text class="u-cell-text">
  21. <RedDot text="姓名" :required="true"></RedDot>
  22. </text>
  23. </view>
  24. <view slot="right-icon" isLink class="cell-right">{{nameCheck.label || '请选择'}}</view>
  25. </u-cell>
  26. <u-popup v-if="type != 2" @close="nameShow=false" :closeOnClickOverlay="true" @cancel="nameShow=false" :overlay="false"
  27. :show="nameShow">
  28. <view style="height: 500rpx; position: relative; display: flex; justify-content: center;">
  29. <view style="position: absolute; top: 80rpx; z-index: 999999; background: #fff;">
  30. <input class="inp" confirm-type="search" v-model="key" @input="serName"
  31. placeholder="学生姓名" />
  32. <u-icon class="inp-img" name="search" color="#8C8C8C" size="49rpx"></u-icon>
  33. </view>
  34. <u-picker :closeOnClickOverlay="true" @close="nameShow=false" :show="nameShow"
  35. :columns="nameData" keyName="label" @cancel="nameShow=false" @confirm="choiceName">
  36. </u-picker>
  37. </view>
  38. </u-popup>
  39. </view>
  40. <view class="content">
  41. <u-cell>
  42. <view slot="title" class="u-slot-title">
  43. <text class="u-cell-text">
  44. 性别
  45. </text>
  46. </view>
  47. <view slot="right-icon" style="padding-right: 40rpx; color: rgba(0,0,0,0.30);">
  48. {{formData.sex == 1 ? '男' : formData.sex == 2 ? '女' : '自动获取'}}
  49. </view>
  50. </u-cell>
  51. </view>
  52. </template>
  53. <!-- 症状及体征 -->
  54. <view class="symptom">
  55. <text class="u-cell-text">
  56. <RedDot text="症状及体征" :required="true"></RedDot>
  57. </text>
  58. <u--textarea border="none" style="margin: 32rpx 0 72rpx 0; padding: 0;" v-model="formData.symptom"
  59. placeholder="请输入" autoHeight></u--textarea>
  60. <text class="u-cell-text">
  61. 症状体征照片
  62. </text>
  63. <upImage :img="imgOne" @addImg="addImg"></upImage>
  64. </view>
  65. <!-- 处理措施 -->
  66. <view class="symptom">
  67. <view v-for="item in formData.disposeRecords">
  68. <RedDot text="处理措施" :required="true"></RedDot>
  69. <u--textarea border="none" style="margin: 32rpx 0 72rpx 0; padding: 0;" v-model="item.text"
  70. placeholder="请输入" autoHeight></u--textarea>
  71. </view>
  72. <text class="u-cell-text">
  73. 应急处置后照片
  74. </text>
  75. <upImage :img="imgTwo" @addImg="addImg1"></upImage>
  76. </view>
  77. <!-- 备注 -->
  78. <!-- <view class="remarks"> -->
  79. <!-- 备注 -->
  80. <!-- <u-icon name="edit-pen" color="#8C8C8C" size="49rpx"></u-icon> -->
  81. <!-- 功能不明确 -->
  82. <!-- </view> -->
  83. <view class="symptom">
  84. <!-- <RedDot text="备注"></RedDot> -->
  85. <text class="u-cell-text">
  86. 备注
  87. </text>
  88. <u--textarea border="none" style="margin: 32rpx 0 72rpx 0; padding: 0;" v-model="formData.remark"
  89. placeholder="请输入" autoHeight></u--textarea>
  90. </view>
  91. <!-- 结论多选 -->
  92. <view class="choice">
  93. <template>
  94. <u-checkbox-group v-model="checkboxValue1" placement="row" class="radio">
  95. <u-checkbox :customStyle="{marginBottom: '8px'}" shape="square" activeColor="#6241D5" label="需要观察"
  96. name="需要观察">
  97. </u-checkbox>
  98. <u-checkbox :customStyle="{marginBottom: '8px'}" shape="square" activeColor="#6241D5" label="通知家长"
  99. name="通知家长">
  100. </u-checkbox>
  101. </u-checkbox-group>
  102. </template>
  103. </view>
  104. <!-- 提交按钮 -->
  105. <view class="submit">
  106. <u-button shape="circle" type="primary" text="提交" color="#7B5DF0" style="width: 550rpx;" @click="add">
  107. </u-button>
  108. </view>
  109. </view>
  110. </template>
  111. <script>
  112. import RedDot from '../../conponents/red-dot.vue'
  113. import upImage from '../../conponents/upload/upImage.vue'
  114. export default {
  115. components: {
  116. RedDot,
  117. upImage,
  118. },
  119. data() {
  120. return {
  121. show: false,
  122. nameShow: false,
  123. type: '', // 是否编辑
  124. formData: {
  125. symptom: "", // 症状文本
  126. disposeRecords: [{
  127. text: '',
  128. studentId: '',
  129. }], // 处理措施
  130. remark: '', // 备注
  131. isWatch: 0, // 是否需要观察
  132. isNoticeParent: 1, // 是否通知家长
  133. sex: '自动生成',
  134. },
  135. checkboxValue1: ['通知家长'],
  136. id: '',
  137. detailsData: '',
  138. classData: [], // 班级列表
  139. nameData: [], // 姓名列表
  140. radiolist1: [{
  141. name: '需要观察',
  142. disabled: false
  143. },
  144. {
  145. name: '通知家长',
  146. disabled: true
  147. }
  148. ],
  149. classCheck: {
  150. label: ''
  151. }, // 选中班级
  152. nameCheck: {
  153. label: ''
  154. }, // 选中姓名
  155. imgOne: [],
  156. imgTwo: [],
  157. emergencyImgs: [], // 应急处置照片
  158. symptomImgs: [], // 症状体征照片
  159. key: '', // 学生姓名
  160. setTime: null,
  161. nameDataTwo: [], // 临时存储学生信息
  162. }
  163. },
  164. onLoad(e) {
  165. console.log(e)
  166. if (e.type == 2) {
  167. this.type = 2
  168. uni.setNavigationBarTitle({
  169. title: '编辑'
  170. })
  171. this.id = e.id
  172. this.getData()
  173. }
  174. if (e.idt) {
  175. this.getBasics(e.idt)
  176. }
  177. this.getClass(e.id)
  178. },
  179. methods: {
  180. choiceUser(e) {
  181. if (e.value[0] != undefined) {
  182. this.show = false;
  183. this.classCheck = e.value[0];
  184. }
  185. },
  186. choiceName(e) {
  187. if (e.value[0] != undefined) {
  188. this.nameShow = false;
  189. this.nameCheck = e.value[0];
  190. for (let item of this.formData.disposeRecords) {
  191. item.studentId = e.value[0].value;
  192. }
  193. this.formData.sex = e.value[0].sex
  194. }
  195. },
  196. // 编辑时调用获取学生信息
  197. getData() {
  198. this.$request({
  199. url: this.$api.index.emergencyDetail,
  200. data: {
  201. id: this.id,
  202. },
  203. }).then(res => {
  204. for (let item of res.data.detail.disposeRecords) {
  205. item.createTime = item.createTime.replace('T', ' ')
  206. }
  207. this.formData = res.data.detail
  208. this.classCheck = {
  209. label: this.formData.className,
  210. value: this.formData.classId,
  211. }
  212. this.nameCheck = {
  213. label: this.formData.name,
  214. value: this.formData.studentId,
  215. }
  216. // emergencyImgs, // 应急处置照片
  217. // symptomImgs, // 症状体征照片
  218. this.symptomImgs = this.formData.symptomImgs.split(',')
  219. this.emergencyImgs = this.formData.emergencyImgs.split(',')
  220. let arr = this.formData.symptomImgs.split(',')
  221. let arr1 = this.formData.emergencyImgs.split(',')
  222. // console.log(this.formData)
  223. if (this.formData.symptomImgs != '') {
  224. for (let item of arr) {
  225. this.imgOne.push({
  226. url: item
  227. })
  228. }
  229. }
  230. if (this.formData.emergencyImgs != '') {
  231. for (let item of arr1) {
  232. this.imgTwo.push({
  233. url: item
  234. })
  235. }
  236. }
  237. this.checkboxValue1 = []
  238. this.formData.isWatch ? this.checkboxValue1.push('需要观察') : ''
  239. this.formData.isNoticeParent ? this.checkboxValue1.push('通知家长') : ''
  240. })
  241. },
  242. // 人脸识别成功获取基础信息
  243. getBasics(id) {
  244. this.$request({
  245. url: this.$api.addHandle.student,
  246. data: {
  247. id: id,
  248. },
  249. }).then(res => {
  250. console.log(res)
  251. this.getClass(res.data.classId)
  252. this.classCheck.label = res.data.className
  253. this.classCheck.value = res.data.classId
  254. this.nameCheck.label = res.data.name
  255. this.nameCheck.value = id
  256. this.formData.sex = res.data.sex
  257. for (let item of this.formData.disposeRecords) {
  258. item.studentId = res.data.studentId
  259. }
  260. })
  261. },
  262. // 获取班级信息
  263. getClass(id) {
  264. this.$request({
  265. url: this.$api.addHandle.getClassSelectVos,
  266. data: {
  267. id: id,
  268. },
  269. }).then(res => {
  270. this.classData = []
  271. this.classData.push(res.data)
  272. })
  273. },
  274. nameshow() {
  275. if (this.classCheck.label == "") {
  276. this.$u.toast('请先选择班级')
  277. } else {
  278. this.getName()
  279. this.nameShow = true
  280. }
  281. // this.nameShow = true
  282. },
  283. // 请求姓名信息
  284. getName() {
  285. this.$request({
  286. url: this.$api.addHandle.getNameSelectVos,
  287. data: {
  288. classId: this.classCheck.value,
  289. },
  290. }).then(res => {
  291. this.nameData = []
  292. this.nameData.push(res.data)
  293. this.nameDataTwo.push(res.data)
  294. })
  295. },
  296. // 学生搜索框
  297. serName() {
  298. // 防抖
  299. this.nameData = this.nameDataTwo
  300. if (this.setTime !== null) {
  301. clearTimeout(this.setTime);
  302. }
  303. this.setTime = setTimeout(() => {
  304. // if (this.key == '') {
  305. // this.nameData = this.nameDataTwo
  306. // return
  307. // }
  308. let arr = []
  309. for (let item of this.nameData[0]) {
  310. if (item.label.search(this.key) == 0) {
  311. arr.push(item)
  312. }
  313. }
  314. this.nameData = [arr]
  315. }, 1000)
  316. },
  317. // 关闭遮罩层
  318. close() {
  319. this.key = '';
  320. this.show = false
  321. this.nameShow = false
  322. this.nameData = this.nameDataTwo
  323. },
  324. addImg(img) {
  325. console.log('img', img)
  326. },
  327. // 提交
  328. add() {
  329. console.log(this.checkboxValue1)
  330. if (this.classCheck.label == '') {
  331. this.$u.toast('未选择班级')
  332. return
  333. } else if (this.nameCheck.label == '') {
  334. this.$u.toast('未选择学生')
  335. return
  336. } else if (this.formData.symptom == '') {
  337. this.$u.toast('症状体征未填写')
  338. return
  339. } else if (this.formData.disposeRecords[0].text == '') {
  340. this.$u.toast('处理措施未填写')
  341. return
  342. }
  343. // else if (this.formData.remark == '') {
  344. // this.$u.toast('备注未填写')
  345. // return
  346. // }
  347. this.checkboxValue1.indexOf("需要观察") != -1 ? this.formData.isWatch = 1 : this.formData.isWatch = 0
  348. this.checkboxValue1.indexOf("通知家长") != -1 ? this.formData.isNoticeParent = 1 : this.formData
  349. .isNoticeParent = 0
  350. for (let item of this.formData.disposeRecords) {
  351. item.disposeText = item.text
  352. }
  353. let add = []
  354. for (let item of this.formData.disposeRecords) {
  355. add.push({
  356. disposeText: item.disposeText,
  357. studentId: item.studentId,
  358. text: item.text,
  359. id: item.id
  360. })
  361. }
  362. this.formData.disposeRecords = add
  363. var arr = {
  364. ...this.formData,
  365. className: this.classCheck.label,
  366. classId: this.classCheck.value,
  367. name: this.nameCheck.label,
  368. studentId: this.nameCheck.value,
  369. emergencyImgs: this.emergencyImgs.join(','), // 应急处置照片
  370. symptomImgs: this.symptomImgs.join(','), // 症状体征照片
  371. id: this.id,
  372. }
  373. console.log(arr, this.id)
  374. if (this.id) {
  375. // 判断是否编辑
  376. console.log('编辑')
  377. this.$request({
  378. url: this.$api.index.modifyAppEmergency,
  379. data: arr,
  380. header: {
  381. contentType: "application/json"
  382. },
  383. method: 'POST',
  384. }).then(res => {
  385. console.log(res)
  386. if (res.code == 200) {
  387. this.$u.toast('编辑成功')
  388. setTimeout(() => {
  389. uni.switchTab({
  390. url: '/pages/index/index'
  391. });
  392. }, 2000)
  393. }
  394. })
  395. } else {
  396. console.log('新增')
  397. arr.disposeText = this.formData.disposeRecords[0].text,
  398. this.$request({
  399. url: this.$api.index.addAppEmergency,
  400. data: arr,
  401. header: {
  402. contentType: "application/json"
  403. },
  404. method: 'POST',
  405. }).then(res => {
  406. console.log(res)
  407. if (res.code == 200) {
  408. this.$u.toast('添加成功')
  409. setTimeout(() => {
  410. uni.switchTab({
  411. url: '/pages/index/index'
  412. });
  413. }, 2000)
  414. }
  415. }).catch(err => {
  416. this.$u.toast(err.msg)
  417. })
  418. }
  419. },
  420. addImg(img) {
  421. // 症状体征图片
  422. let arr = []
  423. this.symptomImgs = []
  424. for (let item of img) {
  425. arr.push(item.url)
  426. }
  427. this.symptomImgs = arr
  428. console.log(img)
  429. },
  430. addImg1(img) {
  431. // 应急处置图片
  432. let arr = []
  433. this.emergencyImgs = []
  434. for (let item of img) {
  435. arr.push(item.url)
  436. }
  437. this.emergencyImgs = arr
  438. console.log(img)
  439. },
  440. }
  441. }
  442. </script>
  443. <style lang="scss" scoped>
  444. page {
  445. /* background-color: #D9D9D9; */
  446. background-color: #F5F5F5 !important;
  447. }
  448. .inp {
  449. height: 72rpx;
  450. border: 2rpx solid #D9D9D9;
  451. border-radius: 50px;
  452. box-sizing: border-box;
  453. padding-left: 60rpx;
  454. }
  455. .inp-img {
  456. position: absolute;
  457. top: 10rpx;
  458. left: 10rpx;
  459. }
  460. .u-cell {
  461. background-color: #fff;
  462. height: 112rpx;
  463. line-height: 73rpx;
  464. }
  465. .u-cell-text {
  466. font-size: 32rpx;
  467. }
  468. .u-cell-text image {
  469. width: 10rpx;
  470. height: 28rpx;
  471. margin-left: 15rpx;
  472. }
  473. .symptom {
  474. margin-top: 20rpx;
  475. padding: 32rpx 32rpx;
  476. box-sizing: border-box;
  477. background-color: #fff;
  478. }
  479. .upImage {
  480. width: 160rpx;
  481. height: 160rpx;
  482. border-radius: 16rpx;
  483. border: 2rpx solid #d9d9d9;
  484. display: flex;
  485. justify-content: center;
  486. }
  487. .remarks {
  488. height: 80rpx;
  489. margin-top: 20rpx;
  490. font-size: 32rpx;
  491. color: rgba(0, 0, 0, 0.60);
  492. background-color: #fff;
  493. display: flex;
  494. align-items: center;
  495. justify-content: center;
  496. }
  497. .choice {
  498. height: 178rpx;
  499. background-color: #fff;
  500. margin-top: 20rpx;
  501. padding-top: 36rpx;
  502. box-sizing: border-box;
  503. }
  504. .radio {
  505. display: flex;
  506. justify-content: space-evenly;
  507. }
  508. .submit {
  509. height: 240rpx;
  510. padding-top: 49rpx;
  511. box-sizing: border-box;
  512. }
  513. .cell-right {
  514. padding-right: 50rpx;
  515. background-image: url(@/static/chevron_right.svg);
  516. background-repeat: no-repeat;
  517. background-position: 100% 12px;
  518. color: rgba(0, 0, 0, 0.30);
  519. }
  520. </style>