index.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { querySingle, patientUpdate } from "../patient-detail/service";
  2. import { createSubscribe } from "applet-page-component";
  3. import history from "../../utils/history";
  4. Component(
  5. createSubscribe({
  6. async onShow() {
  7. await this.querySingle();
  8. },
  9. })({
  10. props: {},
  11. data: {
  12. patient: {
  13. balance: 0,
  14. id: "",
  15. name: "",
  16. age: "",
  17. sex: "",
  18. phoneNumber: "",
  19. birthDay: "",
  20. idCardNo: "",
  21. relationShip: "",
  22. bindCardNum: "",
  23. medicCards: [],
  24. },
  25. },
  26. didMount() {
  27. this.querySingle();
  28. },
  29. didUnmount() {},
  30. methods: {
  31. querySingle() {
  32. const {
  33. query = {
  34. id: "",
  35. },
  36. } = this.$page.data;
  37. my.showLoading();
  38. querySingle({
  39. id: query.id,
  40. }).then((data) => {
  41. this.setData({
  42. patient: data,
  43. });
  44. my.hideLoading();
  45. });
  46. },
  47. // 修改关系
  48. onChange(e) {
  49. this.setData({
  50. "patient.relationShip": e.name,
  51. });
  52. },
  53. onChangePhone() {
  54. history.push({
  55. query: {
  56. id: this.data.patient.id,
  57. relationShip: this.data.patient.relationShip,
  58. },
  59. title: "修改手机号",
  60. pageType: "patient-detail-phone",
  61. });
  62. },
  63. onSubmit() {
  64. patientUpdate({
  65. id: this.data.patient.id,
  66. name: this.data.patient.name,
  67. relationShip: this.data.patient.relationShip,
  68. }).then(my.navigateBack);
  69. },
  70. },
  71. })
  72. );