registerDoctor.vue 18 KB

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