registerDoctor.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. <template>
  2. <view class="content">
  3. <view class="content">
  4. <view class="inner">
  5. <view class="bg">
  6. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/74645f3b57bc45b08b35e2449fdf90c7.jpg"></image>
  7. <view v-if="form.doctorType==1" class="title">医生注册</view>
  8. <view v-if="form.doctorType==1" class="desc">请填写医生资料</view>
  9. <view v-if="form.doctorType==2" class="title">药师注册</view>
  10. <view v-if="form.doctorType==2" class="desc">请填写药师资料</view>
  11. </view>
  12. <view class="my-form" >
  13. <u-form :rules="rules" :model="form" ref="uForm" labelPosition="left" errorType="toast">
  14. <u-form-item labelWidth="180rpx" borderBottom label="真实姓名" prop="doctorName">
  15. <u-input border="none" placeholder="请输入真实姓名" v-model="form.doctorName" />
  16. </u-form-item>
  17. <u-form-item labelWidth="180rpx" borderBottom label="身份证号" prop="idCard">
  18. <u-input border="none" placeholder="请输入身份证号" v-model="form.idCard" />
  19. </u-form-item>
  20. <u-form-item labelWidth="180rpx" borderBottom label="性别" prop="sex">
  21. <u-radio-group
  22. placement="row"
  23. v-model="form.sex"
  24. >
  25. <u-radio
  26. activeColor="#2583EB"
  27. :customStyle="{marginRight: '8px'}"
  28. key="1"
  29. label="男"
  30. name="1"
  31. >
  32. </u-radio>
  33. <u-radio
  34. activeColor="#2583EB"
  35. key="2"
  36. label="女"
  37. name="2"
  38. >
  39. </u-radio>
  40. </u-radio-group>
  41. </u-form-item>
  42. <u-form-item labelWidth="180rpx" prop="cityIds" @click="cityShow=true" borderBottom label="所在城市">
  43. <u-input
  44. v-model="form.cityName"
  45. disabled
  46. disabledColor="#ffffff"
  47. placeholder="请选择所在城市"
  48. border="none"
  49. ></u-input>
  50. <template #right>
  51. <u-icon
  52. name="arrow-right"
  53. ></u-icon>
  54. </template>
  55. </u-form-item>
  56. <template v-if="form.doctorType==1">
  57. <!-- <u-form-item labelWidth="180rpx" prop="hospitalId" @click="hospitalShow=true" borderBottom label="就职医院">
  58. <u-input
  59. v-model="form.hospitalName"
  60. disabled
  61. disabledColor="#ffffff"
  62. placeholder="请选择医院"
  63. border="none"
  64. ></u-input>
  65. <template #right>
  66. <u-icon
  67. name="arrow-right"
  68. ></u-icon>
  69. </template>
  70. </u-form-item> -->
  71. <u-form-item labelWidth="180rpx" prop="deptId" @click="deptShow=true" borderBottom label="所属科室">
  72. <u-input
  73. v-model="form.deptName"
  74. disabled
  75. disabledColor="#ffffff"
  76. placeholder="请选择科室"
  77. border="none"
  78. ></u-input>
  79. <template #right>
  80. <u-icon
  81. name="arrow-right"
  82. ></u-icon>
  83. </template>
  84. </u-form-item>
  85. </template>
  86. <u-form-item labelWidth="180rpx" prop="position" @click="positionShow=true" borderBottom label="职称">
  87. <u-input
  88. v-model="form.position"
  89. disabled
  90. disabledColor="#ffffff"
  91. placeholder="请选择职称"
  92. border="none"
  93. ></u-input>
  94. <template #right>
  95. <u-icon
  96. name="arrow-right"
  97. ></u-icon>
  98. </template>
  99. </u-form-item>
  100. <u-form-item labelWidth="180rpx" prop="position" @click="storeShow=true" borderBottom label="药店">
  101. <u-input
  102. v-model="form.storeName"
  103. disabled
  104. disabledColor="#ffffff"
  105. placeholder="请选择药店"
  106. border="none"
  107. ></u-input>
  108. <template #right>
  109. <u-icon
  110. name="arrow-right"
  111. ></u-icon>
  112. </template>
  113. </u-form-item>
  114. <template v-if="form.doctorType==1">
  115. <u-form-item labelWidth="180rpx" borderBottom label="擅长领域" prop="">
  116. <u--textarea v-model="form.speciality" placeholder="请输入擅长领域" count ></u--textarea>
  117. </u-form-item>
  118. <u-form-item labelWidth="180rpx" borderBottom label="个人简介" prop="introduction">
  119. <u--textarea v-model="form.introduction" placeholder="请输入个人简介" count ></u--textarea>
  120. </u-form-item>
  121. </template>
  122. <u-form-item labelWidth="180rpx" borderBottom :label="`${typeName}照片`" prop="avatar">
  123. <u-upload
  124. :fileList="fileList1"
  125. @afterRead="afterRead"
  126. @delete="deletePic"
  127. name="1"
  128. multiple
  129. :maxCount="1"
  130. >
  131. </u-upload>
  132. </u-form-item>
  133. <u-form-item labelWidth="180rpx" borderBottom label="身份证照片(正反面)" prop="idCardFrontUrl">
  134. <u-upload
  135. :fileList="fileList2"
  136. @afterRead="afterRead"
  137. @delete="deletePic"
  138. name="2"
  139. multiple
  140. :maxCount="2"
  141. >
  142. </u-upload>
  143. </u-form-item>
  144. <template v-if="form.doctorType==1">
  145. <u-form-item labelWidth="180rpx" borderBottom label="资质证编号" prop="certificateCode">
  146. <u-input border="none" placeholder="请输入资质证编号" v-model="form.certificateCode" />
  147. </u-form-item>
  148. <u-form-item labelWidth="180rpx" borderBottom label="资质证书" prop="certificateImages">
  149. <u-upload
  150. :fileList="fileList3"
  151. @afterRead="afterRead"
  152. @delete="deletePic"
  153. name="3"
  154. :maxCount="3"
  155. ></u-upload>
  156. </u-form-item>
  157. </template>
  158. <u-form-item labelWidth="180rpx" borderBottom label="执业证编号" prop="practiseCode">
  159. <u-input border="none" placeholder="请输入执业证编号" v-model="form.practiseCode" />
  160. </u-form-item>
  161. <u-form-item labelWidth="180rpx" borderBottom label="执业证书" prop="certificateImages">
  162. <u-upload
  163. :fileList="fileList4"
  164. @afterRead="afterRead"
  165. @delete="deletePic"
  166. name="4"
  167. :maxCount="3"
  168. ></u-upload>
  169. </u-form-item>
  170. <u-form-item labelWidth="180rpx" borderBottom label="联系电话" prop="mobile">
  171. <u-input border="none" placeholder="请输入联系电话" v-model="form.mobile" />
  172. </u-form-item>
  173. <u-form-item labelWidth="180rpx" borderBottom label="登录帐号" prop="account">
  174. <u-input border="none" placeholder="请输入登录帐号" v-model="form.account" />
  175. </u-form-item>
  176. <u-form-item labelWidth="180rpx" label="登录密码" prop="password">
  177. <u-input border="none" type="password" placeholder="请输入登录密码" v-model="form.password" />
  178. </u-form-item>
  179. </u-form>
  180. </view>
  181. <view class="agree">
  182. <u-checkbox-group
  183. v-model="checked"
  184. placement="column"
  185. >
  186. <u-checkbox
  187. activeColor="#2583EB"
  188. :customStyle="{marginRight: '8px'}"
  189. :key="1"
  190. label="同意"
  191. :name="1"
  192. >
  193. </u-checkbox>
  194. </u-checkbox-group>
  195. <text class="text" @click="openContent('doctorRegister')" >{{`《${typeName}注册协议》`}}</text>
  196. <text class="text" @click="openContent('doctorFiling')" >{{`《${typeName}多机构备案协议》`}}</text>
  197. </view>
  198. <u-picker ref="cityPicker" @cancel="cityShow = false" keyName="n" @confirm="citySelect" @change="cityChangeHandler" :show="cityShow" :columns="citys"></u-picker>
  199. <u-picker ref="deptPicker" @cancel="deptShow = false" keyName="deptName" @confirm="deptSelect" :show="deptShow" :columns="depts"></u-picker>
  200. <u-picker @cancel="hospitalShow = false" keyName="hospitalName" @confirm="hospitalSelect" :show="hospitalShow" :columns="hospitals"></u-picker>
  201. <u-picker ref="positionPicker" @cancel="positionShow = false" keyName="dictLabel" @confirm="positionSelect" :show="positionShow" :columns="positions"></u-picker>
  202. <u-picker ref="storePicker" @cancel="storeShow = false" keyName="storeName" @confirm="storeSelect" :show="storeShow" :columns="stores"></u-picker>
  203. </view>
  204. <view class="btn-box">
  205. <view class="sub-btn" @click="submit()">提交</view>
  206. </view>
  207. </view>
  208. </view>
  209. </template>
  210. <script>
  211. import {getDictByKey,getHospitalList,getDepartmentList,sendSmsCode,uploadOSS,getCitys} from '@/api/common.js'
  212. import {registerDoctor} from '@/api/user.js'
  213. import { getStoreList } from '@/api/store.js'
  214. export default {
  215. data() {
  216. return {
  217. cityIndex1:0,
  218. cityIndex2:0,
  219. allCitys:[],
  220. citys:[[],[],[]],
  221. cityShow:false,
  222. depts:[[]],
  223. deptShow:false,
  224. hospitals:[[]],
  225. hospitalShow:false,
  226. positions:[[]],
  227. positionShow:false,
  228. fileList1:[],
  229. fileList2:[],
  230. fileList3:[],
  231. fileList4:[],
  232. checked:0,
  233. form:{
  234. sex:"1",
  235. introduction: '',
  236. speciality:''
  237. },
  238. rules: {
  239. doctorName: [
  240. {
  241. required: true,
  242. message: '请输入真实姓名',
  243. }
  244. ],
  245. idCard: [
  246. {
  247. required: true,
  248. message: '请输入身份证号',
  249. // 可以单个或者同时写两个触发验证方式
  250. trigger: ['change','blur'],
  251. }
  252. ],
  253. position: [
  254. {
  255. required: true,
  256. message: '请选择职务',
  257. }
  258. ],
  259. cityIds: [
  260. {
  261. required: true,
  262. message: '请选择所在城市',
  263. }
  264. ],
  265. account: [
  266. {
  267. required: true,
  268. message: '请输入帐号',
  269. }
  270. ],
  271. password: [
  272. {
  273. required: true,
  274. message: '请输入密码',
  275. }
  276. ],
  277. mobile: [
  278. {
  279. required: true,
  280. message: '请输入手机号',
  281. // 可以单个或者同时写两个触发验证方式
  282. trigger: ['change','blur'],
  283. }
  284. ],
  285. practiseCode : [
  286. {
  287. required: true,
  288. message: '请输入执业证编号',
  289. trigger: ['change','blur'],
  290. }
  291. ]
  292. },
  293. typeName: '',
  294. storeShow: false,
  295. stores: [[]]
  296. }
  297. },
  298. onLoad(options) {
  299. this.form.doctorType=options.type;
  300. this.typeName= options.type==1 ? '医生':options.type==2 ? '药师' : ''
  301. uni.setNavigationBarTitle({
  302. title: options.type==1 ? '医生注册':options.type==2 ? '药师注册' : ''
  303. })
  304. this.getCitys()
  305. this.getHospitalList();
  306. this.getDepartmentList();
  307. this.getStoreList()
  308. if(options.type==1) {
  309. }
  310. this.getDictByKey();
  311. },
  312. onShow() {
  313. },
  314. onReady() {
  315. this.$refs.uForm.setRules(this.rules);
  316. },
  317. methods: {
  318. hospitalSelect(e){
  319. this.form.hospitalId=this.hospitals[0][e.indexs[0]].hospitalId;
  320. this.form.hospitalName=this.hospitals[0][e.indexs[0]].hospitalName;
  321. this.hospitalShow=false;
  322. },
  323. deptSelect(e){
  324. console.log(e)
  325. this.form.deptId=this.depts[0][e.indexs[0]].deptId;
  326. this.form.deptName=this.depts[0][e.indexs[0]].deptName;
  327. this.deptShow=false;
  328. },
  329. positionSelect(e){
  330. console.log(e)
  331. this.form.position=this.positions[0][e.indexs[0]].dictLabel;
  332. this.positionShow=false;
  333. },
  334. storeSelect(e){
  335. this.form.storeName=this.stores[0][e.indexs[0]].storeName;
  336. this.form.storeId=this.stores[0][e.indexs[0]].storeId;
  337. this.storeShow=false;
  338. },
  339. getDictByKey(key){
  340. var data={key:this.form.doctorType==2?"sys_pharmacist_position":"sys_doc_position"}
  341. getDictByKey(data).then(
  342. res => {
  343. if(res.code==200){
  344. this.positions[0]=res.data;
  345. }
  346. },
  347. err => {
  348. }
  349. );
  350. },
  351. openContent(type){
  352. uni.navigateTo({
  353. url:"agreement?type="+type
  354. })
  355. },
  356. cityChangeHandler(e) {
  357. const {
  358. columnIndex,
  359. index,
  360. // 微信小程序无法将picker实例传出来,只能通过ref操作
  361. picker = this.$refs.cityPicker
  362. } = e
  363. if(columnIndex==0){
  364. this.cityIndex1=index
  365. console.log(this.cityIndex1)
  366. //获取第二列数据
  367. var citys1 = this.allCitys[this.cityIndex1].c;
  368. console.log(citys1)
  369. picker.setColumnValues(1,citys1)
  370. this.cityIndex2=0
  371. var citys2 = this.allCitys[this.cityIndex1].c[this.cityIndex2].c;
  372. picker.setColumnValues(2,citys2)
  373. }
  374. if(columnIndex==1){
  375. this.cityIndex2=index
  376. //获取第三列数据
  377. var citys = this.allCitys[this.cityIndex1].c[this.cityIndex2].c;
  378. console.log(citys)
  379. picker.setColumnValues(2,citys)
  380. }
  381. },
  382. citySelect(e){
  383. console.log(e)
  384. this.form.cityName=e.value[0].n+">"+e.value[1].n+">"+e.value[2].n
  385. this.form.cityIds=e.value[0].v+","+e.value[1].v+","+e.value[2].v;
  386. this.cityShow=false;
  387. },
  388. getCitys(){
  389. var that=this;
  390. var data={}
  391. getCitys(data).then(
  392. res => {
  393. if(res.code==200){
  394. that.allCitys=res.data;
  395. that.citys=[[],[],[]];
  396. that.citys[0]=that.allCitys;
  397. that.citys[1]=that.allCitys[0].c;
  398. that.citys[2]=that.allCitys[0].c[0].c;
  399. console.log(that.citys)
  400. }
  401. },
  402. err => {
  403. }
  404. );
  405. },
  406. getHospitalList(){
  407. var that=this;
  408. var data={}
  409. getHospitalList(data).then(
  410. res => {
  411. if(res.code==200){
  412. that.hospitals[0]=res.data;
  413. console.log(111)
  414. console.log(that.hospitals)
  415. }
  416. },
  417. err => {
  418. }
  419. );
  420. },
  421. getDepartmentList(){
  422. var that=this;
  423. var data={}
  424. getDepartmentList(data).then(
  425. res => {
  426. if(res.code==200){
  427. that.depts[0]=res.data;
  428. }
  429. },
  430. err => {
  431. }
  432. );
  433. },
  434. getStoreList(){
  435. var that=this;
  436. var data={}
  437. getStoreList(data).then(
  438. res => {
  439. if(res.code==200){
  440. that.stores[0]=res.data;
  441. }
  442. },
  443. err => {
  444. }
  445. );
  446. },
  447. deletePic(event) {
  448. this[`fileList${event.name}`].splice(event.index, 1)
  449. },
  450. async afterRead(event) {
  451. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  452. let lists = [].concat(event.file)
  453. let fileListLen = this[`fileList${event.name}`].length
  454. lists.map((item) => {
  455. this[`fileList${event.name}`].push({
  456. ...item,
  457. status: 'uploading',
  458. message: '上传中'
  459. })
  460. })
  461. for (let i = 0; i < lists.length; i++) {
  462. const result = await this.uploadFilePromise(lists[i].url)
  463. let item = this[`fileList${event.name}`][fileListLen]
  464. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  465. status: 'success',
  466. message: '',
  467. url: result
  468. }))
  469. fileListLen++
  470. }
  471. },
  472. uploadFilePromise(url) {
  473. return new Promise((resolve, reject) => {
  474. let a = uni.uploadFile({
  475. url: uni.getStorageSync('requestPath')+'/app/common/uploadOSS',
  476. filePath: url,
  477. name: 'file',
  478. formData: {
  479. user: 'test'
  480. },
  481. success: (res) => {
  482. setTimeout(() => {
  483. // console.log(JSON.parse(res.data).url)
  484. resolve(JSON.parse(res.data).url)
  485. }, 1000)
  486. }
  487. });
  488. })
  489. },
  490. register(){
  491. registerDoctor(this.form).then(
  492. res => {
  493. console.log(res)
  494. if(res.code==200){
  495. uni.showToast({
  496. icon:'none',
  497. title:res.msg,
  498. });
  499. setTimeout(function() {
  500. uni.navigateBack({
  501. delta: 1
  502. })
  503. }, 2000);
  504. }else{
  505. uni.showToast({
  506. icon:'none',
  507. title: res.msg,
  508. });
  509. }
  510. },
  511. rej => {
  512. console.log(rej)
  513. }
  514. );
  515. },
  516. submit(){
  517. var that=this;
  518. if(this.fileList1.length>0){
  519. this.form.avatar=this.fileList1[0].url
  520. }
  521. if(this.fileList2.length>0){
  522. var images=[]
  523. that.fileList2.forEach(function(item) {
  524. images.push(item.url)
  525. });
  526. if(images.length!=2){
  527. uni.showToast({
  528. icon:'none',
  529. title:"请上传身份证照片(正反面)",
  530. });
  531. return
  532. }
  533. this.form.idCardFrontUrl=images[0];
  534. this.form.idCardBackUrl=images[1];
  535. }
  536. if(this.fileList3.length>0){
  537. var images=[]
  538. that.fileList3.forEach(function(item) {
  539. images.push(item.url)
  540. });
  541. this.form.certificateImages=images.toString();
  542. }
  543. if(this.fileList4.length>0){
  544. var images=[]
  545. that.fileList4.forEach(function(item) {
  546. images.push(item.url)
  547. });
  548. this.form.practiseImages=images.toString();
  549. } else {
  550. uni.showToast({
  551. icon:'none',
  552. title:"请上传职业证书",
  553. });
  554. return
  555. }
  556. if(this.checked!=1){
  557. uni.showToast({
  558. icon:'none',
  559. title:"请同意协议",
  560. });
  561. return
  562. }
  563. console.log(this.form)
  564. // deptId: [
  565. // {
  566. // required: true,
  567. // message: '请选择部门'
  568. // }
  569. // ],
  570. // hospitalId: [
  571. // {
  572. // required: true,
  573. // message: '请选择医院'
  574. // }
  575. // ],
  576. this.$refs.uForm.validate().then(res => {
  577. if(that.form.doctorType == 1&& !that.form.deptId) {
  578. uni.showToast({
  579. title: '请选择科室',
  580. icon: 'none'
  581. })
  582. return
  583. }
  584. if(that.form.doctorType == 1&&!that.form.speciality) {
  585. uni.showToast({
  586. title: '请输入擅长领域',
  587. icon: 'none'
  588. })
  589. return
  590. }
  591. if(!that.form.storeId) {
  592. uni.showToast({
  593. title: '请选择药店',
  594. icon: 'none'
  595. })
  596. return
  597. }
  598. that.register()
  599. }).catch(errors => {
  600. console.log(errors)
  601. })
  602. },
  603. }
  604. }
  605. </script>
  606. <style scoped lang="scss">
  607. .content{
  608. display: flex;
  609. flex-direction: column;
  610. justify-content: flex-start;
  611. .inner{
  612. padding: 20upx 20rpx 120rpx;
  613. .bg{
  614. width: 100%;
  615. height: 300rpx;
  616. position: relative;
  617. display: flex;
  618. flex-direction: column;
  619. justify-content: center;
  620. align-items: flex-start;
  621. image{
  622. position: absolute;
  623. border-radius: 30rpx 30rpx 0rpx 0rpx;
  624. width: 100%;
  625. height: 100%;
  626. }
  627. .title{
  628. z-index: 999;
  629. padding: 0rpx 30rpx;
  630. font-size: 40upx;
  631. font-family: PingFang SC;
  632. font-weight: bold;
  633. color: #FFFFFF;
  634. }
  635. .desc{
  636. z-index: 999;
  637. padding: 0rpx 30rpx;
  638. margin-top: 20rpx;
  639. font-size: 28upx;
  640. opacity: 0.5;
  641. font-family: PingFang SC;
  642. color: #FFFFFF;
  643. }
  644. }
  645. .my-form{
  646. z-index: 1;
  647. background-color: #FFFFFF;
  648. padding: 0 30upx;
  649. input{
  650. text-align: right;
  651. }
  652. }
  653. }
  654. .agree{
  655. padding: 10rpx 20rpx;
  656. display: flex;
  657. align-items: center;
  658. justify-content: flex-start;
  659. .label{
  660. font-size: 24rpx;
  661. }
  662. .text{
  663. margin-left: 10rpx;
  664. color: royalblue;
  665. font-size: 24rpx;
  666. }
  667. }
  668. .btn-box{
  669. z-index: 9999;
  670. width: 100%;
  671. position: fixed;
  672. bottom: 0;
  673. height: 120upx;
  674. padding: 0 30upx;
  675. display: flex;
  676. align-items: center;
  677. justify-content: center;
  678. background: #FFFFFF;
  679. .sub-btn{
  680. width: 100%;
  681. height: 88upx;
  682. line-height: 88upx;
  683. text-align: center;
  684. font-size: 30upx;
  685. font-family: PingFang SC;
  686. font-weight: bold;
  687. color: #FFFFFF;
  688. background: #2583EB;
  689. border-radius: 44upx;
  690. }
  691. }
  692. }
  693. </style>