bhAdd.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view>
  3. <uni-section padding>
  4. <uni-forms ref="bhForms" :model="forms" :rules="rules">
  5. <uni-forms-item label="病患描述" name="bhms">
  6. <uni-easyinput v-model="forms.bhms" placeholder="请输入病患描述" />
  7. </uni-forms-item>
  8. <uni-forms-item label="病患类别" name="bhlb">
  9. <uni-data-select v-model="forms.bhlb" placeholder="请选择病患类别" :localdata="dicts.KH004" />
  10. </uni-forms-item>
  11. <uni-forms-item label="患病时间" name="bhsj">
  12. <uni-easyinput v-model="forms.bhsj" placeholder="请输入患病时间段" />
  13. </uni-forms-item>
  14. <uni-forms-item label="使用药物" name="syyw">
  15. <uni-easyinput type="textarea" v-model="forms.syyw" placeholder="请输入使用药物" />
  16. </uni-forms-item>
  17. <uni-forms-item label="处置手段">
  18. <uni-easyinput type="textarea" v-model="forms.czsd" placeholder="请输入处置手段" />
  19. </uni-forms-item>
  20. <uni-forms-item label="愈后情况">
  21. <uni-easyinput type="textarea" v-model="forms.yhqk" placeholder="请输入愈后情况" />
  22. </uni-forms-item>
  23. <uni-forms-item label="康复措施">
  24. <uni-easyinput type="textarea" v-model="forms.kfcs" placeholder="请输入康复措施" />
  25. </uni-forms-item>
  26. <view class="bottomButton">
  27. <button type="primary" size="mini" @click="submitForm">保存</button>
  28. </view>
  29. </uni-forms>
  30. </uni-section>
  31. </view>
  32. </template>
  33. <script>
  34. import { addKhbhls, updateKhbhls } from '@/api/lr.js'
  35. export default {
  36. data() {
  37. return {
  38. dicts: {
  39. KH004: [],
  40. },
  41. khId: null,
  42. forms: {
  43. bhms: null,
  44. bhlb: null,
  45. bhsj: null,
  46. syyw: null,
  47. czsd: null,
  48. yhqk: null,
  49. kfcs: null,
  50. },
  51. rules: {
  52. bhms: {
  53. rules: [{
  54. required: true,
  55. errorMessage: '病患描述不能为空'
  56. }]
  57. },
  58. bhlb: {
  59. rules: [{
  60. required: true,
  61. errorMessage: '请选择病患类别'
  62. }]
  63. },
  64. bhsj: {
  65. rules: [{
  66. required: true,
  67. errorMessage: '患病时间段不能为空'
  68. }]
  69. },
  70. syyw: {
  71. rules: [{
  72. required: true,
  73. errorMessage: '使用药物不能为空'
  74. }]
  75. },
  76. },
  77. }
  78. },
  79. created() {
  80. this.getDictList(Object.keys(this.dicts), this.dicts)
  81. },
  82. onLoad(option) {
  83. if (option.item) {
  84. this.forms = JSON.parse(option.item)
  85. uni.setNavigationBarTitle({
  86. title: '修改病史记录'
  87. });
  88. }
  89. this.khId = option.id
  90. this.xm = option.xm
  91. },
  92. methods: {
  93. submitForm() {
  94. this.$refs['bhForms'].validate().then(res => {
  95. const submitForm = {
  96. ...this.forms,
  97. khId: this.khId,
  98. xm: this.xm,
  99. };
  100. if (this.forms.id) {
  101. updateKhbhls(submitForm).then(res => {
  102. if (res.code !== 200) return
  103. // 关闭窗口后,恢复默认内容
  104. uni.showToast({
  105. title: `修改成功!`,
  106. duration: 2000,
  107. success: (res) => {
  108. uni.$emit('changeBhls', 'bhls')
  109. setTimeout(function() {
  110. uni.navigateBack({ delta: 1 });
  111. }, 1000)
  112. }
  113. })
  114. })
  115. } else {
  116. addKhbhls(submitForm).then(res => {
  117. if (res.code !== 200) return
  118. // 关闭窗口后,恢复默认内容
  119. uni.showToast({
  120. title: `新增成功!`,
  121. duration: 2000,
  122. success: (res) => {
  123. uni.$emit('changeBhls', 'bhls')
  124. setTimeout(function() {
  125. uni.navigateBack({ delta: 1 });
  126. }, 1000)
  127. }
  128. })
  129. })
  130. }
  131. }).catch(err => {
  132. console.log('err', err);
  133. })
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. .bottomButton {
  140. height: 140rpx;
  141. width: 60%;
  142. margin: 0 auto;
  143. text-align: center;
  144. button {
  145. width: 40%;
  146. }
  147. button+button {
  148. margin-left: 15px;
  149. }
  150. }
  151. </style>