mypage.vue 20 KB

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