homePage.vue 33 KB

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