homePage.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009
  1. <template>
  2. <view class="HomeItem">
  3. <view v-if="!online && online !== undefined && workSchemeType == 1">
  4. <view class="goWork" @click="GoWork()">
  5. <view class="goWork_btn_E">
  6. <view class="goWork_btn_W"> 上班 </view>
  7. </view>
  8. </view>
  9. <view class="goWork_text">
  10. <view class="goWork_text-p">上班提醒</view>
  11. <view>请点击" 上班 "开始抢单!</view>
  12. </view>
  13. </view>
  14. <view v-if="!online && online !== undefined && workSchemeType == 2" class="goWorkAll">
  15. <view class="goWorkSelect combination">
  16. <view class="goWorkSelect-head">上班选择工作组合</view>
  17. <scroll-view class="goWorkSelect-list scroll" scroll-y :refresher-enabled="scroll_refresher_enabled"
  18. :refresher-triggered="triggered" @refresherrefresh="refresherrefresh" @refresherrestore="refresherrestore"
  19. @scrolltolower="scrolltolower" :scroll-top="scroll_top" @refresherabort="refresherabort" @scroll="scroll">
  20. <radio-group @change="radioChange1">
  21. <label class="goWorkSelect-item" v-for="item in zxzData" :key="item.str">
  22. <radio :value="item.str" :checked="item.checked" />
  23. <view>{{ item.configName }}</view>
  24. </label>
  25. </radio-group>
  26. </scroll-view>
  27. </view>
  28. <view class="goWorkSelect history">
  29. <view class="goWorkSelect-head"> 历史上班记录 </view>
  30. <view class="goWorkSelect-list">
  31. <radio-group @change="radioChange2">
  32. <label class="goWorkSelect-item" v-for="(item, index) in historys" :key="index">
  33. <radio :value="item.str" :checked="item.checked" />
  34. <view>{{ item.useTime }}上班记录快捷上班</view>
  35. <button @click="lock(item)">
  36. {{ item.locking == 1 ? "解锁" : "锁定" }}
  37. </button>
  38. </label>
  39. </radio-group>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="login" v-if="!workSchemeType && isApp">
  44. <!-- #ifndef H5 -->
  45. <view class="title"> 转运系统登录 </view>
  46. <input class="login_input" v-model="username" placeholder="请输入用户名" />
  47. <input class="login_input" password v-model="password" placeholder="请输入密码" />
  48. <input class="login_input" v-model="ip" placeholder="请输入域名或IP地址,如:http(s)://192.168.3.108" />
  49. <view class="page_item_btn" @click="login()"> 登录 </view>
  50. <!-- #endif -->
  51. </view>
  52. <view class="botImg" v-if="online || (!online && online !== undefined && workSchemeType == 1)">
  53. <view class="img"></view>
  54. </view>
  55. <!-- 弹窗 -->
  56. <showModel :title="models.title" :icon="models.icon" :disjunctor="models.disjunctor" :content="models.content"
  57. @ok="ok" @cancel="cancel" :operate="models.operate" :phone="models.phone" @know="know"></showModel>
  58. <!-- 锁定-弹窗 -->
  59. <showModel :title="modelsLock.title" :icon="modelsLock.icon" :disjunctor="modelsLock.disjunctor"
  60. :content="modelsLock.content" @ok="okLock" @cancel="cancelLock" :operate="modelsLock.operate" @know="knowLock">
  61. </showModel>
  62. </view>
  63. </template>
  64. <script>
  65. import {
  66. get,
  67. post,
  68. changeIP,
  69. webHandle
  70. } from "../../http/http.js";
  71. import showModel from "../../components/showModel/showModel.vue";
  72. export default {
  73. data() {
  74. return {
  75. //#ifdef H5
  76. type: "",
  77. //#endif
  78. // 是否上班了
  79. online: undefined,
  80. // 是否是app
  81. isApp: false,
  82. // 用户名
  83. username: "",
  84. // 密码
  85. password: "",
  86. //ip地址或域名
  87. ip: "hsms.dashitech.com",
  88. scroll_refresher_enabled: true, //是否开启自定义下拉刷新
  89. triggered: false, //下拉刷新状态
  90. freshing: false, //上拉加载开关
  91. scroll_top: 0, //距离顶部的距离
  92. //分页页码
  93. idx: 0,
  94. // 列表项总数
  95. totalNum: -1,
  96. // 上班选择工作组合列表
  97. zxzData: [],
  98. workSchemeId: "", //启动中工作分配方案id
  99. workSchemeType: "", //启动中工作分配方案类型
  100. ruleType: "", //工作分配方案规则、、例如自由抢单等
  101. // 上班历史记录列表
  102. historys: [],
  103. // 弹窗model
  104. models: {
  105. disjunctor: false,
  106. },
  107. //锁定的选项
  108. itemLock: {},
  109. // 弹窗model--锁定
  110. modelsLock: {
  111. disjunctor: false,
  112. },
  113. };
  114. },
  115. methods: {
  116. // 锁定
  117. lock(data) {
  118. console.log(data);
  119. this.itemLock = data;
  120. this.modelsLock = {
  121. disjunctor: true,
  122. title: "提示",
  123. content: `是否${
  124. this.itemLock.locking == 1 ? "解锁" : "锁定"
  125. }该上班记录`,
  126. icon: "warn",
  127. operate: {
  128. ok: "确定",
  129. cancel: "取消",
  130. },
  131. };
  132. },
  133. //知道了
  134. knowLock() {
  135. this.modelsLock.disjunctor = false;
  136. let userId = uni.getStorageSync("userData").user.id;
  137. this.getHistorys(userId); //获取上班历史记录
  138. },
  139. //确定
  140. okLock() {
  141. this.modelsLock.disjunctor = false;
  142. let postData = {
  143. workConfigHistory: {
  144. id: this.itemLock.id,
  145. locking: this.itemLock.locking == 1 ? 0 : 1,
  146. },
  147. };
  148. uni.showLoading({
  149. title: "加载中",
  150. mask: true,
  151. });
  152. post("/configuration/updData/workConfigHistory", postData).then(
  153. (result) => {
  154. uni.hideLoading();
  155. if (result.status == 200) {
  156. this.modelsLock = {
  157. disjunctor: true,
  158. title: "提示",
  159. content: `${this.itemLock.locking == 0 ? "锁定" : "解锁"}成功`,
  160. icon: "success",
  161. operate: {
  162. know: "知道了",
  163. },
  164. };
  165. } else {
  166. uni.showToast({
  167. icon: "none",
  168. title: "请求失败",
  169. });
  170. }
  171. }
  172. );
  173. },
  174. //取消
  175. cancelLock() {
  176. this.modelsLock.disjunctor = false;
  177. },
  178. // 选择历史上班记录
  179. radioChange2(value) {
  180. this.objHistory = JSON.parse(value.target.value);
  181. let depts = this.objHistory.deptList.map((item) => item.dept).join();
  182. this.models = {
  183. disjunctor: true,
  184. title: "提示",
  185. content: `组合名称是【${this.objHistory.workAllocationQuick.configName}】;选择的科室是【${depts}】`,
  186. icon: "warn",
  187. operate: {
  188. ok: "快捷上班",
  189. cancel: "取消",
  190. },
  191. };
  192. },
  193. //知道了
  194. know() {
  195. this.models.disjunctor = false;
  196. },
  197. //确定
  198. ok() {
  199. this.models.disjunctor = false;
  200. this.ruleType = 3;
  201. uni.setStorageSync("setDepts", this.objHistory.deptList); //存科室列表
  202. uni.setStorageSync("setDeptConfg", {
  203. //存设置科室的配置信息
  204. configName: this.objHistory.workAllocationQuick.configName, //组合名称
  205. workSchemeType: 2, //方案类型
  206. ruleType: 3, //方案规则,科室绑定人员
  207. id: this.objHistory.workAllocationQuick.id, //组合id
  208. });
  209. this.GoWork();
  210. },
  211. //取消
  212. cancel() {
  213. this.models.disjunctor = false;
  214. let userId = uni.getStorageSync("userData").user.id;
  215. this.historys = [];
  216. this.getHistorys(userId); //获取上班历史记录
  217. },
  218. // 获取上班历史记录
  219. getHistorys(id) {
  220. let postData = {
  221. idx: 0,
  222. sum: 3,
  223. workConfigHistory: {
  224. hosId: uni.getStorageSync("userData").user.currentHospital.id,
  225. user: {
  226. id: id,
  227. },
  228. },
  229. };
  230. post("/configuration/fetchDataList/workConfigHistory", postData).then(
  231. (res) => {
  232. if (res.status == 200) {
  233. this.historys = res.list;
  234. this.historys.forEach((item) => {
  235. let d = new Date(item.useTime);
  236. let month = (d.getMonth() + 1 + "").padStart(2, "0");
  237. let day = (d.getDate() + "").padStart(2, "0");
  238. item.useTime = `${month}月${day}日`;
  239. let o = JSON.parse(JSON.stringify(item));
  240. item.str = JSON.stringify(o);
  241. item.checked = false;
  242. });
  243. } else {
  244. uni.showToast({
  245. icon: "none",
  246. title: "请求失败",
  247. });
  248. }
  249. }
  250. );
  251. },
  252. // 选择上班快捷组合
  253. radioChange1(value) {
  254. let obj = JSON.parse(value.target.value);
  255. console.log(obj);
  256. this.ruleType = obj.ruleType;
  257. if (obj.ruleType == 1) {
  258. //自由抢单,直接上班
  259. if (uni.getStorageSync("setDeptConfg")) {
  260. uni.removeStorageSync("setDeptConfg"); //清空选择的科室配置,初始化
  261. }
  262. this.GoWork();
  263. } else if (obj.ruleType == 3) {
  264. //科室绑定人员,进入设置科室界面
  265. uni.setStorageSync("setDeptConfg", {
  266. //存设置科室的配置信息
  267. configName: obj.configName,
  268. workSchemeType: this.workSchemeType,
  269. ruleType: obj.ruleType,
  270. id: obj.id,
  271. });
  272. uni.navigateTo({
  273. url: `../setDept/setDept?configName=${obj.configName}&id=${obj.id}`,
  274. });
  275. }
  276. },
  277. // 连接上下班的websocket baba type如果是wx则是微信,app则是app;有app必有ip
  278. offWork(type, ip) {
  279. let ipp, wws;
  280. if (type == "wx") {
  281. wws = document.location.protocol === "http:" ? "ws" : "wss"; //ws协议
  282. ipp = document.domain;
  283. } else if (type == "app") {
  284. wws = ip.split(":")[0] === "http" ? "ws" : "wss"; //ws协议
  285. ipp = ip.split(":")[1];
  286. }
  287. console.log(ipp, wws);
  288. uni.connectSocket({
  289. url: `${wws}://${ipp}:8080/webSocket/message/onlineStatus`,
  290. // url: `${wws}://192.168.3.74:8080/webSocket/message/onlineStatus`,
  291. });
  292. uni.onSocketOpen(function(res) {
  293. console.log("WebSocket连接已打开!");
  294. let userid = uni.getStorageSync("userData").user.id;
  295. uni.sendSocketMessage({
  296. data: JSON.stringify({
  297. userid,
  298. }),
  299. success: function(res) {
  300. console.log(res, "传参");
  301. },
  302. fail: function(err) {
  303. console.log(err, "传参错误");
  304. },
  305. });
  306. });
  307. uni.onSocketError(function(res) {
  308. console.log("WebSocket连接打开失败,请检查!");
  309. });
  310. uni.onSocketMessage((res) => {
  311. console.log("收到服务器内容:" + res.data);
  312. if (res.data == "ok") {
  313. this.goOffWork();
  314. }
  315. });
  316. },
  317. // 下班
  318. goOffWork() {
  319. let setDeptConfg = uni.getStorageSync("setDeptConfg");
  320. if (setDeptConfg.workSchemeType == 2 && setDeptConfg.ruleType == 3) {
  321. post("/auth/onOrOffLine", {
  322. type: "off",
  323. customWorking: "off",
  324. }).then((res) => {
  325. if (res.status == 200) {
  326. if (uni.getStorageSync("setDeptConfg")) {
  327. uni.removeStorageSync("setDeptConfg"); //清空选择的科室配置,初始化
  328. }
  329. uni.showToast({
  330. icon: "none",
  331. title: "您已被强制下班!",
  332. mask: true,
  333. duration: 5000,
  334. });
  335. setTimeout(() => {
  336. uni.redirectTo({
  337. url: "../mypage/mypage",
  338. });
  339. }, 5000);
  340. } else {
  341. uni.showToast({
  342. icon: "none",
  343. title: "请求失败",
  344. });
  345. }
  346. });
  347. } else {
  348. post("/auth/onOrOffLine", {
  349. type: "off",
  350. }).then((res) => {
  351. if (res.status == 200) {
  352. if (uni.getStorageSync("setDeptConfg")) {
  353. uni.removeStorageSync("setDeptConfg"); //清空选择的科室配置,初始化
  354. }
  355. uni.showToast({
  356. icon: "none",
  357. title: "您已被强制下班!",
  358. mask: true,
  359. duration: 5000,
  360. });
  361. setTimeout(() => {
  362. uni.redirectTo({
  363. url: "../mypage/mypage",
  364. });
  365. }, 5000);
  366. } else {
  367. uni.showToast({
  368. icon: "none",
  369. title: "请求失败",
  370. });
  371. }
  372. });
  373. }
  374. },
  375. // 上班
  376. GoWork() {
  377. uni.showLoading({
  378. title: "加载中",
  379. mask: true,
  380. });
  381. if (this.workSchemeType == 2 && this.ruleType == 3) {
  382. let obj = uni.getStorageSync("setDeptConfg");
  383. let depts = this.objHistory.deptList.map((item) => item.id).join();
  384. let userId = uni.getStorageSync("userData").user.id;
  385. post("/auth/onOrOffLine", {
  386. type: "on",
  387. customWorking: "on",
  388. quickId: obj.id,
  389. deptIds: depts,
  390. userId: userId,
  391. }).then((result) => {
  392. uni.hideLoading();
  393. if (result.status == 200) {
  394. let obj = uni.getStorageSync("userData");
  395. obj.user.online = true;
  396. uni.setStorageSync("userData", obj);
  397. uni.redirectTo({
  398. url: "../receiptpage/receiptpage",
  399. });
  400. } else if (result.status == 504) {
  401. let dept = result.department.dept;
  402. let user = result.user.name;
  403. let phone = result.user.phone;
  404. this.models = {
  405. disjunctor: true,
  406. title: "提示",
  407. content: `您选择的科室已经被使用,请换个科室,或者联系:科室[${dept}]人员[${user}]号码[${phone}] 切换科室解决`,
  408. icon: "warn",
  409. phone,
  410. operate: {
  411. know: "知道了",
  412. },
  413. };
  414. } else {
  415. uni.showToast({
  416. icon: "none",
  417. title: "请求失败",
  418. });
  419. }
  420. });
  421. } else {
  422. post("/auth/onOrOffLine", {
  423. type: "on",
  424. }).then((res) => {
  425. uni.hideLoading();
  426. if (res.status == 200) {
  427. let obj = uni.getStorageSync("userData");
  428. obj.user.online = true;
  429. uni.setStorageSync("userData", obj);
  430. uni.redirectTo({
  431. url: "../receiptpage/receiptpage",
  432. });
  433. } else {
  434. uni.showToast({
  435. icon: "none",
  436. title: "请求失败",
  437. });
  438. }
  439. });
  440. }
  441. },
  442. // 登录
  443. login() {
  444. // 用户名,密码,域名(ip)不能为空
  445. if (
  446. this.username.trim() === "" ||
  447. this.password.trim() === "" ||
  448. this.ip.trim() === ""
  449. ) {
  450. uni.showToast({
  451. icon: "none",
  452. title: "请输入用户名,密码,域名或IP",
  453. });
  454. return;
  455. }
  456. // 域名ip正则验证
  457. let regUrl =
  458. /^https?:\/\/([\w-]+\.)+((com)|(net)|(org)|(gov\.cn)|(info)|(cc)|(com\.cn)|(net\.cn)|(org\.cn)|(name)|(biz)|(tv)|(cn)|(mobi)|(name)|(sh)|(ac)| (io)|(tw)|(com\.tw)|(hk)|(com\.hk)|(ws)|(travel)|(us)|(tm)|(la)|(me\.uk)|(org\.uk)|(ltd\.uk)|(plc\.uk)|(in)|(eu)|(it)|(jp))(\:([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5]))?$/;
  459. let regIp =
  460. /^https?:\/\/((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]\d)|\d)(\.((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]\d)|\d)){3}(\:([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5]))?$/;
  461. if (!regUrl.test(this.ip.trim()) && !regIp.test(this.ip.trim())) {
  462. uni.showToast({
  463. icon: "none",
  464. title: "请输入正确的域名或IP",
  465. });
  466. return;
  467. }
  468. uni.setStorageSync("ip", this.ip);
  469. changeIP(this.ip);
  470. uni.showLoading({
  471. title: "登录中",
  472. mask: true,
  473. });
  474. let data = {
  475. username: this.username.trim(),
  476. password: this.password.trim(),
  477. type: 'APP'
  478. };
  479. post("/auth/login", data).then((res) => {
  480. uni.hideLoading();
  481. if (res.status == 200) {
  482. //获取角色信息
  483. let role = res.user.user.role;
  484. // 配药师和支助人员才能登录
  485. let workerFlag = role.some((item) => item.rolecode === "worker");
  486. let pharmacistFlag = role.some((item) => item.rolecode === "pharmacist");
  487. if (!workerFlag && !pharmacistFlag) {
  488. uni.showToast({
  489. icon: "none",
  490. title: "暂无权限登录!",
  491. });
  492. return;
  493. }
  494. uni.setStorageSync("userData", res.user);
  495. uni.setStorageSync("username", this.username); //存储用户名
  496. uni.setStorageSync("password", this.password); //存储密码
  497. this.getWorkScheme(false, res.user.user.currentHospital.id); //获取当前启动中的工作分配方案
  498. this.getHistorys(res.user.user.id); //获取上班历史记录
  499. this.offWork("app", this.ip);
  500. if (workerFlag) { //有配药师角色
  501. if (!res.user.user.online) {
  502. this.online = false;
  503. } else {
  504. this.online = true;
  505. // 建立websocket连接
  506. webHandle("receiptpage", "app", this.ip);
  507. }
  508. } else {
  509. webHandle("pharmacy", "app", this.ip);
  510. }
  511. } else if (!res.status && !res.remarks) {
  512. //如果乱填写域名或ip
  513. uni.showToast({
  514. icon: "none",
  515. title: "服务器连接失败!请检查输入的域名(IP)及端口号",
  516. });
  517. } else {
  518. uni.showToast({
  519. icon: "none",
  520. title: res.remarks ? res.remarks : "请求失败",
  521. });
  522. }
  523. });
  524. },
  525. // 微信登录公用方法
  526. // user:当前登录用户对象
  527. // type:有值的话则是从菜单访问的
  528. // workerFlag:是否有支助人员角色
  529. // pharmacistFlag:是否有配药师角色
  530. submCommon(user, type, workerFlag, pharmacistFlag) {
  531. //从药房菜单过来的
  532. if (type === "pharmacy") {
  533. //药房来
  534. // 药房才能登录
  535. if (!pharmacistFlag) {
  536. uni.showToast({
  537. icon: "none",
  538. title: "暂无权限登录!",
  539. });
  540. return;
  541. }
  542. } else if (type === "mypage") { //从我的菜单过来的
  543. if (!workerFlag) {
  544. uni.showToast({
  545. icon: "none",
  546. title: "暂无权限登录!",
  547. });
  548. return;
  549. }
  550. } else {
  551. //正常进入
  552. if (!workerFlag && !pharmacistFlag) {
  553. uni.showToast({
  554. icon: "none",
  555. title: "暂无权限登录!",
  556. });
  557. return;
  558. }
  559. }
  560. uni.setStorageSync("userData", user);
  561. this.getWorkScheme(false, user.user.currentHospital.id); //获取当前启动中的工作分配方案
  562. this.getHistorys(user.user.id); //获取上班历史记录
  563. this.offWork("wx");
  564. // uni.setStorageSync('type', '')
  565. if (type === "pharmacy") {
  566. // 建立websocket连接
  567. webHandle("pharmacy", "wx");
  568. } else if (type === "mypage") {
  569. // 建立websocket连接
  570. webHandle("mypage", "wx");
  571. } else {
  572. if (workerFlag) { //有支助人员的角色
  573. if (!user.user.online) {
  574. this.online = false;
  575. } else {
  576. this.online = true;
  577. // 建立websocket连接
  578. webHandle("receiptpage", "wx");
  579. }
  580. } else { //只有药房橘色
  581. webHandle("pharmacy", "wx");
  582. }
  583. }
  584. },
  585. //微信
  586. subm() {
  587. uni.showLoading({
  588. title: "登录中",
  589. mask: true,
  590. });
  591. var href = location.href; //获取链接地址
  592. console.log(href, "href");
  593. var href_wenhao = href.indexOf("?code="); //判断有没有问号,没有是-1
  594. var wenhaohoumian = location.href.split("?code="); //截取问号地址数组
  595. this.arr_last = wenhaohoumian[1]; //地址数组赋值
  596. if (href_wenhao == -1) {
  597. post("/auth/wxlogin").then((res) => {
  598. this.url = res.url;
  599. this.state = res.status;
  600. uni.setStorageSync("type", this.type); //存储来源type
  601. uni.hideLoading();
  602. if (this.state == "200") {
  603. //获取角色信息
  604. let role = res.user.user.role;
  605. let workerFlag = role.some((item) => item.rolecode === "worker");
  606. let pharmacistFlag = role.some((item) => item.rolecode === "pharmacist");
  607. this.submCommon(res.user, this.type, workerFlag, pharmacistFlag);
  608. } else {
  609. console.log(this.url, "url");
  610. // https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww2506abad3086cfab&redirect_uri=http://weixintest2.ngser.dashitech.com/app&response_type=code&scope=snsapi_base&agentid=1000013&state=STATE&connect_redirect=1#wechat_redirect
  611. location.assign(this.url);
  612. }
  613. });
  614. } else if (href_wenhao != -1) {
  615. this.arr_last = this.arr_last.split("&");
  616. this.arr_last = this.arr_last[0];
  617. post("/auth/wxlogina", {
  618. code: this.arr_last,
  619. }).then((res) => {
  620. this.state = res.status;
  621. uni.hideLoading();
  622. if (this.state == "200") {
  623. this.type = uni.getStorageSync("type"); //刷新页面后获取type
  624. console.log(this.type);
  625. //获取角色信息
  626. let role = res.user.user.role;
  627. let workerFlag = role.some((item) => item.rolecode === "worker");
  628. let pharmacistFlag = role.some((item) => item.rolecode === "pharmacist");
  629. this.submCommon(res.user, this.type, workerFlag, pharmacistFlag);
  630. } else {
  631. uni.showToast({
  632. icon: "none",
  633. title: "请求失败",
  634. });
  635. }
  636. });
  637. }
  638. },
  639. // 获取工作组合列表
  640. getCombinationById(idx, type) {
  641. console.log(this.type);
  642. if (this.zxzData.length == this.totalNum && !type) {
  643. uni.showToast({
  644. icon: "none",
  645. title: "没有更多数据了!",
  646. });
  647. this.freshing = true;
  648. return;
  649. }
  650. let data = {
  651. workAllocationQuickConfig: {
  652. workSchemeId: this.workSchemeId,
  653. },
  654. idx: idx,
  655. sum: 20,
  656. };
  657. uni.showLoading({
  658. title: "加载中",
  659. mask: true,
  660. });
  661. // 请求列表数据
  662. post("/configuration/fetchDataList/workAllocationQuickConfig", data).then(
  663. (res) => {
  664. uni.hideLoading();
  665. if (res.status == 200) {
  666. this.triggered = false;
  667. this.freshing = true;
  668. this.totalNum = res.totalNum;
  669. if (idx === 0) {
  670. res.list.forEach((item) => {
  671. let o = JSON.parse(JSON.stringify(item));
  672. item.str = JSON.stringify(o);
  673. item.checked = false;
  674. });
  675. this.zxzData = res.list;
  676. } else {
  677. res.list.forEach((item) => {
  678. let o = JSON.parse(JSON.stringify(item));
  679. item.str = JSON.stringify(o);
  680. item.checked = false;
  681. });
  682. this.zxzData.push(...res.list);
  683. }
  684. } else {
  685. uni.showToast({
  686. icon: "none",
  687. title: "请求失败!",
  688. });
  689. }
  690. }
  691. );
  692. },
  693. //刷新
  694. refresherrefresh() {
  695. if (this.triggered) {
  696. return;
  697. }
  698. console.log("下拉刷新");
  699. this.triggered = true;
  700. this.idx = 0;
  701. this.totalNum = -1;
  702. this.getCombinationById(0);
  703. },
  704. // 下拉刷新复位
  705. refresherrestore() {
  706. this.triggered = false;
  707. console.log("下拉刷新复位");
  708. },
  709. //下拉刷新中止
  710. refresherabort() {
  711. this.triggered = false;
  712. console.log("下拉刷新中止");
  713. },
  714. //分页,上拉加载
  715. scrolltolower() {
  716. if (this.freshing) {
  717. console.log("上拉加载");
  718. this.freshing = false;
  719. this.getCombinationById(++this.idx);
  720. }
  721. },
  722. // 滚动
  723. scroll(e) {
  724. if (e.detail.scrollTop < 20) {
  725. this.scroll_refresher_enabled = true;
  726. } else {
  727. this.scroll_refresher_enabled = false;
  728. }
  729. },
  730. // 获取启动中的工作分配方案
  731. getWorkScheme(type, hosId) {
  732. let postData = {
  733. idx: 0,
  734. workScheme: {
  735. status: 1,
  736. hosId
  737. },
  738. sum: 1,
  739. };
  740. post("/simple/data/fetchDataList/workScheme", postData).then((res) => {
  741. if (res.status == 200) {
  742. this.workSchemeId = res.list[0].id;
  743. this.workSchemeType = res.list[0].workType;
  744. if (type) {
  745. if (this.workSchemeType == 2) {
  746. this.getCombinationById(0, "no");
  747. } else if (this.workSchemeType == 1) {
  748. if (uni.getStorageSync("setDeptConfg")) {
  749. uni.removeStorageSync("setDeptConfg"); //清空选择的科室配置,初始化
  750. }
  751. }
  752. } else {
  753. this.getCombinationById(0);
  754. }
  755. } else {
  756. uni.showToast({
  757. icon: "none",
  758. title: "请求失败!",
  759. });
  760. }
  761. });
  762. },
  763. // 阻止浏览器滑动
  764. stop(e) {
  765. e.preventDefault();
  766. },
  767. },
  768. onHide() {
  769. this.zxzData = [];
  770. this.historys = [];
  771. // #ifdef H5
  772. document.body.removeEventListener("touchmove", this.stop, {
  773. passive: false,
  774. });
  775. // #endif
  776. },
  777. onShow() {
  778. // let flag = true;
  779. if (uni.getStorageSync("userData")) {
  780. this.online = uni.getStorageSync("userData").user.online;
  781. }
  782. if (!this.workSchemeType) {
  783. return;
  784. }
  785. // if (this.workSchemeType == 2 && !this.online) {
  786. // let userId = uni.getStorageSync('userData').user.id;
  787. // this.getCombinationById(this.idx, 'no');
  788. // this.getHistorys(userId); //获取上班历史记录
  789. // }
  790. let userId = uni.getStorageSync("userData").user.id;
  791. this.getWorkScheme(true, uni.getStorageSync("userData").user.currentHospital.id);
  792. this.getHistorys(userId); //获取上班历史记录
  793. // #ifdef APP-PLUS
  794. uni.closeSocket();
  795. // #endif
  796. // #ifdef H5
  797. document.body.addEventListener("touchmove", this.stop, {
  798. passive: false,
  799. });
  800. // #endif
  801. },
  802. onLoad(options) {
  803. if (uni.getStorageSync("setDepts")) {
  804. uni.removeStorageSync("setDepts"); //清空选择的科室,初始化
  805. }
  806. console.log(options);
  807. this.ip = uni.getStorageSync("ip") || this.ip;
  808. this.username = uni.getStorageSync("username") || this.username;
  809. this.password = uni.getStorageSync("password") || this.password;
  810. //#ifdef H5
  811. this.isApp = false;
  812. this.type = options.type || "";
  813. console.log(this.type);
  814. this.subm();
  815. //#endif
  816. // #ifdef APP-PLUS
  817. this.isApp = true;
  818. // 通知权限 start
  819. var main = plus.android.runtimeMainActivity();
  820. var pkName = main.getPackageName();
  821. var NotificationManagerCompat = plus.android.importClass(
  822. "android.support.v4.app.NotificationManagerCompat"
  823. );
  824. var packageNames = NotificationManagerCompat.from(main);
  825. console.log(JSON.stringify(packageNames));
  826. if (packageNames.areNotificationsEnabled()) {
  827. console.log("已开启通知权限");
  828. } else {
  829. uni.showModal({
  830. title: "提示",
  831. content: "请先打开APP通知权限",
  832. showCancel: true,
  833. success: function(res) {
  834. if (res.confirm) {
  835. var Intent = plus.android.importClass("android.content.Intent");
  836. var intent = new Intent(
  837. "android.settings.APP_NOTIFICATION_SETTINGS"
  838. ); //可设置表中所有Action字段
  839. intent.putExtra("android.provider.extra.APP_PACKAGE", pkName);
  840. main.startActivity(intent);
  841. }
  842. },
  843. });
  844. }
  845. // 通知权限 end
  846. // #endif
  847. },
  848. };
  849. </script>
  850. <style lang="less" scoped>
  851. .HomeItem {
  852. height: 100vh;
  853. .login {
  854. height: 420rpx;
  855. padding: 0 32rpx;
  856. padding-top: 164rpx;
  857. position: relative;
  858. z-index: 999;
  859. .login_input {
  860. margin-top: 32rpx;
  861. background-color: #ffffff;
  862. height: 72rpx;
  863. box-sizing: border-box;
  864. padding: 16rpx;
  865. }
  866. .title {
  867. font-size: 36rpx;
  868. color: #42b983;
  869. text-align: center;
  870. }
  871. .page_item_btn {
  872. height: 88rpx;
  873. background-image: linear-gradient(to right, #72c172, #3bb197);
  874. border-radius: 8rpx;
  875. line-height: 88rpx;
  876. color: #fff;
  877. font-size: 36rpx;
  878. font-weight: 700;
  879. margin-top: 64rpx;
  880. text-align: center;
  881. }
  882. }
  883. //上班页面
  884. .goWorkAll {
  885. height: 100%;
  886. display: flex;
  887. flex-direction: column;
  888. justify-content: space-between;
  889. /deep/ .uni-radio-input-checked {
  890. background-color: #42b983 !important;
  891. border-color: #42b983 !important;
  892. }
  893. .goWorkSelect {
  894. &.history {
  895. height: 356rpx;
  896. padding-bottom: 16rpx;
  897. }
  898. &.combination {
  899. .goWorkSelect-head {
  900. position: fixed;
  901. top: 0;
  902. left: 0;
  903. width: 100%;
  904. }
  905. .goWorkSelect-list {
  906. margin-top: 82rpx;
  907. }
  908. }
  909. .goWorkSelect-head {
  910. font-size: 36rpx;
  911. padding: 16rpx 0;
  912. color: #42b983;
  913. border-bottom: 2rpx solid #42b983;
  914. text-align: center;
  915. }
  916. .goWorkSelect-list {
  917. &.scroll {
  918. height: calc(100vh - 356rpx - 82rpx);
  919. }
  920. .goWorkSelect-item {
  921. height: 52rpx;
  922. display: flex;
  923. align-items: center;
  924. border-bottom: 2rpx solid #e5e9ed;
  925. padding: 16rpx;
  926. button {
  927. font-size: 32rpx;
  928. height: 52rpx;
  929. line-height: 52rpx;
  930. margin: 0;
  931. margin-left: 16rpx;
  932. color: rgb(7, 134, 60);
  933. font-weight: 700;
  934. }
  935. }
  936. }
  937. }
  938. }
  939. .goWork {
  940. margin: 0 auto 48rpx;
  941. width: 240rpx;
  942. height: 240rpx;
  943. .goWork_btn_E {
  944. width: 100%;
  945. height: 100%;
  946. background: #bee1a7;
  947. border-radius: 30%;
  948. .goWork_btn_W {
  949. width: 75%;
  950. height: 75%;
  951. background-image: linear-gradient(to right, #72c172, #3bb197);
  952. border-radius: 30%;
  953. margin: 0 auto;
  954. position: relative;
  955. top: 12.5%;
  956. line-height: 180rpx;
  957. color: #fff;
  958. font-size: 36rpx;
  959. text-align: center;
  960. }
  961. }
  962. }
  963. .goWork_text {
  964. width: 100%;
  965. view {
  966. text-align: center;
  967. }
  968. .goWork_text-p {
  969. font-size: 36rpx;
  970. margin-bottom: 48rpx;
  971. }
  972. }
  973. .botImg {
  974. height: 600rpx;
  975. width: 100%;
  976. position: fixed;
  977. bottom: 0;
  978. .img {
  979. height: 100%;
  980. background: url("../../static/img/BG.png") no-repeat center center;
  981. background-size: 100% 100%;
  982. }
  983. }
  984. }
  985. </style>