index.vue 13 KB

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