addEditPatient.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. "use strict";
  2. var common_vendor = require("../common/vendor.js");
  3. var api_patient = require("../api/patient.js");
  4. require("../common/request.js");
  5. const _sfc_main = {
  6. data() {
  7. return {
  8. relationShow: false,
  9. relations: [
  10. {
  11. name: "\u672C\u4EBA"
  12. },
  13. {
  14. name: "\u914D\u5076"
  15. },
  16. {
  17. name: "\u7236\u6BCD"
  18. },
  19. {
  20. name: "\u5B50\u5973"
  21. },
  22. {
  23. name: "\u670B\u53CB"
  24. },
  25. {
  26. name: "\u4EB2\u621A"
  27. },
  28. {
  29. name: "\u5176\u4ED6"
  30. }
  31. ],
  32. historyAllergics: [
  33. {
  34. name: "\u963F\u53F8\u5339\u6797",
  35. checked: 0
  36. },
  37. {
  38. name: "\u78FA\u80FA\u7C7B",
  39. checked: 0
  40. },
  41. {
  42. name: "\u5934\u5B62\u7C7B",
  43. checked: 0
  44. },
  45. {
  46. name: "\u9752\u6BD2\u7D20\u7C7B",
  47. checked: 0
  48. },
  49. {
  50. name: "\u5976\u5236\u54C1",
  51. checked: 0
  52. },
  53. {
  54. name: "\u5176\u4ED6",
  55. checked: 0
  56. }
  57. ],
  58. selfMedHistorys: [
  59. {
  60. name: "\u7CD6\u5C3F\u75C5",
  61. checked: 0
  62. },
  63. {
  64. name: "\u54EE\u5598",
  65. checked: 0
  66. },
  67. {
  68. name: "\u6076\u6027\u80BF\u7624",
  69. checked: 0
  70. },
  71. {
  72. name: "\u9AD8\u8840\u538B",
  73. checked: 0
  74. },
  75. {
  76. name: "\u5176\u4ED6",
  77. checked: 0
  78. }
  79. ],
  80. familyMedHistorys: [
  81. {
  82. name: "\u7CD6\u5C3F\u75C5",
  83. checked: 0
  84. },
  85. {
  86. name: "\u54EE\u5598",
  87. checked: 0
  88. },
  89. {
  90. name: "\u6076\u6027\u80BF\u7624",
  91. checked: 0
  92. },
  93. {
  94. name: "\u9AD8\u8840\u538B",
  95. checked: 0
  96. },
  97. {
  98. name: "\u5176\u4ED6",
  99. checked: 0
  100. }
  101. ],
  102. type: null,
  103. patientId: null,
  104. form: {
  105. sex: 1,
  106. birthday: "",
  107. idCard: "",
  108. relation: "",
  109. liverUnusual: "\u6B63\u5E38",
  110. renalUnusual: "\u6B63\u5E38",
  111. historyAllergic: "\u65E0",
  112. familyMedHistory: "\u65E0",
  113. selfMedHistory: "\u65E0"
  114. }
  115. };
  116. },
  117. onLoad(option) {
  118. this.type = option.type;
  119. if (this.type == "edit") {
  120. this.patientId = option.patientId;
  121. this.getPatientById();
  122. common_vendor.index.setNavigationBarTitle({
  123. title: "\u7F16\u8F91\u5C31\u8BCA\u4EBA"
  124. });
  125. } else {
  126. common_vendor.index.setNavigationBarTitle({
  127. title: "\u65B0\u589E\u5C31\u8BCA\u4EBA"
  128. });
  129. }
  130. },
  131. methods: {
  132. liverUnusualChange(item) {
  133. console.log(item);
  134. this.form.liverUnusual = item.detail.value;
  135. },
  136. renalUnusualChange(item) {
  137. console.log(item);
  138. this.form.renalUnusual = item.detail.value;
  139. },
  140. historyAllergicOptionChange(item) {
  141. item.checked = item.checked == 1 ? 0 : 1;
  142. },
  143. selfMedHistoryOptionChange(item) {
  144. item.checked = item.checked == 1 ? 0 : 1;
  145. },
  146. familyMedHistoryOptionChange(item) {
  147. item.checked = item.checked == 1 ? 0 : 1;
  148. },
  149. historyAllergicChange(item) {
  150. console.log(item);
  151. this.form.historyAllergic = item.detail.value;
  152. },
  153. selfMedHistoryChange(item) {
  154. console.log(item);
  155. this.form.selfMedHistory = item.detail.value;
  156. },
  157. familyMedHistoryChange(item) {
  158. console.log(item);
  159. this.form.familyMedHistory = item.detail.value;
  160. },
  161. relationSelect(e) {
  162. this.form.relation = e.name;
  163. },
  164. idcardChange() {
  165. if (this.form.idCard.length == 18) {
  166. var json = this.$parseIDCardInfo(this.form.idCard);
  167. this.form.birthday = json.birthday;
  168. console.log(json);
  169. }
  170. },
  171. genderChange(type) {
  172. this.form.sex = type;
  173. },
  174. getPatientById() {
  175. var data = { patientId: this.patientId };
  176. api_patient.getPatientById(data).then((res) => {
  177. if (res.code == 200) {
  178. this.form = res.data;
  179. this.date = this.form.birthday;
  180. if (this.form.historyAllergic != null && this.form.historyAllergic != "\u65E0") {
  181. var options = this.form.historyAllergic.split(",");
  182. this.historyAllergics.forEach((item) => {
  183. for (var i = 0; i < options.length; i++) {
  184. if (item.name == options[i]) {
  185. item.checked = 1;
  186. }
  187. }
  188. });
  189. this.form.historyAllergic = "\u6709";
  190. }
  191. if (this.form.selfMedHistory != null && this.form.selfMedHistory != "\u65E0") {
  192. var options = this.form.selfMedHistory.split(",");
  193. this.selfMedHistorys.forEach((item) => {
  194. for (var i = 0; i < options.length; i++) {
  195. if (item.name == options[i]) {
  196. item.checked = 1;
  197. }
  198. }
  199. });
  200. this.form.selfMedHistory = "\u6709";
  201. }
  202. if (this.form.familyMedHistory != null && this.form.familyMedHistory != "\u65E0") {
  203. var options = this.form.familyMedHistory.split(",");
  204. this.familyMedHistorys.forEach((item) => {
  205. for (var i = 0; i < options.length; i++) {
  206. if (item.name == options[i]) {
  207. item.checked = 1;
  208. }
  209. }
  210. });
  211. this.form.familyMedHistory = "\u6709";
  212. }
  213. } else {
  214. common_vendor.index.showToast({
  215. title: res.msg
  216. });
  217. }
  218. }, (rej) => {
  219. });
  220. },
  221. submit() {
  222. if (this.type == "add") {
  223. this.addPatient();
  224. } else if (this.type == "edit") {
  225. this.editPatient();
  226. }
  227. },
  228. editPatient() {
  229. var data = {
  230. patientId: this.patientId,
  231. patientName: this.form.patientName,
  232. mobile: this.form.mobile,
  233. sex: this.form.sex,
  234. birthday: this.form.birthday,
  235. idCard: this.form.idCard,
  236. relation: this.form.relation,
  237. liverUnusual: this.form.liverUnusual,
  238. renalUnusual: this.form.renalUnusual
  239. };
  240. if (this.form.historyAllergic == "\u6709") {
  241. var options = [];
  242. this.historyAllergics.forEach((item) => {
  243. if (item.checked == 1) {
  244. options.push(item.name);
  245. }
  246. });
  247. data.historyAllergic = options.toString();
  248. } else {
  249. data.historyAllergic = this.form.historyAllergic;
  250. }
  251. if (this.form.selfMedHistory == "\u6709") {
  252. var options = [];
  253. this.selfMedHistorys.forEach((item) => {
  254. if (item.checked == 1) {
  255. options.push(item.name);
  256. }
  257. });
  258. data.selfMedHistory = options.toString();
  259. } else {
  260. data.selfMedHistory = this.form.selfMedHistory;
  261. }
  262. if (this.form.familyMedHistory == "\u6709") {
  263. var options = [];
  264. this.familyMedHistorys.forEach((item) => {
  265. if (item.checked == 1) {
  266. options.push(item.name);
  267. }
  268. });
  269. data.familyMedHistory = options.toString();
  270. } else {
  271. data.familyMedHistory = this.form.familyMedHistory;
  272. }
  273. api_patient.editPatient(data).then((res) => {
  274. if (res.code == 200) {
  275. common_vendor.index.showToast({
  276. icon: "success",
  277. title: "\u64CD\u4F5C\u6210\u529F"
  278. });
  279. setTimeout(function() {
  280. common_vendor.index.$emit("refreshPatient");
  281. common_vendor.index.navigateBack({
  282. delta: 1
  283. });
  284. }, 500);
  285. } else {
  286. common_vendor.index.showToast({
  287. icon: "none",
  288. title: res.msg
  289. });
  290. }
  291. }, (rej) => {
  292. });
  293. },
  294. addPatient() {
  295. var data = {
  296. patientName: this.form.patientName,
  297. mobile: this.form.mobile,
  298. sex: this.form.sex,
  299. birthday: this.form.birthday,
  300. idCard: this.form.idCard,
  301. relation: this.form.relation,
  302. liverUnusual: this.form.liverUnusual,
  303. renalUnusual: this.form.renalUnusual
  304. };
  305. if (this.form.historyAllergic == "\u6709") {
  306. var options = [];
  307. this.historyAllergics.forEach((item) => {
  308. if (item.checked == 1) {
  309. options.push(item.name);
  310. }
  311. });
  312. data.historyAllergic = options.toString();
  313. } else {
  314. data.historyAllergic = this.form.historyAllergic;
  315. }
  316. if (this.form.selfMedHistory == "\u6709") {
  317. var options = [];
  318. this.selfMedHistorys.forEach((item) => {
  319. if (item.checked == 1) {
  320. options.push(item.name);
  321. }
  322. });
  323. data.selfMedHistory = options.toString();
  324. } else {
  325. data.selfMedHistory = this.form.selfMedHistory;
  326. }
  327. if (this.form.familyMedHistory == "\u6709") {
  328. var options = [];
  329. this.familyMedHistorys.forEach((item) => {
  330. if (item.checked == 1) {
  331. options.push(item.name);
  332. }
  333. });
  334. data.familyMedHistory = options.toString();
  335. } else {
  336. data.familyMedHistory = this.form.familyMedHistory;
  337. }
  338. api_patient.addPatient(data).then((res) => {
  339. if (res.code == 200) {
  340. common_vendor.index.showToast({
  341. icon: "success",
  342. title: "\u64CD\u4F5C\u6210\u529F"
  343. });
  344. setTimeout(function() {
  345. common_vendor.index.$emit("refreshPatient");
  346. common_vendor.index.navigateBack({
  347. delta: 1
  348. });
  349. }, 500);
  350. } else {
  351. common_vendor.index.showToast({
  352. icon: "none",
  353. title: res.msg
  354. });
  355. }
  356. }, (rej) => {
  357. });
  358. },
  359. birthdayChange: function(e) {
  360. this.form.birthday = e.target.value;
  361. }
  362. }
  363. };
  364. if (!Array) {
  365. const _easycom_u_alert2 = common_vendor.resolveComponent("u-alert");
  366. const _easycom_u_tag2 = common_vendor.resolveComponent("u-tag");
  367. const _easycom_u_action_sheet2 = common_vendor.resolveComponent("u-action-sheet");
  368. (_easycom_u_alert2 + _easycom_u_tag2 + _easycom_u_action_sheet2)();
  369. }
  370. const _easycom_u_alert = () => "../uni_modules/uview-plus/components/u-alert/u-alert.js";
  371. const _easycom_u_tag = () => "../uni_modules/uview-plus/components/u-tag/u-tag.js";
  372. const _easycom_u_action_sheet = () => "../uni_modules/uview-plus/components/u-action-sheet/u-action-sheet.js";
  373. if (!Math) {
  374. (_easycom_u_alert + _easycom_u_tag + _easycom_u_action_sheet)();
  375. }
  376. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  377. return common_vendor.e({
  378. a: common_vendor.p({
  379. title: "\u56FD\u5BB6\u536B\u5065\u59D4\u8981\u6C42\uFF0C\u5C31\u533B\u884C\u4E3A\u5FC5\u987B\u5B9E\u540D\u767B\u8BB0",
  380. type: "info"
  381. }),
  382. b: $data.form.patientName,
  383. c: common_vendor.o(($event) => $data.form.patientName = $event.detail.value),
  384. d: common_vendor.o(($event) => $options.genderChange(1)),
  385. e: $data.form.sex === 1,
  386. f: common_vendor.o(($event) => $options.genderChange(2)),
  387. g: $data.form.sex === 2,
  388. h: $data.form.mobile,
  389. i: common_vendor.o(($event) => $data.form.mobile = $event.detail.value),
  390. j: common_vendor.o(($event) => $options.idcardChange()),
  391. k: $data.form.idCard,
  392. l: common_vendor.o(($event) => $data.form.idCard = $event.detail.value),
  393. m: $data.form.birthday,
  394. n: $data.form.birthday,
  395. o: common_vendor.o((...args) => $options.birthdayChange && $options.birthdayChange(...args)),
  396. p: $data.form.relation,
  397. q: common_vendor.o(($event) => $data.relationShow = true),
  398. r: $data.form.liverUnusual === "\u6B63\u5E38",
  399. s: $data.form.liverUnusual === "\u5F02\u5E38",
  400. t: common_vendor.o((...args) => $options.liverUnusualChange && $options.liverUnusualChange(...args)),
  401. v: $data.form.renalUnusual === "\u6B63\u5E38",
  402. w: $data.form.renalUnusual === "\u5F02\u5E38",
  403. x: common_vendor.o((...args) => $options.renalUnusualChange && $options.renalUnusualChange(...args)),
  404. y: $data.form.historyAllergic === "\u65E0",
  405. z: $data.form.historyAllergic === "\u6709",
  406. A: common_vendor.o((...args) => $options.historyAllergicChange && $options.historyAllergicChange(...args)),
  407. B: $data.form.historyAllergic == "\u6709"
  408. }, $data.form.historyAllergic == "\u6709" ? {
  409. C: common_vendor.f($data.historyAllergics, (item, index, i0) => {
  410. return {
  411. a: common_vendor.o(($event) => $options.historyAllergicOptionChange(item)),
  412. b: "0a9339af-1-" + i0,
  413. c: common_vendor.p({
  414. borderColor: item.checked == 1 ? "#ffffff" : "#C39A58",
  415. bgColor: item.checked == 1 ? "#C39A58" : "#ffffff",
  416. color: item.checked == 1 ? "#ffffff" : "#C39A58",
  417. shape: "circle",
  418. text: item.name
  419. })
  420. };
  421. })
  422. } : {}, {
  423. D: $data.form.selfMedHistory === "\u65E0",
  424. E: $data.form.selfMedHistory === "\u6709",
  425. F: common_vendor.o((...args) => $options.selfMedHistoryChange && $options.selfMedHistoryChange(...args)),
  426. G: $data.form.selfMedHistory == "\u6709"
  427. }, $data.form.selfMedHistory == "\u6709" ? {
  428. H: common_vendor.f($data.selfMedHistorys, (item, index, i0) => {
  429. return {
  430. a: common_vendor.o(($event) => $options.selfMedHistoryOptionChange(item)),
  431. b: "0a9339af-2-" + i0,
  432. c: common_vendor.p({
  433. borderColor: item.checked == 1 ? "#ffffff" : "#C39A58",
  434. bgColor: item.checked == 1 ? "#C39A58" : "#ffffff",
  435. color: item.checked == 1 ? "#ffffff" : "#C39A58",
  436. shape: "circle",
  437. text: item.name
  438. })
  439. };
  440. })
  441. } : {}, {
  442. I: $data.form.familyMedHistory === "\u65E0",
  443. J: $data.form.familyMedHistory === "\u6709",
  444. K: common_vendor.o((...args) => $options.familyMedHistoryChange && $options.familyMedHistoryChange(...args)),
  445. L: $data.form.familyMedHistory == "\u6709"
  446. }, $data.form.familyMedHistory == "\u6709" ? {
  447. M: common_vendor.f($data.familyMedHistorys, (item, index, i0) => {
  448. return {
  449. a: common_vendor.o(($event) => $options.familyMedHistoryOptionChange(item)),
  450. b: "0a9339af-3-" + i0,
  451. c: common_vendor.p({
  452. borderColor: item.checked == 1 ? "#ffffff" : "#C39A58",
  453. bgColor: item.checked == 1 ? "#C39A58" : "#ffffff",
  454. color: item.checked == 1 ? "#ffffff" : "#C39A58",
  455. shape: "circle",
  456. text: item.name
  457. })
  458. };
  459. })
  460. } : {}, {
  461. N: common_vendor.o(($event) => $options.submit()),
  462. O: common_vendor.o(($event) => $data.relationShow = false),
  463. P: common_vendor.o($options.relationSelect),
  464. Q: common_vendor.p({
  465. show: $data.relationShow,
  466. actions: $data.relations,
  467. title: "\u8BF7\u9009\u62E9"
  468. })
  469. });
  470. }
  471. var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "E:/Project/2023/\u95EE\u8BCA\u5E73\u53F0/his_user_miniapp/pages_user/addEditPatient.vue"]]);
  472. wx.createPage(MiniProgramPage);