homePage.vue 34 KB

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