index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view class="main">
  3. <view class="one">
  4. <upload class='upload' :list="form.icon" name="icon" :count="1" @uplSuc="uplSuc" @uplDel="uplDel">
  5. </upload>
  6. </view>
  7. <view class="two">
  8. <view class="two_1">
  9. <view class="left">姓名</view>
  10. <view class="right">
  11. <input v-model="form.name" placeholder="请输入真实姓名" />
  12. <text class="iconfont icon-dayuhao"></text>
  13. </view>
  14. </view>
  15. <view class="two_1">
  16. <view class="left">手机号</view>
  17. <view class="right">
  18. <input v-model="form.mobile" placeholder="请输入手机号" />
  19. <text class="iconfont icon-dayuhao"></text>
  20. </view>
  21. </view>
  22. <view class="two_1" v-if="user.role!='Patient'">
  23. <view class="left">医院名称</view>
  24. <view class="right">
  25. <input v-model="form.hos_name" placeholder="请输入医院名称" />
  26. <text class="iconfont icon-dayuhao"></text>
  27. </view>
  28. </view>
  29. <view class="two_1" v-if="user.role!='Patient'">
  30. <view class="left">科室名称</view>
  31. <view class="right">
  32. <input v-model="form.dept_name" placeholder="请输入科室名称" />
  33. <text class="iconfont icon-dayuhao"></text>
  34. </view>
  35. </view>
  36. <view class="two_1" v-if="user.role!='Patient'">
  37. <view class="left">职务</view>
  38. <view class="right">
  39. <input v-model="form.title" placeholder="请输入职务" />
  40. <text class="iconfont icon-dayuhao"></text>
  41. </view>
  42. </view>
  43. <view class="two_1" v-if="user.role!='Patient'">
  44. <view class="left">职称</view>
  45. <view class="right">
  46. <input v-model="form.post" placeholder="请输入职称" />
  47. <text class="iconfont icon-dayuhao"></text>
  48. </view>
  49. </view>
  50. <view class="two_1" v-if="user.role!='Patient'">
  51. <view class="left">简介</view>
  52. <view class="right">
  53. <input v-model="form.content" placeholder="请输入简介" />
  54. <text class="iconfont icon-dayuhao"></text>
  55. </view>
  56. </view>
  57. <view class="two_1" v-if="user.role=='Patient'">
  58. <view class="left">就诊编号/卡号</view>
  59. <view class="right">
  60. <input v-model="form.card_no" placeholder="请输入就诊编号/卡号" />
  61. <text class="iconfont icon-dayuhao"></text>
  62. </view>
  63. </view>
  64. <view class="two_1" v-if="user.role=='Patient'">
  65. <view class="left">性别</view>
  66. <view class="right">
  67. <picker class="picker" mode="selector" :range="genderList" @change="genderChange" range-key="label">
  68. <view>{{form.gender||'请选择性别'}}</view>
  69. </picker>
  70. <text class="iconfont icon-dayuhao"></text>
  71. </view>
  72. </view>
  73. <view class="two_1" v-if="user.role=='Patient'">
  74. <view class="left">年龄</view>
  75. <view class="right">
  76. <input v-model="form.age" placeholder="请输入年龄" />
  77. <text class="iconfont icon-dayuhao"></text>
  78. </view>
  79. </view>
  80. <view class="two_1" v-if="user.role=='Patient'">
  81. <view class="left">住址</view>
  82. <view class="right">
  83. <input v-model="form.address" placeholder="请输入住址" />
  84. <text class="iconfont icon-dayuhao"></text>
  85. </view>
  86. </view>
  87. <view class="two_1" v-if="user.role=='Patient'">
  88. <view class="left">紧急联系人</view>
  89. <view class="right">
  90. <input v-model="form.urgent_name" placeholder="请输入紧急联系人" />
  91. <text class="iconfont icon-dayuhao"></text>
  92. </view>
  93. </view>
  94. <view class="two_1" v-if="user.role=='Patient'">
  95. <view class="left">紧急联系人电话</view>
  96. <view class="right">
  97. <input v-model="form.urgent_mobile" placeholder="请输入紧急联系人电话" />
  98. <text class="iconfont icon-dayuhao"></text>
  99. </view>
  100. </view>
  101. <view class="two_1" v-if="user.role=='Patient'">
  102. <view class="left">病例</view>
  103. <view class="right">
  104. <upload class='upload' :list="form.emrs" name="emrs" :count="1" @uplSuc="uplSuc" @uplDel="uplDel">
  105. </upload>
  106. </view>
  107. </view>
  108. </view>
  109. <view class="thr">
  110. <button class="button" type="primary" size="mini" @click="onSubmit()">保存</button>
  111. </view>
  112. </view>
  113. </template>
  114. <script>
  115. import upload from '../../components/upload/index.vue';
  116. export default {
  117. components: {
  118. upload
  119. },
  120. data() {
  121. return {
  122. user: {},
  123. form: {},
  124. // 字典表
  125. genderList: [{
  126. label: '男',
  127. value: '男'
  128. },
  129. {
  130. label: '女',
  131. value: '女'
  132. }
  133. ],
  134. }
  135. },
  136. onLoad: async function(e) {
  137. const that = this;
  138. await that.searchToken();
  139. await that.search();
  140. },
  141. methods: {
  142. // 用户信息
  143. searchToken() {
  144. const that = this;
  145. try {
  146. const res = uni.getStorageSync('token');
  147. if (res) {
  148. const user = that.$jwt(res);
  149. that.$set(that, `user`, user);
  150. }
  151. } catch (e) {}
  152. },
  153. // 查询
  154. async search() {
  155. const that = this;
  156. const user = that.user
  157. if (user) {
  158. let res;
  159. if (user.role == 'Doctor') res = await that.$api(`/doctor/${user._id}`, 'GET', {})
  160. else if (user.role == 'Nurse') res = await that.$api(`/nurse/${user._id}`, 'GET', {})
  161. else res = await that.$api(`/patient/${user._id}`, 'GET', {})
  162. if (res.errcode == '0') {
  163. that.$set(that, `form`, res.data)
  164. } else {
  165. uni.showToast({
  166. title: res.errmsg,
  167. icon: 'none'
  168. });
  169. }
  170. }
  171. },
  172. // 图片上传
  173. uplSuc(e) {
  174. const that = this;
  175. that.$set(that.form, e.name, [e.data]);
  176. },
  177. // 图片删除
  178. uplDel(e) {
  179. const that = this;
  180. that.$set(that.form, e.name, [])
  181. },
  182. // 性别选择
  183. genderChange(e) {
  184. const that = this;
  185. let data = that.genderList[e.detail.value];
  186. if (data) that.$set(that.form, `gender`, data.value)
  187. },
  188. // 保存
  189. async onSubmit() {
  190. const that = this;
  191. const user = that.user
  192. const form = that.form
  193. if (!user) {
  194. uni.showToast({
  195. title: "缺少用户信息 无法保存!",
  196. icon: 'none'
  197. })
  198. return
  199. }
  200. let res;
  201. if (user.role == 'Doctor') res = await that.$api(`/doctor/${form._id}`, 'POST', form)
  202. else if (user.role == 'Nurse') res = await that.$api(`/nurse/${user._id}`, 'POST', form)
  203. else res = await that.$api(`/patient/${user._id}`, 'POST', form)
  204. if (res.errcode == '0') {
  205. uni.showToast({
  206. title: '维护信息成功',
  207. icon: 'none'
  208. })
  209. that.search()
  210. } else {
  211. uni.showToast({
  212. title: res.errmsg,
  213. icon: 'none'
  214. });
  215. }
  216. },
  217. }
  218. }
  219. </script>
  220. <style lang="scss" scoped>
  221. .main {
  222. .one {
  223. display: flex;
  224. justify-content: center;
  225. padding: 2vw;
  226. }
  227. .two {
  228. padding: 2vw;
  229. .two_1 {
  230. display: flex;
  231. justify-content: space-between;
  232. padding: 4vw;
  233. border-bottom: 1px solid var(--f9Color);
  234. font-size: var(--font14Size);
  235. color: var(--f69Color);
  236. .right {
  237. display: flex;
  238. align-items: center;
  239. input {
  240. text-align: right;
  241. padding: 0 1vw;
  242. }
  243. }
  244. }
  245. }
  246. .thr {
  247. text-align: center;
  248. .button {
  249. margin: 2vw 0 0 0;
  250. background-color: var(--f3CColor);
  251. color: var(--mainColor);
  252. font-size: var(--font14Size);
  253. }
  254. }
  255. }
  256. </style>