homePage.vue 43 KB

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