From a1a73e25593d2914ea58cd84ec2540bc56bd6934 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期一, 26 一月 2026 17:43:25 +0800
Subject: [PATCH] 来票台账接口更改

---
 src/pages/equipmentManagement/runManagement/index.vue |  547 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 547 insertions(+), 0 deletions(-)

diff --git a/src/pages/equipmentManagement/runManagement/index.vue b/src/pages/equipmentManagement/runManagement/index.vue
new file mode 100644
index 0000000..d5eb0ba
--- /dev/null
+++ b/src/pages/equipmentManagement/runManagement/index.vue
@@ -0,0 +1,547 @@
+<template>
+  <view class="notice-page">
+    <PageHeader title="杩愯绠$悊"
+                @back="goBack" />
+    <!-- 閫氱煡鍏憡鏉� -->
+    <view class="notice-board">
+      <!-- 缁熶竴閫氱煡鍖哄煙 -->
+      <view class="notice-section">
+        <view class="section-header">
+          <h3>璁惧杩愯璁板綍</h3>
+        </view>
+        <view class="notice-cards">
+          <!-- 鏀惧亣閫氱煡 -->
+          <view v-for="notice in holidayNotices"
+                :key="'holiday-' + notice.id"
+                class="notice-card holiday-card"
+                :class="{ 'urgent': isOverdue(notice) }">
+            <view class="card-header">
+              <view class="card-title">
+                <view class="holiday-icon">
+                  <up-icon name="calendar"
+                           size="18"
+                           color="#67c23a" />
+                </view>
+                <text>璁惧鍚嶇О锛歿{ notice.deviceName }}</text>
+              </view>
+              <view class="card-actions warning"
+                    v-if="isOverdue(notice)">
+                <up-icon name="info-circle"
+                         size="16"
+                         color="#fff" />
+                <text>{{ '瓒呮椂鏈惎鍔�' }}</text>
+              </view>
+              <view v-else
+                    class="card-actions"
+                    :class="getTagType(notice.status)">
+                <up-icon :name="getIconName(notice.status)"
+                         size="16"
+                         color="#fff" />
+                <text>{{ notice.status || '鏈煡' }}</text>
+              </view>
+            </view>
+            <view class="card-content">
+              <text>瑙勬牸鍨嬪彿锛歿{ notice.deviceModel || "-" }}</text>
+            </view>
+            <view class="card-content">
+              <text>璁″垝杩愯鏃堕棿锛歿{ notice.planRuntimeTime || "-" }}</text>
+            </view>
+            <view class="card-content">
+              <text>寮�濮嬭繍琛屾椂闂达細{{ notice.startRuntimeTime || "-" }}</text>
+            </view>
+            <view class="card-content">
+              <text>缁撴潫杩愯鏃堕棿锛歿{ notice.endRuntimeTime || "-" }}</text>
+            </view>
+            <view class="card-content">
+              <text>杩愯鏃堕暱锛歿{ notice.runtimeDuration || "-" }}</text>
+            </view>
+            <up-button text
+                       v-if="isOverdue(notice)"
+                       type="warning"
+                       size="small"
+                       @click="handleEdit(notice, '鍚姩杩愯')"
+                       :disabled="isNoticeExpired(notice)">
+              <up-icon name="play-circle"
+                       size="16"
+                       style="margin-right: 10rpx;"
+                       color="#fff" />
+              绔嬪嵆鍚姩
+            </up-button>
+            <up-button text
+                       v-else-if="notice.status"
+                       :type="getTagType2(notice.status)"
+                       size="small"
+                       @click="handleEdit(notice, notice.status === '杩愯涓�' ? '鍋滄杩愯' : '鍚姩杩愯')"
+                       :disabled="isNoticeExpired(notice)">
+              <up-icon :name="getIconName2(notice.status)"
+                       size="16"
+                       color="#fff" />
+              {{ notice.status === '杩愯涓�' ? '鍋滄杩愯' : '绔嬪嵆鍚姩' }}
+            </up-button>
+          </view>
+        </view>
+      </view>
+      <!-- 绌虹姸鎬� -->
+      <view class="empty-state"
+            v-if="holidayNotices.length === 0 && maintenanceNotices.length === 0">
+        <text>鏆傛棤閫氱煡鍏憡</text>
+      </view>
+    </view>
+  </view>
+</template>
+
+<script setup>
+  import { onMounted, ref } from "vue";
+  import PageHeader from "@/components/PageHeader.vue";
+  import {
+    getLedgerPage,
+    editLedger,
+  } from "@/api/equipmentManagement/runManagement.js";
+
+  // 鑾峰彇鏍囩绫诲瀷
+  const getTagType = status => {
+    switch (status) {
+      case "杩愯涓�":
+        return "success";
+      case "鍋滄杩愯":
+        return "error";
+      default:
+        return "info";
+    }
+  };
+  const getTagType2 = status => {
+    switch (status) {
+      case "鍋滄杩愯":
+        return "success";
+      case "杩愯涓�":
+        return "error";
+      default:
+        return "info";
+    }
+  };
+  // 鑾峰彇鍥炬爣鍚嶇О
+  const getIconName = status => {
+    switch (status) {
+      case "杩愯涓�":
+        return "play-circle";
+      case "鍋滄杩愯":
+        return "pause-circle";
+      default:
+        return "question-circle";
+    }
+  };
+  // 鑾峰彇鍥炬爣鍚嶇О2
+  const getIconName2 = status => {
+    switch (status) {
+      case "鍋滄杩愯":
+        return "play-circle";
+      case "杩愯涓�":
+        return "pause-circle";
+      default:
+        return "question-circle";
+    }
+  };
+  const goBack = () => {
+    uni.navigateBack();
+  };
+  const isOverdue = notice => {
+    if (
+      notice.status == "杩愯涓�" ||
+      !notice.planRuntimeTime ||
+      notice.startRuntimeTime
+    ) {
+      return false;
+    }
+    const planTime = new Date(notice.planRuntimeTime).getTime();
+    const currentTime = new Date().getTime();
+    return currentTime > planTime;
+  };
+
+  const isNoticeExpired = notice => {
+    if (!notice || !notice.expirationDate) {
+      return false;
+    }
+
+    const expiration = new Date(notice.expirationDate);
+
+    if (Number.isNaN(expiration.getTime())) {
+      return false;
+    }
+
+    expiration.setHours(23, 59, 59, 999);
+
+    return new Date() > expiration;
+  };
+
+  const handleEdit = async (device, status) => {
+    try {
+      const currentTime = new Date()
+        .toLocaleString("zh-CN", {
+          year: "numeric",
+          month: "2-digit",
+          day: "2-digit",
+          hour: "2-digit",
+          minute: "2-digit",
+          second: "2-digit",
+          hour12: false,
+        })
+        .replace(/\//g, "-");
+
+      // 鏇存柊璁惧鐘舵�佸拰鐩稿叧鏃堕棿瀛楁
+      if (status === "鍚姩杩愯") {
+        device.status = "杩愯涓�";
+        device.startRuntimeTime = currentTime;
+        device.endRuntimeTime = null; // 娓呯┖缁撴潫鏃堕棿
+        device.runtimeDuration = null; // 娓呯┖杩愯鏃堕暱
+      } else {
+        device.status = "鍋滄杩愯";
+        device.endRuntimeTime = currentTime;
+        // 璁$畻杩愯鏃堕暱
+        if (device.startRuntimeTime) {
+          const startTime = new Date(device.startRuntimeTime);
+          const endTime = new Date(currentTime);
+          const duration = endTime - startTime;
+          const hours = Math.floor(duration / (1000 * 60 * 60));
+          const minutes = Math.floor((duration % (1000 * 60 * 60)) / (1000 * 60));
+          device.runtimeDuration = `${hours}灏忔椂${minutes}鍒嗛挓`;
+        }
+      }
+      const params = {
+        id: device.id,
+        status: device.status,
+        planRuntimeTime: device.planRuntimeTime,
+        startRuntimeTime: device.startRuntimeTime,
+        endRuntimeTime: device.endRuntimeTime,
+        runtimeDuration: device.runtimeDuration,
+      };
+      // 璋冪敤API鏇存柊璁惧鐘舵��
+      const response = await editLedger(params);
+      if (response.code === 200) {
+        showToast(`${device.deviceName} ${status}鎴愬姛`);
+        // 鍒锋柊鍒楄〃
+        await fetchHolidayNotices();
+      } else {
+        showToast(response.msg || "鎿嶄綔澶辫触");
+      }
+    } catch (error) {
+      console.error("鏇存柊璁惧鐘舵�佸け璐�:", error);
+      showToast("鎿嶄綔澶辫触");
+    }
+  };
+
+  const holidayNotices = ref([]);
+  const maintenanceNotices = ref([]);
+
+  const fetchHolidayNotices = (append = false) => {
+    getLedgerPage({}).then(res => {
+      holidayNotices.value = res?.data?.records || [];
+    });
+  };
+
+  // 鐢熷懡鍛ㄦ湡
+  onMounted(() => {
+    fetchHolidayNotices();
+  });
+</script>
+
+<style scoped>
+  .notice-page {
+    min-height: 100vh;
+    background: #f5f7fa;
+    padding-bottom: 16px;
+    display: flex;
+    flex-direction: column;
+  }
+
+  .search_form {
+    background: #ffffff;
+    padding: 12px 16px;
+    margin: 8px 12px 12px;
+    border-radius: 10px;
+    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
+    display: flex;
+    justify-content: flex-start;
+    align-items: center;
+  }
+
+  .search_title {
+    font-weight: 500;
+    color: #333;
+    margin-right: 8px;
+  }
+
+  .ml10 {
+    margin-left: 10px;
+  }
+
+  .notice-board {
+    padding: 0 12px 16px;
+  }
+
+  .notice-section {
+    margin-bottom: 16px;
+  }
+
+  .section-header {
+    display: flex;
+    align-items: center;
+    margin: 4px 4px 12px;
+  }
+
+  .section-header h3 {
+    margin: 0;
+    color: #303133;
+    font-size: 16px;
+    font-weight: 600;
+  }
+
+  .section-count {
+    margin-left: 10px;
+    background: #409eff;
+    color: white;
+    padding: 2px 8px;
+    border-radius: 12px;
+    font-size: 12px;
+  }
+
+  .notice-cards {
+    display: flex;
+    flex-direction: column;
+    gap: 12px;
+  }
+
+  .notice-card {
+    background: white;
+    border-radius: 12px;
+    padding: 14px 14px 10px;
+    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06);
+    transition: all 0.3s ease;
+    border-left: 4px solid transparent;
+  }
+
+  .notice-card:hover {
+    transform: translateY(-2px);
+    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
+  }
+
+  .holiday-card {
+    border-left-color: #bec4c3;
+  }
+
+  .maintenance-card {
+    border-left-color: #e6a23c;
+  }
+
+  .urgent {
+    border-left-color: #f56c6c;
+    background: linear-gradient(135deg, #fff5f5 0%, #ffffff 100%);
+  }
+
+  .card-header {
+    display: flex;
+    justify-content: space-between;
+    align-items: flex-start;
+    margin-bottom: 10px;
+  }
+
+  .card-title {
+    display: flex;
+    align-items: center;
+    font-size: 15px;
+    font-weight: 600;
+    color: #303133;
+    flex: 1;
+  }
+
+  .holiday-icon {
+    color: #67c23a;
+    margin-right: 8px;
+    font-size: 18px;
+  }
+
+  .maintenance-icon {
+    color: #e6a23c;
+    margin-right: 8px;
+    font-size: 18px;
+  }
+
+  .card-actions {
+    display: flex;
+    gap: 8px;
+    padding: 4rpx 8rpx;
+    border-radius: 10rpx;
+  }
+
+  .card-content {
+    margin-bottom: 10px;
+  }
+
+  .card-content text {
+    color: #606266;
+    line-height: 1.6;
+    font-size: 13px;
+  }
+
+  .card-footer {
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    margin-bottom: 10px;
+  }
+
+  .card-meta {
+    display: flex;
+    gap: 8px;
+  }
+
+  .type,
+  .priority,
+  .status {
+    padding: 2px 8px;
+    border-radius: 12px;
+    font-size: 12px;
+    font-weight: 500;
+  }
+
+  .type-1 {
+    background: #f0f9ff;
+    color: #0369a1;
+  }
+
+  .type-2 {
+    background: #fef3c7;
+    color: #d97706;
+  }
+
+  .priority-1 {
+    background: #f0f9ff;
+    color: #0369a1;
+  }
+
+  .priority-2 {
+    background: #fef3c7;
+    color: #d97706;
+  }
+  .success {
+    background: #67c23a;
+    color: #fff;
+  }
+  .error {
+    background: #f56c6c;
+    color: #fff;
+  }
+  .info {
+    background: #a8a9aa;
+    color: #fff;
+  }
+  .warning {
+    background: #e6a23c;
+    color: #fff;
+  }
+
+  .priority-3 {
+    background: #fef2f2;
+    color: #dc2626;
+  }
+
+  .status-0 {
+    background: #f3f4f6;
+    color: #6b7280;
+  }
+
+  .status-1 {
+    background: #d1fae5;
+    color: #059669;
+  }
+
+  .status-2 {
+    background: #fef3c7;
+    color: #d97706;
+  }
+
+  .card-info {
+    display: flex;
+    flex-direction: column;
+    align-items: flex-end;
+    font-size: 12px;
+    color: #909399;
+  }
+
+  .creator {
+    font-weight: 500;
+    margin-bottom: 2px;
+  }
+
+  .expiration {
+    margin-top: 2px;
+  }
+
+  .card-remark {
+    display: flex;
+    align-items: center;
+    gap: 6px;
+    padding: 8px 12px;
+    background: #f8f9fa;
+    border-radius: 6px;
+    font-size: 12px;
+    color: #606266;
+    border-left: 3px solid #409eff;
+  }
+
+  .empty-state {
+    text-align: center;
+    padding: 48px 16px;
+    color: #999;
+    font-size: 13px;
+  }
+
+  .dialog-footer {
+    text-align: right;
+  }
+
+  /* 绉诲姩绔脊绐楁牱寮� */
+  .dialog-container {
+    background: #ffffff;
+    border-radius: 18px 18px 0 0;
+    max-height: 80vh;
+    display: flex;
+    flex-direction: column;
+  }
+
+  .dialog-header {
+    padding: 16px 20px 8px 20px;
+  }
+
+  .dialog-title {
+    font-size: 16px;
+    font-weight: 600;
+    color: #303133;
+  }
+
+  .dialog-body {
+    flex: 1;
+    padding: 0 16px 12px 16px;
+    overflow-y: auto;
+  }
+
+  .dialog-footer {
+    display: flex;
+    padding: 12px 16px 16px 16px;
+    border-top: 1px solid #f0f0f0;
+  }
+
+  /* 鍝嶅簲寮忚璁� */
+  @media (max-width: 768px) {
+    .search_form {
+      flex-direction: column;
+      gap: 15px;
+      align-items: flex-start;
+    }
+
+    .search_form > div {
+      width: 100%;
+      display: flex;
+      gap: 10px;
+    }
+  }
+</style>

--
Gitblit v1.9.3