zhangwencui
2026-05-23 26b2a4b21b3c2cd34e6781cf7876eae580a7e1ec
src/pages/equipmentManagement/repair/index.vue
@@ -37,10 +37,8 @@
              <text class="item-id">设备名称:{{ item.deviceName }}</text>
            </view>
            <view class="status-tag">
              <u-tag v-if="item.status === 1"
                     type="success">完结</u-tag>
              <u-tag v-if="item.status === 0"
                     type="error">待维修</u-tag>
              <u-tag :type="getStatusType(item.status)"
                     size="mini">{{ getStatusLabel(item.status) }}</u-tag>
            </view>
          </view>
          <up-divider></up-divider>
@@ -62,6 +60,10 @@
              <text class="detail-value">{{ item.maintenanceName || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">验收人</text>
              <text class="detail-value">{{ item.acceptanceName || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">维修项目</text>
              <text class="detail-value">{{ item.machineryCategory || '-' }}</text>
            </view>
@@ -75,11 +77,26 @@
            </view>
            <view class="detail-row">
              <text class="detail-label">维修日期</text>
              <text class="detail-value">{{ formatDate(item.maintenanceTime) || '-' }}</text>
              <text class="detail-value">{{ formatDateTime(item.maintenanceTime) || '-' }}</text>
            </view>
          </view>
          <!-- 按钮区域 -->
          <view class="action-buttons">
            <u-button type="info"
                      size="small"
                      plain
                      class="action-btn"
                      @click="goDetail(item)">
              详情
            </u-button>
            <u-button type="success"
                      size="small"
                      class="action-btn"
                      v-if="item.status === 3"
                      :disabled="!canAccept(item)"
                      @click="goAcceptance(item)">
              验收
            </u-button>
            <u-button type="primary"
                      size="small"
                      class="action-btn"
@@ -135,6 +152,22 @@
  const userStore = useUserStore();
  const STATUS_MAP = {
    0: { label: "待维修", type: "error" },
    1: { label: "完成", type: "success" },
    2: { label: "维修失败", type: "warning" },
    3: { label: "待验收", type: "primary" },
  };
  const getStatusLabel = status => STATUS_MAP[status]?.label || "-";
  const getStatusType = status => STATUS_MAP[status]?.type || "info";
  const canAccept = item => {
    if (item.status !== 3) return false;
    const currentName = userStore.nickName || userStore.name || "";
    return currentName && item.acceptanceName === currentName;
  };
  // 搜索关键词
  const searchKeyword = ref("");
@@ -154,6 +187,18 @@
    const month = String(date.getMonth() + 1).padStart(2, "0");
    const day = String(date.getDate()).padStart(2, "0");
    return `${year}-${month}-${day}`;
  };
  const formatDateTime = dateStr => {
    if (!dateStr) return "";
    const date = new Date(dateStr);
    const year = date.getFullYear();
    const month = String(date.getMonth() + 1).padStart(2, "0");
    const day = String(date.getDate()).padStart(2, "0");
    const hours = String(date.getHours()).padStart(2, "0");
    const minutes = String(date.getMinutes()).padStart(2, "0");
    const seconds = String(date.getSeconds()).padStart(2, "0");
    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  };
  // 查询列表
@@ -194,7 +239,6 @@
      showToast("参数错误");
      return;
    }
    // 使用uni.setStorageSync存储id
    uni.setStorageSync("repairId", id);
    uni.navigateTo({
      url: "/pages/equipmentManagement/repair/maintain",
@@ -208,13 +252,31 @@
    });
  };
  // 编辑 - 跳转到add页面,通过id区分新增还是编辑
  // 编辑
  const edit = id => {
    if (!id) return;
    // 使用uni.setStorageSync存储id
    // uni.setStorageSync("repairId", id);
    uni.navigateTo({
      url: "/pages/equipmentManagement/repair/add?id=" + id,
    });
  };
  // 详情
  const goDetail = item => {
    uni.setStorageSync("repairDetail", JSON.stringify(item));
    uni.navigateTo({
      url: "/pages/equipmentManagement/repair/detail?id=" + item.id,
    });
  };
  // 验收
  const goAcceptance = item => {
    if (!canAccept(item)) {
      showToast("仅指定验收人可进行验收");
      return;
    }
    uni.setStorageSync("repairDetail", JSON.stringify(item));
    uni.navigateTo({
      url: "/pages/equipmentManagement/repair/acceptance?id=" + item.id,
    });
  };
@@ -243,6 +305,9 @@
  };
  onMounted(() => {
    if (!userStore.nickName) {
      userStore.getInfo().catch(() => {});
    }
    getList();
  });
@@ -254,9 +319,8 @@
<style scoped lang="scss">
  @import "@/styles/sales-common.scss";
  // 设备维修特有样式
  .sales-account {
    padding-bottom: 80px; // 为浮动按钮留出空间
    padding-bottom: 80px;
  }
  .status-tag {
@@ -265,6 +329,7 @@
  }
  .action-buttons {
    gap: 8px; // 与公共样式中的 12px 不同
    gap: 8px;
    flex-wrap: wrap;
  }
</style>
</style>