add_archives.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. <template>
  2. <view class="main">
  3. <form>
  4. <view class="cu-form-group margin-top">
  5. <view class="title">头像</view>
  6. <image class="cu-avatar radius bg-gray" @click="ChooseImage" :src='imgList[0]' mode='aspectFill'>
  7. </image>
  8. </view>
  9. <view class="cu-form-group">
  10. <view class="title">就诊人姓名:</view>
  11. <input v-model="name" placeholder-style="text-align:right" style="text-align: right;" placeholder="请输入姓名"></input>
  12. </view>
  13. <view class="cu-form-group">
  14. <view class="title">出身年月:</view>
  15. <picker mode="date" :value="date" :end="time" @change="bindDateChange">
  16. <view class="picker">
  17. {{date}}
  18. </view>
  19. </picker>
  20. </view>
  21. <view class="cu-form-group" v-if="jsGetAge(date)<18&&date!='请选择出生日期'">
  22. <view class="title">监护人姓名:</view>
  23. <input v-model="jianhuname" placeholder-style="text-align:right" style="text-align: right;" placeholder="请输入监护人姓名"></input>
  24. </view>
  25. <view class="cu-form-group">
  26. <view class="title">联系电话:</view>
  27. <input type="number" v-model="phone" placeholder-style="text-align:right" style="text-align: right;" placeholder="请输入联系电话"></input>
  28. </view>
  29. <!-- <view class="cu-form-group">
  30. <view class="title">出生医院:</view>
  31. <input v-model="birthhospital" placeholder-style="text-align:right" style="text-align: right;" placeholder="请输入出生医院"></input>
  32. </view> -->
  33. <view class="cu-form-group" @click="loncationTap">
  34. <view class="title">地址:</view>
  35. <input v-model="address" placeholder-style="text-align:right" :disabled="true" style="text-align: right;"></input>
  36. <u-icon name="map-fill" color="#2979ff" size="32"></u-icon>
  37. </view>
  38. <view class="cu-form-group">
  39. <view class="title">详细住址:</view>
  40. <input v-model="infoaddress" placeholder-style="text-align:right" style="text-align: right;" placeholder="请输入详细住址"></input>
  41. </view>
  42. <view class="cu-form-group">
  43. <view class="title">就诊人性别:</view>
  44. <u-radio-group v-model="value" @change="radioGroupChange">
  45. <u-radio v-for="(item, index) in list" :key="index" :name="item.name" :disabled="item.disabled">
  46. {{item.name}}
  47. </u-radio>
  48. </u-radio-group>
  49. </view>
  50. <view class="cu-form-group" @click="show=!show">
  51. <view class="title">与就诊人关系:</view>
  52. <picker :value="guanxi" @change="confirm" :range="guanxilist" range-key="label">
  53. <view class="picker">
  54. {{guanxi}}
  55. </view>
  56. </picker>
  57. </view>
  58. <view class="cu-form-group margin-top">
  59. <view class="title">就诊信息(非必填)</view>
  60. </view>
  61. <view class="cu-form-group">
  62. <view class="title">就诊人身份证:</view>
  63. <input v-model="idcrad" placeholder-style="text-align:right" style="text-align: right;" placeholder="请输入就诊人身份证号"></input>
  64. </view>
  65. <view class="cu-form-group">
  66. <view class="title">电子邮箱:</view>
  67. <input v-model="email" placeholder-style="text-align:right" style="text-align: right;" placeholder="请输入电子邮箱"></input>
  68. </view>
  69. <view class="cu-form-group">
  70. <view class="title">社保卡号:</view>
  71. <input v-model="social" placeholder-style="text-align:right" style="text-align: right;" placeholder="请输入社保卡号"></input>
  72. </view>
  73. <view class="padding-sm bg-white" style="color: #C0C0C0;">
  74. 注:就诊人信息用于平台审核和医疗业务使用,不会外传。请正却确填写就诊人信息,如需修改身份信息可电话联系客服修改(13330431369)
  75. </view>
  76. </form>
  77. <view class="cu-bar bg-white tabbar" v-if="info==''" style="position: fixed;bottom: 0;width: 100%;z-index: 22;">
  78. <view class="submit" style="background-color: #0B73B9;color: white;" @click="addarchives">
  79. 提交
  80. </view>
  81. </view>
  82. <view class="cu-bar bg-white tabbar" v-else style="position: fixed;bottom: 0;width: 100%; z-index: 22;">
  83. <view class="submit" style="background-color: #0B73B9;color: white;" @click="editarchives">
  84. 修改
  85. </view>
  86. </view>
  87. <view class="cu-tabbar-height"></view>
  88. <view class="cu-tabbar-height"></view>
  89. </view>
  90. </template>
  91. <script>
  92. import {
  93. getLocation
  94. } from "../../common/authorize.js"
  95. export default {
  96. onLoad(options) {
  97. let date = new Date();
  98. let nian = date.getFullYear()
  99. let yue = date.getMonth() + 1
  100. let ri = date.getDate() >= 10 ? date.getDate() : '0' + date.getDate()
  101. this.time = nian + "-" + yue + "-" + ri
  102. if (options.info) {
  103. this.info = JSON.parse(options.info)
  104. }
  105. if (this.info != "") {
  106. uni.setNavigationBarTitle({
  107. title: "修改档案"
  108. })
  109. this.isaddress = false
  110. this.name = this.info.name
  111. this.imgList = [this.info.avatar]
  112. this.touxiang = this.info.avatar
  113. this.date = this.info.birthday
  114. this.value = this.list[this.info.sex - 1].name
  115. this.guanxi = this.guanxilist[this.info.relationship_type].label
  116. this.guanxiindex = this.info.relationship_type
  117. this.idcrad = this.info.card_number
  118. this.jianhuname = this.info.guardian_name
  119. this.phone = this.info.phone
  120. this.email = this.info.email
  121. // this.birthhospital = this.info.born_hospital
  122. this.address = this.info.address.split(' ')[0]
  123. this.infoaddress = this.info.address.split(' ')[1]
  124. this.social = this.info.social_card_number
  125. }
  126. this.GetCurrentAddress()
  127. },
  128. onShow() {
  129. },
  130. data() {
  131. return {
  132. infoaddress: "",
  133. address: "定位中...",
  134. birthhospital: "",
  135. email: "",
  136. phone: "",
  137. jianhuname: "",
  138. imgList: ['https://zhengda.oss-cn-chengdu.aliyuncs.com/baoma/static/%E5%A4%B4%E5%83%8F.png'],
  139. name: "",
  140. list: [{
  141. name: '男',
  142. disabled: false
  143. },
  144. {
  145. name: '女',
  146. disabled: false
  147. },
  148. ],
  149. value: '男',
  150. date: "请选择出生日期",
  151. show: false,
  152. guanxi: "请选择",
  153. guanxiindex: -1,
  154. guanxilist: [{
  155. value: '1',
  156. label: '父子'
  157. },
  158. {
  159. value: '2',
  160. label: '母子'
  161. },
  162. {
  163. value: '3',
  164. label: '祖孙'
  165. },
  166. {
  167. value: '4',
  168. label: '亲属'
  169. },
  170. {
  171. value: '5',
  172. label: '本人'
  173. },
  174. {
  175. value: '6',
  176. label: '其他'
  177. },
  178. ],
  179. idcrad: "",
  180. touxiang: "",
  181. time: "",
  182. info: "",
  183. social: "", //社保卡号
  184. isaddress: true,
  185. latitude: 0,
  186. longitude: 0
  187. }
  188. },
  189. methods: {
  190. jsGetAge(strBirthday) {
  191. let returnAge;
  192. let strBirthdayArr = strBirthday.split("-");
  193. let birthYear = strBirthdayArr[0];
  194. let birthMonth = strBirthdayArr[1];
  195. let birthDay = strBirthdayArr[2];
  196. let d = new Date();
  197. let nowYear = d.getFullYear();
  198. let nowMonth = d.getMonth() + 1;
  199. let nowDay = d.getDate();
  200. if (nowYear == birthYear) {
  201. returnAge = 0; //同年 则为0岁
  202. } else {
  203. let ageDiff = nowYear - birthYear; //年之差
  204. if (ageDiff > 0) {
  205. if (nowMonth == birthMonth) {
  206. let dayDiff = nowDay - birthDay; //日之差
  207. if (dayDiff < 0) {
  208. returnAge = ageDiff - 1;
  209. } else {
  210. returnAge = ageDiff;
  211. }
  212. } else {
  213. let monthDiff = nowMonth - birthMonth; //月之差
  214. if (monthDiff < 0) {
  215. returnAge = ageDiff - 1;
  216. } else {
  217. returnAge = ageDiff;
  218. }
  219. }
  220. } else {
  221. returnAge = -1; //返回-1 表示出生日期输入错误 晚于今天
  222. }
  223. }
  224. return returnAge; //返回周岁年龄
  225. },
  226. ChooseImage() {
  227. uni.chooseImage({
  228. count: 1, //默认9
  229. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  230. sourceType: ['album', 'camera'], //从相册选择
  231. success: (res) => {
  232. this.imgList = res.tempFilePaths
  233. this.$request.upload("/api/v1/common/uploadFile", this.imgList[0]).then(data => {
  234. let re = JSON.parse(data)
  235. if (re.status == 0) {
  236. this.touxiang = re.data.url
  237. console.log(this.touxiang)
  238. }
  239. })
  240. }
  241. });
  242. },
  243. loncationTap() {
  244. uni.chooseLocation({
  245. latitude: this.latitude,
  246. longitude: this.longitude,
  247. success: (res) => {
  248. console.log(res)
  249. if (res.name !== "" || res.address !== "") {
  250. this.address = res.address
  251. this.latitude = res.latitude
  252. this.longitude = res.longitude
  253. } else {
  254. uni.showToast({
  255. title: "请选择位置",
  256. icon: "none"
  257. })
  258. return false
  259. }
  260. }
  261. })
  262. },
  263. GetCurrentAddress() {
  264. if (this.isaddress) {
  265. getLocation().then(res => {
  266. this.address = res.address.address
  267. this.latitude = res.latitude
  268. this.longitude = res.longitude
  269. console.log(res)
  270. }).catch(res => {})
  271. }
  272. },
  273. // 选中任一radio时,由radio-group触发
  274. radioGroupChange(e) {
  275. this.value = e
  276. },
  277. bindDateChange({
  278. detail
  279. }) {
  280. this.date = detail.value
  281. },
  282. confirm(e) {
  283. this.guanxiindex = e.detail.value
  284. this.guanxi = this.guanxilist[e.detail.value].label
  285. },
  286. addarchives: async function() {
  287. let num = 0
  288. if (this.value == "男") {
  289. num = 1
  290. } else {
  291. num = 2
  292. }
  293. if (this.imgList[0] == undefined) {
  294. uni.showToast({
  295. title: "请上传头像",
  296. icon: "none"
  297. })
  298. return false
  299. }
  300. if (this.name == "") {
  301. uni.showToast({
  302. title: "请填写名称",
  303. icon: "none"
  304. })
  305. return false
  306. }
  307. // if (this.jianhuname == "") {
  308. // uni.showToast({
  309. // title: "请输入监护人姓名",
  310. // icon: "none"
  311. // })
  312. // return false
  313. // }
  314. if (!this.$util.isPhoneNumber(this.phone)) {
  315. uni.showToast({
  316. title: "请输入正确手机号",
  317. icon: "none"
  318. })
  319. return false
  320. }
  321. // if (!this.$util.isEmail(this.email)) {
  322. // uni.showToast({
  323. // title: "请填写正确的邮箱",
  324. // icon: "none"
  325. // })
  326. // return false
  327. // }
  328. // if (this.birthhospital == "") {
  329. // uni.showToast({
  330. // title: "请填写正确的医院",
  331. // icon: "none"
  332. // })
  333. // return false
  334. // }
  335. if (this.infoaddress == "") {
  336. uni.showToast({
  337. title: "请填写正确的地址",
  338. icon: "none"
  339. })
  340. return false
  341. }
  342. if (this.date == "请选择出生日期") {
  343. uni.showToast({
  344. title: "请填写日期",
  345. icon: "none"
  346. })
  347. return false
  348. }
  349. if (this.guanxiindex == -1) {
  350. uni.showToast({
  351. title: "请选择被保人关系",
  352. icon: "none"
  353. })
  354. return false
  355. }
  356. let res = await this.$request.post("/api/v1/patient/createPatient", {
  357. name: this.name,
  358. sex: num,
  359. avatar: this.touxiang == '' ? this.imgList[0] : this.touxiang,
  360. birthday: this.date,
  361. relationship_type: this.guanxiindex,
  362. card_type: 1,
  363. card_number: this.idcrad,
  364. email: this.email,
  365. phone: this.phone,
  366. guardian_name: this.jianhuname,
  367. address: this.address + " " + this.infoaddress,
  368. // born_hospital: this.birthhospital,
  369. social_card_number: this.social
  370. })
  371. if (res.status == 0) {
  372. uni.showToast({
  373. title: "提交成功",
  374. icon: "none",
  375. duration: 1500
  376. })
  377. setTimeout(() => {
  378. uni.navigateBack({
  379. delta: 1
  380. })
  381. }, 1500)
  382. } else {
  383. uni.showModal({
  384. title: "错误",
  385. content: res.message,
  386. showCancel: true,
  387. })
  388. }
  389. },
  390. editarchives: async function() {
  391. let num = 0
  392. if (this.value == "男") {
  393. num = 1
  394. } else {
  395. num = 2
  396. }
  397. if (this.imgList[0] == undefined) {
  398. uni.showToast({
  399. title: "请上传头像",
  400. icon: "none"
  401. })
  402. return false
  403. }
  404. if (this.name == "") {
  405. uni.showToast({
  406. title: "请填写名称",
  407. icon: "none"
  408. })
  409. return false
  410. }
  411. // if (this.jianhuname == "") {
  412. // uni.showToast({
  413. // title: "请输入监护人姓名",
  414. // icon: "none"
  415. // })
  416. // return false
  417. // }
  418. if (!this.$util.isPhoneNumber(this.phone)) {
  419. uni.showToast({
  420. title: "请输入正确手机号",
  421. icon: "none"
  422. })
  423. return false
  424. }
  425. // if (!this.$util.isEmail(this.email)) {
  426. // uni.showToast({
  427. // title: "请填写正确的邮箱",
  428. // icon: "none"
  429. // })
  430. // return false
  431. // }
  432. // if (this.birthhospital == "") {
  433. // uni.showToast({
  434. // title: "请填写正确的医院",
  435. // icon: "none"
  436. // })
  437. // return false
  438. // }
  439. if (this.infoaddress == "") {
  440. uni.showToast({
  441. title: "请填写正确的地址",
  442. icon: "none"
  443. })
  444. return false
  445. }
  446. if (this.date == "请选择出生日期") {
  447. uni.showToast({
  448. title: "请填写日期",
  449. icon: "none"
  450. })
  451. return false
  452. }
  453. if (this.guanxiindex == -1) {
  454. uni.showToast({
  455. title: "请选择被保人关系",
  456. icon: "none"
  457. })
  458. return false
  459. }
  460. let res = await this.$request.post("/api/v1/patient/updatePatient", {
  461. id: this.info.id,
  462. name: this.name,
  463. sex: num,
  464. avatar: this.touxiang,
  465. birthday: this.date,
  466. relationship_type: this.guanxiindex,
  467. card_type: 1,
  468. card_number: this.idcrad,
  469. email: this.email,
  470. phone: this.phone,
  471. guardian_name: this.jianhuname,
  472. address: this.address + " " + this.infoaddress,
  473. // born_hospital: this.birthhospital,
  474. social_card_number: this.social
  475. })
  476. if (res.status == 0) {
  477. uni.showToast({
  478. title: "修改成功",
  479. icon: "none",
  480. duration: 1500
  481. })
  482. setTimeout(() => {
  483. uni.navigateBack({
  484. delta: 1
  485. })
  486. }, 1500)
  487. }
  488. }
  489. }
  490. };
  491. </script>
  492. <style scoped lang="scss">
  493. .main {}
  494. </style>