| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- <!--
- * @Author: liuzhenlin 461480418@qq.ocm
- * @Date: 2023-01-12 11:57:48
- * @LastEditors: wanglj wanglijie@dashoo.cn
- * @LastEditTime: 2025-03-26 17:59:17
- * @Description: file content
- * @FilePath: \labsop小程序\pages\schedule\myAppoint\index.vue
- -->
- <template>
- <div class="panel-wrap">
- <van-empty v-if="appointList.length == 0" mode="list" description="暂无正在上机"></van-empty>
- <van-list v-else v-model:loading="listloading" class="data-list" :finished="finished" finished-text="没有更多了"
- @load="onLoad">
- <div class="inst-item mb40" v-for="(v, index) in appointList" :key="index" @click="toDetail(v)">
- <div class="flex flex-between mb20">
- <div>
- <div class="mr10">
- <span class="fontSize14 primary-color bold">{{ v.instName }}</span>
- </div>
- </div>
- </div>
- <div class="flex mb20">
- <div class="equ-tit">
- <span class="fontSize14 bold">设备型号:</span>
- </div>
- <div>
- <span class="fontSize14">{{ v.instNameEn }}</span>
- </div>
- </div>
- <div class="flex mb20" v-if="v.projectName">
- <div class="equ-tit">
- <span class="fontSize14 bold">课题组:</span>
- </div>
- <div>
- <span class="fontSize14">{{ v.projectName }}</span>
- </div>
- </div>
- <div class="flex mb20" v-if="v.serviceName">
- <div class="equ-tit">
- <span class="fontSize14 bold">服务:</span>
- </div>
- <div>
- <span class="fontSize14">{{ v.serviceName }}</span>
- </div>
- </div>
- <div class="flex mb20">
- <div class="equ-tit">
- <span class="fontSize14 bold">所在位置:</span>
- </div>
- <div>
- <span class="fontSize14">{{ v.placeAddress + '(' + (v.laboratoryName || '') + ')' }}</span>
- </div>
- </div>
- <div class="flex">
- <div class="equ-tit">
- <span class="fontSize14 bold">开始时间:</span>
- </div>
- <div>
- <span class="fontSize14">{{ v.startTime }}</span>
- </div>
- </div>
- <div class="flex mt20">
- <van-button style="width: 70px; height: 30px; margin: 0; font-size: 14px" class="scan-txt" type="danger"
- size="small" @click.native.stop="handleIsGetOff(v)">
- 下机
- </van-button>
- </div>
- </div>
- </van-list>
- <!-- <blue-tooth ref="bluetoothRef" @getOff="callbackOff"></blue-tooth> -->
- </div>
- </template>
- <script>
- // import BlueTooth from '../../../components/BlueTooth'
- import { useMyAppointApi } from '/@/api/appoint'
- const myAppointApi = useMyAppointApi()
- import { useInstrApi } from '/@/api/instr'
- const instApi = useInstrApi()
- import instAppointApi from '/@/api/instr/instAppoint'
- import to from 'await-to-js'
- import { showConfirmDialog, showNotify } from 'vant'
- import { useUserInfo } from '/@/stores/userInfo'
- import { scanCodeWxUrl } from '/@/constants/pageConstants'
- export default {
- // components: { BlueTooth },
- data() {
- return {
- appointList: [],
- queryForm: {
- pageNum: 1,
- pageSize: 10
- },
- curAppointInfo: 0,
- total: 0,
- listloading: false,
- finished: false
- }
- },
- created() { },
- mounted() {
- this.queryForm.pageNum = 1
- this.getInstList()
- },
- methods: {
- // 重新加载
- onLoad() {
- this.queryForm.pageNum++
- this.getInstList()
- },
- // 查询列表
- async getInstList() {
- this.listloading = true
- const [err, res] = await to(myAppointApi.inProgressList(this.queryForm))
- this.listloading = false
- if (err) return
- if (res?.code === 200) {
- this.appointList = this.queryForm.pageNum == 1 ? [...(res?.data?.list || [])] : [...this.appointList, ...(res?.data?.list || [])]
- this.total = res?.data?.total
- if (this.queryForm.pageNum * this.queryForm.pageSize >= res.data.total) {
- this.finished = true
- }
- }
- },
- async handleIsGetOff(row) {
- const [err, res] = await to(instApi.getSettingDetail({ instId: row.instId, code: 'InstCfgUse' }))
- if (err) return
- // 上机时间
- const useTime = this.calcTimeDiff(row.usedStartTime)
- // 是否进行上机时间太短的提示
- // 需要
- if (res?.data?.config.shortWarningEnable) {
- const shortWraningTime = this.getShortWraningTime(res?.data?.config.shortWarning, res?.data?.config.shortWarningUnit)
- if (useTime > shortWraningTime) {
- if (row.controlMode === '30') {
- this.handleBluetoothOffLine()
- } else {
- this.curAppointInfo = row
- showConfirmDialog({
- title: '提示',
- message: `本次上机时长共计${useTime}分钟,确定要下机吗?`
- })
- .then((e) => {
- console.log(e)
- this.getOff()
- })
- .catch(() => {
- console.log('ssss')
- })
- }
- } else {
- if (row.controlMode === '30') {
- this.handleBluetoothOffLine()
- } else {
- this.curAppointInfo = row
- showConfirmDialog({
- title: '提示',
- message: `本次上机时长共计${useTime}分钟,不足${shortWraningTime}分钟,确定要下机吗?`
- })
- .then((e) => {
- console.log(e)
- this.getOff()
- })
- .catch(() => {
- console.log('ssss')
- })
- }
- }
- } else {
- if (row.controlMode === '30') {
- this.handleBluetoothOffLine()
- } else {
- this.curAppointInfo = row
- showConfirmDialog({
- title: '提示',
- message: `本次上机时长共计${useTime}分钟,确定要下机吗?`
- })
- .then((e) => {
- this.getOff()
- })
- .catch(() => {
- console.log('ssss')
- })
- }
- }
- },
- async handleBluetoothOffLine() {
- const res = await useUserInfo().scanCode()
- this.handleDeCode(res, this.handleBluetoothDeCode)
- },
- /**
- * 解码
- * code 二维码内容
- * func 解码后的操作函数
- * */
- async handleDeCode(code, func) {
- if (this.loading) return
- this.loading = true
- const params = { content: code }
- const [err, res] = await to(instApi.decode({ ...params }))
- if (err) {
- this.loading = false
- showNotify({ type: 'danger', message: '解码失败,请重试' })
- return
- }
- if (res?.code == 200 && res?.data?.content) {
- func(res.data.content)
- } else {
- this.loading = false
- showNotify({ type: 'danger', message: res?.message || '解码失败' })
- }
- },
- //蓝牙 重新解码函数,获取解码内容之后 执行跳转操作
- async handleBluetoothDeCode(content) {
- if (content.includes('id')) {
- const terminal = JSON.parse(content)?.terminal
- const url = scanCodeWxUrl(terminal)
- window.location.href = url
- } else {
- const url = scanCodeWxUrl(content)
- window.location.href = url
- }
- },
- // 计算时间转分钟
- getShortWraningTime(time, unit) {
- if (unit == 'hour') {
- return time * 60
- } else if (unit == 'minute') {
- return time
- }
- },
- calcTimeDiff(date) {
- var new_date = new Date() //新建一个日期对象,默认现在的时间
- var old_date = new Date(date) //设置过去的一个时间点,"yyyy-MM-dd HH:mm:ss"格式化日期
- var difftime = new_date - old_date //计算时间差
- return Math.round(difftime / 60000)
- },
- async getOff() {
- const params = { appointId: this.curAppointInfo.id }
- const [err, res] = await to(instAppointApi.getOff({ ...params }))
- if (err) return
- if (res.code == 200) {
- this.queryForm.pageNum = 1
- this.getInstList()
- showNotify({ type: 'success', message: '下机成功' })
- }
- },
- callbackOff() {
- this.queryForm.pageNum = 1
- this.getInstList()
- },
- toDetail(v) {
- this.$router.push(`/onlineInfo?appointId=${v.id}`)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- * {
- box-sizing: border-box;
- }
- .panel-wrap {
- height: 100%;
- .data-list {
- .inst-item {
- border-radius: 10px;
- padding: 15px;
- box-shadow: -2px 0px 9px rgba(0, 0, 0, 0.12);
- margin-bottom: 20px;
- background-color: #fff;
- .equ-tit {
- width: 74px;
- }
- }
- }
- }
- </style>
|