12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658 |
- <template>
- <!-- 设备列表 -->
- <div class="device-management">
- <!-- 头部 -->
- <s-header
- :name="sys?.title || $t('device.managementCenter')"
- :noback="true"
- :isFixed="false"
- class="management-header"
- />
- <!-- 主体内容 -->
- <div
- class="device-list-container"
- ref="scrollContainer"
- @scroll="handleScroll"
- >
- <van-list
- v-model:loading="loading"
- v-model:error="error"
- :error-text="$t('public.requestFailed')"
- :finished-text="$t('public.noMore')"
- offset="100"
- :immediate-check="false"
- :finished="finished"
- @load="onLoad"
- >
- <!-- 数据概览 -->
- <div class="data-overview">
- <div class="overview-header">
- <h3 class="section-title">
- <van-icon name="setting" color="#2c87c8" />
- {{ $t("device.dataOverview") }}
- </h3>
- <div class="action-icons">
- <van-popover
- v-model:show="showPopover"
- placement="left-start"
- theme="dark"
- :actions="actions"
- @select="selectLabel"
- >
- <template #reference>
- <van-icon name="bars" class="icon-filter" />
- </template>
- </van-popover>
- <van-icon
- name="search"
- class="icon-search"
- @click="searchClick"
- />
- </div>
- </div>
- <!-- 统计卡片 -->
- <div class="stats-cards">
- <div class="stat-card">
- <div class="card-value">{{ equipStatus.machineUseNum }}</div>
- <div class="card-label">{{ $t("device.totalNumberOfRuns") }}</div>
- </div>
- <div class="stat-card">
- <div class="card-value">{{ equipStatus.machineTotalNum }}</div>
- <div class="card-label">
- {{ $t("device.totalNumberOfEquipment") }}
- </div>
- </div>
- </div>
- </div>
- <!-- 设备列表 -->
- <div class="device-list-section">
- <van-tabs
- v-model:active="active"
- @click-tab="clickLabel"
- animated
- class="device-tabs"
- color="#2c87c8"
- >
- <van-tab :title="$t('device.whole')" name="" />
- <van-tab :title="$t('device.powerOn')" name="ON" />
- <van-tab :title="$t('device.abnormal')" name="ABNORMAL" />
- <van-tab
- v-for="item in labelList"
- :key="item.id"
- :title="item.name"
- :name="item.id"
- />
- </van-tabs>
- <!-- 设备项 -->
- <div class="device-items">
- <div v-for="item in list" :key="item.id" class="device-item">
- <!-- 设备状态标识 -->
- <div
- class="status-indicator"
- :class="{
- active: item.eqeStatus === 1,
- alert: item.hasTodayAlarm,
- }"
- ></div>
- <!-- 设备主体信息 -->
- <div class="device-main">
- <!-- 基础信息 -->
- <div class="device-info">
- <div class="name-row">
- <h4 class="device-name">
- {{ item.name || item.clientId.slice(-6) }}
- </h4>
- <div
- class="alarm-indicator"
- v-if="item.hasTodayAlarm"
- :class="{ blink: showAlert }"
- />
- <div
- class="status-dot"
- v-else
- :class="{ active: item.eqeStatus === 1 }"
- />
- </div>
- <div class="device-id">
- {{ $t("device.machineUniqueCode") }}:{{ item.clientId }}
- </div>
- <!-- 状态信息 -->
- <div class="status-info">
- <span v-if="user.type < 1" class="lock-status">
- {{ $t("device.lockCondition") }}:{{
- item.isBlocked
- ? $t("device.lockState")
- : $t("device.unLockState")
- }}
- </span>
- <template
- v-if="item.machineType === '0' || !item.machineType"
- >
- <span
- class="temperature"
- :class="{
- warning: item.furnaceTm <= 100 && item.eqeStatus == 1,
- }"
- >
- {{ $t("device.furnaceHeadTemperature") }}:{{
- item.furnaceTm || 0
- }}{{ $t("device.degree") }}
- </span>
- <span class="temperature"
- >{{ $t("device.temperatureInCabinet") }}:{{
- item.cabinetTm || 0
- }}{{ $t("device.degree") }}</span
- >
- <span class="humidity"
- >{{ $t("device.humidityInCabinet") }}:{{
- item.cabinetHd || 0
- }}{{ $t("device.humidity") }}</span
- >
- </template>
- <template v-if="item.machineType === '1'">
- <span class="temperature">
- {{
- $t("device.cornGeneratorTemperature") +
- ":" +
- (item.cabinetTm ? item.cabinetTm : "0") +
- $t("device.degree")
- }}
- </span>
- <span
- v-if="item.equimentType === 'P30'"
- class="temperature"
- >
- {{
- $t("device.stirringTemperature") +
- ":" +
- (item.cabinetHd ? item.cabinetHd : "0") +
- $t("device.degree")
- }}</span
- >
- <span
- v-if="item.furnaceTm && item.furnaceTm != '-1'"
- class="humidity"
- >
- {{
- $t("device.cupQuantity") + ":" + item.furnaceTm
- }}</span
- >
- <span v-if="item.equimentType === 'P30'" class="humidity">
- {{
- $t("device.bucketWeight") +
- ":" +
- item.furnaceSp +
- $t("device.weight")
- }}</span
- >
- </template>
- </div>
- </div>
- <!-- 扩展内容 -->
- <div v-if="item.checkType" class="device-detail">
- <!-- 设备详细信息 -->
- <div class="detail-section" v-if="user.type < 2">
- <label
- >{{ $t("device.affiliatedMerchants") }}:{{
- item.adminUserName
- }}</label
- >
- </div>
- <!-- 睡眠控制 -->
- <div class="detail-section machine-control">
- <div class="control-container">
- <!-- 文本说明 -->
- <span class="status-text">
- {{ $t("device.sleepState") }}:{{
- item.isSleep
- ? $t("device.sleeping")
- : $t("device.notSleeping")
- }}
- </span>
- <!-- 切换按钮 -->
- <van-switch
- :model-value="item.isSleep"
- size="18px"
- active-color="#2c87c8"
- class="switch-button"
- @click="changeSleep(item)"
- />
- </div>
- </div>
- <!-- 睡眠控制下方添加 -->
- <div
- v-if="item.isSleep"
- class="detail-section sleep-description"
- >
- <div class="desc-view" v-if="!sleepDescBoxShow">
- <label class="desc-label"
- >{{ $t("device.sleepDesc") }}:</label
- >
- <span class="desc-text">{{
- item.sleepDesc || $t("device.SuspendBusiness")
- }}</span>
- <van-button
- size="small"
- color="#2c87c8"
- class="edit-btn"
- @click="editSleepDesc(item)"
- >
- {{ $t("device.modify") }}
- </van-button>
- </div>
- <div class="desc-edit" v-else>
- <van-field
- v-model="item.sleepDesc"
- :placeholder="$t('device.sleepDescPlace')"
- class="edit-field"
- label-width="4em"
- clearable
- >
- <template #button>
- <van-button
- size="small"
- type="primary"
- class="confirm-btn"
- @click="sleepDescChg(item.sleepDesc, item.id)"
- >
- {{ $t("device.confirm") }}
- </van-button>
- <van-button
- size="small"
- class="cancel-btn"
- @click="sleepDescBoxShow = false"
- >
- {{ $t("device.cancel") }}
- </van-button>
- </template>
- </van-field>
- </div>
- </div>
- <!-- 炉头状态 -->
- <div
- class="detail-section machine-control"
- v-if="item.machineType === '0' || !item.machineType"
- >
- <div class="control-container">
- <span class="status-text">
- {{
- item.machineType == "0" || item.machineType == null
- ? $t("device.furnHeadStatus")
- : $t("device.deviceStatus")
- }}:
- {{
- item.eqeStatus === 1
- ? $t("device.opened")
- : $t("device.closed")
- }}
- </span>
- <!-- 操作按钮组 -->
- <div class="button-group">
- <van-button
- size="small"
- color="#2c87c8"
- class="action-btn"
- @click="openCloseHead(item.id, 1)"
- >
- {{ $t("device.open") }}
- </van-button>
- <van-button
- size="small"
- type="danger"
- class="action-btn"
- @click="openCloseHead(item.id, 0)"
- >
- {{ $t("device.close") }}
- </van-button>
- <van-button
- size="small"
- type="warning"
- class="action-btn"
- @click="restartHead(item.id)"
- >
- {{ $t("device.restartHead") }}
- </van-button>
- </div>
- </div>
- </div>
- <!-- 定位: -->
- <div class="detail-section" v-if="item.latitude">
- <label @click="viewPosiClk(item)"
- >{{ $t("device.position") }}:{{ item.fullName }}</label
- >
- </div>
- <!-- 物料监控 -->
- <template v-if="item.isMaterialUse === '1'">
- <div
- class="detail-section material-usage"
- v-if="item.machineType === '0' || !item.machineType"
- >
- <!-- 糖类原料 -->
- <div class="material-group">
- <div class="material-grid">
- <div
- v-for="(sugar, index) in sugarTypes"
- :key="index"
- class="material-item"
- >
- <van-icon
- :name="sugar.icon"
- class="material-icon"
- size="25px"
- :style="{ color: sugar.color }"
- />
- <div class="material-info">
- <span class="material-label">{{
- $t(`device.${sugar.type}`)
- }}</span>
- <span class="material-value"
- >{{
- Format_calcuDecial(item[sugar.type])
- }}
- %</span
- >
- </div>
- </div>
- </div>
- </div>
- <!-- 一键补料 -->
- <div class="supply-section">
- <van-button
- block
- type="primary"
- icon="replay"
- class="supply-button"
- @click="replenishmentClk(item)"
- >
- {{ $t("device.oneKeyFeed") }}
- </van-button>
- </div>
- </div>
- <!-- 爆米花物料 -->
- <div
- class="detail-section material-usage"
- v-if="item.machineType === '1'"
- >
- <!-- 爆米花P30物料-->
- <div
- class="material-group"
- v-if="item.equimentType === 'P30'"
- >
- <div class="material-grid">
- <div
- v-for="(poporn, index) in popornTypes"
- :key="index"
- class="material-item"
- >
- <van-icon
- :name="poporn.icon"
- class="material-icon"
- size="25px"
- :style="{ color: poporn.color }"
- />
- <div class="material-info">
- <span class="material-label">{{
- $t(`device.${poporn.type}`)
- }}</span>
- <span class="material-value"
- >{{
- Format_calcuDecial(item[poporn.code])
- }}
- g</span
- >
- </div>
- </div>
- </div>
- </div>
- <!-- 爆米花SBM10物料-->
- <div
- class="material-group"
- v-if="item.equimentType === 'SBM10'"
- >
- <div class="material-grid">
- <div
- v-for="(poporn, index) in poporn10Types"
- :key="index"
- class="material-item"
- >
- <van-icon
- :name="poporn.icon"
- class="material-icon"
- size="25px"
- :style="{ color: poporn.color }"
- />
- <div class="material-info">
- <span class="material-label">{{
- $t(`device.${poporn.type}`)
- }}</span>
- <span class="material-value"
- >{{
- Format_calcuDecial(item[poporn.code])
- }}
- g</span
- >
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- 冰淇淋物料 -->
- <div
- class="detail-section material-usage"
- v-if="item.machineType === '2'"
- >
- <div class="material-group">
- <div class="material-grid">
- <div
- v-for="(ice, index) in iceTypes"
- :key="index"
- class="material-item"
- >
- <van-icon
- :name="ice.icon"
- class="material-icon"
- size="25px"
- :style="{ color: ice.color }"
- />
- <div class="material-info">
- <span class="material-label">{{
- $t(`device.${ice.type}`)
- }}</span>
- <span class="material-value"
- >{{
- Format_calcuDecial(item[ice.code])
- }}
- %</span
- >
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <!-- 最近刷新时间 -->
- <div class="detail-section">
- <label
- >{{ $t("device.lastRefreshTime") }}:{{
- showDateTime(item.lastUpdateTime)
- }}</label
- >
- </div>
- <!-- 音量 -->
- <div class="detail-section">
- <label
- >{{ $t("device.volume") }}:{{ item.volume || 0 }}</label
- >
- </div>
- <!-- 报警信息区域 -->
- <div
- class="detail-section alert-section"
- v-if="item.alarmList?.length"
- >
- <!-- 报警列表 -->
- <div class="alert-list">
- <div
- v-for="itemAlarm in item.alarmList"
- :key="itemAlarm"
- class="alert-item"
- >
- <div class="alert-content">
- <div class="alert-time">
- <van-icon name="clock" class="alert-icon" />
- {{ showDateTime(itemAlarm.occurrenceTime) }}
- </div>
- <div class="alert-message">
- <van-icon name="warning" class="alert-icon" />
- <span class="alert-text">{{
- itemAlarm.alarmContent
- }}</span>
- </div>
- </div>
- </div>
- </div>
- <!-- 一键清除 -->
- <div class="alert-actions">
- <van-button
- block
- type="primary"
- color="#07c160"
- icon="delete"
- @click="clearAllAlarm(item.alarmList, item)"
- >
- {{ $t("device.oneClickClear") }}
- </van-button>
- </div>
- </div>
- <!-- 操作按钮 -->
- <div class="action-buttons">
- <van-button
- color="#2c87c8"
- icon="bars"
- size="small"
- @click="deviceSet(item)"
- >{{ $t("device.editDevice") }}</van-button
- >
- <van-button
- color="#2c87c8"
- icon="setting"
- v-if="controlList.length"
- size="small"
- @click="deviceOprShow(item, controlList)"
- >
- {{ $t("device.commonOperations") }}
- </van-button>
- </div>
- </div>
- <!-- 展开/收起 -->
- <div
- class="toggle-detail"
- @click="item.checkType = !item.checkType"
- >
- <span>{{
- item.checkType ? $t("device.stow") : $t("device.seeMore")
- }}</span>
- <van-icon
- :name="item.checkType ? 'arrow-up' : 'arrow-down'"
- />
- </div>
- </div>
- </div>
- </div>
- </div>
- <van-back-top
- right="20"
- bottom="80"
- style="background-color: #2c87c8"
- />
- </van-list>
- </div>
- <!-- 其他组件 -->
- <device-oper ref="oprRef" @operfinish="operFinish" />
- <device-search ref="searchRef" @search="search" />
- </div>
- </template>
- <script>
- import { Api_postMachineNum } from "../../service/home";
- import {
- onMounted,
- reactive,
- toRefs,
- ref,
- onActivated,
- onBeforeUnmount,
- } from "vue";
- import {
- showFailToast,
- showSuccessToast,
- showToast,
- showConfirmDialog,
- } from "vant";
- import sHeader from "../../components/SimpleHeader";
- import { getLoginUser, Format_calcuDecial } from "../../common/js/utils";
- import {
- eliminate,
- Api_getReplenishment,
- changeSleepDesc,
- setFurnace,
- sleepEquipment,
- getMachineList,
- } from "../../service/device/index";
- import deviceSearch from "./deviceSearch";
- import deviceOper from "./deviceOper";
- import { onBeforeRouteLeave, useRouter } from "vue-router";
- import dateUtil from "../../utils/dateUtil";
- import { useI18n } from "vue-i18n";
- import { Api_getLabelList } from "../../service/labelMan";
- import { getAdminRole } from "@/service/user";
- export default {
- name: "device",
- components: { sHeader, deviceSearch, deviceOper },
- setup() {
- const { t } = useI18n();
- const searchRef = ref(null);
- const oprRef = ref(null);
- const list = ref([]);
- const loading = ref(true);
- const error = ref(false);
- const finished = ref(false);
- const router = useRouter();
- const sys = ref(null);
- const user = getLoginUser();
- const labelList = ref([]);
- // 棉花糖物料
- const sugarTypes = ref([
- { type: "whiteSugar", icon: "stop", color: "#ffffff" },
- { type: "redSugar", icon: "stop", color: "#ff4d4f" },
- { type: "yellowSugar", icon: "stop", color: "#faad14" },
- { type: "blueSugar", icon: "stop", color: "#1890ff" },
- { type: "stick", icon: "minus", color: "#9254de" },
- { type: "water", icon: "weapp-nav", color: "#ADD8E6" },
- { type: "wasteWater", icon: "weapp-nav", color: "#666" },
- ]);
- // 爆米花P30物料
- const popornTypes = ref([
- { code: "whiteSugar", type: "chocolate", icon: "stop", color: "#5C3317" },
- { code: "redSugar", type: "cheese", icon: "stop", color: "#fcdd8d" },
- { code: "yellowSugar", type: "peach", icon: "stop", color: "#FFC0CB" },
- { code: "blueSugar", type: "caramel", icon: "stop", color: "#D2691E" },
- ]);
- // 爆米花P10物料
- const poporn10Types = ref([
- { code: "redSugar", type: "sweet", icon: "stop", color: "#FFC0CB" },
- { code: "whiteSugar", type: "salty", icon: "stop", color: "#fcdd8d" },
- ]);
- // 冰淇淋物料
- const iceTypes = ref([
- { code: "whiteSugar", type: "C01", icon: "stop", color: "#5C3317" },
- { code: "redSugar", type: "C02", icon: "stop", color: "#faad14" },
- { code: "yellowSugar", type: "J01", icon: "stop", color: "#ff4d4f" },
- { code: "blueSugar", type: "J02", icon: "stop", color: "#1890ff" },
- { code: "stick", type: "J03", icon: "stop", color: "#f8ff3b" },
- ]);
- // 创建容器引用
- const scrollContainer = ref(null);
- // 创建响应式滚动位置
- const scrollTop = ref(0);
- // 返回顶部
- const backTop = () => {
- document.documentElement.scrollTop = 0;
- };
- // 滚动处理函数
- const handleScroll = () => {
- // console.log("scrollContainer", scrollContainer.value);
- if (scrollContainer.value) {
- scrollTop.value = scrollContainer.value.scrollTop;
- // 如果需要,可以在这里触发其他逻辑
- // console.log("当前滚动位置:", scrollTop.value);
- }
- };
- onActivated(() => {
- scrollContainer.value.scrollTop = scrollTop.value;
- });
- onBeforeRouteLeave(() => {
- // console.log("离开时的位置", scrollTop.value);
- });
- // 在组件卸载前清除定时器
- onBeforeUnmount(() => {
- clearInterval(updateDataInterval);
- });
- const updateDataInterval = () => {
- // 每隔5分钟更新数据
- setInterval(() => {
- init();
- if (oprRef.value) {
- oprRef.value.closeOper();
- }
- // verticalScrollPosition.value = 0;
- }, 5 * 60 * 1000); // 5分钟的毫秒数
- };
- //控制睡眠描述的显示隐藏
- const sleepDescBoxShow = ref(false);
- // 页面列表查询参数
- let searchParams = reactive({
- id: "", // 用户账户id
- // adminName: '', // 用户登录名
- current: 1, // 页数
- size: 10, // 页大小
- todayDate: dateUtil.formateDate(new Date(), "yyyy-MM-dd"), // 当天时间
- labelId: "", // 分组标签
- });
- // 初始化页面获取列表
- const showAlert = ref(false);
- // 远程操作权限
- const controlList = ref([]);
- // 获取账号权限
- const getAccountPer = async () => {
- const { data } = await getAdminRole({ adminId: user.id });
- if (data.code === "00000") {
- if (data.data.controlCodesJson !== null) {
- controlList.value = JSON.parse(data.data.controlCodesJson);
- }
- }
- };
- onMounted(() => {
- init();
- updateDataInterval();
- getAccountPer();
- // window.addEventListener('scroll', handleScroll);
- // 加载样式
- // styleUrl('device');
- setInterval(() => {
- showAlert.value = !showAlert.value;
- }, 500); // 1000毫秒即1秒
- });
- // 初始化
- const init = () => {
- // 获取设备情况
- getMachineNum();
- getLabelList();
- if (localStorage.getItem("loginSys")) {
- const loginSysString = localStorage.getItem("loginSys");
- sys.value = JSON.parse(loginSysString);
- }
- list.value = [];
- searchParams.current = 1;
- if (user) {
- searchParams.id = user.id;
- getList();
- }
- };
- // 获取设备标签
- const getLabelList = async () => {
- Api_getLabelList({
- adminId: user.id,
- type: "1",
- }).then((res) => {
- const { data } = res.data;
- labelList.value = data;
- });
- };
- // 获取设备列表数据
- const getList = async () => {
- finished.value = false;
- const { data } = await getMachineList(Object.assign({}, searchParams));
- if (data.code === "00000") {
- if (searchParams.current === 0) {
- list.value = [];
- }
- // 列表值叠加
- list.value = list.value.concat(
- data.data.records.map((item) => {
- if (item.sleepDesc == null) {
- item.sleepDesc = t("device.SuspendBusiness");
- }
- return {
- ...item,
- checkType: false,
- };
- })
- );
- if (list.value.length === data.data.total) {
- finished.value = true;
- }
- loading.value = false;
- } else {
- showFailToast(data.message);
- }
- };
- // 滚动加载
- const onLoad = () => {
- if (!finished.value) {
- // console.log("滚动加载")
- searchParams.current = searchParams.current + 1;
- getList();
- }
- };
- // 搜索点击
- const searchClick = () => {
- searchRef.value.showSearch();
- };
- // 搜索条件触发查询
- const search = (e) => {
- list.value = [];
- loading.value = true;
- searchParams.current = 1;
- searchParams = Object.assign(searchParams, e);
- getList();
- getMachineNum();
- };
- // 跳转设备编辑
- const deviceSet = (e) => {
- router.push({ path: "deviceSet", query: { deviceId: e.id } });
- };
- // 常用操作弹窗展示触发
- const deviceOprShow = (e, value) => {
- oprRef.value.showOper(e, value);
- };
- // 消除报警
- const clearAlarm = async (e, e1, e2) => {
- const params = {
- id: e.id,
- name: e.name,
- selfName: e.selfName,
- areaId: e.areaId,
- channel: e.channel,
- contactName: e.contactName,
- contactPhone: e.contactPhone,
- flowers: e.flowers,
- operationalName: e.operationalName,
- operationalPhone: e.operationalPhone,
- timeRuleId: e.timeRuleId,
- };
- const { data } = await eliminate(Object.assign({}, params));
- if (data.code) {
- showSuccessToast(t("device.successfullyEliminatedTheAlarm"));
- setTimeout(() => {
- e2 = e2.filter((item) => item.id !== e.id);
- list.value[
- list.value.findIndex((item) => item.id === e1.id)
- ].alarmList = e2;
- if (e2.length === 0) {
- e1.hasTodayAlarm = false;
- }
- }, 1000);
- } else {
- showFailToast(data.message);
- }
- };
- // 一键消除报警
- const clearAllAlarm = (e, e1) => {
- showConfirmDialog({
- title: t("device.openRemind"),
- message: t("device.isClear"),
- })
- .then(async () => {
- const { data } = await eliminate(Object.assign({}, { id: e[0].id }));
- if (data.code) {
- showSuccessToast(t("device.successfullyEliminatedTheAlarm"));
- setTimeout(() => {
- list.value[
- list.value.findIndex((item) => item.id === e1.id)
- ].alarmList = null;
- e1.hasTodayAlarm = false;
- if (e1.machineType == "0" || e1.machineType == null) {
- restartHead(e1.id, t("device.clearAfter"));
- }
- }, 800);
- } else {
- showFailToast(data.message);
- }
- })
- .catch((error) => {
- console.log(error);
- });
- };
- const showDateTime = (date) => {
- if (!date) {
- return "";
- }
- const currentDate = new Date(
- dateUtil.formateDate(new Date(date), "yyyy/MM/dd hh:mm:ss")
- );
- return dateUtil.timeZoneDate(currentDate);
- };
- // 点击查看定位
- const viewPosiClk = (row) => {
- if (row.latitude) {
- router.push({
- path: "viewPosition",
- query: {
- latitude: row.latitude,
- longitude: row.longitude,
- fullName: row.fullName,
- name: row.name ? row.name : row.clientId.slice(-6),
- status: row.eqeStatus,
- },
- });
- } else {
- showToast(`${t("device.noPosition")}!!!`);
- }
- };
- // 点击补料
- const replenishmentClk = (row) => {
- showConfirmDialog({
- title: t("user.tips"),
- message: t("device.isReplenishment"),
- })
- .then(async () => {
- const { data } = await Api_getReplenishment({
- equipmentId: row.id,
- });
- if (data.code) {
- showSuccessToast(t("device.sentSuccessfully"));
- setTimeout(() => {
- // router.go(0);
- init();
- }, 1500);
- } else {
- showFailToast(data.message);
- }
- })
- .catch(() => {
- return;
- });
- };
- // 操作弹窗完成的回调
- const operFinish = () => {
- init();
- };
- // 设备状况
- const equipStatus = ref({});
- // 获取设备情况
- const getMachineNum = () => {
- Api_postMachineNum({
- adminId: user.id,
- companyType: searchParams.companyType,
- }).then((res) => {
- equipStatus.value = res.data.data || {};
- });
- };
- // 点击运行总数和总设备数
- const eqeStatusClk = (val) => {
- searchParams.eqeStatus = val;
- // 初始化
- searchParams.current = 1;
- list.value = [];
- getList();
- };
- // 点击修改图标
- const editSleepDesc = () => {
- sleepDescBoxShow.value = !sleepDescBoxShow.value;
- };
- // 点击睡眠描述的确定按钮
- const sleepDescChg = async (sleepDesc, id) => {
- if (!sleepDesc) {
- showToast(t("device.sleepDescPlace"));
- } else {
- const { data } = await changeSleepDesc({
- equipmentId: id,
- sleepDesc,
- });
- if (data.code === "00000") {
- showToast(t("device.modificationSucceeded"));
- setTimeout(() => {
- sleepDescBoxShow.value = false;
- }, 500);
- }
- }
- };
- // 点击标签
- const active = ref("");
- const clickLabel = (item) => {
- console.log(item);
- list.value = [];
- searchParams.current = 1;
- searchParams.labelId = item.name;
- getList();
- };
- // 分组管理
- const showPopover = ref(false);
- const actions = [
- { text: t("device.group"), value: "0" },
- { text: t("device.addGroup"), value: "1" },
- ];
- const selectLabel = (action) => {
- // showToast(action.value);
- if (action.value == "0") {
- router.push("/labelMan");
- }
- if (action.value == "1") {
- router.push("/labelManAdd");
- }
- };
- // 睡眠切换
- const changeSleep = (item) => {
- showConfirmDialog({
- title: t("user.tips"),
- message: t("device.changeSleep"),
- })
- .then(async () => {
- const { data } = await sleepEquipment({
- id: item.id,
- isSleep: item.isSleep ? "0" : "1",
- });
- if (data.code) {
- showSuccessToast(t("device.changeSleepSuccess"));
- setTimeout(() => {
- init();
- }, 1500);
- } else {
- showFailToast(data.message);
- }
- })
- .catch(() => {
- return;
- });
- };
- // 重启炉头
- const restartHead = (id, msg) => {
- showConfirmDialog({
- title: t("user.tips"),
- message: msg ? msg : t("device.restartFurnaceHeadTips"),
- })
- .then(async () => {
- const { data } = await setFurnace({
- id: id,
- eqeStatus: 1,
- });
- if (data.code) {
- showSuccessToast(t("device.restartSucceeded"));
- setTimeout(() => {
- init();
- }, 1500);
- } else {
- showFailToast(data.message);
- }
- })
- .catch(() => {
- return;
- });
- };
- // 开启/关闭炉头
- const openCloseHead = (id, status) => {
- showConfirmDialog({
- title: t("user.tips"),
- message:
- status == 1
- ? t("device.openFurnaceHeadTips")
- : t("device.closeFurnaceHeadTips"),
- })
- .then(async () => {
- const { data } = await setFurnace({
- id: id,
- eqeStatus: status,
- });
- if (data.code) {
- showSuccessToast(
- (status == 1 ? t("device.open") : t("device.close")) +
- t("device.success")
- );
- setTimeout(() => {
- init();
- }, 1500);
- } else {
- showFailToast(data.message);
- }
- })
- .catch(() => {
- return;
- });
- };
- return {
- showAlert,
- ...toRefs(searchParams),
- list,
- loading,
- error,
- finished,
- onLoad,
- searchRef,
- searchClick,
- search,
- deviceSet,
- clearAlarm,
- clearAllAlarm,
- oprRef,
- deviceOprShow,
- showDateTime,
- sys,
- viewPosiClk,
- replenishmentClk,
- Format_calcuDecial,
- operFinish,
- equipStatus,
- eqeStatusClk,
- editSleepDesc,
- sleepDescBoxShow,
- sleepDescChg,
- changeSleep,
- backTop,
- user,
- labelList,
- clickLabel,
- active,
- actions,
- showPopover,
- selectLabel,
- restartHead,
- openCloseHead,
- controlList,
- sugarTypes,
- popornTypes,
- iceTypes,
- poporn10Types,
- scrollContainer,
- scrollTop,
- handleScroll,
- };
- },
- };
- </script>
- <style lang="less" scoped>
- .device-management {
- --primary-color: #2c87c8;
- --success-color: #07c160;
- --warning-color: #ff976a;
- --danger-color: #ff463c;
- --text-primary: #404d74;
- --text-secondary: #666;
- --border-color: #eee;
- --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
- --tabbar-height: 40px;
- --tabbar-padding: calc(var(--tabbar-height) + 20px);
- background: #f8f9fa;
- min-height: 100vh;
- .device-list-container {
- height: calc(100% - 95px);
- overflow: auto;
- overflow-x: hidden;
- }
- .management-header {
- box-shadow: var(--card-shadow);
- }
- .data-overview {
- background: white;
- margin: 10px;
- border-radius: 8px;
- box-shadow: var(--card-shadow);
- .overview-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 16px;
- border-bottom: 1px solid var(--border-color);
- .section-title {
- font-size: 15px;
- color: var(--text-primary);
- margin: 0;
- }
- .action-icons {
- .icon-filter,
- .icon-search {
- font-size: 20px;
- color: var(--primary-color);
- margin-left: 12px;
- }
- }
- }
- .stats-cards {
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- gap: 16px;
- padding: 16px;
- .stat-card {
- background: linear-gradient(145deg, #f3f4ff, #ffffff);
- border-radius: 8px;
- padding: 20px;
- text-align: center;
- transition: transform 1s;
- &:active {
- transform: scale(0.98);
- }
- .card-value {
- font-size: 24px;
- font-weight: 600;
- color: var(--primary-color);
- margin-bottom: 8px;
- }
- .card-label {
- font-size: 14px;
- color: var(--text-secondary);
- }
- }
- }
- }
- .device-list-section {
- margin: 10px;
- background: white;
- border-radius: 8px;
- box-shadow: var(--card-shadow);
- :deep(.van-tabs__wrap) {
- border-radius: 8px;
- }
- .device-tabs {
- :deep(.van-tab) {
- font-size: 14px;
- &--active {
- color: var(--primary-color);
- font-weight: 500;
- }
- }
- }
- .device-items {
- .device-item {
- display: flex;
- margin: 12px;
- background: white;
- border-radius: 8px;
- box-shadow: var(--card-shadow);
- .status-indicator {
- width: 4px;
- border-radius: 2px 0 0 2px;
- background: #ddd;
- &.active {
- background: var(--success-color);
- }
- &.alert {
- background: var(--danger-color);
- animation: pulse 1.5s infinite;
- }
- }
- .device-main {
- flex: 1;
- padding: 16px;
- .name-row {
- display: flex;
- align-items: center;
- margin-bottom: 8px;
- .device-name {
- font-size: 16px;
- color: var(--text-primary);
- margin: 0;
- flex: 1;
- }
- .status-dot {
- width: 12px;
- height: 12px;
- border-radius: 50%;
- background: #ddd;
- &.active {
- background: var(--success-color);
- }
- }
- .alarm-indicator {
- width: 12px;
- height: 12px;
- border-radius: 50%;
- background: var(--danger-color);
- &.blink {
- animation: pulse 2s infinite;
- }
- }
- }
- .device-id {
- font-size: 12px;
- color: var(--text-secondary);
- margin-bottom: 12px;
- }
- .status-info {
- > span {
- display: block;
- font-size: 14px;
- margin: 8px 0;
- color: var(--text-primary);
- &.warning {
- color: var(--danger-color);
- font-weight: 500;
- }
- }
- }
- .device-detail {
- border-top: 1px solid var(--border-color);
- margin-top: 12px;
- .detail-section {
- padding: 12px 0;
- border-bottom: 1px solid var(--border-color);
- // 新增睡眠控制样式
- &.machine-control {
- .control-container {
- display: flex;
- flex-wrap: wrap; // 允许换行
- align-items: center;
- gap: 12px; // 控制文本和按钮间距
- // 文本部分
- .status-text {
- color: var(--text-primary);
- white-space: nowrap; // 防止文本换行
- }
- // 切换按钮
- .van-switch {
- flex-shrink: 0; // 防止按钮被压缩
- position: relative;
- top: 1px; // 微调垂直对齐
- }
- // 控制按钮
- .button-group {
- display: flex;
- gap: 8px; // 按钮间距
- flex-shrink: 0; // 防止按钮压缩
- .action-btn {
- // 保持与全局按钮样式一致
- border-radius: 4px;
- padding: 0 10px;
- max-width: 120px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- height: 28px;
- line-height: 28px;
- // 移动端适配
- @media (max-width: 480px) {
- max-width: 80px;
- padding: 0 8px;
- }
- }
- }
- }
- }
- // 睡眠描述样式(保持与报警模块一致)
- &.sleep-description {
- // 查看状态
- .desc-view {
- display: flex;
- align-items: center;
- gap: 2px;
- .desc-label {
- color: var(--text-primary);
- flex-shrink: 0;
- }
- .desc-text {
- color: var(--text-primary);
- word-break: break-word;
- padding-right: 10px;
- }
- .edit-btn {
- flex-shrink: 0;
- border-radius: 4px;
- padding: 0 10px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- height: 28px;
- line-height: 28px;
- // 移动端适配
- @media (max-width: 480px) {
- max-width: 80px;
- padding: 0 8px;
- }
- }
- }
- // 编辑状态
- .desc-edit {
- .edit-field {
- padding: 8px 12px;
- background: #f8f9fa;
- border-radius: 6px;
- :deep(.van-field__control) {
- min-height: 36px;
- padding: 4px 8px;
- background: white;
- border-radius: 4px;
- }
- :deep(.van-button) {
- margin-left: 8px;
- height: 28px;
- line-height: 26px;
- &.confirm-btn {
- background: var(--primary-color);
- border-color: var(--primary-color);
- padding: 0 5px;
- }
- &.cancel-btn {
- color: var(--text-secondary);
- border-color: #ddd;
- padding: 0 5px;
- }
- }
- }
- }
- // 保持与报警信息相同的交互细节
- &:last-child {
- border-bottom: none;
- padding-bottom: 0;
- }
- }
- // 物料监控样式
- &.material-usage {
- --material-icon-size: 20px;
- --material-grid-gap: 12px;
- .material-group {
- // margin-bottom: 20px;
- .material-title {
- color: var(--text-primary);
- font-size: 12px;
- margin: 0 0 12px 0;
- font-weight: 500;
- }
- .material-grid {
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
- gap: var(--material-grid-gap);
- }
- .material-item {
- display: flex;
- align-items: center;
- padding: 8px;
- background: #e7e7e7;
- border-radius: 6px;
- .material-icon {
- font-size: var(--material-icon-size);
- margin-right: 8px;
- flex-shrink: 0;
- }
- .material-info {
- flex: 1;
- min-width: 0;
- }
- .material-label {
- display: block;
- font-size: 13px;
- color: var(--text-secondary);
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .material-value {
- display: block;
- font-size: 15px;
- color: var(--text-primary);
- font-weight: 500;
- }
- }
- }
- .supply-section {
- margin-top: 16px;
- .supply-button {
- border-radius: 6px;
- --van-button-default-height: 40px;
- .van-icon {
- font-size: 18px;
- vertical-align: -2px;
- }
- }
- }
- }
- // 报警样式
- &.alert-section {
- --alert-icon-size: 16px;
- --alert-spacing: 8px;
- .alert-list {
- margin-bottom: 16px;
- .alert-item {
- &:not(:last-child) {
- margin-bottom: 12px;
- }
- }
- }
- .alert-content {
- background: #fff5f5;
- border-radius: 6px;
- padding: 12px;
- }
- .alert-time {
- display: flex;
- align-items: center;
- color: var(--text-secondary);
- font-size: 13px;
- margin-bottom: var(--alert-spacing);
- .alert-icon {
- font-size: var(--alert-icon-size);
- margin-right: 6px;
- color: var(--text-secondary);
- }
- }
- .alert-message {
- display: flex;
- align-items: flex-start;
- color: var(--danger-color);
- .alert-icon {
- font-size: var(--alert-icon-size);
- margin-right: 6px;
- flex-shrink: 0;
- }
- .alert-text {
- flex: 1;
- word-break: break-word;
- line-height: 1.4;
- }
- }
- .alert-actions {
- margin-top: 16px;
- .van-button {
- border-radius: 6px;
- &::before {
- border-radius: 5px !important;
- }
- }
- }
- }
- // 保留原有label样式
- label {
- color: var(--text-primary);
- }
- }
- .action-buttons {
- display: flex;
- gap: 8px;
- padding: 12px 0;
- .van-button {
- flex: 1;
- }
- }
- }
- .toggle-detail {
- display: flex;
- align-items: center;
- justify-content: center;
- color: var(--primary-color);
- padding-top: 12px;
- cursor: pointer;
- .van-icon {
- margin-left: 4px;
- }
- }
- }
- }
- }
- }
- }
- @keyframes pulse {
- 0%,
- 100% {
- opacity: 0.6;
- }
- 50% {
- opacity: 1;
- }
- }
- </style>
|