config.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <template>
  2. <view class="mine">
  3. <scroll-view scroll-y class="body">
  4. <view class="bottom">
  5. <view class="bottom_name">个人信息</view>
  6. <view class="bottom_list">
  7. <view class="bottom_list_item">
  8. <view class="name"><text class="required newicon newicon-bitian"></text>工号</view>
  9. <view class="value no-mar">{{dataForm.account}}</view>
  10. </view>
  11. <view class="bottom_list_item">
  12. <view class="name"><text class="required newicon newicon-bitian"></text>姓名</view>
  13. <view class="value no-mar">{{dataForm.name}}</view>
  14. </view>
  15. <view class="bottom_list_item">
  16. <view class="name"><text class="required newicon newicon-bitian"></text>院区名称</view>
  17. <uni-data-picker class="value" placeholder="请选择院区名称"
  18. v-model="dataForm.branch" :localdata="branchData" @change="branchChange"
  19. :clear-icon="false" :class="{formRed: isSubmit && !dataForm.branch}">
  20. </uni-data-picker>
  21. <text class="newicon newicon-youjiantou icon"></text>
  22. </view>
  23. <view class="bottom_list_item" v-if="deptRepair.valueconfig==1" @click="selectDepartment">
  24. <!-- <view class="name"><text class="required newicon newicon-bitian"></text>科室名称</view>
  25. <uni-data-picker class="value" placeholder="请选择报修科室"
  26. v-model="dataForm.dept" :localdata="deptData"
  27. :clear-icon="false" :class="{formRed: isSubmit && !dataForm.dept}">
  28. </uni-data-picker> -->
  29. <text class="newicon newicon-youjiantou icon"></text>
  30. <!-- <view class="form_item"> -->
  31. <view class="title select"><text class="required newicon newicon-bitian"></text>报修科室:</view>
  32. <view class="value category">
  33. <text class="categoryName ellipsis-multiline">{{dataForm.departmentName}}</text>
  34. <!-- <text class="newicon newicon-weibiaoti2010104"></text> -->
  35. </view>
  36. <!-- </view> -->
  37. </view>
  38. <view class="bottom_list_item" v-if="deptRepair.valueconfig==1" @click="deptSelect">
  39. <view class="name">常用科室</view>
  40. <view class="value">{{commonDeptName}}</view>
  41. <text class="newicon newicon-youjiantou icon"></text>
  42. </view>
  43. <view class="bottom_list_item">
  44. <view class="name"><text class="required newicon newicon-bitian"></text>联系电话</view>
  45. <view class="value no-mar" @click="makePhoneCall(dataForm.phone)">{{dataForm.phone}}</view>
  46. </view>
  47. </view>
  48. </view>
  49. </scroll-view>
  50. <view class="foot_common_btns">
  51. <button @click="addInfo" type="default" class="primaryButton btn">保存</button>
  52. </view>
  53. </view>
  54. </template>
  55. <script setup>
  56. import { ref, reactive } from 'vue'
  57. import { onLoad, onShow, onHide, onTabItemTap } from '@dcloudio/uni-app'
  58. import { api_userSave, api_user, api_department, api_getDictionary ,api_branch, api_systemConfiguration} from "@/http/api.js"
  59. import { defaultColor } from '@/static/js/theme.js'
  60. import { useSetTitle } from '@/share/useSetTitle.js'
  61. import { useMakePhoneCall } from '@/share/useMakePhoneCall.js'
  62. import { useLoginUserStore } from '@/stores/loginUser'
  63. import { useIncidentNumStore } from '@/stores/incidentNum'
  64. import { repositoryListSearchStore } from '@/stores/repositorySearch'
  65. import { useSetTabbar } from '@/share/useSetTabbar.js'
  66. useSetTitle();
  67. const loginUserStore = useLoginUserStore();
  68. const incidentNumStore = useIncidentNumStore();
  69. const { makePhoneCall } = useMakePhoneCall();
  70. const repositorySearchStore = repositoryListSearchStore();
  71. const { setTabbar } = useSetTabbar();
  72. // 主题颜色
  73. const primaryColor = ref(defaultColor)
  74. const deptRepair = ref(null)
  75. const deptData = ref([])
  76. const branchData = ref([])
  77. const commonDeptName = ref(null)
  78. const commonDeptData = ref(null)
  79. const dataForm = reactive({
  80. name:loginUserStore.loginUser.user.name,
  81. account:loginUserStore.loginUser.user.account,
  82. phone:loginUserStore.loginUser.user.phone,
  83. dept: '',
  84. departmentName:'',
  85. branch:'',
  86. commonDeptName:'',
  87. commonDeptData:'',
  88. dataType:false
  89. })
  90. const operationType = ref(null)
  91. const userTypes = ref(null)
  92. const userData = reactive(loginUserStore.loginUser.user)
  93. const commonDeptDTO = ref([])
  94. // 是否提交
  95. const isSubmit = ref(false)
  96. // 数据
  97. const dataInfo = reactive({
  98. num: 0,
  99. })
  100. // 保存
  101. function addInfo(){
  102. if(!dataForm.branch){
  103. uni.showToast({
  104. icon: 'none',
  105. title: '院区不能为空'
  106. });
  107. return
  108. }
  109. if(!dataForm.dept){
  110. uni.showToast({
  111. icon: 'none',
  112. title: '报修科室不能为空'
  113. });
  114. return
  115. }
  116. uni.showLoading({
  117. title: "加载中",
  118. mask: true,
  119. });
  120. isSubmit.value = true
  121. userData.currentHospital.id = dataForm.branch
  122. userData.commonDeptName = commonDeptName.value
  123. userData.dept={
  124. id:dataForm.dept
  125. }
  126. let arr = []
  127. for(let i of commonDeptDTO.value){
  128. arr.push({
  129. dept:i
  130. })
  131. }
  132. let postData = {
  133. ...loginUserStore.loginUser.user,
  134. // ...userData,
  135. hospital:{
  136. id:dataForm.branch
  137. },
  138. dept:{
  139. id:dataForm.dept
  140. },
  141. commonDept:commonDeptData.value,
  142. commonDeptDTO:arr,
  143. upType: "changeDept"
  144. }
  145. api_userSave({
  146. user: postData,
  147. }).then(res => {
  148. uni.hideLoading();
  149. if(res.status == 200){
  150. loginUserStore.setLoginUser(postData);
  151. uni.showToast({
  152. icon: 'none',
  153. title: '保存成功'
  154. });
  155. }else{
  156. uni.showToast({
  157. icon: 'none',
  158. title: res.msg || '请求数据失败!'
  159. });
  160. }
  161. })
  162. }
  163. // 选择院区
  164. function branchChange(){
  165. dataForm.dept = null
  166. dataForm.departmentName = null
  167. dataForm.commonDeptName = null
  168. dataForm.commonDeptData = null
  169. commonDeptName.value = null
  170. commonDeptData.value = null
  171. // getRepairTypes()
  172. }
  173. // 跳转到科室
  174. function selectDepartment(){
  175. if(commonDeptName.value){
  176. dataForm.dataType = true
  177. }else{
  178. dataForm.dataType = false
  179. }
  180. uni.setStorageSync('configData',JSON.stringify(dataForm))
  181. uni.navigateTo({
  182. url: `/pages/searchDept/searchDept?type=config&branchId=${dataForm.branch}`
  183. })
  184. }
  185. // 获取科室列表
  186. function getRepairTypes(){
  187. uni.showLoading({
  188. title: "加载中",
  189. mask: true,
  190. });
  191. let postData = {
  192. department: {
  193. hospital: dataForm.branch?dataForm.branch:loginUserStore.loginUser.user.currentHospital.id,
  194. },
  195. idx:0,
  196. sum:9999
  197. }
  198. api_department(postData).then(res => {
  199. uni.hideLoading();
  200. res = res.list || [];
  201. deptData.value = res.map(v => ({
  202. text: v.dept,
  203. value: v.id,
  204. }));
  205. })
  206. }
  207. // 获取院区列表
  208. function getBranch(){
  209. let arr = loginUserStore.loginUser.hospital.filter(i=>i.parent==undefined)
  210. branchData.value = arr.map(v => ({
  211. text: v.hosName,
  212. value: v.id,
  213. }));
  214. }
  215. // 选择常用科室
  216. function deptSelect(){
  217. uni.setStorageSync('configData',JSON.stringify(dataForm))
  218. let data = commonDeptData.value
  219. // ? commonDeptData.value : loginUserStore.loginUser.user.commonDept
  220. if(!data){
  221. data = 'none'
  222. }
  223. let deptId = dataForm.branch?dataForm.branch:loginUserStore.loginUser.user.currentHospital.id
  224. uni.navigateTo({
  225. url: `/pages/repair/deptSelect?data=${JSON.stringify(data)}&commonDeptName=${commonDeptName.value}&deptId=${deptId}&type=home`
  226. })
  227. }
  228. // 初始化
  229. function onLoadFn(){
  230. if(uni.getStorageSync('sysData')){
  231. let data = JSON.parse(uni.getStorageSync('sysData'))
  232. deptRepair.value = data.find(i=>i.keyconfig=='deptRepair')
  233. }
  234. getBranch()
  235. }
  236. function getUserInfo(){
  237. let user = loginUserStore.loginUser.user
  238. let userId = user.currentHospital.id
  239. // if(user.currentHospital.parent){
  240. // userId = user.currentHospital.parent.id
  241. // }else{
  242. // userId = user.currentHospital.id
  243. // }
  244. let postData = {
  245. idx: 0,
  246. sum: 999,
  247. user: {
  248. hospital:{
  249. id:userId
  250. },
  251. name: user.name,
  252. userTypeIds: userTypes.value?String(userTypes.value.map(v => v.id)):undefined
  253. }
  254. }
  255. api_user(postData).then(res => {
  256. if(res.status == 200){
  257. let item = res.list.find(i=>i.id==user.id)
  258. let data = uni.getStorageSync('configData')
  259. if(operationType.value=='selectDept'){
  260. if(data){
  261. data = JSON.parse(data)
  262. dataForm.name = data.name
  263. dataForm.account = data.account
  264. dataForm.phone = data.phone
  265. dataForm.dept = data.dept
  266. dataForm.departmentName = data.departmentName
  267. dataForm.branch = Number(data.branch)
  268. dataForm.commonDeptName = data.commonDeptName
  269. dataForm.commonDeptData = data.commonDeptData
  270. if(data.dataType){
  271. commonDeptData.value = data.commonDeptData
  272. commonDeptName.value = data.commonDeptName
  273. }
  274. }
  275. }else if(item){
  276. if(item.hospital.parent){
  277. dataForm.branch = item.hospital.parent.id
  278. }else{
  279. dataForm.branch = item.hospital.id
  280. }
  281. if(item.dept){
  282. dataForm.dept = item.dept.id
  283. dataForm.departmentName = item.dept.dept
  284. }
  285. // getRepairTypes()
  286. let id = []
  287. let name = []
  288. if(item.commonDeptDTO){
  289. for(let i of item.commonDeptDTO){
  290. id.push(i.id)
  291. name.push(i.dept)
  292. }
  293. commonDeptData.value = id.join(',')
  294. commonDeptName.value = name.join('/')
  295. dataForm.commonDeptName = commonDeptName.value
  296. dataForm.commonDeptData = commonDeptData.value
  297. }
  298. }else{
  299. // let data = uni.getStorageSync('configData')
  300. // if(data){
  301. // data = JSON.parse(data)
  302. // dataForm.dept = data.dept
  303. // dataForm.branch = data.branch
  304. // }else{
  305. if(user.currentHospital.parent){
  306. dataForm.branch = user.currentHospital.parent.id
  307. }else{
  308. dataForm.branch = user.currentHospital.id
  309. }
  310. if(user.dept){
  311. dataForm.dept = user.dept.id
  312. dataForm.departmentName = user.dept.dept
  313. }
  314. // }
  315. if(user.commonDeptDTO){
  316. let name = []
  317. for(let i of user.commonDeptDTO){
  318. name.push(i.dept)
  319. }
  320. commonDeptData.value = user.commonDept
  321. commonDeptName.value = name.join('/')
  322. dataForm.commonDeptName = commonDeptName.value
  323. dataForm.commonDeptData = commonDeptData.value
  324. }
  325. // getRepairTypes()
  326. }
  327. }else{
  328. uni.showToast({
  329. icon: 'none',
  330. title: res.msg || '请求数据失败!'
  331. });
  332. }
  333. })
  334. }
  335. onHide(opt=>{
  336. dataInfo.num = 0
  337. dataForm.branch = null
  338. })
  339. onShow((option) => {
  340. if(uni.getStorageSync('groupData')){
  341. userTypes.value = JSON.parse(uni.getStorageSync('groupData'))
  342. }
  343. onLoadFn()
  344. if(dataInfo.num==0){
  345. getUserInfo()
  346. }
  347. for(let i = 0; i<7; i++){
  348. setTabbar(i)
  349. }
  350. })
  351. onLoad((option) => {
  352. if(uni.getStorageSync('groupData')){
  353. userTypes.value = JSON.parse(uni.getStorageSync('groupData'))
  354. }
  355. onLoadFn();
  356. dataInfo.num = 1
  357. if(option && option.configType){
  358. operationType.value = option.configType
  359. }
  360. if(option.data){
  361. let data = JSON.parse(option.data)
  362. commonDeptData.value = data.data.join(',')
  363. commonDeptName.value = data.name.join('/')
  364. commonDeptDTO.value = data.name
  365. dataForm.commonDeptData = data.data.join(',')
  366. dataForm.commonDeptName = data.name.join('/')
  367. let data2 = uni.getStorageSync('configData')
  368. if(data2){
  369. data2 = JSON.parse(data2)
  370. dataForm.dept = data2.dept
  371. dataForm.departmentName = data2.departmentName
  372. dataForm.branch = data2.branch
  373. }
  374. // getRepairTypes()
  375. }else{
  376. getUserInfo()
  377. }
  378. for(let i = 0; i<7; i++){
  379. setTabbar(i)
  380. }
  381. })
  382. onTabItemTap(e => {
  383. // onLoadFn();
  384. })
  385. </script>
  386. <style scoped>
  387. >>> .uni-data-tree-input{
  388. width: 100% !important;
  389. }
  390. >>> .input-value-border{
  391. border: none !important;
  392. }
  393. >>> .input-value{
  394. padding:0 !important;
  395. flex-direction: row-reverse !important;
  396. }
  397. >>> .selected-list{
  398. flex-direction: row-reverse !important;
  399. }
  400. >>> .arrow-area{
  401. display: none !important;
  402. }
  403. >>>.uni-data-tree-dialog{
  404. z-index: 9999;
  405. }
  406. </style>
  407. <style lang="scss" scoped>
  408. page{
  409. height: calc(100vh - var(--window-bottom));
  410. background-color: #EBEBEB;
  411. }
  412. .mine{
  413. height: 100%;
  414. display: flex;
  415. flex-direction: column;
  416. justify-content: space-between;
  417. .phone-filled{
  418. margin-right: 5rpx;
  419. }
  420. .newicon-xinjian2,
  421. .newicon-zhishiku{
  422. margin-right: 10rpx;
  423. }
  424. .body{
  425. width: 714rpx;
  426. height: 100%;
  427. margin: 16rpx auto var(--window-bottom) auto;
  428. box-sizing: border-box;
  429. border-radius: 8rpx;
  430. .top{
  431. padding: 30rpx;
  432. background-color: #fff;
  433. .top_name{
  434. font-size: 28rpx;
  435. font-weight: bold;
  436. }
  437. .top_count{
  438. margin-top: 45rpx;
  439. display: flex;
  440. align-items: center;
  441. justify-content: space-between;
  442. .top_count_item{
  443. text-align: center;
  444. .name{
  445. color: #949494;
  446. font-size: 22rpx;
  447. }
  448. .value{
  449. font-size: 50rpx;
  450. font-weight: bold;
  451. margin-top: 15rpx;
  452. }
  453. }
  454. }
  455. }
  456. .bottom{
  457. background-color: #fff;
  458. margin-top: 15rpx;
  459. .bottom_name{
  460. font-size: 26rpx;
  461. color: $uni-primary;
  462. padding: 21rpx 24rpx;
  463. }
  464. .bottom_list{
  465. .bottom_list_item{
  466. border-top: 1rpx solid #DEDEDE;
  467. padding: 30rpx 30rpx 30rpx 30rpx;
  468. display: flex;
  469. justify-content: space-between;
  470. align-items: center;
  471. font-size: 24rpx;
  472. position: relative;
  473. .value{
  474. max-width: 380rpx;
  475. color: #333;
  476. display: flex;
  477. align-items: center;
  478. text-align: justify;
  479. margin-right: 30rpx;
  480. }
  481. .no-mar{
  482. margin-right:0 !important;
  483. }
  484. .icon{
  485. position: absolute;
  486. right: 20rpx;
  487. }
  488. }
  489. }
  490. }
  491. }
  492. }
  493. </style>