config.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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">{{loginUserStore.loginUser.user.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">{{loginUserStore.loginUser.user.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"
  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">
  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>
  31. <view class="bottom_list_item" v-if="deptRepair.valueconfig==1" @click="deptSelect">
  32. <view class="name">常用科室</view>
  33. <view class="value">{{commonDeptName}}</view>
  34. <text class="newicon newicon-youjiantou icon"></text>
  35. </view>
  36. <view class="bottom_list_item">
  37. <view class="name"><text class="required newicon newicon-bitian"></text>联系电话</view>
  38. <view class="value no-mar" @click="makePhoneCall(loginUserStore.loginUser.user.phone)">{{loginUserStore.loginUser.user.phone}}</view>
  39. </view>
  40. </view>
  41. </view>
  42. </scroll-view>
  43. <view class="foot_common_btns">
  44. <button @click="addInfo" type="default" class="primaryButton btn">保存</button>
  45. </view>
  46. </view>
  47. </template>
  48. <script setup>
  49. import { ref, reactive } from 'vue'
  50. import { onLoad, onTabItemTap } from '@dcloudio/uni-app'
  51. import { api_userSave, api_department, api_branch, api_systemConfiguration} from "@/http/api.js"
  52. import { defaultColor } from '@/static/js/theme.js'
  53. import { useSetTitle } from '@/share/useSetTitle.js'
  54. import { useMakePhoneCall } from '@/share/useMakePhoneCall.js'
  55. import { useLoginUserStore } from '@/stores/loginUser'
  56. import { useIncidentNumStore } from '@/stores/incidentNum'
  57. import { repositoryListSearchStore } from '@/stores/repositorySearch'
  58. import { useSetTabbar } from '@/share/useSetTabbar.js'
  59. useSetTitle();
  60. const loginUserStore = useLoginUserStore();
  61. const incidentNumStore = useIncidentNumStore();
  62. const { makePhoneCall } = useMakePhoneCall();
  63. const repositorySearchStore = repositoryListSearchStore();
  64. const { setTabbar } = useSetTabbar();
  65. // 主题颜色
  66. const primaryColor = ref(defaultColor)
  67. const deptRepair = ref(null)
  68. const deptData = ref([])
  69. const branchData = ref([])
  70. const commonDeptName = ref(null)
  71. const commonDeptData = ref(null)
  72. const dataForm = reactive({
  73. dept: '',
  74. branch:''
  75. })
  76. const userData = reactive(loginUserStore.loginUser.user)
  77. const commonDeptDTO = ref([])
  78. // 是否提交
  79. const isSubmit = ref(false)
  80. // 数据
  81. const dataInfo = reactive({
  82. todo: 0,
  83. doing: 0,
  84. owns: 0,
  85. resolve: 0,
  86. })
  87. // 保存
  88. function addInfo(){
  89. uni.showLoading({
  90. title: "加载中",
  91. mask: true,
  92. });
  93. isSubmit.value = true
  94. userData.currentHospital.id = dataForm.branch
  95. userData.commonDeptName = commonDeptName.value
  96. userData.dept={
  97. id:dataForm.dept
  98. }
  99. let arr = []
  100. for(let i of commonDeptDTO.value){
  101. arr.push({
  102. dept:i
  103. })
  104. }
  105. let postData = {
  106. ...loginUserStore.loginUser.user,
  107. commonDept:commonDeptData.value,
  108. commonDeptDTO:arr
  109. }
  110. api_userSave({
  111. user: postData,
  112. }).then(res => {
  113. uni.hideLoading();
  114. if(res.status == 200){
  115. loginUserStore.setLoginUser(postData);
  116. uni.showToast({
  117. icon: 'none',
  118. title: '保存成功'
  119. });
  120. }else{
  121. uni.showToast({
  122. icon: 'none',
  123. title: res.msg || '请求数据失败!'
  124. });
  125. }
  126. })
  127. }
  128. // 获取科室列表
  129. function getRepairTypes(){
  130. uni.showLoading({
  131. title: "加载中",
  132. mask: true,
  133. });
  134. let postData = {
  135. department: {
  136. hospital: loginUserStore.loginUser.user.currentHospital.id,
  137. },
  138. idx:0,
  139. sum:9999
  140. }
  141. api_department(postData).then(res => {
  142. uni.hideLoading();
  143. getBranch()
  144. res = res.list || [];
  145. deptData.value = res.map(v => ({
  146. text: v.dept,
  147. value: v.id,
  148. }));
  149. })
  150. }
  151. // 获取院区列表
  152. function getBranch(){
  153. let postData = {
  154. // hosId:loginUserStore.loginUser.user.currentHospital.id,
  155. idx:0,
  156. sum:9999
  157. }
  158. // if(loginUserStore.loginUser.user.duty){
  159. // postData.branch = loginUserStore.loginUser.user.currentHospital.id;
  160. // }else if(loginUserStore.loginUser.user.branch){
  161. // postData.branch = loginUserStore.loginUser.user.branch.id;
  162. // }
  163. api_branch(postData).then(res => {
  164. uni.hideLoading();
  165. res = res.list || [];
  166. branchData.value = res.map(v => ({
  167. text: v.hosName,
  168. value: v.id,
  169. }));
  170. })
  171. }
  172. // 选择常用科室
  173. function deptSelect(){
  174. uni.setStorageSync('configData',JSON.stringify(dataForm))
  175. let data = commonDeptData.value ?
  176. commonDeptData.value : loginUserStore.loginUser.user.commonDept
  177. if(!data){
  178. data = 'none'
  179. }
  180. uni.navigateTo({
  181. url: '/pages/repair/deptSelect?data='+JSON.stringify(data)
  182. })
  183. }
  184. // 初始化
  185. function onLoadFn(){
  186. let data = JSON.parse(uni.getStorageSync('sysData'))
  187. deptRepair.value = data.find(i=>i.keyconfig=='deptRepair')
  188. getRepairTypes()
  189. }
  190. onLoad((option) => {
  191. if(option.data){
  192. let data = JSON.parse(option.data)
  193. commonDeptData.value = data.data.join(',')
  194. commonDeptName.value = data.name.join('/')
  195. commonDeptDTO.value = data.name
  196. }else{
  197. let user = loginUserStore.loginUser.user
  198. if(user){
  199. dataForm.branch = user.currentHospital.id
  200. dataForm.dept = user.dept.id
  201. if(user.commonDeptDTO){
  202. let dept = user.commonDeptDTO.map(i=>{
  203. return i.dept
  204. })
  205. commonDeptName.value = dept.join('/')
  206. }else{
  207. commonDeptName.value = user.commonDeptName
  208. }
  209. }
  210. }
  211. let data = uni.getStorageSync('configData')
  212. if(data){
  213. data = JSON.parse(data)
  214. dataForm.dept = data.dept
  215. dataForm.branch = data.branch
  216. }
  217. for(let i = 0; i<5; i++){
  218. setTabbar(i)
  219. }
  220. onLoadFn();
  221. })
  222. onTabItemTap(e => {
  223. onLoadFn();
  224. })
  225. </script>
  226. <style scoped>
  227. >>> .uni-data-tree-input{
  228. width: 100% !important;
  229. }
  230. >>> .input-value-border{
  231. border: none !important;
  232. }
  233. >>> .input-value{
  234. padding:0 !important;
  235. flex-direction: row-reverse !important;
  236. }
  237. >>> .selected-list{
  238. flex-direction: row-reverse !important;
  239. }
  240. >>> .arrow-area{
  241. display: none !important;
  242. }
  243. >>>.uni-data-tree-dialog{
  244. z-index: 9999;
  245. }
  246. </style>
  247. <style lang="scss" scoped>
  248. page{
  249. height: calc(100vh - var(--window-bottom));
  250. background-color: #EBEBEB;
  251. }
  252. .mine{
  253. height: 100%;
  254. display: flex;
  255. flex-direction: column;
  256. justify-content: space-between;
  257. .phone-filled{
  258. margin-right: 5rpx;
  259. }
  260. .newicon-xinjian2,
  261. .newicon-zhishiku{
  262. margin-right: 10rpx;
  263. }
  264. .body{
  265. width: 714rpx;
  266. height: 100%;
  267. margin: 16rpx auto var(--window-bottom) auto;
  268. box-sizing: border-box;
  269. border-radius: 8rpx;
  270. .top{
  271. padding: 30rpx;
  272. background-color: #fff;
  273. .top_name{
  274. font-size: 28rpx;
  275. font-weight: bold;
  276. }
  277. .top_count{
  278. margin-top: 45rpx;
  279. display: flex;
  280. align-items: center;
  281. justify-content: space-between;
  282. .top_count_item{
  283. text-align: center;
  284. .name{
  285. color: #949494;
  286. font-size: 22rpx;
  287. }
  288. .value{
  289. font-size: 50rpx;
  290. font-weight: bold;
  291. margin-top: 15rpx;
  292. }
  293. }
  294. }
  295. }
  296. .bottom{
  297. background-color: #fff;
  298. margin-top: 15rpx;
  299. .bottom_name{
  300. font-size: 26rpx;
  301. color: $uni-primary;
  302. padding: 21rpx 24rpx;
  303. }
  304. .bottom_list{
  305. .bottom_list_item{
  306. border-top: 1rpx solid #DEDEDE;
  307. padding: 30rpx 30rpx 30rpx 30rpx;
  308. display: flex;
  309. justify-content: space-between;
  310. align-items: center;
  311. font-size: 24rpx;
  312. position: relative;
  313. .value{
  314. max-width: 380rpx;
  315. color: #333;
  316. display: flex;
  317. align-items: center;
  318. text-align: justify;
  319. margin-right: 30rpx;
  320. }
  321. .no-mar{
  322. margin-right:0 !important;
  323. }
  324. .icon{
  325. position: absolute;
  326. right: 20rpx;
  327. }
  328. }
  329. }
  330. }
  331. }
  332. }
  333. </style>