mypage.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. <template>
  2. <view class="mypage">
  3. <view class="myTop">
  4. <view class="topText">
  5. <view class="topTextHeader">
  6. <view class="text">
  7. <view>
  8. 您好,{{ userData.name }}
  9. </view>
  10. <view>{{userData.currentHospital.hosName}}</view>
  11. </view>
  12. <!-- <button v-show="!userData.online" class="changeHospital" size="mini" type="default" @click="changeHospital">
  13. 切换院区
  14. </button> -->
  15. <view class="goWork_btn_E">
  16. <view class="goWork_btn_W" v-show="userData.online">
  17. <text class="left-icon newicon newicon-xiuxizhong"></text>
  18. <text class="state">工作中</text>
  19. </view>
  20. <view class="goWork_btn_X" v-show="!userData.online">
  21. <text class="left-icon newicon newicon-gongzuozhong"></text>
  22. <text class="state">休息中</text>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- <view>当前积分 : {{ tabNum.score }}</view> -->
  27. </view>
  28. <!-- <view class="goWork" @click="GoWork()">
  29. <view class="goWork_btn_E">
  30. <view class="goWork_btn_W" v-show="userData.online"> 下班 </view>
  31. <view class="goWork_btn_X" v-show="!userData.online"> 上班 </view>
  32. </view>
  33. </view> -->
  34. </view>
  35. <view class="myCont">
  36. <view class="myCont_cont">
  37. <view class="myCont_cont_tab">
  38. <view style="border-right: 1px solid rgb(229, 233, 237)" @click="tab('day', '今日')"
  39. :class="{ acts: tabType == 'day' }">
  40. 今日 ({{ tabNum.day || 0 }})
  41. </view>
  42. <view style="border-right: 1px solid rgb(229, 233, 237)" @click="tab('week', '本周')"
  43. :class="{ acts: tabType == 'week' }">
  44. 本周 ({{ tabNum.week || 0 }})
  45. </view>
  46. <view @click="tab('month', '本月')" :class="{ acts: tabType == 'month' }">
  47. 本月 ({{ tabNum.month || 0 }})
  48. </view>
  49. </view>
  50. <view class="TB" v-show="tabNums > 0 && !TBLoading">
  51. <view class="TB_inner" style="
  52. display: flex;
  53. align-items: center;
  54. justify-content: space-between;
  55. ">
  56. <view class="tbTitle">
  57. {{ types }}已完成工单{{ tabNums }}单,未评价工单{{
  58. tabEvaluate
  59. }}单,共计得分{{ tabScores }}分
  60. </view>
  61. <view class="tbText" @click="my_list(tabType)"> 查看明细>> </view>
  62. </view>
  63. <view class="canvasRing_wrap">
  64. <canvas ref="canvasRef" canvas-id="canvasRing" id="canvasRing" class="charts"
  65. @touchstart="touchRing"></canvas>
  66. </view>
  67. </view>
  68. <view class="TB1" v-show="tabNums == 0 && !TBLoading">
  69. <view class="title">
  70. {{ types }}已完成工单{{ tabComplete }}单,未评价工单{{
  71. tabEvaluate
  72. }}单,共计得分{{ tabScores }}分
  73. </view>
  74. <view class="cont"> 暂无数据 </view>
  75. </view>
  76. <view class="TB_list" v-show="!TBLoading">
  77. <view v-for="(data, i) of BtData" :key="i">
  78. <view class="TB_list_L">
  79. {{ data.name }}
  80. </view>
  81. <view class="TB_list_R">
  82. {{ data.value }}单
  83. <text :style="{ color: data.itemStyle.color }">{{
  84. data.percent
  85. }}</text>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. <view v-if="!userData.online" class="df-fl">
  92. <view class="page_item_btn width-50" hover-class="seimin-btn-hover" @click="changeHospital">切换院区</view>
  93. <view class="page_item_btn width-50" hover-class="seimin-btn-hover" @click="GoWork()">继续工作</view>
  94. </view>
  95. <view v-if="userData.online">
  96. <view class="page_item_btn width-100" hover-class="seimin-btn-hover" @click="GoWork()">我要下班</view>
  97. </view>
  98. <!-- 弹窗 -->
  99. <showModel :title="models.title" :icon="models.icon" :disjunctor="models.disjunctor" :content="models.content"
  100. @ok="ok" @cancel="cancel" :operate="models.operate"></showModel>
  101. <!-- 切换院区弹窗 -->
  102. <changeHospital v-if="hosModels.disjunctor" :title="hosModels.title" :disjunctor="hosModels.disjunctor" @ok="hosOk"
  103. @cancel="hosCancel">
  104. </changeHospital>
  105. </view>
  106. </template>
  107. <script>
  108. import showModel from "../../components/showModel/showModel.vue";
  109. import changeHospital from "../../components/changeHospital/changeHospital.vue";
  110. // http://doc.ucharts.cn/1172177
  111. import uCharts from "../../js_sdk/u-charts/u-charts/u-charts.js";
  112. import {
  113. get,
  114. post,
  115. webHandle
  116. } from "../../http/http.js";
  117. export default {
  118. data() {
  119. return {
  120. // 弹窗model
  121. models: {
  122. disjunctor: false,
  123. },
  124. // 切换院区弹窗model
  125. hosModels: {
  126. disjunctor: false,
  127. },
  128. type: "",
  129. tabType: "day",
  130. tabNum: {},
  131. BtData: [],
  132. types: "今日",
  133. tabNums: "", //总数量
  134. tabComplete: "", //已完成工单数量
  135. tabEvaluate: "", //未评价工单数量
  136. tabScores: "", //积分
  137. sxbType: false,
  138. userData: {},
  139. // 图表数据
  140. cWidth: "",
  141. cHeight: "",
  142. pixelRatio: 1,
  143. serverData: "",
  144. canvaRing: null,
  145. TBLoading: false,
  146. };
  147. },
  148. components: {
  149. showModel,
  150. changeHospital,
  151. },
  152. methods: {
  153. // 切换院区-确认
  154. hosOk(hosId) {
  155. let userData = uni.getStorageSync("userData");
  156. this.hosModels.disjunctor = false;
  157. if(userData.user.currentHospital.id == hosId){
  158. return;
  159. }
  160. uni.showLoading({
  161. title: "正在加载中",
  162. mask: true,
  163. });
  164. let type = "";
  165. // #ifdef APP-PLUS
  166. type = "APP";
  167. // #endif
  168. // #ifdef H5
  169. type = "Wechat";
  170. // #endif
  171. post("/auth/changeHospital", {
  172. currentHosId: hosId,
  173. loginType: type,
  174. }).then((result) => {
  175. uni.hideLoading();
  176. if (result.status == 200) {
  177. uni.showToast({
  178. icon: "success",
  179. title: "切换院区成功",
  180. });
  181. console.log(userData);
  182. userData.user.currentHospital = result.user.user.currentHospital;
  183. uni.setStorageSync("userData", userData);
  184. this.tab("day", "今日");
  185. setTimeout(_=>{
  186. this.userData = uni.getStorageSync("userData").user;
  187. })
  188. } else {
  189. uni.showToast({
  190. icon: "none",
  191. title: "切换院区失败",
  192. });
  193. }
  194. });
  195. },
  196. // 切换院区-取消
  197. hosCancel() {
  198. this.hosModels.disjunctor = false;
  199. },
  200. // 切换院区
  201. changeHospital() {
  202. this.hosModels = {
  203. title: "切换院区",
  204. disjunctor: true,
  205. };
  206. },
  207. // 绘图
  208. showRing(canvasId, chartData) {
  209. this.canvaRing = new uCharts({
  210. $this: this,
  211. canvasId: canvasId,
  212. type: "ring",
  213. fontSize: 11,
  214. padding: [5, 5, 5, 5],
  215. legend: {
  216. show: false, //右侧描述
  217. position: "right",
  218. float: "center",
  219. itemGap: 10,
  220. padding: 5,
  221. lineHeight: 26,
  222. margin: 5,
  223. borderWidth: 1,
  224. },
  225. background: "#FFFFFF",
  226. pixelRatio: this.pixelRatio,
  227. series: chartData.series,
  228. animation: true,
  229. width: this.cWidth * this.pixelRatio,
  230. height: this.cHeight * this.pixelRatio,
  231. disablePieStroke: true,
  232. dataLabel: false, //折线描述
  233. subtitle: {
  234. name: "",
  235. color: "#7cb5ec",
  236. fontSize: 25 * this.pixelRatio,
  237. },
  238. title: {
  239. name: "",
  240. color: "#666666",
  241. fontSize: 15 * this.pixelRatio,
  242. },
  243. extra: {
  244. pie: {
  245. offsetAngle: 0,
  246. ringWidth: 28 * this.pixelRatio,
  247. labelWidth: 15,
  248. },
  249. },
  250. });
  251. this.TBLoading = false;
  252. uni.hideLoading();
  253. },
  254. touchRing(e) {
  255. this.canvaRing.touchLegend(e, {
  256. animation: false,
  257. });
  258. this.canvaRing.showToolTip(e, {
  259. format: function(item) {
  260. return item.name + ":" + item.data;
  261. },
  262. });
  263. },
  264. // 查看明细
  265. my_list(type) {
  266. uni.navigateTo({
  267. url: `../my_list/my_list?type=${type}`,
  268. });
  269. },
  270. // 获取启动中的工作分配方案
  271. getWorkSchemeAndRule() {
  272. return post("/auth/getUserWorkDept", {});
  273. },
  274. // 获取执行中列表
  275. getWorkingNum() {
  276. return post("/workerOrder/executingOrders", {
  277. idx: 0,
  278. sum: 1,
  279. });
  280. },
  281. // 自选排班下班
  282. customOff() {
  283. post("/auth/onOrOffLine", {
  284. type: "off",
  285. customWorking: "off",
  286. classId: uni.getStorageSync("setDeptConfg").classesId,
  287. }).then((res) => {
  288. uni.hideLoading();
  289. if (res.status == 200) {
  290. let obj = uni.getStorageSync("userData");
  291. obj.user.online = false;
  292. if (uni.getStorageSync("setDeptConfg")) {
  293. uni.removeStorageSync("setDeptConfg"); //清空选择的科室配置,初始化
  294. }
  295. if (uni.getStorageSync("setDepts")) {
  296. uni.removeStorageSync("setDepts"); //清空选择的科室,初始化
  297. }
  298. if (uni.getStorageSync("manager")) {
  299. uni.removeStorageSync("manager"); //清空选择的分组组长,初始化
  300. }
  301. uni.setStorageSync("userData", obj);
  302. this.getCurrentUser();
  303. this.getTabData();
  304. } else {
  305. uni.showToast({
  306. icon: "none",
  307. title: res.msg || "接口获取数据失败!",
  308. });
  309. }
  310. });
  311. },
  312. //上下班弹窗确定
  313. ok() {
  314. this.models.disjunctor = false;
  315. let setDeptConfg = uni.getStorageSync("setDeptConfg");
  316. if (this.type == "on") {
  317. uni.redirectTo({
  318. url: `../homePage/homePage`,
  319. });
  320. } else if (this.type == "off") {
  321. uni.showLoading({
  322. title: "加载中",
  323. mask: true,
  324. });
  325. // 判断当前启用的工作方案是自主还是综合排班
  326. this.getWorkSchemeAndRule().then((ress) => {
  327. if (ress.status == 200) {
  328. let workType = ress.settings ? ress.settings.workType : -1; //1是综合,2是自主
  329. // 自主下班,并且是科室绑定人员,科室绑定分组,绑定分组
  330. if (workType == 2) {
  331. this.customOff();
  332. } else {
  333. post("/auth/onOrOffLine", {
  334. type: "off",
  335. classId: uni.getStorageSync("setDeptConfg").classesId,
  336. }).then((res) => {
  337. uni.hideLoading();
  338. if (res.status == 200) {
  339. if (uni.getStorageSync("setDeptConfg")) {
  340. uni.removeStorageSync("setDeptConfg"); //清空选择的科室配置,初始化
  341. }
  342. if (uni.getStorageSync("setDepts")) {
  343. uni.removeStorageSync("setDepts"); //清空选择的科室,初始化
  344. }
  345. if (uni.getStorageSync("manager")) {
  346. uni.removeStorageSync("manager"); //清空选择的分组组长,初始化
  347. }
  348. let obj = uni.getStorageSync("userData");
  349. obj.user.online = false;
  350. uni.setStorageSync("userData", obj);
  351. this.getCurrentUser();
  352. this.getTabData();
  353. } else {
  354. uni.showToast({
  355. icon: "none",
  356. title: res.msg || "接口获取数据失败!",
  357. });
  358. }
  359. });
  360. }
  361. } else if (ress.status == 500) {
  362. //500的时候自选下班
  363. this.customOff();
  364. } else {
  365. uni.hideLoading();
  366. uni.showToast({
  367. icon: "none",
  368. title: ress.msg || "接口获取数据失败!",
  369. });
  370. }
  371. });
  372. }
  373. },
  374. //上下班弹窗取消
  375. cancel() {
  376. this.models.disjunctor = false;
  377. },
  378. // 上下班
  379. async GoWork() {
  380. let types = "";
  381. let workingNum = 0;
  382. if (this.userData.online) {
  383. //有online为上班 传off
  384. this.type = "off";
  385. uni.showLoading({
  386. title: "加载中",
  387. mask: true,
  388. });
  389. let workingNumResult = await this.getWorkingNum();
  390. uni.hideLoading();
  391. if (workingNumResult.status == 200) {
  392. workingNum = workingNumResult.data.data.length;
  393. }
  394. if (workingNum) {
  395. types =
  396. "您还<b style='color:red'>有未完成的工单</b>,确定下班后,<b style='color:red'>未完成工单将不计算积分。</b>";
  397. } else {
  398. types = "确定是否下班 ?";
  399. }
  400. } else {
  401. this.type = "on";
  402. types = "确定是否上班 ?";
  403. }
  404. this.models = {
  405. disjunctor: true,
  406. title: this.type == "off" ? "下班提醒" : "上班提醒",
  407. content: types,
  408. icon: "warn",
  409. operate: {
  410. ok: "确定",
  411. cancel: "取消",
  412. },
  413. };
  414. },
  415. //环形图数据
  416. getBtData() {
  417. get("/api/countOrderTypesByDate/" + this.tabType).then((res) => {
  418. if (res.status == 200) {
  419. this.BtData = [];
  420. let color = [
  421. "#39B199",
  422. "#56BAB6",
  423. "#A4C4C1",
  424. "#48717F",
  425. "#07863C",
  426. "#BEE1A7",
  427. ];
  428. for (var i = 0; i < res.data.length; i++) {
  429. let data = {
  430. value: Number,
  431. name: "",
  432. itemStyle: {
  433. color: "",
  434. },
  435. };
  436. data.value = Number(res.data[i].num);
  437. data.percent = res.data[i].percent;
  438. data.name = res.data[i].name;
  439. data.itemStyle.color = color[i];
  440. this.BtData.push(data);
  441. }
  442. let Ring = {
  443. series: [],
  444. };
  445. let dataRing = res.data.map((item) => {
  446. return {
  447. name: item.name,
  448. data: item.num - 0,
  449. };
  450. });
  451. //这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
  452. Ring.series = dataRing;
  453. console.log(this.tabNums);
  454. if (this.tabNums > 0) {
  455. this.showRing("canvasRing", Ring);
  456. } else {
  457. this.TBLoading = false;
  458. uni.hideLoading();
  459. }
  460. } else {
  461. this.TBLoading = false;
  462. uni.hideLoading();
  463. uni.showToast({
  464. icon: "none",
  465. title: res.msg || "接口获取数据失败!",
  466. });
  467. }
  468. });
  469. },
  470. //tab数据
  471. getTabData() {
  472. this.TBLoading = true;
  473. uni.showLoading({
  474. title: "加载中",
  475. mask: true,
  476. });
  477. get("/api/countOrderByDate").then((res) => {
  478. this.tabNum = res;
  479. if (this.tabType == "day") {
  480. this.tabNums = this.tabNum.day;
  481. this.tabComplete = this.tabNum.dayComplete;
  482. this.tabEvaluate = this.tabNum.dayEvaluate;
  483. this.tabScores = this.tabNum.dayTotal;
  484. }
  485. if (this.tabType == "week") {
  486. this.tabNums = this.tabNum.week;
  487. this.tabComplete = this.tabNum.weekComplete;
  488. this.tabEvaluate = this.tabNum.weekEvaluate;
  489. this.tabScores = this.tabNum.weekTotal;
  490. }
  491. if (this.tabType == "month") {
  492. this.tabNums = this.tabNum.month;
  493. this.tabComplete = this.tabNum.monthComplete;
  494. this.tabEvaluate = this.tabNum.monthEvaluate;
  495. this.tabScores = this.tabNum.monthTotal;
  496. }
  497. this.getBtData();
  498. });
  499. },
  500. // 本日,本周,本月
  501. tab(type, types) {
  502. this.types = types;
  503. this.tabType = type;
  504. this.getTabData();
  505. },
  506. // 获取当前用户信息
  507. getCurrentUser() {
  508. if (uni.getStorageSync("userData")) {
  509. this.userData = uni.getStorageSync("userData").user;
  510. } else {
  511. this.userData = {};
  512. }
  513. },
  514. },
  515. onLoad(options) {
  516. this.getCurrentUser();
  517. //#ifdef H5
  518. if (options.login == 1) {
  519. uni.redirectTo({
  520. url: "../homePage/homePage?type=mypage",
  521. });
  522. }
  523. //#endif
  524. if (options.login != 1) {
  525. this.tab("day", "今日");
  526. }
  527. //图表
  528. this.cWidth = uni.upx2px(500);
  529. this.cHeight = uni.upx2px(500);
  530. // #ifdef APP-PLUS
  531. webHandle("no", "app");
  532. // #endif
  533. // #ifdef H5
  534. webHandle("no", "wx");
  535. // #endif
  536. },
  537. };
  538. </script>
  539. <style lang="less">
  540. .mypage {
  541. padding: 20rpx;
  542. background: #F0F6ED;
  543. position: relative;
  544. .charts {
  545. width: 625upx;
  546. height: 500upx;
  547. background-color: #ffffff;
  548. }
  549. .canvasRing_wrap {
  550. background-color: #ffffff;
  551. }
  552. #canvasRing {
  553. left: 50%;
  554. margin-left: -250rpx;
  555. }
  556. .myTop {
  557. height: 160rpx;
  558. background: #fff;
  559. border-radius: 8rpx;
  560. padding: 40rpx;
  561. .goWork_btn_E {
  562. text-align: center;
  563. margin-top: 70rpx;
  564. font-weight: bold;
  565. .state{
  566. margin-left: 8rpx;
  567. }
  568. .newicon{
  569. font-size: 42rpx !important;
  570. }
  571. .goWork_btn_W {
  572. color: #FFBA30;
  573. font-size: 40rpx;
  574. }
  575. .goWork_btn_X {
  576. color: #64BD7B;
  577. font-size: 40rpx;
  578. }
  579. }
  580. .topText {
  581. .topTextHeader {
  582. .text{
  583. display: flex;
  584. justify-content: space-between;
  585. font-size: 30rpx;
  586. font-weight: bold;
  587. }
  588. .changeHospital {
  589. margin-left: 16rpx;
  590. margin-right: 0;
  591. }
  592. }
  593. }
  594. }
  595. .myCont {
  596. background: #fff;
  597. margin-top: 20rpx;
  598. border-radius: 8rpx;
  599. .myCont_top {
  600. text-align: left;
  601. line-height: 90rpx;
  602. height: 90rpx;
  603. background: rgb(229, 233, 237);
  604. padding-left: 10rpx;
  605. padding-right: 10rpx;
  606. .myCont_topL {
  607. float: left;
  608. width: 60%;
  609. height: 100%;
  610. overflow: hidden;
  611. text-overflow: ellipsis;
  612. white-space: nowrap;
  613. }
  614. .myCont_topR {
  615. width: 35%;
  616. height: 100%;
  617. float: right;
  618. overflow: hidden;
  619. text-overflow: ellipsis;
  620. white-space: nowrap;
  621. }
  622. }
  623. .myCont_cont {
  624. height: calc(100vh - 410rpx);
  625. overflow-y: auto;
  626. overflow-x: hidden;
  627. margin-bottom: 20rpx;
  628. .myCont_cont_tab {
  629. height: 90rpx;
  630. line-height: 90rpx;
  631. font-size: 32rpx;
  632. border-bottom: 4rpx solid rgb(229, 233, 237);
  633. view {
  634. float: left;
  635. width: 33%;
  636. height: 100%;
  637. text-align: center;
  638. }
  639. }
  640. .TB {
  641. position: relative;
  642. .TB_inner {
  643. display: flex;
  644. justify-content: space-between;
  645. align-items: center;
  646. background-color: #fff;
  647. margin-top: 26rpx;
  648. .tbTitle {
  649. width: 70%;
  650. font-size: 32rpx;
  651. color: rgb(72, 113, 127);
  652. font-weight: 500;
  653. margin-left: 10rpx;
  654. }
  655. .tbText {
  656. font-size: 32rpx;
  657. color: rgb(72, 113, 127);
  658. margin-right: 10rpx;
  659. }
  660. }
  661. }
  662. .TB1 {
  663. height: 180rpx;
  664. .title {
  665. text-align: left;
  666. font-size: 32rpx;
  667. color: rgb(72, 113, 127);
  668. font-weight: 500;
  669. margin-top: 26rpx;
  670. padding-left: 10rpx;
  671. }
  672. .cont {
  673. font-size: 36rpx;
  674. margin-top: 30rpx;
  675. text-align: center;
  676. }
  677. }
  678. .acts {
  679. color: rgb(73, 184, 86);
  680. border-bottom: 2rpx solid rgb(73, 184, 86);
  681. }
  682. .TB_list {
  683. width: 100%;
  684. text-align: left;
  685. view {
  686. height: 84rpx;
  687. line-height: 84rpx;
  688. border-bottom: 2rpx solid rgb(229, 233, 237);
  689. padding: 0 10rpx;
  690. font-size: 32rpx;
  691. .TB_list_L {
  692. float: left;
  693. }
  694. .TB_list_R {
  695. float: right;
  696. text {
  697. font-size: 28rpx;
  698. }
  699. }
  700. }
  701. }
  702. }
  703. }
  704. .df-fl{
  705. display: flex;
  706. justify-content: space-between;
  707. }
  708. .page_item_btn {
  709. // position: fixed;
  710. height: 88rpx;
  711. background-image: linear-gradient(to right, #72c172, #3bb197);
  712. border-radius: 8rpx;
  713. line-height: 88rpx;
  714. color: #fff;
  715. font-size: 36rpx;
  716. font-weight: 700;
  717. text-align: center;
  718. }
  719. .width-50{
  720. width: 48%;
  721. }
  722. .width-100{
  723. width: 100%;
  724. }
  725. }
  726. </style>