123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569 |
- <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 != 'P10'"
- 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.furnaceSp" 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'"
- >
- <div class="material-group">
- <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>
- </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 {
- getDeviceList,
- eliminate,
- Api_getReplenishment,
- changeSleepDesc,
- setFurnace,
- sleepEquipment,
- } 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" },
- ]);
- // 爆米花物料
- 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" },
- ]);
- // 创建容器引用
- 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 getDeviceList(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) => {
- // console.log("row 是 >>>", row);
- if (row.latitude) {
- router.push({
- path: "viewPosition",
- query: {
- latitude: row.latitude,
- longitude: row.longitude,
- fullName: row.fullName,
- },
- });
- } 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({
- equipmentId: item.id,
- eqeStatus: item.isSleep ? "0" : "1",
- });
- if (data.code) {
- showSuccessToast(t("device.changeSleepSuccess"));
- setTimeout(() => {
- init();
- }, 1000);
- } 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({
- equipmentId: id,
- eqeStatus: 1,
- });
- if (data.code) {
- showSuccessToast(t("device.restartSucceeded"));
- setTimeout(() => {
- router.go(0);
- }, 1000);
- } else {
- showFailToast(data.message);
- }
- })
- .catch(() => {
- return;
- });
- };
- // 开启/关闭炉头
- const openCloseHead = (id, status) => {
- // console.log("id", id);
- // console.log("status", status);
- showConfirmDialog({
- title: t("user.tips"),
- message:
- status == 1
- ? t("device.openFurnaceHeadTips")
- : t("device.closeFurnaceHeadTips"),
- })
- .then(async () => {
- const { data } = await setFurnace({
- equipmentId: id,
- eqeStatus: status,
- });
- if (data.code) {
- showSuccessToast(
- (status == 1 ? t("device.open") : t("device.close")) +
- t("device.success")
- );
- setTimeout(() => {
- router.go(0);
- }, 1000);
- } 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,
- 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>
|