mypage.vue 20 KB

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