add.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <!-- header -->
  3. <div class="nav-container page-component">
  4. <!--左侧导航 #start -->
  5. <div class="nav left-nav">
  6. <div class="nav-item ">
  7. <span class="v-link clickable dark" onclick="javascript:window.location='/user'">实名认证 </span>
  8. </div>
  9. <div class="nav-item ">
  10. <span class="v-link clickable dark" onclick="javascript:window.location='/order'"> 挂号订单 </span>
  11. </div>
  12. <div class="nav-item selected">
  13. <span class="v-link selected dark" onclick="javascript:window.location='/patient'"> 就诊人管理 </span>
  14. </div>
  15. <div class="nav-item ">
  16. <span class="v-link clickable dark"> 修改账号信息 </span>
  17. </div>
  18. <div class="nav-item ">
  19. <span class="v-link clickable dark"> 意见反馈 </span>
  20. </div>
  21. </div>
  22. <!-- 左侧导航 #end -->
  23. <!-- 右侧内容 #start -->
  24. <div class="page-container">
  25. <div class="personal-patient">
  26. <div class="header-wrapper">
  27. <div class="title"> 添加就诊人</div>
  28. </div>
  29. <div>
  30. <div class="sub-title">
  31. <div class="block"></div>
  32. 就诊人信息
  33. </div>
  34. <div class="content-wrapper">
  35. <el-form :model="patient" label-width="110px" label-position="left" ref="patient" :rules="validateRules">
  36. <el-form-item prop="name" label="姓名:">
  37. <el-input v-model="patient.name" placeholder="请输入真实姓名全称" class="input v-input"/>
  38. </el-form-item>
  39. <el-form-item prop="certificatesType" label="证件类型:" >
  40. <el-select v-model="patient.certificatesType" placeholder="请选择证件类型" class="v-select patient-select">
  41. <el-option
  42. v-for="item in certificatesTypeList"
  43. :key="item.value"
  44. :label="item.name"
  45. :value="item.value">
  46. </el-option>
  47. </el-select>
  48. </el-form-item>
  49. <el-form-item prop="certificatesNo" label="证件号码:" >
  50. <el-input v-model="patient.certificatesNo" placeholder="请输入证件号码" class="input v-input"/>
  51. </el-form-item>
  52. <el-form-item prop="sex" label="性别:">
  53. <el-radio-group v-model="patient.sex">
  54. <el-radio :label="1">男</el-radio>
  55. <el-radio :label="0">女</el-radio>
  56. </el-radio-group>
  57. </el-form-item>
  58. <el-form-item prop="birthdate" label="出生日期:" >
  59. <el-date-picker
  60. v-model="patient.birthdate"
  61. class="v-date-picker"
  62. type="date"
  63. placeholder="选择日期">
  64. </el-date-picker>
  65. </el-form-item>
  66. <el-form-item prop="phone" label="手机号码:" >
  67. <el-input v-model="patient.phone" placeholder="请输入手机号码" maxlength="11" class="input v-input"/>
  68. </el-form-item>
  69. </el-form>
  70. </div>
  71. <div class="sub-title">
  72. <div class="block"></div>
  73. 建档信息(完善后部分医院首次就诊不排队建档)
  74. </div>
  75. <div class="content-wrapper">
  76. <el-form :model="patient" label-width="110px" label-position="left" ref="patient" :rules="validateRules">
  77. <el-form-item prop="isMarry" label="婚姻状况:">
  78. <el-radio-group v-model="patient.isMarry">
  79. <el-radio :label="0">未婚</el-radio>
  80. <el-radio :label="1">已婚</el-radio>
  81. </el-radio-group>
  82. </el-form-item>
  83. <el-form-item prop="isInsure" label="自费/医保:">
  84. <el-radio-group v-model="patient.isInsure">
  85. <el-radio :label="0">自费</el-radio>
  86. <el-radio :label="1">医保</el-radio>
  87. </el-radio-group>
  88. </el-form-item>
  89. <el-form-item prop="addressSelected" label="当前住址:" >
  90. <el-cascader
  91. ref="selectedShow"
  92. v-model="patient.addressSelected"
  93. class="v-address"
  94. :props="props"
  95. ></el-cascader>
  96. </el-form-item>
  97. <el-form-item prop="address" label="详细地址:" >
  98. <el-input v-model="patient.address" placeholder="应公安机关要求,请填写现真实住址" class="input v-input"/>
  99. </el-form-item>
  100. </el-form>
  101. </div>
  102. <div class="sub-title">
  103. <div class="block"></div>
  104. 联系人信息(选填)
  105. </div>
  106. <div class="content-wrapper">
  107. <el-form :model="patient" label-width="110px" label-position="left">
  108. <el-form-item prop="contactsName" label="姓名:">
  109. <el-input v-model="patient.contactsName" placeholder="请输入联系人姓名全称" class="input v-input"/>
  110. </el-form-item>
  111. <el-form-item prop="contactsCertificatesType" label="证件类型:">
  112. <el-select v-model="patient.contactsCertificatesType" placeholder="请选择证件类型" class="v-select patient-select">
  113. <el-option
  114. v-for="item in certificatesTypeList"
  115. :key="item.value"
  116. :label="item.name"
  117. :value="item.value">
  118. </el-option>
  119. </el-select>
  120. </el-form-item>
  121. <el-form-item prop="contactsCertificatesNo" label="证件号码:">
  122. <el-input v-model="patient.contactsCertificatesNo" contactsCertificatesNo="请输入联系人证件号码" class="input v-input"/>
  123. </el-form-item>
  124. <el-form-item prop="contactsPhone" label="手机号码:">
  125. <el-input v-model="patient.contactsPhone" placeholder="请输入联系人手机号码" class="input v-input"/>
  126. </el-form-item>
  127. </el-form>
  128. </div>
  129. </div>
  130. <div class="bottom-wrapper">
  131. <div class="button-wrapper">
  132. <div class="v-button" @click="saveOrUpdate()">{{ submitBnt }}</div>
  133. </div>
  134. </div>
  135. </div>
  136. </div>
  137. <!-- 右侧内容 #end -->
  138. </div>
  139. <!-- footer -->
  140. </template>
  141. <script>
  142. import '~/assets/css/hospital_personal.css'
  143. import '~/assets/css/hospital.css'
  144. import '~/assets/css/personal.css'
  145. import dictApi from '@/api/cmn/dict'
  146. import patientApi from '@/api/user/patient'
  147. const defaultForm = {
  148. name: '',
  149. certificatesType: '',
  150. certificatesNo: '',
  151. sex: 1,
  152. birthdate: '',
  153. phone: '',
  154. isMarry: 0,
  155. isInsure: 0,
  156. provinceCode: '',
  157. cityCode: '',
  158. districtCode: '',
  159. addressSelected: null,
  160. address: '',
  161. contactsName: '',
  162. contactsCertificatesType: '',
  163. contactsCertificatesNo: '',
  164. contactsPhone: '',
  165. param: {}
  166. }
  167. export default {
  168. data() {
  169. return {
  170. patient: defaultForm,
  171. certificatesTypeList: [],
  172. props: {
  173. lazy: true,
  174. async lazyLoad (node, resolve) {
  175. const { level } = node
  176. //异步获取省市区
  177. dictApi.findByParentId(level ? node.value : '86').then(response => {
  178. let list= response.data
  179. let provinceList = list.map((item, i) => {
  180. return {
  181. value: item.id,
  182. label: item.name,
  183. leaf: node.level == 2 ? true : false,//可控制显示几级
  184. }
  185. })
  186. resolve && resolve(provinceList)
  187. })
  188. }
  189. },
  190. submitBnt: '保存',
  191. validateRules: {
  192. name: [{ required: true, trigger: 'blur', message: '必须输入' }],
  193. certificatesType: [{ required: true, trigger: 'blur', message: '必须输入' }],
  194. certificatesNo: [{ required: true, trigger: 'blur', message: '必须输入' }],
  195. birthdate: [{ required: true, trigger: 'blur', message: '必须输入' }],
  196. phone: [{ required: true, trigger: 'blur', message: '必须输入' }],
  197. addressSelected: [{ required: true, trigger: 'blur', message: '必须输入' }],
  198. address: [{ required: true, trigger: 'blur', message: '必须输入' }]
  199. }
  200. }
  201. },
  202. created() {
  203. this.init();
  204. },
  205. mounted() {
  206. if (this.$route.query.id) {
  207. setTimeout(()=>{
  208. this.$refs.selectedShow.presentText = this.patient.param.provinceString + '/' + this.patient.param.cityString + '/' +this.patient.param.districtString //"北京市/市辖区/西城区";// 首次手动复制
  209. // this.$refs.selectedShow.value = '110000/110100/110102';
  210. },1000)
  211. }
  212. },
  213. methods: {
  214. init() {
  215. if (this.$route.query.id) {
  216. const id = this.$route.query.id
  217. this.fetchDataById(id)
  218. } else {
  219. // 对象拓展运算符:拷贝对象,而不是赋值对象的引用
  220. this.patient = { ...defaultForm }
  221. }
  222. this.getDict()
  223. },
  224. fetchDataById(id) {
  225. patientApi.getById(id).then(response => {
  226. this.patient = response.data
  227. //添加默认值
  228. this.patient.addressSelected = [this.patient.provinceCode, this.patient.cityCode, this.patient.districtCode]
  229. })
  230. },
  231. getDict() {
  232. dictApi.findByDictCode("CertificatesType").then(response => {
  233. this.certificatesTypeList = response.data
  234. })
  235. },
  236. saveOrUpdate() {
  237. this.$refs.patient.validate(valid => {
  238. if (valid) {
  239. //地址处理
  240. if(this.patient.addressSelected.length == 3) {
  241. this.patient.provinceCode = this.patient.addressSelected[0]
  242. this.patient.cityCode = this.patient.addressSelected[1]
  243. this.patient.districtCode = this.patient.addressSelected[2]
  244. }
  245. if (!this.patient.id) {
  246. this.saveData()
  247. } else {
  248. this.updateData()
  249. }
  250. }
  251. })
  252. },
  253. // 新增
  254. saveData() {
  255. if(this.submitBnt == '正在提交...') {
  256. this.$message.info('重复提交')
  257. return
  258. }
  259. this.submitBnt = '正在提交...'
  260. patientApi.save(this.patient).then(response => {
  261. this.$message.success("提交成功")
  262. window.location.href = '/patient'
  263. }).catch(e => {
  264. this.submitBnt = '保存'
  265. })
  266. },
  267. // 根据id更新记录
  268. updateData() {
  269. if(this.submitBnt == '正在提交...') {
  270. this.$message.info('重复提交')
  271. return
  272. }
  273. this.submitBnt = '正在提交...'
  274. patientApi.updateById(this.patient).then(response => {
  275. this.$message.success("提交成功")
  276. window.location.href = '/patient'
  277. }).catch(e => {
  278. this.submitBnt = '保存'
  279. })
  280. }
  281. }
  282. }
  283. </script>
  284. <style>
  285. .header-wrapper .title {
  286. font-size: 16px;
  287. margin-top: 0;
  288. }
  289. .sub-title {
  290. margin-top: 0;
  291. }
  292. .bottom-wrapper{
  293. padding: 0;
  294. margin: 0;
  295. }
  296. .bottom-wrapper .button-wrapper{
  297. margin-top: 0;
  298. }
  299. </style>