mypage.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  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. }).then((res) => {
  268. uni.hideLoading();
  269. if (res.status == 200) {
  270. let obj = uni.getStorageSync("userData");
  271. obj.user.online = false;
  272. if (uni.getStorageSync("setDeptConfg")) {
  273. uni.removeStorageSync("setDeptConfg"); //清空选择的科室配置,初始化
  274. }
  275. if (uni.getStorageSync("setDepts")) {
  276. uni.removeStorageSync("setDepts"); //清空选择的科室,初始化
  277. }
  278. uni.setStorageSync("userData", obj);
  279. this.getCurrentUser();
  280. this.getTabData();
  281. } else {
  282. uni.showToast({
  283. icon: "none",
  284. title: "请求失败!",
  285. });
  286. }
  287. });
  288. } else {
  289. post("/auth/onOrOffLine", {
  290. type: "off"
  291. }).then((res) => {
  292. uni.hideLoading();
  293. if (res.status == 200) {
  294. if (uni.getStorageSync("setDeptConfg")) {
  295. uni.removeStorageSync("setDeptConfg"); //清空选择的科室配置,初始化
  296. }
  297. if (uni.getStorageSync("setDepts")) {
  298. uni.removeStorageSync("setDepts"); //清空选择的科室,初始化
  299. }
  300. let obj = uni.getStorageSync("userData");
  301. obj.user.online = false;
  302. uni.setStorageSync("userData", obj);
  303. this.getCurrentUser();
  304. this.getTabData();
  305. } else {
  306. uni.showToast({
  307. icon: "none",
  308. title: "请求失败!",
  309. });
  310. }
  311. });
  312. }
  313. } else {
  314. uni.hideLoading();
  315. uni.showToast({
  316. icon: "none",
  317. title: "请求失败!",
  318. });
  319. }
  320. });
  321. }
  322. },
  323. //上下班弹窗取消
  324. cancel() {
  325. this.models.disjunctor = false;
  326. },
  327. // 上下班
  328. async GoWork() {
  329. let types = "";
  330. let workingNum = 0;
  331. if (this.userData.online) {
  332. //有online为上班 传off
  333. this.type = "off";
  334. uni.showLoading({
  335. title: '加载中',
  336. mask: true
  337. });
  338. let workingNumResult = await this.getWorkingNum();
  339. uni.hideLoading();
  340. if (workingNumResult.status == 200) {
  341. workingNum = workingNumResult.data.data.length;
  342. }
  343. if (workingNum) {
  344. types = "您还<b style='color:red'>有未完成的工单</b>,确定下班后,<b style='color:red'>未完成工单将不计算积分。</b>";
  345. } else {
  346. types = "确定是否下班 ?";
  347. }
  348. } else {
  349. this.type = "on";
  350. types = "确定是否上班 ?";
  351. }
  352. this.models = {
  353. disjunctor: true,
  354. title: this.type == 'off' ? '下班提醒' : "上班提醒",
  355. content: types,
  356. icon: "warn",
  357. operate: {
  358. ok: "确定",
  359. cancel: "取消",
  360. },
  361. };
  362. },
  363. //环形图数据
  364. getBtData() {
  365. get("/api/countOrderTypesByDate/" + this.tabType).then((res) => {
  366. if (res.status == 200) {
  367. this.BtData = [];
  368. let color = [
  369. "#39B199",
  370. "#56BAB6",
  371. "#A4C4C1",
  372. "#48717F",
  373. "#07863C",
  374. "#BEE1A7",
  375. ];
  376. for (var i = 0; i < res.data.length; i++) {
  377. let data = {
  378. value: Number,
  379. name: "",
  380. itemStyle: {
  381. color: "",
  382. },
  383. };
  384. data.value = Number(res.data[i].num);
  385. data.percent = res.data[i].percent;
  386. data.name = res.data[i].name;
  387. data.itemStyle.color = color[i];
  388. this.BtData.push(data);
  389. }
  390. let Ring = {
  391. series: [],
  392. };
  393. let dataRing = res.data.map((item) => {
  394. return {
  395. name: item.name,
  396. data: item.num - 0,
  397. };
  398. });
  399. //这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
  400. Ring.series = dataRing;
  401. console.log(this.tabNums);
  402. if (this.tabNums > 0) {
  403. this.showRing("canvasRing", Ring);
  404. } else {
  405. this.TBLoading = false;
  406. uni.hideLoading();
  407. }
  408. } else {
  409. this.TBLoading = false;
  410. uni.hideLoading();
  411. uni.showToast({
  412. icon: "none",
  413. title: "请求失败!",
  414. });
  415. }
  416. });
  417. },
  418. //tab数据
  419. getTabData() {
  420. this.TBLoading = true;
  421. uni.showLoading({
  422. title: "加载中",
  423. mask: true,
  424. });
  425. get("/api/countOrderByDate").then((res) => {
  426. this.tabNum = res;
  427. if (this.tabType == "day") {
  428. this.tabNums = this.tabNum.day;
  429. this.tabComplete = this.tabNum.dayComplete;
  430. this.tabEvaluate = this.tabNum.dayEvaluate;
  431. this.tabScores = this.tabNum.dayTotal;
  432. }
  433. if (this.tabType == "week") {
  434. this.tabNums = this.tabNum.week;
  435. this.tabComplete = this.tabNum.weekComplete;
  436. this.tabEvaluate = this.tabNum.weekEvaluate;
  437. this.tabScores = this.tabNum.weekTotal;
  438. }
  439. if (this.tabType == "month") {
  440. this.tabNums = this.tabNum.month;
  441. this.tabComplete = this.tabNum.monthComplete;
  442. this.tabEvaluate = this.tabNum.monthEvaluate;
  443. this.tabScores = this.tabNum.monthTotal;
  444. }
  445. this.getBtData();
  446. });
  447. },
  448. // 本日,本周,本月
  449. tab(type, types) {
  450. this.types = types;
  451. this.tabType = type;
  452. this.getTabData();
  453. },
  454. // 获取当前用户信息
  455. getCurrentUser() {
  456. if (uni.getStorageSync("userData")) {
  457. this.userData = uni.getStorageSync("userData").user;
  458. } else {
  459. this.userData = {};
  460. }
  461. },
  462. },
  463. onLoad(options) {
  464. this.getCurrentUser();
  465. //#ifdef H5
  466. if (options.login == 1) {
  467. uni.redirectTo({
  468. url: "../homePage/homePage?type=mypage",
  469. });
  470. }
  471. //#endif
  472. this.tab("day", "今日");
  473. //图表
  474. this.cWidth = uni.upx2px(500);
  475. this.cHeight = uni.upx2px(500);
  476. // #ifdef APP-PLUS
  477. webHandle("no", "app");
  478. // #endif
  479. // #ifdef H5
  480. webHandle("no", "wx");
  481. // #endif
  482. },
  483. };
  484. </script>
  485. <style lang="less">
  486. .mypage {
  487. .charts {
  488. width: 625upx;
  489. height: 500upx;
  490. background-color: #ffffff;
  491. }
  492. .canvasRing_wrap {
  493. background-color: #ffffff;
  494. }
  495. #canvasRing {
  496. left: 50%;
  497. margin-left: -250rpx;
  498. }
  499. .myTop {
  500. height: 390rpx;
  501. background-image: url(../../static/img/BG_xiaban.png);
  502. background-repeat: no-repeat;
  503. background-size: 100% 100%;
  504. .goWork {
  505. margin: 0 auto 20rpx auto;
  506. padding-top: 30rpx;
  507. width: 240rpx;
  508. height: 240rpx;
  509. .goWork_btn_E {
  510. width: 100%;
  511. height: 100%;
  512. background: #bee1a7;
  513. border-radius: 30%;
  514. text-align: center;
  515. .goWork_btn_W {
  516. width: 75%;
  517. height: 75%;
  518. background-image: linear-gradient(to right, #72c172, #3bb197);
  519. border-radius: 30%;
  520. margin: 0 auto;
  521. /*水平居中*/
  522. position: relative;
  523. /*脱离文档流*/
  524. top: 12.5%;
  525. /*偏移*/
  526. line-height: 180rpx;
  527. color: #fff;
  528. font-size: 36rpx;
  529. }
  530. .goWork_btn_X {
  531. width: 75%;
  532. height: 75%;
  533. background-image: linear-gradient(to left, #72c172, #3bb197);
  534. border-radius: 30%;
  535. margin: 0 auto;
  536. /*水平居中*/
  537. position: relative;
  538. /*脱离文档流*/
  539. top: 12.5%;
  540. /*偏移*/
  541. line-height: 180rpx;
  542. color: #fff;
  543. font-size: 36rpx;
  544. }
  545. }
  546. }
  547. .topText {
  548. font-size: 36rpx;
  549. text-align: center;
  550. .topTextHeader {
  551. display: flex;
  552. justify-content: center;
  553. align-items: center;
  554. .changeHospital {
  555. margin-left: 16rpx;
  556. margin-right: 0;
  557. }
  558. }
  559. }
  560. }
  561. .myCont {
  562. .myCont_top {
  563. text-align: left;
  564. line-height: 90rpx;
  565. height: 90rpx;
  566. background: rgb(229, 233, 237);
  567. padding-left: 10rpx;
  568. padding-right: 10rpx;
  569. .myCont_topL {
  570. float: left;
  571. width: 60%;
  572. height: 100%;
  573. overflow: hidden;
  574. text-overflow: ellipsis;
  575. white-space: nowrap;
  576. }
  577. .myCont_topR {
  578. width: 35%;
  579. height: 100%;
  580. float: right;
  581. overflow: hidden;
  582. text-overflow: ellipsis;
  583. white-space: nowrap;
  584. }
  585. }
  586. .myCont_cont {
  587. .myCont_cont_tab {
  588. height: 90rpx;
  589. line-height: 90rpx;
  590. font-size: 32rpx;
  591. border-bottom: 4rpx solid rgb(229, 233, 237);
  592. view {
  593. float: left;
  594. width: 33%;
  595. height: 100%;
  596. text-align: center;
  597. }
  598. }
  599. .TB {
  600. position: relative;
  601. .TB_inner {
  602. display: flex;
  603. justify-content: space-between;
  604. align-items: center;
  605. background-color: #fff;
  606. margin-top: 26rpx;
  607. .tbTitle {
  608. width: 70%;
  609. font-size: 32rpx;
  610. color: rgb(72, 113, 127);
  611. font-weight: 500;
  612. margin-left: 10rpx;
  613. }
  614. .tbText {
  615. font-size: 32rpx;
  616. color: rgb(72, 113, 127);
  617. margin-right: 10rpx;
  618. }
  619. }
  620. }
  621. .TB1 {
  622. height: 200rpx;
  623. .title {
  624. text-align: left;
  625. font-size: 32rpx;
  626. color: rgb(72, 113, 127);
  627. font-weight: 500;
  628. margin-top: 26rpx;
  629. padding-left: 10rpx;
  630. }
  631. .cont {
  632. font-size: 36rpx;
  633. margin-top: 30rpx;
  634. text-align: center;
  635. }
  636. }
  637. .acts {
  638. color: rgb(73, 184, 86);
  639. border-bottom: 2rpx solid rgb(73, 184, 86);
  640. }
  641. .TB_list {
  642. width: 100%;
  643. text-align: left;
  644. view {
  645. height: 84rpx;
  646. line-height: 84rpx;
  647. border-bottom: 2rpx solid rgb(229, 233, 237);
  648. padding: 0 10rpx;
  649. font-size: 32rpx;
  650. .TB_list_L {
  651. float: left;
  652. }
  653. .TB_list_R {
  654. float: right;
  655. text {
  656. font-size: 28rpx;
  657. }
  658. }
  659. }
  660. }
  661. }
  662. }
  663. }
  664. </style>