mypage.vue 21 KB

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