addUser.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. <template>
  2. <view class="content">
  3. <view class="inner">
  4. <view class="form-box">
  5. <text class="form-title">基本信息</text>
  6. <view class="form-item justify-between">
  7. <text class="label">头像</text>
  8. <view class="right">
  9. <image :src="form.avatar==null?maleurl:form.avatar" class="w90 h90"></image>
  10. <image class="w48 h48" src="/static/images/health/right_arrow_right_icon24.png"></image>
  11. <button class="wx-head" type="balanced" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  12. </button>
  13. </view>
  14. </view>
  15. <view class="form-item">
  16. <text class="label">姓名<text class="color-price">*</text></text>
  17. <input class="input-width" type="text" v-model="form.username" placeholder="请输入姓名"
  18. placeholder-class="form-input" />
  19. </view>
  20. <view class="form-item">
  21. <text class="label">性别<text class="color-price">*</text></text>
  22. <view class="sex-box">
  23. <view :class="form.sex==0?'sex-item active':'sex-item'" @click="sexChange(0)" >
  24. <u-icon name="man" :color="form.sex==0?'#008FD3':'#898E91'" size="20"></u-icon>
  25. <text>男</text>
  26. </view>
  27. <view :class="form.sex==1?'sex-item active2':'sex-item'" @click="sexChange(1)" >
  28. <u-icon name="woman" :color="form.sex==1?'#FF5030':'#898E91'" size="20"></u-icon>
  29. <text>女</text>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="form-item">
  34. <text class="label">出生年月<text class="color-price">*</text></text>
  35. <picker class="birth-picker" mode="date" @change="bindDateChange">
  36. <view class="right-box">
  37. <view class="input-box">
  38. <input type="text" :value="form.birthdate" placeholder="请选择出生年月" placeholder-class="form-input" disabled="disabled" />
  39. </view>
  40. <image class="w48 h48" src="/static/images/health/right_arrow_right_icon24.png"></image>
  41. </view>
  42. </picker>
  43. </view>
  44. <view class="form-item">
  45. <text class="label">手机号<text class="color-price">*</text></text>
  46. <input maxlength="11" class="input-width" type="number" v-model="form.phone" placeholder="请输入手机号" placeholder-class="form-input" />
  47. </view>
  48. <view class="form-item">
  49. <text class="label">身份证号<text class="color-price">*</text></text>
  50. <input maxlength="18" class="input-width" type="idcard" v-model="form.idCard" placeholder="请如实填写身份证号" placeholder-class="form-input" />
  51. </view>
  52. <view class="form-item">
  53. <text class="label">退休前工作单位<text class="color-price">*</text></text>
  54. <input class="input-width" type="text" v-model="form.previousEmployer" placeholder="请输入工作单位"
  55. placeholder-class="form-input" />
  56. </view>
  57. <view class="form-item">
  58. <text class="label">可支配收入<text class="color-price">*</text></text>
  59. <input class="input-width" type="digit" v-model="form.disposableIncome" placeholder="请输入支配收入"
  60. placeholder-class="form-input" />
  61. </view>
  62. <view class="form-item">
  63. <text class="label">实际消费<text class="color-price">*</text></text>
  64. <input class="input-width" type="digit" v-model="form.actualConsumption" placeholder="请输入实际消费"
  65. placeholder-class="form-input" />
  66. </view>
  67. </view>
  68. <view class="form-box">
  69. <text class="form-title">家庭地址及居住情况</text>
  70. <view class="form-item">
  71. <text class="label">市区<text class="color-price">*</text></text>
  72. <picker class="birth-picker" mode="region" level="city" @change="bindCityChange">
  73. <view class="right-box">
  74. <view class="input-box">
  75. <input type="text" :value="form.city" placeholder="请选择市区" placeholder-class="form-input" disabled="disabled" />
  76. </view>
  77. <image class="w48 h48" src="/static/images/health/right_arrow_right_icon24.png"></image>
  78. </view>
  79. </picker>
  80. </view>
  81. <view class="form-item">
  82. <text class="label">小区名称</text>
  83. <input maxlength="10" class="input-width" type="text" v-model="form.residentialCommunity" placeholder="请输入小区名称"
  84. placeholder-class="form-input" />
  85. </view>
  86. <view class="form-item">
  87. <text class="label">门牌</text>
  88. <input maxlength="10" class="input-width" type="text" v-model="form.houseNumber" placeholder="请输入门牌号"
  89. placeholder-class="form-input" />
  90. </view>
  91. <view class="form-item">
  92. <text class="label">面积</text>
  93. <input maxlength="10" class="input-width" type="text" v-model="form.area" placeholder="请输入面积"
  94. placeholder-class="form-input" />
  95. </view>
  96. <view class="form-item">
  97. <text class="label">楼层</text>
  98. <input maxlength="10" class="input-width" type="text" v-model="form.floor" placeholder="请输入楼层"
  99. placeholder-class="form-input" />
  100. </view>
  101. </view>
  102. <view class="form-box">
  103. <text class="form-title">家庭情况</text>
  104. <view class="form-item">
  105. <text class="label">伴侣</text>
  106. <input class="input-width" type="text" v-model="form.partnerName" placeholder="请输入伴侣姓名"
  107. placeholder-class="form-input" />
  108. </view>
  109. <view class="form-item">
  110. <text class="label">伴侣年龄</text>
  111. <input class="input-width" type="number" v-model="form.partnerAge" placeholder="请输入伴侣年龄"
  112. placeholder-class="form-input" />
  113. </view>
  114. <view class="form-item">
  115. <text class="label">子辈单位</text>
  116. <input maxlength="10" class="input-width" type="text" v-model="form.partnerEmployer" placeholder="请输入子辈工作单位"
  117. placeholder-class="form-input" />
  118. </view>
  119. <view class="form-item">
  120. <text class="label">孙辈学校</text>
  121. <input maxlength="10" class="input-width" type="text" v-model="form.grandchildrenSchool" placeholder="请输入所在学校"
  122. placeholder-class="form-input" />
  123. </view>
  124. </view>
  125. <view class="form-box">
  126. <text class="form-title">会员情况</text>
  127. <view class="form-item justify-between">
  128. <text class="label">是否是会员</text>
  129. <radio-group style="display: flex;align-items: center;">
  130. <label style="margin-right: 50upx;">
  131. <radio @click="radioClick(1)" value="1" :checked="form.isMember==1"
  132. style="margin-right: 16upx;" />
  133. <text class="sex-text">是</text>
  134. </label>
  135. <label>
  136. <radio @click="radioClick(0)" value="0" :checked="form.isMember==0"
  137. style="margin-right: 16upx;" />
  138. <text class="sex-text">否</text>
  139. </label>
  140. </radio-group>
  141. </view>
  142. <view class="form-item">
  143. <text class="label">会员分类</text>
  144. <picker class="birth-picker" mode="selector" @change="bindMemberChange($event,tags)" :range="tags" range-key="dictLabel">
  145. <view class="right-box">
  146. <view class="input-box">
  147. <input type="text" :value="form.memberLevel" placeholder="请选择会员分类" placeholder-class="form-input" disabled="disabled" />
  148. </view>
  149. <image class="w48 h48" src="/static/images/health/right_arrow_right_icon24.png"></image>
  150. </view>
  151. </picker>
  152. </view>
  153. <view class="form-item">
  154. <text class="label">加入时间</text>
  155. <picker class="birth-picker" mode="date" @change="bindJoinChange">
  156. <view class="right-box">
  157. <view class="input-box">
  158. <input type="text" :value="form.joinTime" placeholder="请选择加入时间" placeholder-class="form-input" disabled="disabled" />
  159. </view>
  160. <image class="w48 h48" src="/static/images/health/right_arrow_right_icon24.png"></image>
  161. </view>
  162. </picker>
  163. </view>
  164. <view class="form-item">
  165. <text class="label">到期时间</text>
  166. <picker class="birth-picker" mode="date" @change="bindEndChange">
  167. <view class="right-box">
  168. <view class="input-box">
  169. <input type="text" :value="form.expiryTime" placeholder="请选择到期时间" placeholder-class="form-input" disabled="disabled" />
  170. </view>
  171. <image class="w48 h48" src="/static/images/health/right_arrow_right_icon24.png"></image>
  172. </view>
  173. </picker>
  174. </view>
  175. <view class="form-item">
  176. <text class="label">管理月份</text>
  177. <picker class="birth-picker" mode="date" fields="month" @change="bindMonthChange">
  178. <view class="right-box">
  179. <view class="input-box">
  180. <input type="text" :value="form.managementMonth" placeholder="请选择管理月份" placeholder-class="form-input" disabled="disabled" />
  181. </view>
  182. <image class="w48 h48" src="/static/images/health/right_arrow_right_icon24.png"></image>
  183. </view>
  184. </picker>
  185. </view>
  186. </view>
  187. <view class="form-box">
  188. <text class="form-title">特殊情况</text>
  189. <view class="form-item">
  190. <text class="label">职位</text>
  191. <input class="input-width" type="text" v-model="form.position" placeholder="请输入职位"
  192. placeholder-class="form-input" />
  193. </view>
  194. <view class="form-item">
  195. <text class="label">癖好</text>
  196. <input maxlength="10" class="input-width" type="text" v-model="form.hobbies" placeholder="请输入癖好"
  197. placeholder-class="form-input" />
  198. </view>
  199. <view class="form-item">
  200. <text class="label">平日喜好</text>
  201. <input maxlength="10" class="input-width" type="text" v-model="form.specialties" placeholder="请输入平日喜好"
  202. placeholder-class="form-input" />
  203. </view>
  204. <view class="form-item">
  205. <text class="label">信仰</text>
  206. <input maxlength="10" class="input-width" type="text" v-model="form.faith" placeholder="请输入信仰"
  207. placeholder-class="form-input" />
  208. </view>
  209. <view class="form-item">
  210. <text class="label">担忧</text>
  211. <input maxlength="10" class="input-width" type="text" v-model="form.concerns" placeholder="请输入担忧"
  212. placeholder-class="form-input" />
  213. </view>
  214. </view>
  215. <view class="form-box">
  216. <text class="form-title">其他<text class="color-price">*</text></text>
  217. <view class="form-item">
  218. <!-- <text class="label">备注</text> -->
  219. <textarea maxlength="200" class="form-textarea" v-model="form.problemsToSolve" placeholder="请输入用户想解决的问题" placeholder-class="textarea-input" />
  220. </view>
  221. <view class="form-item">
  222. <!-- <text class="label">备注</text> -->
  223. <textarea maxlength="200" class="form-textarea" v-model="form.healthSuggestions" placeholder="请输入健康管理师对用户的建议" placeholder-class="textarea-input"/>
  224. </view>
  225. </view>
  226. </view>
  227. <view class="btn-box">
  228. <view class="sub-btn" @click="submit()">保存</view>
  229. </view>
  230. </view>
  231. </template>
  232. <script>
  233. import {getInfo,updateInfo,deleteInfo,addInfo,getMember} from '@/api/health.js'
  234. import {
  235. getDocDetails,
  236. addDoc,
  237. editDoc
  238. } from '@/api/doc.js'
  239. export default {
  240. data() {
  241. return {
  242. type: null,
  243. patientId: null,
  244. famaleurl:"/static/images/health/female_profile.png",
  245. maleurl:"/static/images/health/my_heads.png",
  246. checked:1,
  247. array:[
  248. {id:1,name:'是'},
  249. {id:0,name:'否'},
  250. ],
  251. tags: [],
  252. municipalities: ['北京市', '上海市', '天津市', '重庆市'],
  253. isAdd:null,
  254. form: {
  255. "username": null,
  256. avatar:null,
  257. "sex":0,
  258. "birthdate": null,
  259. "age": 0,
  260. "phone": null,
  261. "idCard": null,
  262. "previousEmployer": null,
  263. "disposableIncome": null,
  264. "actualConsumption": null,
  265. "city": null,
  266. "residentialCommunity": null,
  267. "houseNumber": null,
  268. "area": null,
  269. "floor": null,
  270. "partnerName": null,
  271. "partnerAge": null,
  272. "partnerEmployer": null,
  273. "grandchildrenSchool": null,
  274. "isMember": 1,
  275. "memberLevel": null,
  276. "joinTime": null,
  277. "expiryTime": null,
  278. "managementMonth":null,
  279. "position":null,
  280. "hobbies": null,
  281. "specialties": null,
  282. "faith": null,
  283. "concerns": null,
  284. "problemsToSolve": null,
  285. "healthSuggestions": null,
  286. }
  287. };
  288. },
  289. onLoad(options) {
  290. this.type = options.type;
  291. this.userId=options.userId;
  292. this.companyUserId=options.companyUserId;
  293. this.form.userId=options.userId;
  294. this.form.companyUserId=options.companyUserId;
  295. if (this.type == 'edit') {
  296. this.getInfo();
  297. }
  298. this.getMember()
  299. },
  300. methods: {
  301. sexChange(type) {
  302. this.form.sex = type
  303. },
  304. radioClick(id) {
  305. this.form.isMember=id
  306. },
  307. getMember(){
  308. getMember().then(
  309. res => {
  310. if (res.code == 200) {
  311. this.tags= res.data;
  312. } else {
  313. uni.showToast({
  314. title: res.msg,
  315. });
  316. }
  317. },
  318. rej => {}
  319. );
  320. },
  321. getInfo() {
  322. var data = {
  323. userId: this.userId
  324. };
  325. getInfo(data).then(
  326. res => {
  327. if (res.code == 200) {
  328. this.form = res.data;
  329. } else {
  330. uni.showToast({
  331. title: res.msg,
  332. });
  333. }
  334. },
  335. rej => {}
  336. );
  337. },
  338. onChooseAvatar(e){
  339. // 处理用户取消的情况
  340. if (e.detail.errMsg && e.detail.errMsg.includes('cancel')) {
  341. console.log('选择头像已取消')
  342. return
  343. }
  344. let {
  345. avatarUrl
  346. } = e.detail;
  347. uni.uploadFile({
  348. url: uni.getStorageSync('requestPath')+'/app/common/uploadOSS', //仅为示例,非真实的接口地址
  349. filePath: avatarUrl,
  350. name: 'file',
  351. formData: {
  352. 'user': 'test' // 上传附带参数
  353. },
  354. success: (uploadFileRes) => {
  355. this.form.avatar =JSON.parse(uploadFileRes.data).url
  356. }
  357. });
  358. },
  359. submit() {
  360. if (this.form.username == null) {
  361. uni.showToast({
  362. icon: 'none',
  363. title: "姓名不能为空",
  364. });
  365. return;
  366. }
  367. if (this.form.phone == null) {
  368. uni.showToast({
  369. icon: 'none',
  370. title: "手机号不能为空",
  371. });
  372. return;
  373. }
  374. if (this.form.idCard == null) {
  375. uni.showToast({
  376. icon: 'none',
  377. title: "身份证号不能为空",
  378. });
  379. return;
  380. }
  381. if (this.form.sex == null) {
  382. uni.showToast({
  383. icon: 'none',
  384. title: "性别不能为空",
  385. });
  386. return;
  387. }
  388. if (this.form.birthdate == null) {
  389. uni.showToast({
  390. icon: 'none',
  391. title: "出生年月不能为空",
  392. });
  393. return;
  394. }
  395. if (this.form.city == null) {
  396. uni.showToast({
  397. icon: 'none',
  398. title: "市区不能为空",
  399. });
  400. return;
  401. }
  402. if (this.form.problemsToSolve == null) {
  403. uni.showToast({
  404. icon: 'none',
  405. title: "用户问题不能为空",
  406. });
  407. return;
  408. }
  409. if(this.type=="add"){
  410. this.addDoc()
  411. }
  412. else if(this.type=="edit"){
  413. this.editDoc()
  414. }
  415. // uni.navigateTo({
  416. // url: '/pages_health/doc?type=edit&docId='
  417. // })
  418. },
  419. editDoc() {
  420. updateInfo(this.form).then(
  421. res => {
  422. if (res.code == 200) {
  423. uni.showToast({
  424. icon: 'success',
  425. title: "操作成功",
  426. });
  427. setTimeout(function() {
  428. uni.$emit('refreshDoc');
  429. uni.navigateBack({
  430. delta: 1
  431. })
  432. }, 500);
  433. } else {
  434. uni.showToast({
  435. icon: 'none',
  436. title: res.msg,
  437. });
  438. }
  439. },
  440. rej => {}
  441. );
  442. },
  443. addDoc() {
  444. addInfo(this.form).then(
  445. res => {
  446. if (res.code == 200) {
  447. uni.showToast({
  448. icon: 'success',
  449. title: "操作成功",
  450. });
  451. setTimeout(function() {
  452. uni.$emit('refreshDoc');
  453. uni.navigateBack({
  454. delta: 1
  455. })
  456. }, 500);
  457. } else {
  458. uni.showToast({
  459. icon: 'none',
  460. title: res.msg,
  461. });
  462. }
  463. },
  464. rej => {}
  465. );
  466. },
  467. // 出生日期选择
  468. bindDateChange: function(e) {
  469. this.form.birthdate = e.target.value
  470. },
  471. //市区
  472. bindCityChange:function(e) {
  473. const region = e.detail.value; // 格式: [省, 市, 区]
  474. let displayText = '';
  475. // 处理直辖市重复问题
  476. if (this.municipalities.includes(region[0])) {
  477. // 直辖市:省和市名称相同,只显示一次
  478. // 格式变为 "北京市 海淀区" 而非 "北京市 北京市 海淀区"
  479. displayText = `${region[0]}`;
  480. } else {
  481. // 非直辖市:正常显示省市区
  482. displayText = region;
  483. }
  484. this.form.city = displayText;
  485. },
  486. //会员情况
  487. // bindIsMemberChange:function(e) {
  488. // this.form.isMember = e
  489. // },
  490. //会员分类
  491. bindMemberChange:function(e,list) {
  492. var index=e.target.value
  493. this.form.memberLevel = list[e.target.value].dictLabel
  494. },
  495. //加入时间
  496. bindJoinChange:function(e) {
  497. this.form.joinTime = e.target.value
  498. },
  499. //到期时间
  500. bindEndChange:function(e) {
  501. this.form.expiryTime = e.target.value
  502. },
  503. //月份
  504. bindMonthChange:function(e) {
  505. this.form.managementMonth = e.target.value
  506. },
  507. }
  508. }
  509. </script>
  510. <style lang="scss">
  511. page {
  512. height: 100%;
  513. }
  514. .content {
  515. height: 100%;
  516. display: flex;
  517. flex-direction: column;
  518. justify-content: space-between;
  519. .inner {
  520. // height: calc(100% - 120upx);
  521. padding: 20upx;
  522. .form-box {
  523. padding: 0 30upx;
  524. background: #FFFFFF;
  525. border-radius: 16upx;
  526. margin-bottom: 20upx;
  527. .form-title {
  528. font-family: PingFang SC;
  529. font-weight: 600;
  530. font-size: 40rpx;
  531. color: #222426;
  532. text-align: left;
  533. padding: 30rpx 0;
  534. display: block;
  535. }
  536. .form-item {
  537. padding: 30upx 0;
  538. display: flex;
  539. align-items: flex-start;
  540. border-bottom: 1px solid #F1F1F1;
  541. &:last-child {
  542. border-bottom: none;
  543. }
  544. .label {
  545. width: 300upx;
  546. text-align: left;
  547. font-size: 32upx;
  548. line-height: 44upx;
  549. font-family: PingFang SC;
  550. font-weight: 500;
  551. color: #222222;
  552. flex-shrink: 0;
  553. }
  554. input {
  555. text-align: right;
  556. }
  557. .form-input {
  558. font-size: 30upx;
  559. font-family: PingFang SC;
  560. font-weight: 500;
  561. color: #999999;
  562. text-align: right;
  563. }
  564. .form-item-tag{
  565. margin-right: 16rpx;
  566. .tag{
  567. border-radius: 8rpx 8rpx 8rpx 8rpx;
  568. border: 2rpx solid #ECECEC;
  569. display: flex;
  570. align-items: center;
  571. padding: 24rpx;
  572. font-family: PingFang SC;
  573. font-weight: 400;
  574. font-size: 24rpx;
  575. &.active{
  576. background: #F0FAFF;
  577. border: 2rpx solid #008FD3;
  578. color: #008FD3;
  579. }
  580. }
  581. }
  582. .right{
  583. display: flex;
  584. align-items: center;
  585. position: relative;
  586. image{
  587. border-radius: 50%;
  588. }
  589. .wx-head{
  590. position: absolute;
  591. width: 140upx;
  592. height: 80upx;
  593. opacity: 0;
  594. }
  595. }
  596. .sex-box{
  597. flex:1;
  598. display: flex;
  599. align-items: center;
  600. justify-content: flex-end;
  601. .sex-item{
  602. width: 146rpx;
  603. height: 64rpx;
  604. display: flex;
  605. align-items: center;
  606. justify-content: center;
  607. background: #F5F7FA;
  608. border-radius: 32rpx 32rpx 32rpx 32rpx;
  609. margin-left: 16rpx;
  610. .u-icon__icon{
  611. margin: 0;
  612. }
  613. text{
  614. // font-family: PingFang SC, PingFang SC;
  615. font-weight: 400;
  616. font-size: 28rpx;
  617. color: #898E91;
  618. margin-left: 12rpx;
  619. }
  620. &.active{
  621. background: #EBF8FF;
  622. text{
  623. color:#008FD3
  624. }
  625. }
  626. &.active2{
  627. background: #FCF0E7;
  628. text{
  629. color:#FF5030
  630. }
  631. }
  632. }
  633. }
  634. .form-textarea{
  635. font-size: 30upx;
  636. // color: #999999;
  637. height: 100upx;
  638. padding: 4upx 0;
  639. }
  640. .textarea-input{
  641. color: #999999;
  642. }
  643. .birth-picker {
  644. flex: 1;
  645. display: flex;
  646. align-items: center;
  647. .right-box{
  648. width: 100%;
  649. display: flex;
  650. align-items: center;
  651. .input-box{
  652. // width: 470upx;
  653. }
  654. .arrow{
  655. width: 13upx;
  656. height: 23upx;
  657. margin-left: 20upx;
  658. }
  659. }
  660. }
  661. }
  662. }
  663. }
  664. .btn-box {
  665. height: 120upx;
  666. padding: 0 30upx;
  667. display: flex;
  668. align-items: center;
  669. justify-content: center;
  670. // position: fixed;
  671. // width: 90%;
  672. // bottom: 0;
  673. // left: 50%;
  674. // transform: translate(-50%,-50%);
  675. // background: #FFFFFF;
  676. .sub-btn {
  677. width: 100%;
  678. height: 88upx;
  679. line-height: 88upx;
  680. text-align: center;
  681. font-size: 32upx;
  682. font-family: PingFang SC;
  683. font-weight: bold;
  684. color: #FFFFFF;
  685. background: #008FD3 ;
  686. border-radius: 44upx;
  687. margin-bottom: 40upx;
  688. }
  689. }
  690. }
  691. </style>