user-appoint-record.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. <template>
  2. <div>
  3. <el-card>
  4. <div class="toolbar-wrap">
  5. <div class="switch-date">
  6. <div
  7. class="btn day"
  8. :class="curSelectedDate == 'd' ? 'actived' : ''"
  9. @click="selectDate('d')"
  10. >
  11. </div>
  12. <div
  13. class="btn week"
  14. :class="curSelectedDate == 'w' ? 'actived' : ''"
  15. @click="selectDate('w')"
  16. >
  17. </div>
  18. <div
  19. class="btn month"
  20. :class="curSelectedDate == 'm' ? 'actived' : ''"
  21. @click="selectDate('m')"
  22. >
  23. </div>
  24. </div>
  25. <div class="date-wrap">
  26. <div class="prev" @click="handlePrev">
  27. <el-button icon="el-icon-arrow-left" size="small" circle />
  28. </div>
  29. <div class="date">
  30. <el-popover :width="200" placement="top-start" trigger="click">
  31. <div slot="reference">
  32. <span class="time">{{ curTime }}</span>
  33. </div>
  34. <el-date-picker
  35. @change="getAppointList"
  36. style="width: 100%"
  37. v-model="curTime"
  38. type="date"
  39. placeholder="选择日期"
  40. value-format="yyyy-MM-dd"
  41. :clearable="false"
  42. />
  43. </el-popover>
  44. <span class="week">{{ WEEKS[moment(curTime).day()] }}</span>
  45. </div>
  46. <div class="next" @click="handleNext">
  47. <el-button icon="el-icon-arrow-right" size="small" circle />
  48. </div>
  49. </div>
  50. </div>
  51. <div class="table-wrap">
  52. <el-table :data="appointData" border height="500" style="width: 922px">
  53. <el-table-column
  54. type="index"
  55. width="50"
  56. align="center"
  57. ></el-table-column>
  58. <el-table-column prop="instName" label="仪器名称" min-width="160" />
  59. <el-table-column
  60. prop="projectName"
  61. label="课题组/服务"
  62. min-width="160"
  63. >
  64. <template #default="{ row }">
  65. <span v-if="row.projectName">{{ row.projectName }}</span>
  66. <span v-else>{{ row.serviceName }}</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column prop="startTime" label="开始时间" width="160">
  70. <template #default="{ row }">
  71. {{ parseTime(row.startTime, "{y}-{m}-{d}") }}
  72. </template>
  73. </el-table-column>
  74. <el-table-column prop="endTime" label="结束时间" width="160">
  75. <template #default="{ row }">
  76. {{ parseTime(row.endTime, "{y}-{m}-{d}") }}
  77. </template>
  78. </el-table-column>
  79. <el-table-column prop="userName" label="预约人" width="140" />
  80. <el-table-column prop="userContact" label="联系方式" width="160" />
  81. <el-table-column prop="appointStatus" label="预约状态" width="160">
  82. <template #default="{ row }">
  83. {{ setStatus(row.appointStatus) }}
  84. </template>
  85. </el-table-column>
  86. <el-table-column prop="appointStatus" label="违约情况" width="160">
  87. <template #default="{ row }">
  88. {{ getBreachTypes(row) }}
  89. </template>
  90. </el-table-column>
  91. <el-table-column prop="breachScore" label="扣分明细" width="160">
  92. <template #default="{ row }">
  93. <span>{{ row.breachScore }}分</span>
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="操作" fixed="right" width="160">
  97. <template #default="{ row }">
  98. <el-button
  99. type="primary"
  100. v-if="row.appointStatus == '10'"
  101. @click="editAppoint(row)"
  102. text
  103. >
  104. 编辑
  105. </el-button>
  106. <el-button
  107. type="danger"
  108. v-if="showCancelBtn(row)"
  109. @click="cancelAppoint(row)"
  110. text
  111. >
  112. 取消
  113. </el-button>
  114. </template>
  115. </el-table-column>
  116. </el-table>
  117. </div>
  118. </el-card>
  119. </div>
  120. </template>
  121. <script>
  122. import { userCancelAppoint, cancelAppoint } from "@/api/instr";
  123. import moment from "moment";
  124. import to from "await-to-js";
  125. export default {
  126. name: "UserAppointRecord",
  127. data() {
  128. return {
  129. curSelectedDate: "",
  130. };
  131. },
  132. mounted() {
  133. this.tabSelect(this.options[0], 0);
  134. this.curTime = this.getToday();
  135. this.initChart();
  136. this.getNotice();
  137. this.getInstr();
  138. },
  139. methods: {
  140. moment,
  141. // 獲取當前日期
  142. getToday() {
  143. return moment(moment().startOf("day").valueOf()).format("YYYY-MM-DD");
  144. },
  145. getYesterday() {
  146. this.curTime = moment(
  147. moment(this.curTime).add(-1, "days").startOf("day").valueOf()
  148. ).format("YYYY-MM-DD");
  149. },
  150. getTomorrow() {
  151. this.curTime = moment(
  152. moment(this.curTime).add(+1, "days").startOf("day").valueOf()
  153. ).format("YYYY-MM-DD");
  154. },
  155. getPrevWeekDays() {
  156. this.curTime = moment(this.curTime)
  157. .subtract(1, "week")
  158. .format("YYYY-MM-DD");
  159. },
  160. getNextWeekDays() {
  161. this.curTime = moment(this.curTime).add(1, "week").format("YYYY-MM-DD");
  162. },
  163. getPrevMonthDays() {
  164. this.curTime = moment(this.curTime)
  165. .subtract(1, "months")
  166. .format("YYYY-MM-DD");
  167. },
  168. getNextMonthDays() {
  169. this.curTime = moment(this.curTime)
  170. .add(1, "months")
  171. .format("YYYY-MM-DD");
  172. },
  173. getWeekDate() {
  174. // 获取当前周的周一0点
  175. var startOfWeek = moment(this.curTime)
  176. .startOf("isoWeek")
  177. .format("YYYY-MM-DD HH:mm:ss");
  178. // 获取下一周的周一0点
  179. var startOfNextWeek = moment(this.curTime)
  180. .startOf("isoWeek")
  181. .add(1, "weeks")
  182. .format("YYYY-MM-DD HH:mm:ss");
  183. return [startOfWeek, startOfNextWeek];
  184. },
  185. getMonthDate() {
  186. const date = moment(this.curTime);
  187. // 获取当前月份的最后一天
  188. return [
  189. date.startOf("month").format("YYYY-MM-DD HH:mm:ss"),
  190. date.endOf("month").add(1, "days").format("YYYY-MM-DD") + " 00:00:00",
  191. ];
  192. },
  193. // 上一周、天、月
  194. handlePrev() {
  195. if (this.curSelectedDate == "d") {
  196. this.getYesterday();
  197. } else if (this.curSelectedDate == "w") {
  198. this.getPrevWeekDays();
  199. } else if (this.curSelectedDate == "m") {
  200. this.getPrevMonthDays();
  201. }
  202. this.getAppointList();
  203. },
  204. // 下一周、天、月
  205. handleNext() {
  206. if (this.curSelectedDate == "d") {
  207. this.getTomorrow();
  208. } else if (this.curSelectedDate == "w") {
  209. this.getNextWeekDays();
  210. } else if (this.curSelectedDate == "m") {
  211. this.getNextMonthDays();
  212. }
  213. this.getAppointList();
  214. },
  215. selectDate(date) {
  216. this.curSelectedDate = date;
  217. this.getAppointList();
  218. },
  219. async getAppointList() {
  220. let startTimeStart = "";
  221. let startTimeEnd = "";
  222. if (this.curSelectedDate == "d") {
  223. startTimeStart = moment(this.curTime).format("YYYY-MM-DD HH:mm:ss");
  224. startTimeEnd = moment(this.curTime)
  225. .add(1, "days")
  226. .format("YYYY-MM-DD HH:mm:ss");
  227. } else if (this.curSelectedDate == "w") {
  228. startTimeStart = this.getWeekDate()[0];
  229. startTimeEnd = this.getWeekDate()[1];
  230. } else if (this.curSelectedDate == "m") {
  231. startTimeStart = moment(this.curTime)
  232. .startOf("month")
  233. .format("YYYY-MM-DD HH:mm:ss");
  234. startTimeEnd = this.getMonthDate()[1];
  235. }
  236. const [err, res] = await to(
  237. getInstrListByUser({ startTimeStart, startTimeEnd })
  238. );
  239. if (err) return;
  240. this.appointData = res.data.list;
  241. },
  242. setStatus(key) {
  243. let str = "";
  244. switch (key) {
  245. case "10":
  246. str = "待审核";
  247. break;
  248. case "11":
  249. str = "已退回";
  250. break;
  251. case "20":
  252. str = "已通过";
  253. break;
  254. case "30":
  255. str = "已驳回";
  256. break;
  257. case "40":
  258. str = "已取消";
  259. break;
  260. case "50":
  261. str = "已上机";
  262. break;
  263. case "60":
  264. str = "已完成";
  265. break;
  266. case "70":
  267. str = "审核超时";
  268. break;
  269. case "80":
  270. str = "超时取消";
  271. break;
  272. case "90":
  273. str = "超时未上机";
  274. break;
  275. }
  276. return str;
  277. },
  278. getBreachTypes(row) {
  279. let breachTypes = [];
  280. if (row.isLate) breachTypes.push("迟到");
  281. if (row.isOvertime) breachTypes.push("超时");
  282. if (row.isLeaveEarly) breachTypes.push("早退");
  283. if (row.isAbsence) breachTypes.push("爽约");
  284. return breachTypes.join("、") || "-";
  285. },
  286. cancelAppoint(row) {
  287. // 删除附件
  288. this.$confirm("确认取消预约?", "提示", {
  289. confirmButtonText: "确认",
  290. cancelButtonText: "取消",
  291. type: "warning",
  292. })
  293. .then(async () => {
  294. const post =
  295. row.userId == props.curUserId
  296. ? userCancelAppoint({ id: Number(row.id) })
  297. : cancelAppoint({ id: Number(row.id) });
  298. const [err] = await to(post);
  299. if (err) return;
  300. this.$message.success("取消成功");
  301. this.getAppointList();
  302. })
  303. .catch(() => {});
  304. },
  305. editAppoint() {},
  306. // 选择tab
  307. tabSelect(row, index) {
  308. this.active = index;
  309. this.selectTab = { ...row };
  310. this.breadList = [...this.routeList, { name: this.selectTab.label }];
  311. },
  312. async getNotice() {
  313. const [err, res] = await to(getNoticeList());
  314. if (err) return;
  315. this.noticeList = res.data.list || [];
  316. },
  317. async getInstr() {
  318. const [err, res] = await to(getInstrList({ pageSize: 4, pageNum: 1 }));
  319. if (err) return;
  320. this.instrList = res.data.list || [];
  321. },
  322. initChart() {
  323. let chart = echarts.init(document.getElementById("chart"));
  324. const options = {
  325. series: [
  326. {
  327. type: "gauge",
  328. startAngle: 180,
  329. endAngle: 0,
  330. center: ["50%", "75%"],
  331. radius: "90%",
  332. min: 0,
  333. max: 1,
  334. splitNumber: 8,
  335. axisLine: {
  336. lineStyle: {
  337. width: 6,
  338. color: [
  339. [0.25, "#FF6E76"],
  340. [0.5, "#FDDD60"],
  341. [0.75, "#58D9F9"],
  342. [1, "#7CFFB2"],
  343. ],
  344. },
  345. },
  346. pointer: {
  347. icon: "path://M12.8,0.7l12,40.1H0.7L12.8,0.7z",
  348. length: "12%",
  349. width: 20,
  350. offsetCenter: [0, "-60%"],
  351. itemStyle: {
  352. color: "auto",
  353. },
  354. },
  355. axisTick: {
  356. length: 12,
  357. lineStyle: {
  358. color: "auto",
  359. width: 2,
  360. },
  361. },
  362. splitLine: {
  363. length: 20,
  364. lineStyle: {
  365. color: "auto",
  366. width: 5,
  367. },
  368. },
  369. axisLabel: {
  370. color: "#464646",
  371. fontSize: 14,
  372. distance: -40,
  373. rotate: "tangential",
  374. formatter: function (value) {
  375. if (value === 0.875) {
  376. return "充足";
  377. } else if (value === 0.625) {
  378. return "可控";
  379. } else if (value === 0.375) {
  380. return "紧张";
  381. } else if (value === 0.125) {
  382. return "危险";
  383. }
  384. return "";
  385. },
  386. },
  387. title: {
  388. offsetCenter: [0, "-10%"],
  389. fontSize: 14,
  390. },
  391. detail: {
  392. fontSize: 20,
  393. offsetCenter: [0, "-35%"],
  394. valueAnimation: true,
  395. formatter: function (value) {
  396. return Math.round(value * 100) + "";
  397. },
  398. color: "inherit",
  399. },
  400. data: [
  401. {
  402. value: 0.7,
  403. name: "危险预算余额",
  404. },
  405. ],
  406. },
  407. ],
  408. };
  409. chart.setOption(options);
  410. },
  411. handleDateClick(dateClickInfo) {
  412. console.log(dateClickInfo);
  413. },
  414. },
  415. };
  416. </script>
  417. <style lang="scss" scoped>
  418. .flex {
  419. width: 100%;
  420. flex-wrap: wrap;
  421. .el-card {
  422. flex: 0 0 calc(50% - 14px);
  423. height: 400px;
  424. ::v-deep .el-card__body {
  425. padding: 10px;
  426. height: calc(100% - 79px);
  427. }
  428. &.calendar {
  429. height: 500px;
  430. ul {
  431. display: flex;
  432. flex-direction: column;
  433. justify-content: space-around;
  434. height: 130px;
  435. li {
  436. font-size: 14px;
  437. display: flex;
  438. align-items: center;
  439. &:before {
  440. content: "";
  441. display: inline-block;
  442. width: 6px;
  443. height: 6px;
  444. border-radius: 3px;
  445. background-color: #a30014;
  446. margin-right: 4px;
  447. }
  448. }
  449. }
  450. }
  451. &.cost {
  452. height: 300px;
  453. }
  454. }
  455. &.technical .el-card {
  456. height: auto;
  457. ::v-deep .el-card__body {
  458. height: auto;
  459. }
  460. }
  461. }
  462. .cage-list {
  463. display: flex;
  464. flex-wrap: wrap;
  465. list-style: none;
  466. li {
  467. height: 160px;
  468. width: 221px;
  469. font-size: 14px;
  470. border: 1px solid #ebeef5;
  471. border-radius: 6px;
  472. display: flex;
  473. flex-direction: column;
  474. justify-content: space-around;
  475. padding: 10px;
  476. &:nth-child(2n) {
  477. margin-left: 4px;
  478. }
  479. &:nth-child(n + 3) {
  480. margin-top: 4px;
  481. }
  482. header {
  483. display: flex;
  484. justify-content: space-between;
  485. p {
  486. color: #1d66dc;
  487. }
  488. }
  489. }
  490. }
  491. .platform-list {
  492. height: 100%;
  493. display: flex;
  494. flex-direction: column;
  495. li {
  496. flex: 1;
  497. display: flex;
  498. align-items: center;
  499. margin: 12px;
  500. border-radius: 8px;
  501. overflow: hidden;
  502. border: 1px solid #ebeef5;
  503. .text {
  504. flex: 1;
  505. height: 100%;
  506. padding: 12px;
  507. }
  508. .btn {
  509. width: 120px;
  510. height: 100%;
  511. color: #fff;
  512. font-size: 20px;
  513. background-color: #73b9b9;
  514. display: flex;
  515. flex-direction: column;
  516. align-items: center;
  517. justify-content: space-around;
  518. header {
  519. font-size: 14px;
  520. }
  521. .remain-time {
  522. color: #f56c6c;
  523. }
  524. }
  525. }
  526. }
  527. .chart-container {
  528. display: flex;
  529. .text {
  530. flex: 1;
  531. font-size: 14px;
  532. display: flex;
  533. flex-direction: column;
  534. header {
  535. color: #1d66dc;
  536. }
  537. ul {
  538. margin-top: 12px;
  539. flex: 1;
  540. display: flex;
  541. flex-direction: column;
  542. justify-content: space-around;
  543. }
  544. li {
  545. background-color: #e4b5bb;
  546. border-radius: 4px;
  547. padding: 4px 8px;
  548. }
  549. }
  550. #chart {
  551. width: 233px;
  552. height: 220px;
  553. }
  554. }
  555. .technical {
  556. p {
  557. font-size: 16px;
  558. height: 24px;
  559. line-height: 24px;
  560. }
  561. ul {
  562. display: flex;
  563. height: 50px;
  564. line-height: 50px;
  565. border-radius: 4px;
  566. overflow: hidden;
  567. margin: 20px 0;
  568. li {
  569. flex: 1;
  570. text-align: center;
  571. background-color: #d9fba5;
  572. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  573. &:nth-child(2) {
  574. background-color: #98ca49;
  575. }
  576. &:nth-child(3) {
  577. background-color: #a4dffa;
  578. }
  579. &:nth-child(4) {
  580. background-color: #48bff4;
  581. }
  582. &:nth-child(5) {
  583. background-color: #b6b6f1;
  584. }
  585. &:nth-child(6) {
  586. background-color: #ebcda7;
  587. }
  588. &:nth-child(7) {
  589. background-color: #f2a4ad;
  590. }
  591. }
  592. }
  593. }
  594. .toolbar-wrap {
  595. height: 30px;
  596. display: flex;
  597. justify-content: space-between;
  598. align-items: center;
  599. // margin-bottom: 20px;
  600. .switch-date {
  601. width: 108px;
  602. height: 28px;
  603. border-radius: 2px;
  604. border: 1px solid #b5c1d8;
  605. display: flex;
  606. padding: 4px 6px 0;
  607. .btn {
  608. cursor: pointer;
  609. flex: 1;
  610. font-size: 13px;
  611. color: #585858;
  612. display: flex;
  613. align-items: center;
  614. justify-content: center;
  615. &.actived {
  616. background: #eef3fe;
  617. font-weight: bold;
  618. color: #2c78ff;
  619. }
  620. }
  621. }
  622. .date-wrap {
  623. display: flex;
  624. align-items: center;
  625. :deep(.el-button--small.is-circle) {
  626. width: 26px;
  627. height: 26px;
  628. }
  629. .date {
  630. margin: 0 10px;
  631. font-size: 14px;
  632. color: #585858;
  633. }
  634. .week {
  635. color: #2c78ff;
  636. padding-left: 6px;
  637. }
  638. }
  639. }
  640. .table-wrap {
  641. flex: 1;
  642. margin: 20px 0 0;
  643. // overflow: hidden;
  644. }
  645. </style>