index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  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: 20rpx; z-index: 999999;">
  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.nameCheck.label = res.data.name
  254. this.formData.sex = res.data.sex
  255. for (let item of this.formData.disposeRecords) {
  256. item.studentId = res.data.studentId
  257. }
  258. })
  259. },
  260. // 获取班级信息
  261. getClass(id) {
  262. this.$request({
  263. url: this.$api.addHandle.getClassSelectVos,
  264. data: {
  265. id: id,
  266. },
  267. }).then(res => {
  268. this.classData = []
  269. this.classData.push(res.data)
  270. })
  271. },
  272. nameshow() {
  273. if (this.classCheck.label == "") {
  274. this.$u.toast('请先选择班级')
  275. } else {
  276. this.getName()
  277. this.nameShow = true
  278. }
  279. // this.nameShow = true
  280. },
  281. // 请求姓名信息
  282. getName() {
  283. this.$request({
  284. url: this.$api.addHandle.getNameSelectVos,
  285. data: {
  286. classId: this.classCheck.value,
  287. },
  288. }).then(res => {
  289. this.nameData = []
  290. this.nameData.push(res.data)
  291. this.nameDataTwo.push(res.data)
  292. })
  293. },
  294. // 学生搜索框
  295. serName() {
  296. // 防抖
  297. this.nameData = this.nameDataTwo
  298. if (this.setTime !== null) {
  299. clearTimeout(this.setTime);
  300. }
  301. this.setTime = setTimeout(() => {
  302. // if (this.key == '') {
  303. // this.nameData = this.nameDataTwo
  304. // return
  305. // }
  306. let arr = []
  307. for (let item of this.nameData[0]) {
  308. if (item.label.search(this.key) == 0) {
  309. arr.push(item)
  310. }
  311. }
  312. this.nameData = [arr]
  313. }, 1000)
  314. },
  315. // 关闭遮罩层
  316. close() {
  317. this.key = '';
  318. this.show = false
  319. this.nameShow = false
  320. this.nameData = this.nameDataTwo
  321. },
  322. addImg(img) {
  323. console.log('img', img)
  324. },
  325. // 提交
  326. add() {
  327. console.log(this.checkboxValue1)
  328. if (this.classCheck.label == '') {
  329. this.$u.toast('未选择班级')
  330. return
  331. } else if (this.nameCheck.label == '') {
  332. this.$u.toast('未选择学生')
  333. return
  334. } else if (this.formData.symptom == '') {
  335. this.$u.toast('症状体征未填写')
  336. return
  337. } else if (this.formData.disposeRecords[0].text == '') {
  338. this.$u.toast('处理措施未填写')
  339. return
  340. }
  341. // else if (this.formData.remark == '') {
  342. // this.$u.toast('备注未填写')
  343. // return
  344. // }
  345. this.checkboxValue1.indexOf("需要观察") != -1 ? this.formData.isWatch = 1 : this.formData.isWatch = 0
  346. this.checkboxValue1.indexOf("通知家长") != -1 ? this.formData.isNoticeParent = 1 : this.formData
  347. .isNoticeParent = 0
  348. for (let item of this.formData.disposeRecords) {
  349. item.disposeText = item.text
  350. }
  351. let add = []
  352. for (let item of this.formData.disposeRecords) {
  353. add.push({
  354. disposeText: item.disposeText,
  355. studentId: item.studentId,
  356. text: item.text,
  357. id: item.id
  358. })
  359. }
  360. this.formData.disposeRecords = add
  361. var arr = {
  362. ...this.formData,
  363. className: this.classCheck.label,
  364. classId: this.classCheck.value,
  365. name: this.nameCheck.label,
  366. studentId: this.nameCheck.value,
  367. emergencyImgs: this.emergencyImgs.join(','), // 应急处置照片
  368. symptomImgs: this.symptomImgs.join(','), // 症状体征照片
  369. id: this.id,
  370. }
  371. console.log(arr, this.id)
  372. if (this.id) {
  373. // 判断是否编辑
  374. console.log('编辑')
  375. this.$request({
  376. url: this.$api.index.modifyAppEmergency,
  377. data: arr,
  378. header: {
  379. contentType: "application/json"
  380. },
  381. method: 'POST',
  382. }).then(res => {
  383. console.log(res)
  384. if (res.code == 200) {
  385. this.$u.toast('编辑成功')
  386. setTimeout(() => {
  387. uni.switchTab({
  388. url: '/pages/index/index'
  389. });
  390. }, 2000)
  391. }
  392. })
  393. } else {
  394. console.log('新增')
  395. arr.disposeText = this.formData.disposeRecords[0].text,
  396. this.$request({
  397. url: this.$api.index.addAppEmergency,
  398. data: arr,
  399. header: {
  400. contentType: "application/json"
  401. },
  402. method: 'POST',
  403. }).then(res => {
  404. console.log(res)
  405. if (res.code == 200) {
  406. this.$u.toast('添加成功')
  407. setTimeout(() => {
  408. uni.switchTab({
  409. url: '/pages/index/index'
  410. });
  411. }, 2000)
  412. }
  413. }).catch(err => {
  414. this.$u.toast(err.msg)
  415. })
  416. }
  417. },
  418. addImg(img) {
  419. // 症状体征图片
  420. let arr = []
  421. this.symptomImgs = []
  422. for (let item of img) {
  423. arr.push(item.url)
  424. }
  425. this.symptomImgs = arr
  426. console.log(img)
  427. },
  428. addImg1(img) {
  429. // 应急处置图片
  430. let arr = []
  431. this.emergencyImgs = []
  432. for (let item of img) {
  433. arr.push(item.url)
  434. }
  435. this.emergencyImgs = arr
  436. console.log(img)
  437. },
  438. }
  439. }
  440. </script>
  441. <style lang="scss" scoped>
  442. page {
  443. /* background-color: #D9D9D9; */
  444. background-color: #F5F5F5 !important;
  445. }
  446. .inp {
  447. height: 72rpx;
  448. border: 2rpx solid #D9D9D9;
  449. border-radius: 50px;
  450. box-sizing: border-box;
  451. padding-left: 60rpx;
  452. }
  453. .inp-img {
  454. position: absolute;
  455. top: 10rpx;
  456. left: 10rpx;
  457. }
  458. .u-cell {
  459. background-color: #fff;
  460. height: 112rpx;
  461. line-height: 73rpx;
  462. }
  463. .u-cell-text {
  464. font-size: 32rpx;
  465. }
  466. .u-cell-text image {
  467. width: 10rpx;
  468. height: 28rpx;
  469. margin-left: 15rpx;
  470. }
  471. .symptom {
  472. margin-top: 20rpx;
  473. padding: 32rpx 32rpx;
  474. box-sizing: border-box;
  475. background-color: #fff;
  476. }
  477. .upImage {
  478. width: 160rpx;
  479. height: 160rpx;
  480. border-radius: 16rpx;
  481. border: 2rpx solid #d9d9d9;
  482. display: flex;
  483. justify-content: center;
  484. }
  485. .remarks {
  486. height: 80rpx;
  487. margin-top: 20rpx;
  488. font-size: 32rpx;
  489. color: rgba(0, 0, 0, 0.60);
  490. background-color: #fff;
  491. display: flex;
  492. align-items: center;
  493. justify-content: center;
  494. }
  495. .choice {
  496. height: 178rpx;
  497. background-color: #fff;
  498. margin-top: 20rpx;
  499. padding-top: 36rpx;
  500. box-sizing: border-box;
  501. }
  502. .radio {
  503. display: flex;
  504. justify-content: space-evenly;
  505. }
  506. .submit {
  507. height: 240rpx;
  508. padding-top: 49rpx;
  509. box-sizing: border-box;
  510. }
  511. .cell-right {
  512. padding-right: 50rpx;
  513. background-image: url(@/static/chevron_right.svg);
  514. background-repeat: no-repeat;
  515. background-position: 100% 12px;
  516. color: rgba(0, 0, 0, 0.30);
  517. }
  518. </style>