Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

xt_user.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. import { modifyAdminInfo, verifyToken } from '@/api/login/login'
  2. // import { mapGetters } from 'vuex'
  3. // import { getToken, setToken, removeToken } from '@/utils/auth'
  4. import { cacheAdminUserInfo, getAdminUserInfoCache, removeAdminUserInfoCache } from '@/utils/admin_info_cache'
  5. import { getFiledConfigList, setFiledConfigList } from '@/utils/data_config' // getConfigList from sessionStorage
  6. const xt_user = {
  7. state: {
  8. org_id: 0,
  9. schedule_type_selected: 0,
  10. zone_selected: 0,
  11. patient_state_selected: 0,
  12. treat_state_selected: 0,
  13. selected_date:new Date(),
  14. app_id: 0,
  15. user: {
  16. id: 0,
  17. mobile: '',
  18. avatar: '',
  19. user_name: '',
  20. intro: '',
  21. user_type: 0, // 用户类型(1.管理员;2.医生;3.护士;4.运营)
  22. user_title: 0 // 用户职称(1.医士;2.医师;3.住院医师;4.主治医师;5.副主任医师;6.主任医师;7.护士;8.护师;9.主管护师;10.副主任护师;11.主任护师;12.运营专员;13.运营主管)
  23. },
  24. template_info: {
  25. id: 0,
  26. org_id: 0,
  27. template_id: 0
  28. },
  29. org: {
  30. id: 0,
  31. org_name: '',
  32. org_short_name: '',
  33. org_intro: '',
  34. org_logo: '',
  35. province: 0,
  36. city: 0,
  37. district: 0,
  38. address: ''
  39. },
  40. subscibe: {
  41. id: 0,
  42. period_start: 0,
  43. period_end: 0,
  44. state: 2, // 1正版(标准) 2试用(免费) 3过期(或其他无效状态) 8 专业 9 永久,
  45. patients: 20 // 患者数
  46. },
  47. scrm_role_exist: false,
  48. cdm_role_exist: false,
  49. mall_role_exist: false,
  50. // 示例: ['', '',]
  51. urlfors: [],
  52. fileds: [],
  53. //监测的搜索状态
  54. search_mode: 1,
  55. //监测的搜索值
  56. search_value:''
  57. },
  58. mutations: {
  59. SET_SEARCH_VALUE:(state, search_value) => {
  60. state.search_value = search_value
  61. },
  62. SET_SEARCH_MODE:(state, search_mode) => {
  63. state.search_mode = search_mode
  64. },
  65. SET_SCHEDULE_TYPE_SELECTED: (state, schedule_type_selected) => {
  66. state.schedule_type_selected = schedule_type_selected
  67. },
  68. SET_ZONE_SELECTED: (state, zone_selected) => {
  69. state.zone_selected = zone_selected
  70. },
  71. SET_PAtIENT_STATE_SELECTED: (state, patient_state_selected) => {
  72. state.patient_state_selected = patient_state_selected
  73. },
  74. SET_TREAT_STATE_SELECTED: (state, treat_state_selected) => {
  75. state.treat_state_selected = treat_state_selected
  76. },
  77. SET_SELECTED_DATE: (state, selected_date) => {
  78. state.selected_date = selected_date
  79. },
  80. SET_FILEDS_LIST: (state, configlist) => {
  81. state.fileds = configlist
  82. },
  83. // cur_info: { user, cur_org_id, cur_app_id }
  84. SET_CURRENT_INFO: (state, cur_info) => {
  85. state.user.id = cur_info.user.id
  86. state.user.mobile = cur_info.user.mobile
  87. state.user.avatar = cur_info.user.avatar
  88. state.user.user_name = cur_info.user.user_name
  89. state.user.intro = cur_info.user.intro
  90. state.user.user_type = cur_info.user.user_type
  91. state.user.user_title = cur_info.user.user_title
  92. state.org_id = cur_info.cur_org_id
  93. state.app_id = cur_info.cur_app_id
  94. state.org.id = cur_info.org.id
  95. state.org.org_name = cur_info.org.org_name
  96. state.org.org_short_name = cur_info.org.org_short_name
  97. state.org.org_logo = cur_info.org.org_logo
  98. state.org.org_intro = cur_info.org.org_intro
  99. state.org.province = cur_info.org.province
  100. state.org.city = cur_info.org.city
  101. state.org.district = cur_info.org.district
  102. state.org.address = cur_info.org.address
  103. state.subscibe.id = cur_info.subscibe.id
  104. state.subscibe.period_start = cur_info.subscibe.period_start
  105. state.subscibe.period_end = cur_info.subscibe.period_end
  106. state.subscibe.state = cur_info.subscibe.state
  107. state.scrm_role_exist = cur_info.scrm_role_exist
  108. state.cdm_role_exist = cur_info.cdm_role_exist
  109. state.mall_role_exist = cur_info.mall_role_exist
  110. state.template_info.id = cur_info.template_info.id
  111. state.template_info.org_id = cur_info.template_info.org_id
  112. state.template_info.template_id = cur_info.template_info.template_id
  113. },
  114. SET_FILEDS: (state, payload) => {
  115. state.fileds = payload.fileds
  116. },
  117. SET_URLFORS: (state, payload) => {
  118. state.urlfors = payload.urlfors
  119. },
  120. MODIFY_USER_INFO: (state, payload) => {
  121. state.user.user_name = payload.user_name
  122. state.user.avatar = payload.avatar
  123. },
  124. MODIFY_ORG_INFO: (state, payload) => {
  125. state.org.org_name = payload.org_name
  126. state.org.org_short_name = payload.org_short_name
  127. },
  128. SET_SUBSCIBE_PATIENT: (state) => {
  129. state.subscibe.patients += 1
  130. },
  131. CLEAR_USER_INFO: (state) => {
  132. state.org_id = 0
  133. state.app_id = 0
  134. state.user.id = 0
  135. state.user.mobile = ''
  136. state.user.avatar = ''
  137. state.user.user_name = ''
  138. state.user.intro = ''
  139. state.user_type = ''
  140. state.user_title = ''
  141. state.org.id = 0
  142. state.org.org_name = ''
  143. state.org.org_short_name = ''
  144. state.org.org_logo = ''
  145. state.org.org_intro = ''
  146. state.org.province = 0
  147. state.org.city = 0
  148. state.org.district = 0
  149. state.org.address = ''
  150. state.subscibe.id = 0
  151. state.subscibe.period_start = 0
  152. state.subscibe.period_end = 0
  153. state.subscibe.state = 3
  154. state.subscibe.patients = 0
  155. state.scrm_role_exist = false
  156. state.cdm_role_exist = false
  157. state.mall_role_exist = false
  158. state.template_info.id = 0
  159. state.template_info.org_id = 0
  160. state.template_info.template_id = 1
  161. state.urlfors = []
  162. state.fileds = []
  163. }
  164. },
  165. getters: {
  166. current_role_urls: state => {
  167. return state.urlfors
  168. }
  169. },
  170. actions: {
  171. SetSearchValue({ commit }, search_value) {
  172. commit('SET_SEARCH_VALUE', search_value)
  173. },
  174. SetSearchMode({ commit }, search_mode) {
  175. commit('SET_SEARCH_MODE', search_mode)
  176. },
  177. SetScheduleTypeSelected({ commit }, schedule_type_selected) {
  178. commit('SET_SCHEDULE_TYPE_SELECTED', schedule_type_selected)
  179. },
  180. SetZoneSelected({ commit }, zone_selected) {
  181. commit('SET_ZONE_SELECTED', zone_selected)
  182. },
  183. SetPatientStateSelected({ commit }, patient_state_selected) {
  184. commit('SET_PAtIENT_STATE_SELECTED', patient_state_selected)
  185. },
  186. SetTreatStateSelected({ commit }, treat_state_selected) {
  187. commit('SET_TREAT_STATE_SELECTED', treat_state_selected)
  188. },
  189. SetSelectedDate({ commit }, selected_date) {
  190. commit('SET_SELECTED_DATE', selected_date)
  191. },
  192. SetSubscibePatients({
  193. commit,
  194. state
  195. }) {
  196. commit('SET_SUBSCIBE_PATIENT')
  197. },
  198. VerifyToken({
  199. commit,
  200. state
  201. }, token) {
  202. // console.log('验证 token 之前:token = ' + token)
  203. return new Promise((resolve, reject) => {
  204. var cacheInfo = getAdminUserInfoCache()
  205. var fileds = getFiledConfigList()
  206. var infoJSON = JSON.parse(fileds)
  207. commit('SET_FILEDS', {
  208. fileds: infoJSON
  209. })
  210. // console.log('登录信息缓存:', cacheInfo)
  211. verifyToken(token).then(response => {
  212. if (response.data.state === 1) {
  213. // alert('验证通过')
  214. // console.log('验证通过')
  215. var data = response.data.data
  216. this.commit('SET_CURRENT_INFO', {
  217. user: data.user,
  218. cur_org_id: data.current_org_id,
  219. cur_app_id: data.current_app_id,
  220. org: data.org,
  221. subscibe: data.subscibe,
  222. template_info: data.template_info,
  223. scrm_role_exist: data.scrm_role_exist,
  224. cdm_role_exist: data.cdm_role_exist,
  225. mall_role_exist: data.mall_role_exist
  226. })
  227. const urlfors = data.urlfors
  228. if (data.cdm_role_exist == true) {
  229. console.log('有')
  230. urlfors.push('/slow')
  231. this.commit('SET_URLFORS', {
  232. urlfors: urlfors
  233. })
  234. } else {
  235. this.commit('SET_URLFORS', {
  236. urlfors: data.urlfors
  237. })
  238. }
  239. if (data.scrm_role_exist == true) {
  240. urlfors.push('/scrm')
  241. this.commit('SET_URLFORS', {
  242. urlfors: urlfors
  243. })
  244. } else {
  245. this.commit('SET_URLFORS', {
  246. urlfors: data.urlfors
  247. })
  248. }
  249. if (data.mall_role_exist == true) {
  250. console.log('有')
  251. urlfors.push('/shop')
  252. this.commit('SET_URLFORS', {
  253. urlfors: urlfors
  254. })
  255. } else {
  256. this.commit('SET_URLFORS', {
  257. urlfors: data.urlfors
  258. })
  259. }
  260. // this.commit('SET_URLFORS', {
  261. // urlfors: data.urlfors
  262. // })
  263. commit('SET_FILEDS', {
  264. fileds: data.fileds
  265. })
  266. setFiledConfigList(JSON.stringify(data.fileds))
  267. cacheAdminUserInfo(JSON.stringify(data))
  268. resolve(data.user.id)
  269. } else {
  270. alert('请求失败:' + response.data.msg)
  271. reject({
  272. msg: response.data.msg,
  273. code: response.data.code
  274. })
  275. }
  276. })
  277. })
  278. },
  279. ModifyAdminUserInfo({
  280. commit,
  281. state
  282. }, params) {
  283. commit('MODIFY_USER_INFO', {
  284. user_name: params.user_name,
  285. avatar: params.avatar
  286. })
  287. cacheAdminUserInfo(
  288. JSON.stringify({
  289. user: state.user,
  290. org: state.org,
  291. current_org_id: state.org_id,
  292. current_app_id: state.app_id,
  293. urlfors: state.urlfors,
  294. subscibe: state.subscibe,
  295. template_info: state.template_info,
  296. scrm_role_exist: state.scrm_role_exist,
  297. cdm_role_exist: state.cdm_role_exist,
  298. mall_role_exist: state.mall_role_exist
  299. })
  300. )
  301. },
  302. ModifyOrgInfo({
  303. commit,
  304. state
  305. }, params) {
  306. commit('MODIFY_ORG_INFO', {
  307. org_name: params.org_name,
  308. org_short_name: params.org_short_name
  309. })
  310. cacheAdminUserInfo(
  311. JSON.stringify({
  312. user: state.user,
  313. org: state.org,
  314. current_org_id: state.org_id,
  315. current_app_id: state.app_id,
  316. urlfors: state.urlfors,
  317. subscibe: state.subscibe,
  318. template_info: state.template_info,
  319. scrm_role_exist: state.scrm_role_exist,
  320. cdm_role_exist: state.cdm_role_exist,
  321. mall_role_exist: state.mall_role_exist
  322. })
  323. )
  324. },
  325. // InitAdminUserInfo( {commit, state} ) {
  326. // var cacheInfo = getAdminUserInfoCache()
  327. // console.log("登录信息缓存:", cacheInfo)
  328. // if (cacheInfo != null && cacheInfo.length > 0) {
  329. // var infoJSON = JSON.parse(cacheInfo)
  330. // console.log(infoJSON)
  331. // commit('SET_CURRENT_INFO', {
  332. // user: infoJSON.user,
  333. // cur_org_id: infoJSON.current_org_id,
  334. // cur_app_id: infoJSON.current_app_id,
  335. // org: infoJSON.org,
  336. // })
  337. // commit('SET_URLFORS', {
  338. // urlfors: infoJSON.urlfors
  339. // })
  340. // }
  341. // }
  342. // 登出
  343. FrontendLogout({
  344. commit
  345. }) {
  346. commit('CLEAR_USER_INFO')
  347. removeAdminUserInfoCache()
  348. }, updateFiledConfigList({ commit }, object) {
  349. var oldFiledList = getFiledConfigList()
  350. console.log('oldFiledList', oldFiledList)
  351. var infoJSON = JSON.parse(oldFiledList)
  352. console.log(object)
  353. return new Promise((resolve, reject) => {
  354. for (let i = 0; i < infoJSON.length; i++) {
  355. if (infoJSON[i].id == object.id) {
  356. infoJSON[i].is_show = object.is_show
  357. }
  358. }
  359. setFiledConfigList(JSON.stringify(infoJSON))
  360. commit('SET_FILEDS_LIST', infoJSON)
  361. resolve()
  362. })
  363. }, updateAllFiledConfigList({ commit }, object) {
  364. console.log(object)
  365. var oldFiledList = getFiledConfigList()
  366. var infoJSON = JSON.parse(oldFiledList)
  367. return new Promise((resolve, reject) => {
  368. infoJSON = object
  369. console.log(infoJSON)
  370. setFiledConfigList(JSON.stringify(infoJSON))
  371. commit('SET_FILEDS_LIST', infoJSON)
  372. resolve()
  373. })
  374. }, ModifyAdminUserOrgInfo({ commit, state }, obj) {
  375. this.commit('SET_CURRENT_INFO', obj)
  376. }, ModifyUrlInfo({ commit, state }, obj) {
  377. this.commit('SET_URLFORS', obj)
  378. }, ModifyFiled({ commit, state }, obj) {
  379. commit('SET_FILEDS', obj)
  380. }
  381. }
  382. }
  383. export default xt_user