add_archives.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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">
  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. export default {
  93. onLoad(options) {
  94. let date = new Date();
  95. let nian = date.getFullYear()
  96. let yue = date.getMonth() + 1
  97. let ri = date.getDate() >= 10 ? date.getDate() : '0' + date.getDate()
  98. this.time = nian + "-" + yue + "-" + ri
  99. if (options.info) {
  100. this.info = JSON.parse(options.info)
  101. }
  102. if (this.info != "") {
  103. uni.setNavigationBarTitle({
  104. title: "修改档案"
  105. })
  106. this.name = this.info.name
  107. this.imgList = [this.info.avatar]
  108. this.touxiang = this.info.avatar
  109. this.date = this.info.birthday
  110. this.value = this.list[this.info.sex - 1].name
  111. this.guanxi = this.guanxilist[this.info.relationship_type].label
  112. this.guanxiindex = this.info.relationship_type
  113. this.idcrad = this.info.card_number
  114. this.jianhuname = this.info.guardian_name
  115. this.phone = this.info.phone
  116. this.email = this.info.email
  117. // this.birthhospital = this.info.born_hospital
  118. this.address = this.info.address
  119. this.social = this.info.social_card_number
  120. }
  121. },
  122. onShow() {
  123. },
  124. data() {
  125. return {
  126. infoaddress: "",
  127. address: "定位中...",
  128. birthhospital: "",
  129. email: "",
  130. phone: "",
  131. jianhuname: "",
  132. imgList: ['https://zhengda.oss-cn-chengdu.aliyuncs.com/baoma/static/%E5%A4%B4%E5%83%8F.png'],
  133. name: "",
  134. list: [{
  135. name: '男',
  136. disabled: false
  137. },
  138. {
  139. name: '女',
  140. disabled: false
  141. },
  142. ],
  143. value: '男',
  144. date: "请选择出生日期",
  145. show: false,
  146. guanxi: "请选择",
  147. guanxiindex: -1,
  148. guanxilist: [{
  149. value: '1',
  150. label: '父子'
  151. },
  152. {
  153. value: '2',
  154. label: '母子'
  155. },
  156. {
  157. value: '3',
  158. label: '祖孙'
  159. },
  160. {
  161. value: '4',
  162. label: '亲属'
  163. },
  164. {
  165. value: '5',
  166. label: '本人'
  167. },
  168. {
  169. value: '6',
  170. label: '其他'
  171. },
  172. ],
  173. idcrad: "",
  174. touxiang: "",
  175. time: "",
  176. info: "",
  177. social: "" //社保卡号
  178. }
  179. },
  180. methods: {
  181. jsGetAge(strBirthday) {
  182. let returnAge;
  183. let strBirthdayArr = strBirthday.split("-");
  184. let birthYear = strBirthdayArr[0];
  185. let birthMonth = strBirthdayArr[1];
  186. let birthDay = strBirthdayArr[2];
  187. let d = new Date();
  188. let nowYear = d.getFullYear();
  189. let nowMonth = d.getMonth() + 1;
  190. let nowDay = d.getDate();
  191. if (nowYear == birthYear) {
  192. returnAge = 0; //同年 则为0岁
  193. } else {
  194. let ageDiff = nowYear - birthYear; //年之差
  195. if (ageDiff > 0) {
  196. if (nowMonth == birthMonth) {
  197. let dayDiff = nowDay - birthDay; //日之差
  198. if (dayDiff < 0) {
  199. returnAge = ageDiff - 1;
  200. } else {
  201. returnAge = ageDiff;
  202. }
  203. } else {
  204. let monthDiff = nowMonth - birthMonth; //月之差
  205. if (monthDiff < 0) {
  206. returnAge = ageDiff - 1;
  207. } else {
  208. returnAge = ageDiff;
  209. }
  210. }
  211. } else {
  212. returnAge = -1; //返回-1 表示出生日期输入错误 晚于今天
  213. }
  214. }
  215. return returnAge; //返回周岁年龄
  216. },
  217. ChooseImage() {
  218. uni.chooseImage({
  219. count: 1, //默认9
  220. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  221. sourceType: ['album', 'camera'], //从相册选择
  222. success: (res) => {
  223. this.imgList = res.tempFilePaths
  224. this.$request.upload("/api/v1/common/uploadFile", this.imgList[0]).then(data => {
  225. let re = JSON.parse(data)
  226. if (re.status == 0) {
  227. this.touxiang = re.data.url
  228. console.log(this.touxiang)
  229. }
  230. })
  231. }
  232. });
  233. },
  234. // 选中任一radio时,由radio-group触发
  235. radioGroupChange(e) {
  236. this.value = e
  237. },
  238. bindDateChange({
  239. detail
  240. }) {
  241. this.date = detail.value
  242. },
  243. confirm(e) {
  244. this.guanxiindex = e.detail.value
  245. this.guanxi = this.guanxilist[e.detail.value].label
  246. },
  247. addarchives: async function() {
  248. let num = 0
  249. if (this.value == "男") {
  250. num = 1
  251. } else {
  252. num = 2
  253. }
  254. if (this.imgList[0] == undefined) {
  255. uni.showToast({
  256. title: "请上传头像",
  257. icon: "none"
  258. })
  259. return false
  260. }
  261. if (this.name == "") {
  262. uni.showToast({
  263. title: "请填写名称",
  264. icon: "none"
  265. })
  266. return false
  267. }
  268. if (this.jianhuname == "") {
  269. uni.showToast({
  270. title: "请输入监护人姓名",
  271. icon: "none"
  272. })
  273. return false
  274. }
  275. if (!this.$util.isPhoneNumber(this.phone)) {
  276. uni.showToast({
  277. title: "请输入正确手机号",
  278. icon: "none"
  279. })
  280. return false
  281. }
  282. // if (!this.$util.isEmail(this.email)) {
  283. // uni.showToast({
  284. // title: "请填写正确的邮箱",
  285. // icon: "none"
  286. // })
  287. // return false
  288. // }
  289. // if (this.birthhospital == "") {
  290. // uni.showToast({
  291. // title: "请填写正确的医院",
  292. // icon: "none"
  293. // })
  294. // return false
  295. // }
  296. if (this.infoaddress == "") {
  297. uni.showToast({
  298. title: "请填写正确的地址",
  299. icon: "none"
  300. })
  301. return false
  302. }
  303. if (this.date == "请选择出生日期") {
  304. uni.showToast({
  305. title: "请填写日期",
  306. icon: "none"
  307. })
  308. return false
  309. }
  310. if (this.guanxiindex == -1) {
  311. uni.showToast({
  312. title: "请选择被保人关系",
  313. icon: "none"
  314. })
  315. return false
  316. }
  317. let res = await this.$request.post("/api/v1/patient/createPatient", {
  318. name: this.name,
  319. sex: num,
  320. avatar: this.touxiang == '' ? this.imgList[0] : this.touxiang,
  321. birthday: this.date,
  322. relationship_type: this.guanxiindex,
  323. card_type: 1,
  324. card_number: this.idcrad,
  325. email: this.email,
  326. phone: this.phone,
  327. guardian_name: this.jianhuname,
  328. address: this.address,
  329. // born_hospital: this.birthhospital,
  330. social_card_number: this.social
  331. })
  332. if (res.status == 0) {
  333. uni.showToast({
  334. title: "提交成功",
  335. icon: "none",
  336. duration: 1500
  337. })
  338. setTimeout(() => {
  339. uni.navigateBack({
  340. delta: 1
  341. })
  342. }, 1500)
  343. } else {
  344. uni.showModal({
  345. title: "错误",
  346. content: res.message,
  347. showCancel: true,
  348. })
  349. }
  350. },
  351. editarchives: async function() {
  352. let num = 0
  353. if (this.value == "男") {
  354. num = 1
  355. } else {
  356. num = 2
  357. }
  358. if (this.imgList[0] == undefined) {
  359. uni.showToast({
  360. title: "请上传头像",
  361. icon: "none"
  362. })
  363. return false
  364. }
  365. if (this.name == "") {
  366. uni.showToast({
  367. title: "请填写名称",
  368. icon: "none"
  369. })
  370. return false
  371. }
  372. if (this.jianhuname == "") {
  373. uni.showToast({
  374. title: "请输入监护人姓名",
  375. icon: "none"
  376. })
  377. return false
  378. }
  379. if (!this.$util.isPhoneNumber(this.phone)) {
  380. uni.showToast({
  381. title: "请输入正确手机号",
  382. icon: "none"
  383. })
  384. return false
  385. }
  386. // if (!this.$util.isEmail(this.email)) {
  387. // uni.showToast({
  388. // title: "请填写正确的邮箱",
  389. // icon: "none"
  390. // })
  391. // return false
  392. // }
  393. // if (this.birthhospital == "") {
  394. // uni.showToast({
  395. // title: "请填写正确的医院",
  396. // icon: "none"
  397. // })
  398. // return false
  399. // }
  400. if (this.infoaddress == "") {
  401. uni.showToast({
  402. title: "请填写正确的地址",
  403. icon: "none"
  404. })
  405. return false
  406. }
  407. if (this.date == "请选择出生日期") {
  408. uni.showToast({
  409. title: "请填写日期",
  410. icon: "none"
  411. })
  412. return false
  413. }
  414. if (this.guanxiindex == -1) {
  415. uni.showToast({
  416. title: "请选择被保人关系",
  417. icon: "none"
  418. })
  419. return false
  420. }
  421. let res = await this.$request.post("/api/v1/patient/updatePatient", {
  422. id: this.info.id,
  423. name: this.name,
  424. sex: num,
  425. avatar: this.touxiang,
  426. birthday: this.date,
  427. relationship_type: this.guanxiindex,
  428. card_type: 1,
  429. card_number: this.idcrad,
  430. email: this.email,
  431. phone: this.phone,
  432. guardian_name: this.jianhuname,
  433. address: this.address,
  434. // born_hospital: this.birthhospital,
  435. social_card_number: this.social
  436. })
  437. if (res.status == 0) {
  438. uni.showToast({
  439. title: "修改成功",
  440. icon: "none",
  441. duration: 1500
  442. })
  443. setTimeout(() => {
  444. uni.navigateBack({
  445. delta: 1
  446. })
  447. }, 1500)
  448. }
  449. }
  450. }
  451. };
  452. </script>
  453. <style scoped lang="scss">
  454. .main {}
  455. </style>