mypage.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  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. this.tab("day", "今日");
  475. //图表
  476. this.cWidth = uni.upx2px(500);
  477. this.cHeight = uni.upx2px(500);
  478. // #ifdef APP-PLUS
  479. webHandle("no", "app");
  480. // #endif
  481. // #ifdef H5
  482. webHandle("no", "wx");
  483. // #endif
  484. },
  485. };
  486. </script>
  487. <style lang="less">
  488. .mypage {
  489. .charts {
  490. width: 625upx;
  491. height: 500upx;
  492. background-color: #ffffff;
  493. }
  494. .canvasRing_wrap {
  495. background-color: #ffffff;
  496. }
  497. #canvasRing {
  498. left: 50%;
  499. margin-left: -250rpx;
  500. }
  501. .myTop {
  502. height: 390rpx;
  503. background-image: url(../../static/img/BG_xiaban.png);
  504. background-repeat: no-repeat;
  505. background-size: 100% 100%;
  506. .goWork {
  507. margin: 0 auto 20rpx auto;
  508. padding-top: 30rpx;
  509. width: 240rpx;
  510. height: 240rpx;
  511. .goWork_btn_E {
  512. width: 100%;
  513. height: 100%;
  514. background: #bee1a7;
  515. border-radius: 30%;
  516. text-align: center;
  517. .goWork_btn_W {
  518. width: 75%;
  519. height: 75%;
  520. background-image: linear-gradient(to right, #72c172, #3bb197);
  521. border-radius: 30%;
  522. margin: 0 auto;
  523. /*水平居中*/
  524. position: relative;
  525. /*脱离文档流*/
  526. top: 12.5%;
  527. /*偏移*/
  528. line-height: 180rpx;
  529. color: #fff;
  530. font-size: 36rpx;
  531. }
  532. .goWork_btn_X {
  533. width: 75%;
  534. height: 75%;
  535. background-image: linear-gradient(to left, #72c172, #3bb197);
  536. border-radius: 30%;
  537. margin: 0 auto;
  538. /*水平居中*/
  539. position: relative;
  540. /*脱离文档流*/
  541. top: 12.5%;
  542. /*偏移*/
  543. line-height: 180rpx;
  544. color: #fff;
  545. font-size: 36rpx;
  546. }
  547. }
  548. }
  549. .topText {
  550. font-size: 36rpx;
  551. text-align: center;
  552. .topTextHeader {
  553. display: flex;
  554. justify-content: center;
  555. align-items: center;
  556. .changeHospital {
  557. margin-left: 16rpx;
  558. margin-right: 0;
  559. }
  560. }
  561. }
  562. }
  563. .myCont {
  564. .myCont_top {
  565. text-align: left;
  566. line-height: 90rpx;
  567. height: 90rpx;
  568. background: rgb(229, 233, 237);
  569. padding-left: 10rpx;
  570. padding-right: 10rpx;
  571. .myCont_topL {
  572. float: left;
  573. width: 60%;
  574. height: 100%;
  575. overflow: hidden;
  576. text-overflow: ellipsis;
  577. white-space: nowrap;
  578. }
  579. .myCont_topR {
  580. width: 35%;
  581. height: 100%;
  582. float: right;
  583. overflow: hidden;
  584. text-overflow: ellipsis;
  585. white-space: nowrap;
  586. }
  587. }
  588. .myCont_cont {
  589. .myCont_cont_tab {
  590. height: 90rpx;
  591. line-height: 90rpx;
  592. font-size: 32rpx;
  593. border-bottom: 4rpx solid rgb(229, 233, 237);
  594. view {
  595. float: left;
  596. width: 33%;
  597. height: 100%;
  598. text-align: center;
  599. }
  600. }
  601. .TB {
  602. position: relative;
  603. .TB_inner {
  604. display: flex;
  605. justify-content: space-between;
  606. align-items: center;
  607. background-color: #fff;
  608. margin-top: 26rpx;
  609. .tbTitle {
  610. width: 70%;
  611. font-size: 32rpx;
  612. color: rgb(72, 113, 127);
  613. font-weight: 500;
  614. margin-left: 10rpx;
  615. }
  616. .tbText {
  617. font-size: 32rpx;
  618. color: rgb(72, 113, 127);
  619. margin-right: 10rpx;
  620. }
  621. }
  622. }
  623. .TB1 {
  624. height: 200rpx;
  625. .title {
  626. text-align: left;
  627. font-size: 32rpx;
  628. color: rgb(72, 113, 127);
  629. font-weight: 500;
  630. margin-top: 26rpx;
  631. padding-left: 10rpx;
  632. }
  633. .cont {
  634. font-size: 36rpx;
  635. margin-top: 30rpx;
  636. text-align: center;
  637. }
  638. }
  639. .acts {
  640. color: rgb(73, 184, 86);
  641. border-bottom: 2rpx solid rgb(73, 184, 86);
  642. }
  643. .TB_list {
  644. width: 100%;
  645. text-align: left;
  646. view {
  647. height: 84rpx;
  648. line-height: 84rpx;
  649. border-bottom: 2rpx solid rgb(229, 233, 237);
  650. padding: 0 10rpx;
  651. font-size: 32rpx;
  652. .TB_list_L {
  653. float: left;
  654. }
  655. .TB_list_R {
  656. float: right;
  657. text {
  658. font-size: 28rpx;
  659. }
  660. }
  661. }
  662. }
  663. }
  664. }
  665. }
  666. </style>