已添加2个文件
已修改12个文件
2694 ■■■■ 文件已修改
src/api/equipmentManagement/inspection.js 212 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/equipmentManagement/upkeep.js 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages.json 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/equipmentManagement/repair/add.vue 460 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/equipmentManagement/repair/index.vue 368 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/equipmentManagement/repair/maintain.vue 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/equipmentManagement/smartDispatch/index.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/equipmentManagement/upkeep/index.vue 360 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/equipmentManagement/upkeepTask/components/formDia.vue 659 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/equipmentManagement/upkeepTask/index.vue 454 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/index.vue 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/indexItem.vue 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/inspectionManagement/index.vue 75 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/safeProduction/dangerInvestigation/detail.vue 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/equipmentManagement/inspection.js
@@ -1,6 +1,6 @@
import request from '@/utils/request'
import request from "@/utils/request";
// ==================== å·¡æ£€ä»»åŠ¡ç®¡ç† ====================
// ==================== å·¡æ£€ä»»åŠ¡ ====================
/**
 * @desc æŸ¥è¯¢å·¡æ£€ä»»åŠ¡åˆ—è¡¨
@@ -12,10 +12,10 @@
 */
export function getInspectionTaskList(query) {
  return request({
    url: '/equipment/inspection/task/list',
    method: 'get',
    params: query
  })
    url: "/equipment/inspection/task/list",
    method: "get",
    params: query,
  });
}
/**
@@ -25,9 +25,9 @@
 */
export function getInspectionTask(id) {
  return request({
    url: '/equipment/inspection/task/' + id,
    method: 'get'
  })
    url: "/equipment/inspection/task/" + id,
    method: "get",
  });
}
/**
@@ -37,10 +37,10 @@
 */
export function createInspectionTask(data) {
  return request({
    url: '/equipment/inspection/task',
    method: 'post',
    data: data
  })
    url: "/equipment/inspection/task",
    method: "post",
    data: data,
  });
}
/**
@@ -50,10 +50,10 @@
 */
export function updateInspectionTask(data) {
  return request({
    url: '/equipment/inspection/task',
    method: 'put',
    data: data
  })
    url: "/equipment/inspection/task",
    method: "put",
    data: data,
  });
}
/**
@@ -63,9 +63,9 @@
 */
export function deleteInspectionTask(id) {
  return request({
    url: '/equipment/inspection/task/' + id,
    method: 'delete'
  })
    url: "/equipment/inspection/task/" + id,
    method: "delete",
  });
}
/**
@@ -75,9 +75,9 @@
 */
export function startInspectionTask(taskId) {
  return request({
    url: '/equipment/inspection/task/' + taskId + '/start',
    method: 'post'
  })
    url: "/equipment/inspection/task/" + taskId + "/start",
    method: "post",
  });
}
/**
@@ -88,10 +88,10 @@
 */
export function completeInspectionTask(taskId, data) {
  return request({
    url: '/equipment/inspection/task/' + taskId + '/complete',
    method: 'post',
    data: data
  })
    url: "/equipment/inspection/task/" + taskId + "/complete",
    method: "post",
    data: data,
  });
}
// ==================== å·¡æ£€è®°å½•管理 ====================
@@ -103,10 +103,10 @@
 */
export function submitInspectionRecord(data) {
  return request({
    url: '/equipment/inspection/record/submit',
    method: 'post',
    data: data
  })
    url: "/equipment/inspection/record/submit",
    method: "post",
    data: data,
  });
}
/**
@@ -116,10 +116,10 @@
 */
export function getInspectionRecordList(query) {
  return request({
    url: '/equipment/inspection/record/list',
    method: 'get',
    params: query
  })
    url: "/equipment/inspection/record/list",
    method: "get",
    params: query,
  });
}
/**
@@ -129,9 +129,9 @@
 */
export function getInspectionRecord(id) {
  return request({
    url: '/equipment/inspection/record/' + id,
    method: 'get'
  })
    url: "/equipment/inspection/record/" + id,
    method: "get",
  });
}
// ==================== æ–‡ä»¶ä¸Šä¼  ====================
@@ -143,13 +143,13 @@
 */
export function uploadInspectionImage(file) {
  return request({
    url: '/equipment/inspection/upload/image',
    method: 'post',
    url: "/equipment/inspection/upload/image",
    method: "post",
    data: file,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
      "Content-Type": "multipart/form-data",
    },
  });
}
/**
@@ -159,13 +159,13 @@
 */
export function uploadInspectionVideo(file) {
  return request({
    url: '/equipment/inspection/upload/video',
    method: 'post',
    url: "/equipment/inspection/upload/video",
    method: "post",
    data: file,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
      "Content-Type": "multipart/form-data",
    },
  });
}
/**
@@ -175,13 +175,13 @@
 */
export function batchUploadFiles(formData) {
  return request({
    url: '/equipment/inspection/upload/batch',
    method: 'post',
    url: "/equipment/inspection/upload/batch",
    method: "post",
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
      "Content-Type": "multipart/form-data",
    },
  });
}
// ==================== å¼‚常报备管理 ====================
@@ -193,10 +193,10 @@
 */
export function reportAbnormalSituation(data) {
  return request({
    url: '/equipment/inspection/abnormal/report',
    method: 'post',
    data: data
  })
    url: "/equipment/inspection/abnormal/report",
    method: "post",
    data: data,
  });
}
/**
@@ -206,10 +206,10 @@
 */
export function getAbnormalReportList(query) {
  return request({
    url: '/equipment/inspection/abnormal/list',
    method: 'get',
    params: query
  })
    url: "/equipment/inspection/abnormal/list",
    method: "get",
    params: query,
  });
}
/**
@@ -219,9 +219,9 @@
 */
export function getAbnormalReport(id) {
  return request({
    url: '/equipment/inspection/abnormal/' + id,
    method: 'get'
  })
    url: "/equipment/inspection/abnormal/" + id,
    method: "get",
  });
}
/**
@@ -232,10 +232,10 @@
 */
export function handleAbnormalReport(id, data) {
  return request({
    url: '/equipment/inspection/abnormal/' + id + '/handle',
    method: 'post',
    data: data
  })
    url: "/equipment/inspection/abnormal/" + id + "/handle",
    method: "post",
    data: data,
  });
}
/**
@@ -246,10 +246,10 @@
 */
export function transferAbnormalReport(id, data) {
  return request({
    url: '/equipment/inspection/abnormal/' + id + '/transfer',
    method: 'post',
    data: data
  })
    url: "/equipment/inspection/abnormal/" + id + "/transfer",
    method: "post",
    data: data,
  });
}
/**
@@ -260,10 +260,10 @@
 */
export function closeAbnormalReport(id, data) {
  return request({
    url: '/equipment/inspection/abnormal/' + id + '/close',
    method: 'post',
    data: data
  })
    url: "/equipment/inspection/abnormal/" + id + "/close",
    method: "post",
    data: data,
  });
}
// ==================== ç»Ÿè®¡åˆ†æž ====================
@@ -275,10 +275,10 @@
 */
export function getInspectionStats(params) {
  return request({
    url: '/equipment/inspection/stats',
    method: 'get',
    params: params
  })
    url: "/equipment/inspection/stats",
    method: "get",
    params: params,
  });
}
/**
@@ -288,10 +288,10 @@
 */
export function getAbnormalStats(params) {
  return request({
    url: '/equipment/inspection/abnormal/stats',
    method: 'get',
    params: params
  })
    url: "/equipment/inspection/abnormal/stats",
    method: "get",
    params: params,
  });
}
/**
@@ -301,11 +301,11 @@
 */
export function exportInspectionReport(params) {
  return request({
    url: '/equipment/inspection/export/report',
    method: 'get',
    url: "/equipment/inspection/export/report",
    method: "get",
    params: params,
    responseType: 'blob'
  })
    responseType: "blob",
  });
}
/**
@@ -315,11 +315,11 @@
 */
export function exportAbnormalRecords(params) {
  return request({
    url: '/equipment/inspection/abnormal/export',
    method: 'get',
    url: "/equipment/inspection/abnormal/export",
    method: "get",
    params: params,
    responseType: 'blob'
  })
    responseType: "blob",
  });
}
// ==================== è®¾å¤‡äºŒç»´ç  ====================
@@ -332,8 +332,8 @@
export function getDeviceQRCode(deviceId) {
  return request({
    url: `/equipment/device/${deviceId}/qrcode`,
    method: 'get'
  })
    method: "get",
  });
}
/**
@@ -343,10 +343,10 @@
 */
export function verifyDeviceQRCode(data) {
  return request({
    url: '/equipment/device/qrcode/verify',
    method: 'post',
    data: data
  })
    url: "/equipment/device/qrcode/verify",
    method: "post",
    data: data,
  });
}
// ==================== æ¨¡æ¿ç®¡ç† ====================
@@ -358,10 +358,10 @@
 */
export function getInspectionTemplateList(query) {
  return request({
    url: '/equipment/inspection/template/list',
    method: 'get',
    params: query
  })
    url: "/equipment/inspection/template/list",
    method: "get",
    params: query,
  });
}
/**
@@ -371,7 +371,7 @@
 */
