mypage.vue 19 KB

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