index.vue 9.8 KB

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