export function getInspectionTemplate(id) {
  return request({
    url: '/equipment/inspection/template/' + id,
    method: 'get'
  })
}
    url: "/equipment/inspection/template/" + id,
    method: "get",
  });
}
src/api/equipmentManagement/upkeep.js
@@ -97,6 +97,42 @@
  });
}
// ---------- è®¾å¤‡ä¿å…»å®šæ—¶ä»»åŠ¡ï¼ˆå®šæ—¶ä»»åŠ¡ç®¡ç†ï¼‰ ----------
/** è®¾å¤‡ä¿å…»å®šæ—¶ä»»åŠ¡åˆ†é¡µåˆ—è¡¨ */
export const deviceMaintenanceTaskList = (params) => {
  return request({
    url: "/deviceMaintenanceTask/listPage",
    method: "get",
    params,
  });
};
/** æ–°å¢žè®¾å¤‡ä¿å…»å®šæ—¶ä»»åŠ¡ */
export const deviceMaintenanceTaskAdd = (data) => {
  return request({
    url: "/deviceMaintenanceTask/add",
    method: "post",
    data,
  });
};
/** ä¿®æ”¹è®¾å¤‡ä¿å…»å®šæ—¶ä»»åŠ¡ */
export const deviceMaintenanceTaskEdit = (data) => {
  return request({
    url: "/deviceMaintenanceTask/update",
    method: "post",
    data,
  });
};
/** åˆ é™¤è®¾å¤‡ä¿å…»å®šæ—¶ä»»åŠ¡ */
export const deviceMaintenanceTaskDel = (ids) => {
  return request({
    url: "/deviceMaintenanceTask/delete",
    method: "delete",
    data: Array.isArray(ids) ? ids : [ids],
  });
};
// æŸ¥è¯¢å¤‡ä»¶é€‰é¡¹
export const getSparePartsOptions = (params) => {
src/pages.json
@@ -541,6 +541,15 @@
      }
    },
    {
      "path": "pages/equipmentManagement/upkeepTask/index",
      "style": {
        "navigationBarTitleText": "设备保养任务",
        "navigationStyle": "custom",
        "enablePullDownRefresh": true,
        "backgroundColor": "#f8f8f8"
      }
    },
    {
      "path": "pages/equipmentManagement/upkeep/detail",
      "style": {
        "navigationBarTitleText": "保养详情",
@@ -615,7 +624,7 @@
    {
      "path": "pages/inspectionManagement/index",
      "style": {
        "navigationBarTitleText": "巡检任务管理",
        "navigationBarTitleText": "巡检任务",
        "navigationStyle": "custom",
        "enablePullDownRefresh": true,
        "backgroundColor": "#f8f8f8"
src/pages/equipmentManagement/repair/add.vue
@@ -14,17 +14,22 @@
        <u-form-item label="设备名称"
                     prop="deviceLedgerId"
                     required
                     border-bottom>
          <u-input v-model="deviceNameText"
                   placeholder="请选择设备名称"
                   @click="showDevicePicker"
                   clearable
                   readonly="" />
          <template #right>
            <u-icon name="scan"
                    @click="startScan"
                    class="scan-icon" />
          </template>
                     border-bottom
                     class="device-name-form-item">
          <view class="device-picker-wrap">
            <picker mode="selector"
                    class="device-picker-full"
                    :range="deviceOptions"
                    range-key="deviceName"
                    :value="deviceIndex"
                    @change="onDevicePickerChange">
              <view class="picker-input-row">
                <text class="picker-input-text"
                      :class="{ placeholder: !deviceNameText }">{{ deviceNameText || "请选择设备名称" }}</text>
                <view class="picker-input-arrow"><u-icon name="arrow-right" /></view>
              </view>
            </picker>
          </view>
        </u-form-item>
        <u-form-item label="规格型号"
                     prop="deviceModel"
@@ -48,7 +53,7 @@
          </template>
        </u-form-item>
        <u-form-item label="报修状态"
                     prop="repairTime"
                     prop="status"
                     required
                     border-bottom>
          <u-input v-model="repairStatusText"
@@ -80,6 +85,53 @@
                      count
                      maxlength="200" />
        </u-form-item>
        <view class="simple-upload-area">
            <view class="upload-buttons">
              <u-button type="primary"
                        @click="chooseRepairMedia"
                        :loading="uploading"
                        :disabled="repairFileList.length >= uploadConfig.limit"
                        :customStyle="{ marginRight: '10px', flex: 1 }">
                <u-icon name="camera"
                        size="18"
                        color="#fff"
                        style="margin-right: 5px;"></u-icon>
                {{ uploading ? "上传中..." : "拍照" }}
              </u-button>
            </view>
            <view v-if="uploading"
                  class="upload-progress">
              <u-line-progress :percentage="uploadProgress"
                               :showText="true"
                               activeColor="#409eff"></u-line-progress>
            </view>
            <view v-if="repairFileList.length > 0"
                  class="file-list">
              <view v-for="(file, index) in repairFileList"
                    :key="index"
                    class="file-item">
                <view class="file-preview-container">
                  <view class="delete-btn"
                        @click="removeRepairFile(index)">
                    <u-icon name="close"
                            size="12"
                            color="#fff"></u-icon>
                  </view>
                  <image :src="file.url || file.tempFilePath || file.path || file.downloadUrl"
                         class="file-preview"
                         mode="aspectFill" />
                </view>
                <view class="file-info">
                  <text class="file-name">{{ file.bucketFilename || file.name || "图片" }}</text>
                  <text class="file-size">{{ formatFileSize(file.size) }}</text>
                </view>
              </view>
            </view>
            <view v-if="repairFileList.length === 0"
                  class="empty-state">
              <text>请选择要上传的现场照片</text>
            </view>
          </view>
      </u-cell-group>
      <!-- æäº¤æŒ‰é’® -->
      <view class="footer-btns">
@@ -91,12 +143,6 @@
                  :loading="loading">保存</u-button>
      </view>
    </u-form>
    <!-- è®¾å¤‡é€‰æ‹©å™¨ -->
    <up-action-sheet :show="showDevice"
                     :actions="deviceActionList"
                     title="选择设备名称"
                     @select="onDeviceSelect"
                     @close="showDevice = false" />
    <!-- æ—¥æœŸé€‰æ‹©å™¨ -->
    <up-datetime-picker :show="showDate"
                        v-model="pickerDateValue"
@@ -107,7 +153,7 @@
</template>
<script setup>
  import { ref, computed, onMounted, onUnmounted } from "vue";
  import { ref, computed, onMounted } from "vue";
  import { onShow } from "@dcloudio/uni-app";
  import PageHeader from "@/components/PageHeader.vue";
  import { getDeviceLedger } from "@/api/equipmentManagement/ledger";
@@ -116,6 +162,8 @@
    editRepair,
    getRepairById,
  } from "@/api/equipmentManagement/repair";
  import config from "@/config";
  import { getToken } from "@/utils/auth";
  import dayjs from "dayjs";
  import { formatDateToYMD } from "@/utils/ruoyi";
  const showToast = message => {
@@ -133,23 +181,28 @@
  const formRef = ref(null);
  const operationType = ref("add");
  const loading = ref(false);
  const showDevice = ref(false);
  const showDate = ref(false);
  const pickerDateValue = ref(Date.now());
  // ä¸Šä¼ é…ç½®ï¼ˆä¸Žå·¡æ£€ä¸€è‡´ï¼‰
  const uploadConfig = {
    action: "/file/upload",
    limit: 10,
  };
  const uploadFileUrl = computed(() => config.baseUrl + uploadConfig.action);
  const repairFileList = ref([]);
  const uploading = ref(false);
  const uploadProgress = ref(0);
  // è®¾å¤‡é€‰é¡¹
  const deviceOptions = ref([]);
  const deviceNameText = ref("");
  const deviceActionList = computed(() => {
    return deviceOptions.value.map(item => ({
      name: item.deviceName,
      value: item.id,
    }));
  const deviceIndex = computed(() => {
    const id = form.value.deviceLedgerId;
    if (id == null || !deviceOptions.value.length) return 0;
    const idx = deviceOptions.value.findIndex(item => item.id === id || item.id == id);
    return idx >= 0 ? idx : 0;
  });
  // æ‰«ç ç›¸å…³çŠ¶æ€
  const isScanning = ref(false);
  const scanTimer = ref(null);
  // è¡¨å•验证规则
  const formRules = {
@@ -158,6 +211,9 @@
    ],
    repairTime: [
      { required: true, trigger: "change", message: "请选择报修日期" },
    ],
    status: [
      { required: true, trigger: "change", message: "请选择报修状态" },
    ],
    repairName: [{ required: true, trigger: "blur", message: "请输入报修人" }],
    remark: [{ required: true, trigger: "blur", message: "请输入故障现象" }],
@@ -168,6 +224,7 @@
    deviceLedgerId: undefined, // è®¾å¤‡ID
    deviceModel: undefined, // è§„格型号
    repairTime: dayjs().format("YYYY-MM-DD"), // æŠ¥ä¿®æ—¥æœŸ
    status: undefined, // æŠ¥ä¿®çŠ¶æ€
    repairName: undefined, // æŠ¥ä¿®äºº
    remark: undefined, // æ•…障现象
  });
@@ -220,6 +277,7 @@
          form.value.deviceLedgerId = data.deviceLedgerId;
          form.value.deviceModel = data.deviceModel;
          form.value.repairTime = dayjs(data.repairTime).format("YYYY-MM-DD");
          form.value.status = data.status;
          form.value.repairName = data.repairName;
          form.value.remark = data.remark;
          repairStatusText.value =
@@ -232,6 +290,15 @@
          if (device) {
            deviceNameText.value = device.deviceName;
          }
          // å›žæ˜¾é™„件列表(后端返回 fileList æ—¶ï¼‰
          const list = data.fileList || data.commonFileList || [];
          repairFileList.value = (Array.isArray(list) ? list : []).map(f => ({
            url: f.url || f.downloadUrl,
            name: f.bucketFilename || f.originalFilename || f.name,
            bucketFilename: f.bucketFilename || f.originalFilename || f.name,
            size: f.size || f.byteSize,
            uploadResponse: f,
          }));
        }
      } catch (e) {
        showToast("获取详情失败");
@@ -242,77 +309,136 @@
    }
  };
  // æ‰«æäºŒç»´ç åŠŸèƒ½
  const startScan = () => {
    if (isScanning.value) {
      showToast("正在扫描中,请稍候...");
  // ä¸‹æ‹‰æ¡†é€‰æ‹©è®¾å¤‡
  const onDevicePickerChange = e => {
    const index = Number(e.detail?.value ?? 0);
    const item = deviceOptions.value[index];
    if (item) {
      form.value.deviceLedgerId = item.id;
      setDeviceModel(item.id);
    }
  };
  // æ ¼å¼åŒ–文件大小
  const formatFileSize = size => {
    if (!size) return "";
    if (size < 1024) return size + "B";
    if (size < 1024 * 1024) return (size / 1024).toFixed(1) + "KB";
    return (size / (1024 * 1024)).toFixed(1) + "MB";
  };
  // æ‹ç…§é€‰æ‹©ï¼ˆä¸Žå·¡æ£€ä¸€è‡´ï¼‰
  const chooseRepairMedia = () => {
    if (repairFileList.value.length >= uploadConfig.limit) {
      showToast(`最多只能选择${uploadConfig.limit}个文件`);
      return;
    }
    const remaining = uploadConfig.limit - repairFileList.value.length;
    if (typeof uni.chooseMedia === "function") {
      uni.chooseMedia({
        count: Math.min(remaining, 9),
        mediaType: ["image"],
        sizeType: ["compressed", "original"],
        sourceType: ["camera", "album"],
        success: res => {
          const files = res?.tempFiles || [];
          files.forEach((tf, idx) => {
            const filePath = tf.tempFilePath || tf.path || "";
            const file = {
              tempFilePath: filePath,
              path: filePath,
              type: "image",
              name: `repair_${Date.now()}_${idx}.jpg`,
              size: tf.size || 0,
              uid: Date.now() + Math.random() + idx,
            };
            uploadRepairFile(file);
          });
        },
        fail: () => showToast("选择图片失败"),
      });
    } else {
      uni.chooseImage({
        count: remaining,
        sizeType: ["compressed", "original"],
        sourceType: ["camera", "album"],
        success: res => {
          (res.tempFilePaths || []).forEach((path, idx) => {
            uploadRepairFile({
              tempFilePath: path,
              path: path,
              type: "image",
              name: `repair_${Date.now()}_${idx}.jpg`,
              size: 0,
              uid: Date.now() + Math.random(),
            });
          });
        },
        fail: () => showToast("选择图片失败"),
      });
    }
  };
    // è°ƒç”¨uni-app的扫码API
    uni.scanCode({
      scanType: ["qrCode", "barCode"],
  const uploadRepairFile = file => {
    const filePath = file.tempFilePath || file.path;
    if (!filePath) return;
    uploading.value = true;
    uploadProgress.value = 0;
    const token = getToken();
    if (!token) {
      showToast("请先登录");
      uploading.value = false;
      return;
    }
    const uploadTask = uni.uploadFile({
      url: uploadFileUrl.value,
      filePath,
      name: "file",
      header: { Authorization: "Bearer " + token },
      success: res => {
        handleScanResult(res.result);
        try {
          if (res.statusCode === 200) {
            const response = typeof res.data === "string" ? JSON.parse(res.data) : res.data;
            const d = response?.data !== undefined ? response.data : response;
            if (response && (response.code === 200 || response.code === 0) && d) {
              const fileData = {
                ...file,
                id: d.id,
                tempId: d.tempId ?? d.tempFileId ?? d.id,
                url: d.url || d.downloadUrl || filePath,
                bucketFilename: d.bucketFilename || d.originalFilename || file.name,
                downloadUrl: d.downloadUrl || d.url,
                size: d.size ?? d.byteSize ?? file.size,
                uploadResponse: response,
              };
              repairFileList.value.push(fileData);
            } else {
              showToast(response?.msg || "上传失败");
            }
          } else {
            showToast("上传失败");
          }
        } catch (e) {
          showToast("上传失败");
        }
        uploading.value = false;
        uploadProgress.value = 0;
      },
      fail: err => {
        console.error("扫码失败:", err);
        showToast("扫码失败,请重试");
      fail: () => {
        showToast("上传失败");
        uploading.value = false;
        uploadProgress.value = 0;
      },
    });
  };
  // å¤„理扫码结果
  const handleScanResult = scanResult => {
    if (!scanResult) {
      showToast("扫码结果为空");
      return;
    }
    isScanning.value = true;
    showToast("扫码成功");
    // 3秒后处理扫码结果
    scanTimer.value = setTimeout(() => {
      processScanResult(scanResult);
      isScanning.value = false;
    }, 100);
  };
  function getDeviceIdByRegExp(url) {
    // åŒ¹é…deviceId=后面的数字
    const reg = /deviceId=(\d+)/;
    const match = url.match(reg);
    // å¦‚果匹配到结果,返回数字类型,否则返回null
    return match ? Number(match[1]) : null;
  }
  // å¤„理扫码结果并匹配设备
  const processScanResult = scanResult => {
    const deviceId = getDeviceIdByRegExp(scanResult);
    const matchedDevice = deviceOptions.value.find(item => item.id == deviceId);
    if (matchedDevice) {
      // æ‰¾åˆ°åŒ¹é…çš„设备,自动填充
      form.value.deviceLedgerId = matchedDevice.id;
      deviceNameText.value = matchedDevice.deviceName;
      form.value.deviceModel = matchedDevice.deviceModel;
      showToast("设备信息已自动填充");
    } else {
      // æœªæ‰¾åˆ°åŒ¹é…çš„设备
      showToast("未找到匹配的设备,请手动选择");
    if (uploadTask && uploadTask.onProgressUpdate) {
      uploadTask.onProgressUpdate(e => {
        uploadProgress.value = e.progress;
      });
    }
  };
  // æ˜¾ç¤ºè®¾å¤‡é€‰æ‹©å™¨
  const showDevicePicker = () => {
    showDevice.value = true;
  };
  // ç¡®è®¤è®¾å¤‡é€‰æ‹©
  const onDeviceSelect = e => {
    form.value.deviceLedgerId = e.value;
    setDeviceModel(e.value);
    showDevice.value = false;
  const removeRepairFile = index => {
    repairFileList.value.splice(index, 1);
  };
  // æ˜¾ç¤ºæ—¥æœŸé€‰æ‹©å™¨
@@ -339,11 +465,6 @@
  });
  // ç»„件卸载时清理定时器
  onUnmounted(() => {
    if (scanTimer.value) {
      clearTimeout(scanTimer.value);
    }
  });
  // æäº¤è¡¨å•
  const sendForm = async () => {
@@ -357,6 +478,9 @@
      } else if (!form.value.repairTime || form.value.repairTime.trim() === "") {
        isValid = false;
        errorMessage = "请选择报修日期";
      } else if (form.value.status === undefined || form.value.status === null || form.value.status === "") {
        isValid = false;
        errorMessage = "请选择报修状态";
      } else if (!form.value.repairName || form.value.repairName.trim() === "") {
        isValid = false;
        errorMessage = "请输入报修人";
@@ -373,8 +497,13 @@
      loading.value = true;
      const id = getPageId();
      // å‡†å¤‡æäº¤æ•°æ®
      // é™„件数组:上传接口返回的附件信息(与巡检一致传 fileList)
      const fileList = repairFileList.value.map(f => {
        const d = f.uploadResponse?.data !== undefined ? f.uploadResponse.data : f.uploadResponse;
        return d ? { ...d } : null;
      }).filter(Boolean);
      const submitData = { ...form.value };
      if (fileList.length) submitData.fileList = fileList;
      const { code } = id
        ? await editRepair({ id: id, ...submitData })
@@ -480,10 +609,139 @@
    color: #888;
  }
  .scan-icon {
    color: #1989fa;
    font-size: 18px;
    margin-left: 8px;
    cursor: pointer;
  :deep(.device-name-form-item .u-form-item__content) {
    justify-content: flex-start !important;
  }
  .device-picker-wrap {
    width: 100%;
    flex: 1;
    min-width: 0;
  }
  .device-picker-full {
    display: block;
    width: 100%;
  }
  .picker-input-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 36px;
    padding: 0;
  }
  .picker-input-text {
    flex: 1;
    min-width: 0;
    font-size: 15px;
    color: #333;
    line-height: 36px;
    margin-right: 8px;
  }
  .picker-input-arrow {
    flex-shrink: 0;
    display: flex;
    align-items: center;
  }
  .picker-input-text.placeholder {
    color: #c0c4cc;
  }
  .simple-upload-area {
    padding: 15px 20px;
  }
  .upload-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
  }
  .upload-progress {
    margin: 15px 0;
    padding: 0 10px;
  }
  .file-list {
    margin-top: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
  }
  .file-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #fff;
    border-radius: 12px;
    padding: 8px;
    border: 1px solid #e9ecef;
    width: calc(50% - 6px);
    min-width: 120px;
  }
  .file-preview-container {
    position: relative;
    margin-bottom: 8px;
  }
  .file-preview {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    border: 2px solid #f0f0f0;
  }
  .delete-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    background: #ff4757;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
  }
  .file-info {
    text-align: center;
    width: 100%;
  }
  .file-name {
    font-size: 12px;
    color: #333;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
  }
  .file-size {
    font-size: 10px;
    color: #999;
    margin-top: 2px;
    display: block;
  }
  .empty-state {
    text-align: center;
    padding: 24px 16px;
    color: #999;
    font-size: 14px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px dashed #ddd;
  }
</style>
src/pages/equipmentManagement/repair/index.vue
@@ -49,7 +49,7 @@
              <text class="detail-value">{{ formatDate(item.repairTime) || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">报修人</text>
              <text class="detail-label">维修人</text>
              <text class="detail-value">{{ item.repairName || '-' }}</text>
            </view>
            <view class="detail-row">
@@ -57,7 +57,7 @@
              <text class="detail-value">{{ item.remark || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">维修人</text>
              <text class="detail-label">报修人</text>
              <text class="detail-value">{{ item.maintenanceName || '-' }}</text>
            </view>
            <view class="detail-row">
@@ -80,6 +80,14 @@
              @click="edit(item.id)"
            >
              ç¼–辑
            </u-button>
            <u-button
              type="success"
              size="small"
              class="action-btn"
              @click="viewAttachments(item)"
            >
              æŸ¥çœ‹é™„ä»¶
            </u-button>
            <u-button
              type="warning"
@@ -107,6 +115,72 @@
    <view v-else class="no-data">
      <text>暂无设备报修数据</text>
    </view>
    <!-- æŸ¥çœ‹é™„件弹窗 -->
    <view v-if="showAttachmentDialog" class="custom-modal-overlay" @click="closeAttachmentDialog">
      <view class="custom-modal-container" @click.stop>
        <view class="attachment-popup-content">
          <view class="attachment-popup-header">
            <text class="attachment-popup-title">查看附件 - {{ currentViewRepair?.deviceName || '报修' }}</text>
            <view class="close-btn-attachment" @click="closeAttachmentDialog">
              <u-icon name="close" size="16" color="#666"></u-icon>
            </view>
          </view>
          <view class="attachment-popup-body">
            <view class="attachment-content">
              <view v-if="attachmentList.length > 0" class="attachment-list">
                <view
                  v-for="(file, index) in attachmentList"
                  :key="index"
                  class="attachment-item"
                  @click="previewAttachment(file)"
                >
                  <view class="attachment-preview-container">
                    <image
                      v-if="isImageFile(file)"
                      :src="formatFileUrl(file.url || file.downloadUrl)"
                      class="attachment-preview"
                      mode="aspectFill"
                    />
                    <view v-else class="attachment-video-preview">
                      <u-icon name="video" size="24" color="#409eff"></u-icon>
                      <text class="video-text">视频</text>
                    </view>
                  </view>
                  <view class="attachment-info">
                    <text class="attachment-name">{{ file.originalFilename || file.bucketFilename || file.name || '附件' }}</text>
                    <text class="attachment-size">{{ formatFileSize(file.byteSize || file.size) }}</text>
                  </view>
                </view>
              </view>
              <view v-else class="attachment-empty">
                <text>暂无附件</text>
              </view>
            </view>
          </view>
        </view>
      </view>
    </view>
    <!-- è§†é¢‘预览弹窗 -->
    <view v-if="showVideoDialog" class="video-modal-overlay" @click="closeVideoPreview">
      <view class="video-modal-container" @click.stop>
        <view class="video-modal-header">
          <text class="video-modal-title">{{ currentVideoFile?.originalFilename || currentVideoFile?.bucketFilename || '视频预览' }}</text>
          <view class="close-btn-video" @click="closeVideoPreview">
            <u-icon name="close" size="16" color="#fff"></u-icon>
          </view>
        </view>
        <view class="video-modal-body">
          <video
            v-if="currentVideoFile"
            :src="currentVideoFile.url || currentVideoFile.downloadUrl"
            class="video-player"
            controls
            autoplay
            @error="handleVideoError"
          ></video>
        </view>
      </view>
    </view>
    <!-- æµ®åŠ¨æ“ä½œæŒ‰é’® -->
        <view class="fab-button" @click="addRepair">
            <up-icon name="plus" size="24" color="#ffffff"></up-icon>
@@ -118,7 +192,8 @@
import { ref, onMounted } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import PageHeader from '@/components/PageHeader.vue'
import { getRepairPage, delRepair } from '@/api/equipmentManagement/repair'
import { getRepairPage, delRepair, getRepairById } from '@/api/equipmentManagement/repair'
import config from '@/config'
import useUserStore from "@/store/modules/user"
const showToast = (message) => {
@@ -135,6 +210,81 @@
// è®¾å¤‡æŠ¥ä¿®æ•°æ®
const repairList = ref([])
// æŸ¥çœ‹é™„ä»¶
const showAttachmentDialog = ref(false)
const attachmentList = ref([])
const currentViewRepair = ref(null)
const showVideoDialog = ref(false)
const currentVideoFile = ref(null)
const filePreviewBase = config.fileUrl || config.baseUrl || ''
const formatFileUrl = (url) => {
  if (!url) return ''
  if (url.startsWith('http://') || url.startsWith('https://')) return url
  const base = (filePreviewBase || '').replace(/\/$/, '')
  const path = (url || '').replace(/^\/+/, '')
  return path ? `${base}/${path}` : base
}
const isImageFile = (file) => {
  if (file?.contentType && file.contentType.startsWith('image/')) return true
  if (file?.type === 'image') return true
  const name = file?.bucketFilename || file?.originalFilename || file?.name || ''
  const ext = name.split('.').pop()?.toLowerCase()
  return ['jpg', 'jpeg', 'png', 'gif', 'webp'].includes(ext)
}
const formatFileSize = (size) => {
  if (!size) return ''
  if (size < 1024) return size + 'B'
  if (size < 1024 * 1024) return (size / 1024).toFixed(1) + 'KB'
  return (size / (1024 * 1024)).toFixed(1) + 'MB'
}
const viewAttachments = async (item) => {
  try {
    currentViewRepair.value = item
    const { code, data } = await getRepairById(item.id)
    if (code === 200 && data) {
      attachmentList.value = Array.isArray(data.fileList) ? data.fileList : (Array.isArray(data.commonFileList) ? data.commonFileList : [])
      showAttachmentDialog.value = true
    } else {
      showToast('获取附件失败')
    }
  } catch (e) {
    showToast('获取附件失败')
  }
}
const closeAttachmentDialog = () => {
  showAttachmentDialog.value = false
  currentViewRepair.value = null
  attachmentList.value = []
}
const previewAttachment = (file) => {
  if (isImageFile(file)) {
    const urls = attachmentList.value.filter((f) => isImageFile(f)).map((f) => formatFileUrl(f.url || f.downloadUrl))
    uni.previewImage({
      urls,
      current: formatFileUrl(file.url || file.downloadUrl)
    })
  } else {
    currentVideoFile.value = file
    showVideoDialog.value = true
  }
}
const closeVideoPreview = () => {
  showVideoDialog.value = false
  currentVideoFile.value = null
}
const handleVideoError = () => {
  uni.showToast({ title: '视频播放失败', icon: 'none' })
}
// è¿”回上一页
const goBack = () => {
@@ -262,4 +412,216 @@
.action-buttons {
  gap: 8px; // ä¸Žå…¬å…±æ ·å¼ä¸­çš„ 12px ä¸åŒ
}
/* æŸ¥çœ‹é™„件弹窗 */
.custom-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.custom-modal-container {
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.attachment-popup-content {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  min-height: 300px;
  max-height: 70vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.attachment-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #eee;
  background: #f8f9fa;
}
.attachment-popup-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}
.close-btn-attachment {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
}
.attachment-popup-body {
  flex: 1;
  padding: 15px 20px;
  overflow-y: auto;
}
.attachment-content {
  min-height: 200px;
}
.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.attachment-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  border-radius: 12px;
  padding: 8px;
  border: 1px solid #e9ecef;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  width: calc(33.33% - 8px);
  min-width: 100px;
}
.attachment-preview-container {
  margin-bottom: 8px;
}
.attachment-preview {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid #f0f0f0;
}
.attachment-video-preview {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid #f0f0f0;
}
.attachment-info {
  text-align: center;
  width: 100%;
}
.attachment-name {
  font-size: 12px;
  color: #333;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}
.attachment-size {
  font-size: 10px;
  color: #999;
  margin-top: 2px;
  display: block;
}
.attachment-empty {
  text-align: center;
  padding: 60px 20px;
  color: #999;
  font-size: 14px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 2px dashed #ddd;
}
/* è§†é¢‘预览弹窗 */
.video-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.video-modal-container {
  width: 90%;
  max-width: 800px;
  max-height: 80vh;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}
.video-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
}
.video-modal-title {
  font-size: 16px;
  color: #fff;
}
.close-btn-video {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-modal-body {
  background: #000;
}
.video-player {
  width: 100%;
  height: auto;
  max-height: 60vh;
  display: block;
}
.video-text {
  font-size: 12px;
  color: #666;
  margin-top: 4px;
}
</style>
src/pages/equipmentManagement/repair/maintain.vue
@@ -12,10 +12,10 @@
      <u-cell-group title="维修信息"
                    inset>
        <u-form-item prop="maintenanceName"
                     label="维修人"
                     label="报修人"
                     required>
          <u-input v-model="form.maintenanceName"
                   placeholder="请输入维修人"
                   placeholder="请输入报修人"
                   clearable />
        </u-form-item>
        <u-form-item prop="maintenanceResult"
@@ -101,7 +101,7 @@
  // è¡¨å•验证规则
  const formRules = {
    maintenanceName: [
      { required: true, trigger: "blur", message: "请输入维修人" },
      { required: true, trigger: "blur", message: "请输入报修人" },
    ],
    maintenanceResult: [
      { required: true, trigger: "blur", message: "请输入维修结果" },
@@ -223,7 +223,7 @@
  // åˆå§‹åŒ–表单数据
  const initForm = () => {
    form.value.status = "1";
    // è®¾ç½®ç»´ä¿®äººä¸ºå½“前用户昵称
    // è®¾ç½®æŠ¥ä¿®äººä¸ºå½“前用户昵称
    form.value.maintenanceName = userStore.nickName || "";
    // è®¾ç½®å½“前日期(只包含年月日)
    form.value.maintenanceTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
src/pages/equipmentManagement/smartDispatch/index.vue
@@ -68,7 +68,7 @@
              <text class="detail-value">{{ task.faultDescription }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">报修人</text>
              <text class="detail-label">维修人</text>
              <text class="detail-value">{{ task.reporterName }}</text>
            </view>
            <view class="detail-row">
src/pages/equipmentManagement/upkeep/index.vue
@@ -1,92 +1,82 @@
<template>
  <view class="sales-account">
    <!-- ä½¿ç”¨é€šç”¨é¡µé¢å¤´éƒ¨ç»„ä»¶ -->
  <view class="upkeep-page">
    <PageHeader title="设备保养"
                @back="goBack" />
    <!-- æœç´¢åŒºåŸŸ -->
    <view class="search-section">
      <view class="search-bar">
        <view class="search-input">
          <up-input class="search-text"
                    placeholder="请输入设备名称搜索"
                    v-model="searchKeyword"
                    @change="getList"
                    clearable />
        </view>
        <view class="filter-button"
              @click="getList">
          <up-icon name="search"
                   size="24"
                   color="#999"></up-icon>
    <view class="toolbar">
      <view class="search-section">
        <view class="search-bar">
          <view class="search-input">
            <up-input class="search-text"
                      placeholder="请输入设备名称搜索"
                      v-model="searchKeyword"
                      clearable />
          </view>
          <view class="search-button"
                @click="handleQuery">
            <up-icon name="search"
                     size="24"
                     color="#999"></up-icon>
          </view>
        </view>
      </view>
      <view class="meta-bar">
        <text class="meta-text">共 {{ total }} æ¡</text>
      </view>
    </view>
    <!-- è®¾å¤‡ä¿å…»åˆ—表 -->
    <view class="ledger-list"
          v-if="upkeepList.length > 0">
    <view class="list-section">
      <view v-for="(item, index) in upkeepList"
            :key="index">
        <view class="ledger-item"
              @click="toggleSelection(item)">
          <view class="item-header">
            <view class="item-left">
              <view class="document-icon">
                <up-icon name="file-text"
                         size="16"
                         color="#ffffff"></up-icon>
              </view>
              <text class="item-id">设备名称:{{ item.deviceName }}</text>
            :key="item.id || index"
            class="ledger-item">
        <view class="item-header">
          <view class="item-left">
            <view class="document-icon">
              <up-icon name="file-text"
                       size="14"
                       color="#ffffff"></up-icon>
            </view>
            <view class="status-tag">
              <u-tag v-if="item.status === 1"
                     type="success">完结</u-tag>
              <u-tag v-if="item.status === 0"
                     type="warning">待保养</u-tag>
              <u-tag v-if="item.status === 2"
                     type="error">失败</u-tag>
            </view>
            <text class="item-id">{{ item.deviceName || "--" }}</text>
          </view>
          <view class="item-right">
            <u-tag v-if="item.status === 1"
                   type="success">完结</u-tag>
            <u-tag v-if="item.status === 0"
                   type="warning">待保养</u-tag>
            <u-tag v-if="item.status === 2"
                   type="error">失败</u-tag>
          </view>
        </view>
        <up-divider></up-divider>
        <view class="item-details">
          <view class="detail-row">
            <text class="detail-label">规格型号</text>
            <text class="detail-value">{{ item.deviceModel || "--" }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">计划保养日期</text>
            <text class="detail-value">{{ formatDate(item.maintenancePlanTime) || "--" }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">录入人</text>
            <text class="detail-value">{{ item.createUserName || "--" }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">录入日期</text>
            <text class="detail-value">{{ formatDateTime(item.createTime) || "--" }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">实际保养人</text>
            <text class="detail-value">{{ item.maintenanceActuallyName || "--" }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">实际保养日期</text>
            <text class="detail-value">{{ formatDateTime(item.maintenanceActuallyTime) || "--" }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">保养结果</text>
            <text class="detail-value">{{ item.maintenanceResult || "--" }}</text>
          </view>
          <up-divider></up-divider>
          <view class="item-details">
            <view class="detail-row">
              <text class="detail-label">规格型号</text>
              <text class="detail-value">{{ item.deviceModel || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">计划保养日期</text>
              <text class="detail-value">{{ formatDate(item.maintenancePlanTime) || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">录入人</text>
              <text class="detail-value">{{ item.createUserName || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">录入日期</text>
              <text class="detail-value">{{ formatDateTime(item.createTime) || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">实际保养人</text>
              <text class="detail-value">{{ item.maintenanceActuallyName || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">实际保养日期</text>
              <text class="detail-value">{{ formatDateTime(item.maintenanceActuallyTime) || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">保养结果</text>
              <text class="detail-value">{{item.maintenanceResult || '-'}}
              </text>
            </view>
          </view>
          <!-- æŒ‰é’®åŒºåŸŸ -->
          <view class="action-buttons">
            <!-- <u-button type="primary"
                      size="small"
                      class="action-btn"
                      :disabled="item.status === 1"
                      @click.stop="edit(item.id)">
              ç¼–辑
            </u-button> -->
          <view class="card-actions">
            <u-button type="warning"
                      size="small"
                      class="action-btn"
@@ -107,21 +97,14 @@
                      @click.stop="viewDetail(item)">
              è¯¦æƒ…
            </u-button>
            <!-- <u-button type="warning"
                      size="small"
                      class="action-btn"
                      @click.stop="addFile(item.id)">
              é™„ä»¶
            </u-button> -->
          </view>
        </view>
      </view>
      <view v-if="!loading && upkeepList.length === 0"
            class="no-data">
        <text>暂无设备保养数据</text>
      </view>
    </view>
    <view v-else
          class="no-data">
      <text>暂无设备保养数据</text>
    </view>
    <!-- æµ®åŠ¨æ–°å¢žæŒ‰é’® -->
    <view class="fab-button"
          @click="addPlan">
      <up-icon name="plus"
@@ -154,7 +137,10 @@
  // è®¾å¤‡ä¿å…»æ•°æ®
  const upkeepList = ref([]);
  // å¤šé€‰åˆ—表
  const total = ref(0);
  const loading = ref(false);
  // å¤šé€‰åˆ—表(保养按钮未传 id æ—¶ç”¨ï¼‰
  const multipleList = ref([]);
  // è¿”回上一页
@@ -174,9 +160,13 @@
    return dayjs(dateStr).format("YYYY-MM-DD HH:mm:ss");
  };
  const handleQuery = () => {
    getList();
  };
  // æŸ¥è¯¢åˆ—表
  const getList = () => {
    showLoadingToast("加载中...");
    loading.value = true;
    const params = {
      current: -1,
      size: -1,
@@ -184,13 +174,16 @@
    };
    getUpkeepPage(params)
      .then(res => {
        // å¦‚æžœres.data不是数组,设置为空数组
        upkeepList.value = res.records || res.data?.records || [];
        closeToast();
        const records = res?.records ?? res?.data?.records ?? [];
        upkeepList.value = records;
        total.value = Array.isArray(records) ? records.length : Number(res?.total ?? res?.data?.total ?? 0);
      })
      .catch(() => {
        closeToast();
        upkeepList.value = [];
        showToast("获取数据失败");
      })
      .finally(() => {
        loading.value = false;
      });
  };
  // æ–°å¢žé™„ä»¶ - è·³è½¬åˆ°é™„件页面
@@ -322,45 +315,182 @@
</script>
<style scoped lang="scss">
  @import "@/styles/sales-common.scss";
  // è®¾å¤‡ä¿å…»ç‰¹æœ‰æ ·å¼
  .sales-account {
    padding-bottom: 80px; // ä¸ºæµ®åŠ¨æŒ‰é’®ç•™å‡ºç©ºé—´
  .upkeep-page {
    min-height: 100vh;
    background: #f6f7fb;
  }
  .action-section {
    padding: 10px 20px;
  .toolbar {
    padding: 20rpx 24rpx;
    background: #fff;
    border-bottom: 1rpx solid #f0f0f0;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .search-section {
    margin-top: 0;
  }
  .search-bar {
    display: flex;
    align-items: center;
    background: #f7f8fa;
    border-radius: 14rpx;
    padding: 8rpx 12rpx 8rpx 16rpx;
    border: 1rpx solid #eef1f5;
  }
  .search-input {
    flex: 1;
    min-width: 0;
  }
  .search-text {
    background: transparent !important;
  }
  :deep(.search-text .u-input__content),
  :deep(.search-text .up-input__content) {
    background: transparent !important;
    padding: 0 !important;
  }
  .search-button {
    width: 64rpx;
    height: 64rpx;
    border-radius: 12rpx;
    background: #ffffff;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .action-section .action-buttons {
    gap: 8px; // ä¸Žå…¬å…±æ ·å¼ä¸­çš„ 12px ä¸åŒ
    justify-content: flex-start;
  .meta-bar {
    margin-top: 16rpx;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f7f9fc;
    border-radius: 12rpx;
    padding: 10rpx 16rpx;
  }
  .checkbox-wrapper {
  .meta-text {
    color: #5c6b8a;
    font-size: 22rpx;
  }
  .list-section {
    padding: 20rpx 24rpx;
    padding-bottom: calc(132rpx + env(safe-area-inset-bottom));
  }
  .ledger-item {
    background: #ffffff;
    border-radius: 20rpx;
    margin-bottom: 16rpx;
    overflow: hidden;
    box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.05);
    padding: 0 20rpx;
  }
  .item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22rpx 0;
  }
  .item-left {
    display: flex;
    align-items: center;
    gap: 10rpx;
    flex: 1;
    min-width: 0;
  }
  .item-right {
    display: flex;
    align-items: center;
  }
  .status-tag {
  .document-icon {
    width: 38rpx;
    height: 38rpx;
    border-radius: 8rpx;
    background: #2979ff;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .item-id {
    font-size: 28rpx;
    color: #1f1f1f;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .item-details {
    padding: 18rpx 0 20rpx;
  }
  .detail-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 12rpx;
  }
  .detail-label {
    min-width: 80px; // ä¸Žå…¬å…±æ ·å¼ä¸­çš„ 60px ä¸åŒ
    min-width: 160rpx;
    color: #777;
    font-size: 24rpx;
  }
  .detail-value {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex: 1;
    color: #333;
    font-size: 24rpx;
    text-align: right;
    word-break: break-all;
    margin-left: 12rpx;
  }
  .ledger-item .action-buttons {
    gap: 8px; // ä¸Žå…¬å…±æ ·å¼ä¸­çš„ 12px ä¸åŒ
  .card-actions {
    padding-top: 8rpx;
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 12rpx;
  }
  .action-btn {
    min-width: 100rpx;
  }
  .fab-button {
    position: fixed;
    bottom: calc(30px + env(safe-area-inset-bottom));
    right: 30px;
    width: 56px;
    height: 56px;
    background: #2979ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(41, 121, 255, 0.3);
    z-index: 1000;
  }
  .no-data {
    padding: 40rpx 0;
    text-align: center;
    color: #999;
  }
</style>
src/pages/equipmentManagement/upkeepTask/components/formDia.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,659 @@
<template>
  <u-popup :show="dialogVisitable"
           mode="center"
           :round="12"
           :zIndex="900"
           @close="cancel">
    <view class="popup-content">
      <view class="popup-title">{{ operationType === "add" ? "新增保养任务" : "编辑保养任务" }}</view>
      <view class="form-body">
        <view class="form-item">
          <text class="label">任务名称</text>
          <up-input v-model="form.taskName"
                    placeholder="请输入任务名称"
                    border="none"
                    customStyle="background: #f7f8fa; padding: 0 20rpx; min-height: 72rpx; border-radius: 12rpx;" />
        </view>
        <view class="form-item">
          <text class="label">设备</text>
          <view class="picker-value inspector-picker"
                @click="openDevicePopup">
            <text>{{ deviceNamesText || "请选择设备" }}</text>
            <u-icon name="arrow-right"
                    size="14"
                    color="#999" />
          </view>
          <view class="inspector-tags"
                v-if="form.deviceIds?.length">
            <view v-for="id in form.deviceIds"
                  :key="id"
                  class="inspector-tag"
                  @click="toggleDevice(id)">
              <text>{{ getDeviceName(id) }}</text>
              <u-icon name="close"
                      size="11"
                      color="#1677ff" />
            </view>
          </view>
        </view>
        <view class="form-item">
          <text class="label">录入人</text>
          <picker mode="selector"
                  :range="userList"
                  range-key="nickName"
                  :value="inspectorIndex"
                  @change="onInspectorChange">
            <view class="picker-value">{{ form.registrant || "请选择录入人" }}</view>
          </picker>
        </view>
        <view class="form-item">
          <text class="label">登记时间</text>
          <picker mode="date"
                  :value="form.registrationDate || todayStr"
                  @change="onRegistrationDateChange">
            <view class="picker-value">{{ form.registrationDate || "请选择登记时间" }}</view>
          </picker>
        </view>
        <view class="form-item">
          <text class="label">任务频率</text>
          <picker mode="selector"
                  :range="frequencyOptions"
                  range-key="label"
                  :value="frequencyIndex"
                  @change="onFrequencyChange">
            <view class="picker-value">{{ currentFrequencyLabel || "请选择任务频率" }}</view>
          </picker>
        </view>
        <view class="form-item"
              v-if="form.frequencyType === 'DAILY'">
          <text class="label">时间</text>
          <picker mode="time"
                  :value="form.frequencyDetail || '08:00'"
                  @change="onDailyTimeChange">
            <view class="picker-value">{{ form.frequencyDetail || "请选择时间" }}</view>
          </picker>
        </view>
        <view class="form-item"
              v-if="form.frequencyType === 'WEEKLY'">
          <text class="label">每周日期</text>
          <picker mode="selector"
                  :range="weekOptions"
                  range-key="label"
                  :value="weekIndex"
                  @change="onWeekChange">
            <view class="picker-value">{{ currentWeekLabel || "请选择星期" }}</view>
          </picker>
        </view>
        <view class="form-item"
              v-if="form.frequencyType === 'WEEKLY'">
          <text class="label">每周时间</text>
          <picker mode="time"
                  :value="form.time || '08:00'"
                  @change="onWeekTimeChange">
            <view class="picker-value">{{ form.time || "请选择时间" }}</view>
          </picker>
        </view>
        <view class="form-item"
              v-if="form.frequencyType === 'MONTHLY'">
          <text class="label">每月日期与时间</text>
          <picker mode="date"
                  fields="day"
                  :value="monthlyDate"
                  @change="onMonthlyDateChange">
            <view class="picker-value">{{ monthlyDate || "请选择日期" }}</view>
          </picker>
          <picker mode="time"
                  :value="monthlyTime"
                  @change="onMonthlyTimeChange">
            <view class="picker-value">{{ monthlyTime || "请选择时间" }}</view>
          </picker>
        </view>
        <view class="form-item"
              v-if="form.frequencyType === 'QUARTERLY'">
          <text class="label">季度日期与时间</text>
          <picker mode="date"
                  :value="quarterlyDate"
                  @change="onQuarterlyDateChange">
            <view class="picker-value">{{ quarterlyDate || "请选择日期" }}</view>
          </picker>
          <picker mode="time"
                  :value="quarterlyTime"
                  @change="onQuarterlyTimeChange">
            <view class="picker-value">{{ quarterlyTime || "请选择时间" }}</view>
          </picker>
        </view>
        <view class="form-item">
          <text class="label">备注</text>
          <u-textarea v-model="form.remarks"
                      placeholder="请输入备注"
                      :height="80"
                      count />
        </view>
      </view>
      <view class="popup-footer">
        <u-button @click="cancel">取消</u-button>
        <u-button type="primary"
                  @click="submitForm">保存</u-button>
      </view>
    </view>
  </u-popup>
  <u-popup :show="showDevicePopup"
           mode="bottom"
           :round="16"
           :zIndex="1100"
           @close="closeDevicePopup">
    <view class="inspector-popup">
      <view class="inspector-header">
        <text class="inspector-title">选择设备</text>
      </view>
      <scroll-view scroll-y
                   class="inspector-list">
        <view v-for="item in deviceOptions"
              :key="item.id"
              class="inspector-row"
              @click="toggleDevice(item.id)">
          <text class="inspector-name">{{ item.deviceName }}</text>
          <u-icon v-if="(form.deviceIds || []).includes(item.id)"
                  name="checkmark-circle-fill"
                  color="#1677ff"
                  size="20" />
          <u-icon v-else
                  name=""
                  color="#d5d8de"
                  size="20" />
        </view>
      </scroll-view>
      <view class="inspector-footer">
        <u-button @click="closeDevicePopup">确定</u-button>
      </view>
    </view>
  </u-popup>
</template>
<script setup>
  import { computed, reactive, ref } from "vue";
  import useUserStore from "@/store/modules/user";
  import {
    deviceMaintenanceTaskAdd,
    deviceMaintenanceTaskEdit,
  } from "@/api/equipmentManagement/upkeep.js";
  import { userListNoPageByTenantId } from "@/api/system/user.js";
  import { getDeviceLedger } from "@/api/equipmentManagement/ledger.js";
  const emit = defineEmits(["closeDia"]);
  const userStore = useUserStore();
  const dialogVisitable = ref(false);
  const operationType = ref("add");
  const deviceOptions = ref([]);
  const userList = ref([]);
  const showDevicePopup = ref(false);
  const todayStr = ref("");
  try {
    const d = new Date();
    todayStr.value = `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
  } catch (e) {}
  const defaultForm = () => ({
    id: undefined,
    taskName: "",
    deviceIds: [],
    registrantId: undefined,
    registrant: "",
    registrationDate: "",
    remarks: "",
    frequencyType: "",
    frequencyDetail: "",
    week: "",
    time: "",
  });
  const form = reactive(defaultForm());
  const frequencyOptions = [
    { label: "每日", value: "DAILY" },
    { label: "每周", value: "WEEKLY" },
    { label: "每月", value: "MONTHLY" },
    { label: "季度", value: "QUARTERLY" },
  ];
  const weekOptions = [
    { label: "周一", value: "MON" },
    { label: "周二", value: "TUE" },
    { label: "周三", value: "WED" },
    { label: "周四", value: "THU" },
    { label: "周五", value: "FRI" },
    { label: "周六", value: "SAT" },
    { label: "周日", value: "SUN" },
  ];
  const monthlyDate = ref("");
  const monthlyTime = ref("");
  const quarterlyDate = ref("");
  const quarterlyTime = ref("");
  const frequencyIndex = computed(() => {
    const index = frequencyOptions.findIndex(item => item.value === form.frequencyType);
    return index >= 0 ? index : 0;
  });
  const weekIndex = computed(() => {
    const index = weekOptions.findIndex(item => item.value === form.week);
    return index >= 0 ? index : 0;
  });
  const currentFrequencyLabel = computed(() => {
    return frequencyOptions.find(item => item.value === form.frequencyType)?.label || "";
  });
  const currentWeekLabel = computed(() => {
    return weekOptions.find(item => item.value === form.week)?.label || "";
  });
  const inspectorIndex = computed(() => {
    const index = userList.value.findIndex(item => String(item.userId) === String(form.registrantId));
    return index >= 0 ? index : 0;
  });
  const deviceNamesText = computed(() => {
    if (!form.deviceIds?.length) return "";
    return form.deviceIds
      .map(id => getDeviceName(id))
      .filter(Boolean)
      .join("、");
  });
  function getDeviceName(id) {
    const d = deviceOptions.value.find(item => String(item.id) === String(id));
    return d?.deviceName || "";
  }
  const resetForm = () => {
    Object.assign(form, defaultForm());
    monthlyDate.value = "";
    monthlyTime.value = "";
    quarterlyDate.value = "";
    quarterlyTime.value = "";
    showDevicePopup.value = false;
  };
  const normalizeIdList = val => {
    if (!val) return [];
    if (Array.isArray(val)) return val.map(v => (Number.isNaN(Number(v)) ? v : Number(v)));
    if (typeof val === "string") {
      const s = val.trim();
      if (s.startsWith("[") && s.endsWith("]")) {
        try {
          const arr = JSON.parse(s);
          return Array.isArray(arr) ? arr : [];
        } catch {
          return [];
        }
      }
      return s.split(",").map(v => v.trim()).filter(Boolean).map(v => (Number.isNaN(Number(v)) ? v : Number(v)));
    }
    return [];
  };
  const parseWeeklyDetail = detail => {
    if (!detail || typeof detail !== "string" || !detail.includes(",")) return;
    const [week, time] = detail.split(",");
    form.week = week || "";
    form.time = time || "";
  };
  const parseMonthlyDetail = detail => {
    if (!detail || typeof detail !== "string" || !detail.includes(",")) return;
    const [day, time] = detail.split(",");
    if (day) {
      const y = new Date().getFullYear();
      const m = new Date().getMonth() + 1;
      monthlyDate.value = `${y}-${String(m).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
    }
    if (time) monthlyTime.value = time;
  };
  const parseQuarterlyDetail = detail => {
    if (!detail || typeof detail !== "string") return;
    const parts = detail.split(",");
    if (parts.length >= 3) {
      const [mm, dd, time] = parts;
      const y = new Date().getFullYear();
      quarterlyDate.value = `${y}-${String(mm).padStart(2, "0")}-${String(dd).padStart(2, "0")}`;
      quarterlyTime.value = time || "";
    }
  };
  const openDialog = async (type, row) => {
    operationType.value = type;
    dialogVisitable.value = true;
    resetForm();
    try {
      const [userRes, deviceRes] = await Promise.all([
        userListNoPageByTenantId(),
        getDeviceLedger(),
      ]);
      userList.value = userRes?.data || [];
      deviceOptions.value = deviceRes?.data || [];
      if (type === "edit" && row) {
        Object.assign(form, {
          ...defaultForm(),
          ...row,
          deviceIds: normalizeIdList(row.deviceIds ?? row.taskIds ?? row.deviceIds),
        });
        if (!form.registrationDate && row.registrationDate) form.registrationDate = row.registrationDate;
        if (row.registrantId) form.registrantId = row.registrantId;
        if (row.registrant) form.registrant = row.registrant;
        if (form.frequencyType === "WEEKLY") parseWeeklyDetail(form.frequencyDetail);
        if (form.frequencyType === "MONTHLY") parseMonthlyDetail(form.frequencyDetail);
        if (form.frequencyType === "QUARTERLY") parseQuarterlyDetail(form.frequencyDetail);
      } else {
        form.registrationDate = todayStr.value;
        const userInfo = await userStore.getInfo();
        if (userInfo?.user?.userId) {
          form.registrantId = userInfo.user.userId;
          form.registrant = userInfo.user.nickName || userInfo.user.userName || "";
        }
      }
    } catch (error) {
      uni.showToast({
        title: "初始化失败",
        icon: "none",
      });
    }
  };
  const openDevicePopup = () => {
    showDevicePopup.value = true;
  };
  const closeDevicePopup = () => {
    showDevicePopup.value = false;
  };
  const toggleDevice = id => {
    const ids = form.deviceIds || [];
    if (ids.includes(id)) {
      form.deviceIds = ids.filter(i => i !== id);
    } else {
      form.deviceIds = [...ids, id];
    }
  };
  const onInspectorChange = e => {
    const index = Number(e?.detail?.value ?? 0);
    const user = userList.value[index];
    if (user) {
      form.registrantId = user.userId;
      form.registrant = user.nickName || "";
    }
  };
  const onRegistrationDateChange = e => {
    form.registrationDate = e?.detail?.value || "";
  };
  const onFrequencyChange = e => {
    const index = Number(e?.detail?.value ?? 0);
    const selected = frequencyOptions[index];
    form.frequencyType = selected?.value || "";
    form.frequencyDetail = "";
    form.week = "";
    form.time = "";
    monthlyDate.value = "";
    monthlyTime.value = "";
    quarterlyDate.value = "";
    quarterlyTime.value = "";
  };
  const onDailyTimeChange = e => {
    form.frequencyDetail = e?.detail?.value || "";
  };
  const onWeekChange = e => {
    const index = Number(e?.detail?.value ?? 0);
    const selected = weekOptions[index];
    form.week = selected?.value || "";
  };
  const onWeekTimeChange = e => {
    form.time = e?.detail?.value || "";
  };
  const onMonthlyDateChange = e => {
    monthlyDate.value = e?.detail?.value || "";
  };
  const onMonthlyTimeChange = e => {
    monthlyTime.value = e?.detail?.value || "";
  };
  const onQuarterlyDateChange = e => {
    quarterlyDate.value = e?.detail?.value || "";
  };
  const onQuarterlyTimeChange = e => {
    quarterlyTime.value = e?.detail?.value || "";
  };
  const validateForm = () => {
    if (!form.taskName?.trim()) {
      uni.showToast({ title: "请输入任务名称", icon: "none" });
      return false;
    }
    if (!form.deviceIds?.length) {
      uni.showToast({ title: "请选择设备", icon: "none" });
      return false;
    }
    if (!form.registrantId && !form.registrant) {
      uni.showToast({ title: "请选择录入人", icon: "none" });
      return false;
    }
    if (!form.registrationDate) {
      uni.showToast({ title: "请选择登记时间", icon: "none" });
      return false;
    }
    if (!form.frequencyType) {
      uni.showToast({ title: "请选择任务频率", icon: "none" });
      return false;
    }
    if (form.frequencyType === "DAILY" && !form.frequencyDetail) {
      uni.showToast({ title: "请选择时间", icon: "none" });
      return false;
    }
    if (form.frequencyType === "WEEKLY" && (!form.week || !form.time)) {
      uni.showToast({ title: "请选择每周日期和时间", icon: "none" });
      return false;
    }
    if (form.frequencyType === "MONTHLY" && (!monthlyDate.value || !monthlyTime.value)) {
      uni.showToast({ title: "请选择每月日期和时间", icon: "none" });
      return false;
    }
    if (form.frequencyType === "QUARTERLY" && (!quarterlyDate.value || !quarterlyTime.value)) {
      uni.showToast({ title: "请选择季度日期和时间", icon: "none" });
      return false;
    }
    return true;
  };
  const buildFrequencyDetail = () => {
    if (form.frequencyType === "WEEKLY") return `${form.week},${form.time}`;
    if (form.frequencyType === "MONTHLY") {
      const day = monthlyDate.value.split("-")[2] || "";
      return `${day},${monthlyTime.value}`;
    }
    if (form.frequencyType === "QUARTERLY") {
      const [y, m, d] = (quarterlyDate.value || "").split("-");
      return `${m},${d},${quarterlyTime.value}`;
    }
    return form.frequencyDetail || "";
  };
  const submitForm = async () => {
    if (!validateForm()) return;
    try {
      const payload = {
        id: form.id,
        taskName: form.taskName.trim(),
        deviceIds: JSON.stringify(form.deviceIds || []),
        registrantId: form.registrantId,
        registrant: form.registrant,
        registrationDate: form.registrationDate,
        frequencyType: form.frequencyType,
        frequencyDetail: buildFrequencyDetail(),
        remarks: form.remarks || "",
        status: "0",
        active: true,
        deleted: 0,
      };
      if (operationType.value === "edit" && form.id) {
        await deviceMaintenanceTaskEdit(payload);
      } else {
        delete payload.id;
        await deviceMaintenanceTaskAdd(payload);
      }
      uni.showToast({
        title: "提交成功",
        icon: "success",
      });
      cancel();
    } catch (error) {
      uni.showToast({
        title: "提交失败,请重试",
        icon: "none",
      });
    }
  };
  const cancel = () => {
    dialogVisitable.value = false;
    resetForm();
    emit("closeDia");
  };
  defineExpose({ openDialog });
</script>
<style scoped lang="scss">
  :deep(.uni-picker-container) {
    z-index: 1200 !important;
  }
  .popup-content {
    width: 88vw;
    max-height: 80vh;
    background: #fff;
    border-radius: 20rpx;
    overflow: hidden;
  }
  .popup-title {
    text-align: center;
    font-size: 32rpx;
    color: #1f1f1f;
    font-weight: 600;
    padding: 24rpx 20rpx;
    border-bottom: 1rpx solid #f0f0f0;
  }
  .form-body {
    padding: 24rpx;
    max-height: 56vh;
    overflow-y: auto;
  }
  .form-item {
    margin-bottom: 20rpx;
  }
  .label {
    display: block;
    margin-bottom: 10rpx;
    font-size: 24rpx;
    color: #666;
  }
  .picker-value {
    min-height: 72rpx;
    background: #f7f8fa;
    border-radius: 12rpx;
    padding: 0 20rpx;
    display: flex;
    align-items: center;
    color: #333;
    font-size: 26rpx;
  }
  .inspector-picker {
    justify-content: space-between;
  }
  .inspector-tags {
    display: flex;
    flex-wrap: wrap;
    margin-top: 10rpx;
    gap: 10rpx;
  }
  .inspector-tag {
    display: flex;
    align-items: center;
    gap: 8rpx;
    background: #edf3ff;
    color: #1677ff;
    font-size: 22rpx;
    border-radius: 999rpx;
    padding: 6rpx 14rpx;
  }
  .popup-footer {
    display: flex;
    gap: 16rpx;
    padding: 20rpx 24rpx 24rpx;
    border-top: 1rpx solid #f0f0f0;
  }
  .inspector-popup {
    background: #fff;
    border-radius: 24rpx 24rpx 0 0;
    overflow: hidden;
    max-height: 70vh;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .inspector-header {
    padding: 24rpx;
    text-align: center;
    border-bottom: 1rpx solid #f0f0f0;
  }
  .inspector-title {
    color: #1f1f1f;
    font-size: 30rpx;
    font-weight: 600;
  }
  .inspector-list {
    max-height: 46vh;
    padding: 0 24rpx;
  }
  .inspector-row {
    min-height: 82rpx;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1rpx solid #f5f5f5;
  }
  .inspector-name {
    font-size: 26rpx;
    color: #333;
  }
  .inspector-footer {
    display: flex;
    gap: 16rpx;
    padding: 20rpx 24rpx 24rpx;
  }
</style>
src/pages/equipmentManagement/upkeepTask/index.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,454 @@
<template>
  <view class="upkeep-task-page">
    <PageHeader title="定时任务管理"
                @back="goBack" />
    <view class="toolbar">
      <view class="search-section">
        <view class="search-bar">
          <view class="search-input">
            <up-input class="search-text"
                      placeholder="请输入保养任务名称"
                      v-model="queryParams.taskName"
                      clearable />
          </view>
          <view class="search-button"
                @click="handleQuery">
            <up-icon name="search"
                     size="24"
                     color="#999"></up-icon>
          </view>
        </view>
      </view>
      <view class="meta-bar">
        <text class="meta-text">共 {{ total }} æ¡</text>
      </view>
    </view>
    <view class="list-section">
      <uni-swipe-action>
        <uni-swipe-action-item v-for="item in tableData"
                               :key="item.id"
                               :right-options="swipeOptions"
                               @click="onSwipeActionClick($event, item)">
          <view class="ledger-item">
            <view class="item-header">
              <view class="item-left">
                <view class="document-icon">
                  <up-icon name="file-text"
                           size="14"
                           color="#ffffff"></up-icon>
                </view>
                <text class="item-id">{{ item.taskName || "--" }}</text>
              </view>
              <view class="item-right">
                <u-tag :type="getFrequencyTagType(item.frequencyType)"
                       :text="formatFrequency(item.frequencyType) || '未知频次'" />
              </view>
            </view>
            <up-divider></up-divider>
            <view class="item-details">
              <view class="detail-row">
                <text class="detail-label">任务编号</text>
                <text class="detail-value">{{ item.id || "--" }}</text>
              </view>
              <view class="detail-row">
                <text class="detail-label">设备</text>
                <text class="detail-value">{{ item.deviceName || "--" }}</text>
              </view>
              <view class="detail-row">
                <text class="detail-label">开始日期与时间</text>
                <text class="detail-value highlight">{{ formatFrequencyDetail(item.frequencyDetail) }}</text>
              </view>
              <view class="detail-row">
                <text class="detail-label">登记人</text>
                <text class="detail-value">{{ item.registrant || "--" }}</text>
              </view>
              <view class="detail-row">
                <text class="detail-label">登记日期</text>
                <text class="detail-value">{{ item.registrationDate || item.createTime || "--" }}</text>
              </view>
              <view class="detail-row">
                <text class="detail-label">备注</text>
                <text class="detail-value">{{ item.remarks || "无" }}</text>
              </view>
              <up-divider></up-divider>
              <view class="card-actions">
                <u-button type="primary"
                          size="small"
                          class="action-btn"
                          @click.stop="handleAdd(item)">编辑</u-button>
                <u-button type="error"
                          size="small"
                          plain
                          class="action-btn"
                          @click.stop="deleteOne(item)">删除</u-button>
              </view>
            </view>
          </view>
        </uni-swipe-action-item>
      </uni-swipe-action>
      <uni-load-more :status="loadMoreStatus"></uni-load-more>
      <view v-if="!loading && tableData.length === 0"
            class="no-data">
        <text>暂无数据</text>
      </view>
    </view>
    <view class="fab-button"
          @click="handleAdd()">
      <up-icon name="plus"
               size="24"
               color="#ffffff"></up-icon>
    </view>
    <form-dia ref="formDia"
              @closeDia="handleQuery" />
  </view>
</template>
<script setup>
  import { ref, reactive, computed, nextTick } from "vue";
  import { onShow, onReachBottom, onPullDownRefresh } from "@dcloudio/uni-app";
  import PageHeader from "@/components/PageHeader.vue";
  import FormDia from "@/pages/equipmentManagement/upkeepTask/components/formDia.vue";
  import {
    deviceMaintenanceTaskDel,
    deviceMaintenanceTaskList,
  } from "@/api/equipmentManagement/upkeep.js";
  const formDia = ref();
  const queryParams = reactive({
    taskName: "",
  });
  const pageParams = reactive({
    current: 1,
    size: 10,
  });
  const total = ref(0);
  const loading = ref(false);
  const tableData = ref([]);
  const swipeOptions = [
    {
      text: "删除",
      style: {
        backgroundColor: "#ee0a24",
      },
    },
  ];
  const noMore = computed(() => tableData.value.length >= total.value);
  const loadMoreStatus = computed(() => {
    if (loading.value) return "loading";
    if (noMore.value) return "noMore";
    return "more";
  });
  const goBack = () => {
    uni.navigateBack();
  };
  const formatFrequency = value => {
    if (value === "DAILY") return "每日";
    if (value === "WEEKLY") return "每周";
    if (value === "MONTHLY") return "每月";
    if (value === "QUARTERLY") return "季度";
    return "";
  };
  const getFrequencyTagType = value => {
    if (value === "DAILY") return "success";
    if (value === "WEEKLY") return "primary";
    if (value === "MONTHLY") return "warning";
    return "info";
  };
  const formatFrequencyDetail = value => {
    if (!value || typeof value !== "string") return "--";
    return value.replace(
      /MON|TUE|WED|THU|FRI|SAT|SUN/g,
      item =>
        ({
          MON: "周一",
          TUE: "周二",
          WED: "周三",
          THU: "周四",
          FRI: "周五",
          SAT: "周六",
          SUN: "周日",
        })[item] || item
    );
  };
  const getList = async () => {
    if (loading.value) return;
    loading.value = true;
    try {
      const params = {
        ...queryParams,
        current: pageParams.current,
        size: pageParams.size,
      };
      const res = await deviceMaintenanceTaskList(params);
      const records = res?.data?.records || res?.records || [];
      if (pageParams.current === 1) {
        tableData.value = records;
      } else {
        tableData.value = [...tableData.value, ...records];
      }
      total.value = Number(res?.data?.total ?? res?.total ?? 0);
    } catch (error) {
      if (pageParams.current === 1) {
        tableData.value = [];
      }
      uni.showToast({
        title: "获取数据失败",
        icon: "none",
      });
    } finally {
      loading.value = false;
    }
  };
  const handleQuery = () => {
    pageParams.current = 1;
    total.value = 0;
    getList();
  };
  const loadMore = () => {
    if (loading.value || noMore.value) return;
    pageParams.current += 1;
    getList();
  };
  const handleAdd = row => {
    nextTick(() => {
      formDia.value?.openDialog(row ? "edit" : "add", row);
    });
  };
  const deleteOne = async row => {
    if (!row?.id) return;
    const canDelete = await new Promise(resolve => {
      uni.showModal({
        title: "提示",
        content: "是否确认删除该保养任务?",
        success: modalRes => resolve(Boolean(modalRes.confirm)),
        fail: () => resolve(false),
      });
    });
    if (!canDelete) return;
    try {
      await deviceMaintenanceTaskDel([row.id]);
      uni.showToast({
        title: "删除成功",
        icon: "success",
      });
      handleQuery();
    } catch (error) {
      uni.showToast({
        title: "删除失败",
        icon: "none",
      });
    }
  };
  const onSwipeActionClick = (event, row) => {
    if (event?.position !== "right") return;
    deleteOne(row);
  };
  onShow(() => {
    handleQuery();
  });
  onReachBottom(() => {
    loadMore();
  });
  onPullDownRefresh(() => {
    handleQuery();
    uni.stopPullDownRefresh();
  });
</script>
<style scoped>
  .upkeep-task-page {
    min-height: 100vh;
    background: #f6f7fb;
  }
  .toolbar {
    padding: 20rpx 24rpx;
    background: #fff;
    border-bottom: 1rpx solid #f0f0f0;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .search-section {
    margin-top: 0;
  }
  .search-bar {
    display: flex;
    align-items: center;
    background: #f7f8fa;
    border-radius: 14rpx;
    padding: 8rpx 12rpx 8rpx 16rpx;
    border: 1rpx solid #eef1f5;
  }
  .search-input {
    flex: 1;
    min-width: 0;
  }
  .search-text {
    background: transparent !important;
  }
  :deep(.search-text .u-input__content),
  :deep(.search-text .up-input__content) {
    background: transparent !important;
    padding: 0 !important;
  }
  .search-button {
    width: 64rpx;
    height: 64rpx;
    border-radius: 12rpx;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .meta-bar {
    margin-top: 16rpx;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f7f9fc;
    border-radius: 12rpx;
    padding: 10rpx 16rpx;
  }
  .meta-text {
    color: #5c6b8a;
    font-size: 22rpx;
  }
  .list-section {
    padding: 20rpx 24rpx;
    padding-bottom: calc(132rpx + env(safe-area-inset-bottom));
  }
  .ledger-item {
    background: #ffffff;
    border-radius: 20rpx;
    margin-bottom: 16rpx;
    overflow: hidden;
    box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.05);
    padding: 0 20rpx;
  }
  .item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22rpx 0;
  }
  .item-left {
    display: flex;
    align-items: center;
    gap: 10rpx;
    flex: 1;
    min-width: 0;
  }
  .item-right {
    display: flex;
    align-items: center;
  }
  .document-icon {
    width: 38rpx;
    height: 38rpx;
    border-radius: 8rpx;
    background: #2979ff;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .item-id {
    font-size: 28rpx;
    color: #1f1f1f;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .item-details {
    padding: 18rpx 0 20rpx;
  }
  .detail-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 12rpx;
  }
  .detail-label {
    min-width: 160rpx;
    color: #777;
    font-size: 24rpx;
  }
  .detail-value {
    flex: 1;
    color: #333;
    font-size: 24rpx;
    text-align: right;
    word-break: break-all;
    margin-left: 12rpx;
  }
  .detail-value.highlight {
    color: #2979ff;
    font-weight: 500;
  }
  .card-actions {
    padding-top: 8rpx;
    display: flex;
    justify-content: flex-end;
  }
  .action-btn {
    min-width: 140rpx;
  }
  .fab-button {
    position: fixed;
    bottom: calc(30px + env(safe-area-inset-bottom));
    right: 30px;
    width: 56px;
    height: 56px;
    background: #2979ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(41, 121, 255, 0.3);
    z-index: 1000;
  }
  .no-data {
    padding: 40rpx 0;
    text-align: center;
    color: #999;
  }
</style>
src/pages/index.vue
@@ -433,12 +433,13 @@
    },
    {
      icon: "/static/images/icon/xunjianshangchuan@2x.png",
      label: "巡检管理",
      label: "巡检任务",
    },
    {
      icon: "/static/images/icon/xunjianshangchuan@2x.png",
      label: "巡检任务管理",
    }
      label: "巡检管理",
    },
  ]);
  // å¤„理常用功能点击
@@ -653,6 +654,11 @@
          url: "/pages/equipmentManagement/repair/index",
        });
        break;
      case "设备保养任务":
        uni.navigateTo({
          url: "/pages/equipmentManagement/upkeepTask/index",
        });
        break;
      case "设备保养":
        uni.navigateTo({
          url: "/pages/equipmentManagement/upkeep/index",
@@ -663,7 +669,7 @@
          url: "/pages/inspectionUpload/index",
        });
        break;
      case "巡检任务管理":
      case "巡检任务":
        uni.navigateTo({
          url: "/pages/inspectionManagement/index",
        });
@@ -1040,17 +1046,26 @@
    const originalEquipment = [
      { icon: "/static/images/icon/shbeibaoxiu@2x.png", label: "运行管理" },
      { icon: "/static/images/icon/shbeibaoxiu@2x.png", label: "设备报修" },
      { icon: "/static/images/icon/shbeibaoyang@2x.png", label: "设备保养任务" },
      { icon: "/static/images/icon/shbeibaoyang@2x.png", label: "设备保养" },
      { icon: "/static/images/icon/xunjianshangchuan@2x.png", label: "巡检任务" },
      { icon: "/static/images/icon/xunjianshangchuan@2x.png", label: "巡检管理" },
      { icon: "/static/images/icon/xunjianshangchuan@2x.png", label: "巡检任务管理" },
    ];
    const filteredEquipment = originalEquipment.filter(item => {
      return allowedMenuTitles.has(item.label);
    });
    if (filteredEquipment.some(i => i.label === "设备保养")) {
      const upkeepTask = originalEquipment.find(i => i.label === "设备保养任务");
      if (upkeepTask && !filteredEquipment.some(i => i.label === "设备保养任务")) {
        const upkeepIndex = filteredEquipment.findIndex(i => i.label === "设备保养");
        filteredEquipment.splice(upkeepIndex, 0, upkeepTask);
      }
    }
    if (filteredEquipment.some(i => i.label === "巡检管理")) {
      const task = originalEquipment.find(i => i.label === "巡检任务管理");
      if (task && !filteredEquipment.some(i => i.label === "巡检任务管理")) {
        filteredEquipment.push(task);
      const task = originalEquipment.find(i => i.label === "巡检任务");
      if (task && !filteredEquipment.some(i => i.label === "巡检任务")) {
        const manageIndex = filteredEquipment.findIndex(i => i.label === "巡检管理");
        filteredEquipment.splice(manageIndex, 0, task);
      }
    }
    equipmentItems.splice(0, equipmentItems.length, ...filteredEquipment);
src/pages/indexItem.vue
@@ -325,6 +325,11 @@
          url: "/pages/equipmentManagement/repair/index",
        });
        break;
      case "设备保养任务":
        uni.navigateTo({
          url: "/pages/equipmentManagement/upkeepTask/index",
        });
        break;
      case "设备保养":
        uni.navigateTo({
          url: "/pages/equipmentManagement/upkeep/index",
src/pages/inspectionManagement/index.vue
@@ -1,17 +1,8 @@
<template>
  <view class="inspection-management-page">
    <PageHeader title="巡检任务管理"
    <PageHeader title="定时任务管理"
                @back="goBack" />
    <view class="toolbar">
      <view class="tab-wrap">
        <view v-for="tab in tabs"
              :key="tab.name"
              class="tab-item"
              :class="{ active: activeTab === tab.name }"
              @click="switchTab(tab.name)">
          {{ tab.label }}
        </view>
      </view>
      <view class="search-section">
        <view class="search-bar">
          <view class="search-input">
@@ -36,8 +27,7 @@
      <uni-swipe-action>
        <uni-swipe-action-item v-for="item in tableData"
                               :key="item.id"
                               :right-options="activeTab === 'taskManage' ? swipeOptions : []"
                               :disabled="activeTab !== 'taskManage'"
                               :right-options="swipeOptions"
                               @click="onSwipeActionClick($event, item)">
          <view class="ledger-item">
            <view class="item-header">
@@ -92,16 +82,15 @@
              </view>
              <up-divider></up-divider>
              <view class="card-actions">
                <u-button v-if="activeTab === 'taskManage'"
                          type="primary"
                <u-button type="primary"
                          size="small"
                          class="action-btn"
                          @click.stop="handleAdd(item)">编辑</u-button>
                <u-button v-else
                          type="success"
                <u-button type="error"
                          size="small"
                          plain
                          class="action-btn"
                          @click.stop="viewFile(item)">查看附件</u-button>
                          @click.stop="deleteOne(item)">删除</u-button>
              </view>
            </view>
          </view>
@@ -113,8 +102,7 @@
        <text>暂无数据</text>
      </view>
    </view>
    <view v-if="activeTab === 'taskManage'"
          class="fab-button"
    <view class="fab-button"
          @click="handleAdd()">
      <up-icon name="plus"
               size="24"
@@ -122,7 +110,6 @@
    </view>
    <form-dia ref="formDia"
              @closeDia="handleQuery" />
    <view-files ref="viewFiles" />
  </view>
</template>
@@ -131,20 +118,12 @@
  import { onShow, onReachBottom, onPullDownRefresh } from "@dcloudio/uni-app";
  import PageHeader from "@/components/PageHeader.vue";
  import FormDia from "@/pages/inspectionManagement/components/formDia.vue";
  import ViewFiles from "@/pages/inspectionManagement/components/viewFiles.vue";
  import {
    delTimingTask,
    inspectionTaskList,
    timingTaskList,
  } from "@/api/inspectionManagement/index.js";
  const formDia = ref();
  const viewFiles = ref();
  const activeTab = ref("taskManage");
  const tabs = [
    { name: "taskManage", label: "定时任务管理" },
    { name: "task", label: "定时任务记录" },
  ];
  const queryParams = reactive({
    taskName: "",
  });
@@ -219,12 +198,6 @@
    return [String(val)];
  };
  const switchTab = tabName => {
    if (activeTab.value === tabName) return;
    activeTab.value = tabName;
    handleQuery();
  };
  const getList = async () => {
    if (loading.value) return;
    loading.value = true;
@@ -234,8 +207,7 @@
        current: pageParams.current,
        size: pageParams.size,
      };
      const request = activeTab.value === "task" ? inspectionTaskList : timingTaskList;
      const res = await request(params);
      const res = await timingTaskList(params);
      const records = res?.data?.records || [];
      const normalized = records.map(item => ({
        ...item,
@@ -278,12 +250,6 @@
    });
  };
  const viewFile = row => {
    nextTick(() => {
      viewFiles.value?.openDialog(row);
    });
  };
  const deleteOne = async row => {
    if (!row?.id) return;
    const canDelete = await new Promise(resolve => {
@@ -311,7 +277,6 @@
  };
  const onSwipeActionClick = (event, row) => {
    if (activeTab.value !== "taskManage") return;
    if (event?.position !== "right") return;
    deleteOne(row);
  };
@@ -345,30 +310,8 @@
    z-index: 10;
  }
  .tab-wrap {
    display: flex;
    background: #f4f5f8;
    border-radius: 16rpx;
    padding: 6rpx;
  }
  .tab-item {
    flex: 1;
    text-align: center;
    padding: 14rpx 0;
    font-size: 26rpx;
    color: #666;
    border-radius: 12rpx;
  }
  .tab-item.active {
    background: #1677ff;
    color: #fff;
    font-weight: 600;
  }
  .search-section {
    margin-top: 20rpx;
    margin-top: 0;
  }
  .search-bar {
src/pages/safeProduction/dangerInvestigation/detail.vue
@@ -50,13 +50,6 @@
                      count
                      :autoHeight="true" />
        </u-form-item>
        <u-form-item label="隐患具体位置"
                     prop="location"
                     required
                     border-bottom>
          <u-input v-model="form.location"
                   placeholder="请输入隐患具体位置" />
        </u-form-item>
        <u-form-item label="整改完成期限"
                     prop="rectifyTime"
                     required
@@ -167,7 +160,6 @@
    type: "",
    riskLevel: "",
    hiddenDesc: "",
    location: "",
    rectifyTime: "",
    rectifyUserName: "",
    rectifyUserMobile: "",
@@ -276,11 +268,6 @@
    if (!form.value.hiddenDesc) {
      showToast("请输入隐患描述");
      return;
    }
    if (!form.value.location) {
      showToast("请输入隐患具体位置");
      return;
    }