index.vue 13 KB

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