addUser.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  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':'#EBF8FF'" 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/healthUser.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. // 定义直辖市列表,用于判断特殊处理
  248. municipalities: ['北京市', '上海市', '天津市', '重庆市'],
  249. array:[
  250. {id:1,name:'是'},
  251. {id:0,name:'否'},
  252. ],
  253. tags: [],
  254. isAdd:null,
  255. form: {
  256. "username": null,
  257. avatar:null,
  258. "sex":0,
  259. "birthdate": null,
  260. "age": 0,
  261. "phone": null,
  262. "idCard": null,
  263. "previousEmployer": null,
  264. "disposableIncome": null,
  265. "actualConsumption": null,
  266. "city": null,
  267. "residentialCommunity": null,
  268. "houseNumber": null,
  269. "area": null,
  270. "floor": null,
  271. "partnerName": null,
  272. "partnerAge": null,
  273. "partnerEmployer": null,
  274. "grandchildrenSchool": null,
  275. "isMember": 1,
  276. "memberLevel": null,
  277. "joinTime": null,
  278. "expiryTime": null,
  279. "managementMonth":null,
  280. "position":null,
  281. "hobbies": null,
  282. "specialties": null,
  283. "faith": null,
  284. "concerns": null,
  285. "problemsToSolve": null,
  286. "healthSuggestions": null,
  287. }
  288. };
  289. },
  290. onLoad(options) {
  291. this.type = options.type;
  292. this.userId=options.userId;
  293. this.companyUserId=options.companyUserId;
  294. this.form.userId=options.userId;
  295. this.form.companyUserId=options.companyUserId;
  296. if (this.type == 'edit') {
  297. this.getInfo();
  298. }
  299. this.getMember()
  300. },
  301. methods: {
  302. sexChange(type) {
  303. this.form.sex = type
  304. },
  305. radioClick(id) {
  306. this.form.isMember=id
  307. },
  308. getMember(){
  309. getMember().then(
  310. res => {
  311. if (res.code == 200) {
  312. this.tags= res.data;
  313. } else {
  314. uni.showToast({
  315. title: res.msg,
  316. });
  317. }
  318. },
  319. rej => {}
  320. );
  321. },
  322. getInfo() {
  323. var data = {
  324. userId: this.userId
  325. };
  326. getInfo(data).then(
  327. res => {
  328. if (res.code == 200) {
  329. this.form = res.data;
  330. } else {
  331. uni.showToast({
  332. title: res.msg,
  333. });
  334. }
  335. },
  336. rej => {}
  337. );
  338. },
  339. onChooseAvatar(e){
  340. // 处理用户取消的情况
  341. if (e.detail.errMsg && e.detail.errMsg.includes('cancel')) {
  342. console.log('选择头像已取消')
  343. return
  344. }
  345. let {
  346. avatarUrl
  347. } = e.detail;
  348. uni.uploadFile({
  349. url: uni.getStorageSync('requestPath')+'/app/common/uploadOSS', //仅为示例,非真实的接口地址
  350. filePath: avatarUrl,
  351. name: 'file',
  352. formData: {
  353. 'user': 'test' // 上传附带参数
  354. },
  355. success: (uploadFileRes) => {
  356. this.form.avatar =JSON.parse(uploadFileRes.data).url
  357. }
  358. });
  359. },
  360. submit() {
  361. if (this.form.username == null) {
  362. uni.showToast({
  363. icon: 'none',
  364. title: "姓名不能为空",
  365. });
  366. return;
  367. }
  368. if (this.form.phone == null) {
  369. uni.showToast({
  370. icon: 'none',
  371. title: "手机号不能为空",
  372. });
  373. return;
  374. }
  375. if (this.form.idCard == null) {
  376. uni.showToast({
  377. icon: 'none',
  378. title: "身份证号不能为空",
  379. });
  380. return;
  381. }
  382. if (this.form.sex == null) {
  383. uni.showToast({
  384. icon: 'none',
  385. title: "性别不能为空",
  386. });
  387. return;
  388. }
  389. if (this.form.birthdate == null) {
  390. uni.showToast({
  391. icon: 'none',
  392. title: "出生年月不能为空",
  393. });
  394. return;
  395. }
  396. if (this.form.city == null) {
  397. uni.showToast({
  398. icon: 'none',
  399. title: "市区不能为空",
  400. });
  401. return;
  402. }
  403. if (this.form.problemsToSolve == null) {
  404. uni.showToast({
  405. icon: 'none',
  406. title: "用户问题不能为空",
  407. });
  408. return;
  409. }
  410. if(this.type=="add"){
  411. this.addDoc()
  412. }
  413. else if(this.type=="edit"){
  414. this.editDoc()
  415. }
  416. // uni.navigateTo({
  417. // url: '/pages_health/doc?type=edit&docId='
  418. // })
  419. },
  420. editDoc() {
  421. updateInfo(this.form).then(
  422. res => {
  423. if (res.code == 200) {
  424. uni.showToast({
  425. icon: 'success',
  426. title: "操作成功",
  427. });
  428. setTimeout(function() {
  429. uni.$emit('refreshDoc');
  430. uni.navigateBack({
  431. delta: 1
  432. })
  433. }, 500);
  434. } else {
  435. uni.showToast({
  436. icon: 'none',
  437. title: res.msg,
  438. });
  439. }
  440. },
  441. rej => {}
  442. );
  443. },
  444. addDoc() {
  445. addInfo(this.form).then(
  446. res => {
  447. if (res.code == 200) {
  448. uni.showToast({
  449. icon: 'success',
  450. title: "操作成功",
  451. });
  452. setTimeout(function() {
  453. uni.$emit('refreshDoc');
  454. uni.navigateBack({
  455. delta: 1
  456. })
  457. }, 500);
  458. } else {
  459. uni.showToast({
  460. icon: 'none',
  461. title: res.msg,
  462. });
  463. }
  464. },
  465. rej => {}
  466. );
  467. },
  468. // 出生日期选择
  469. bindDateChange: function(e) {
  470. this.form.birthdate = e.target.value
  471. },
  472. //市区
  473. bindCityChange:function(e) {
  474. const region = e.detail.value; // 格式: [省, 市, 区]
  475. let displayText = '';
  476. // 处理直辖市重复问题
  477. if (this.municipalities.includes(region[0])) {
  478. // 直辖市:省和市名称相同,只显示一次
  479. // 格式变为 "北京市 海淀区" 而非 "北京市 北京市 海淀区"
  480. displayText = `${region[0]}`;
  481. } else {
  482. // 非直辖市:正常显示省市区
  483. displayText = region;
  484. }
  485. this.form.city = displayText;
  486. },
  487. //会员情况
  488. // bindIsMemberChange:function(e) {
  489. // this.form.isMember = e
  490. // },
  491. //会员分类
  492. bindMemberChange:function(e,list) {
  493. var index=e.target.value
  494. this.form.memberLevel = list[e.target.value].dictLabel
  495. },
  496. //加入时间
  497. bindJoinChange:function(e) {
  498. this.form.joinTime = e.target.value
  499. },
  500. //到期时间
  501. bindEndChange:function(e) {
  502. this.form.expiryTime = e.target.value
  503. },
  504. //月份
  505. bindMonthChange:function(e) {
  506. this.form.managementMonth = e.target.value
  507. },
  508. }
  509. }
  510. </script>
  511. <style lang="scss">
  512. page {
  513. height: 100%;
  514. }
  515. .content {
  516. height: 100%;
  517. display: flex;
  518. flex-direction: column;
  519. justify-content: space-between;
  520. .inner {
  521. // height: calc(100% - 120upx);
  522. padding: 20upx;
  523. .form-box {
  524. padding: 0 30upx;
  525. background: #FFFFFF;
  526. border-radius: 16upx;
  527. margin-bottom: 20upx;
  528. .form-title {
  529. font-family: PingFang SC;
  530. font-weight: 600;
  531. font-size: 40rpx;
  532. color: #222426;
  533. text-align: left;
  534. padding: 30rpx 0;
  535. display: block;
  536. }
  537. .form-item {
  538. padding: 30upx 0;
  539. display: flex;
  540. align-items: flex-start;
  541. border-bottom: 1px solid #F1F1F1;
  542. &:last-child {
  543. border-bottom: none;
  544. }
  545. .label {
  546. width: 300upx;
  547. text-align: left;
  548. font-size: 32upx;
  549. line-height: 44upx;
  550. font-family: PingFang SC;
  551. font-weight: 500;
  552. color: #222222;
  553. flex-shrink: 0;
  554. }
  555. input {
  556. text-align: right;
  557. }
  558. .form-input {
  559. font-size: 30upx;
  560. font-family: PingFang SC;
  561. font-weight: 500;
  562. color: #999999;
  563. text-align: right;
  564. }
  565. .form-item-tag{
  566. margin-right: 16rpx;
  567. .tag{
  568. border-radius: 8rpx 8rpx 8rpx 8rpx;
  569. border: 2rpx solid #ECECEC;
  570. display: flex;
  571. align-items: center;
  572. padding: 24rpx;
  573. font-family: PingFang SC;
  574. font-weight: 400;
  575. font-size: 24rpx;
  576. &.active{
  577. background: #F0FAFF;
  578. border: 2rpx solid #008FD3;
  579. color: #008FD3;
  580. }
  581. }
  582. }
  583. .right{
  584. display: flex;
  585. align-items: center;
  586. position: relative;
  587. image{
  588. border-radius: 50%;
  589. }
  590. .wx-head{
  591. position: absolute;
  592. width: 140upx;
  593. height: 80upx;
  594. opacity: 0;
  595. }
  596. }
  597. .sex-box{
  598. flex:1;
  599. display: flex;
  600. align-items: center;
  601. justify-content: flex-end;
  602. .sex-item{
  603. width: 146rpx;
  604. height: 64rpx;
  605. display: flex;
  606. align-items: center;
  607. justify-content: center;
  608. background: #F5F7FA;
  609. border-radius: 32rpx 32rpx 32rpx 32rpx;
  610. margin-left: 16rpx;
  611. .u-icon__icon{
  612. margin: 0;
  613. }
  614. text{
  615. // font-family: PingFang SC, PingFang SC;
  616. font-weight: 400;
  617. font-size: 28rpx;
  618. color: #898E91;
  619. margin-left: 12rpx;
  620. }
  621. &.active{
  622. background: #EBF8FF;
  623. text{
  624. color:#008FD3
  625. }
  626. }
  627. &.active2{
  628. background: #FCF0E7;
  629. text{
  630. color:#FF5030
  631. }
  632. }
  633. }
  634. }
  635. .form-textarea{
  636. font-size: 30upx;
  637. // color: #999999;
  638. height: 100upx;
  639. padding: 4upx 0;
  640. }
  641. .textarea-input{
  642. color: #999999;
  643. }
  644. .birth-picker {
  645. flex: 1;
  646. display: flex;
  647. align-items: center;
  648. .right-box{
  649. width: 100%;
  650. display: flex;
  651. align-items: center;
  652. .input-box{
  653. // width: 470upx;
  654. }
  655. .arrow{
  656. width: 13upx;
  657. height: 23upx;
  658. margin-left: 20upx;
  659. }
  660. }
  661. }
  662. }
  663. }
  664. }
  665. .btn-box {
  666. height: 120upx;
  667. padding: 0 30upx;
  668. display: flex;
  669. align-items: center;
  670. justify-content: center;
  671. // position: fixed;
  672. // width: 90%;
  673. // bottom: 0;
  674. // left: 50%;
  675. // transform: translate(-50%,-50%);
  676. // background: #FFFFFF;
  677. .sub-btn {
  678. width: 100%;
  679. height: 88upx;
  680. line-height: 88upx;
  681. text-align: center;
  682. font-size: 32upx;
  683. font-family: PingFang SC;
  684. font-weight: bold;
  685. color: #FFFFFF;
  686. background: #008FD3 ;
  687. border-radius: 44upx;
  688. margin-bottom: 40upx;
  689. }
  690. }
  691. }
  692. </style>