已添加10个文件
已修改6个文件
3321 ■■■■■ 文件已修改
src/api/safeProduction/dangerInvestigation.js 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/safeProduction/hazardousMaterialsControl.js 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages.json 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/index.vue 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/safeProduction/dangerInvestigation/acceptance.vue 376 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/safeProduction/dangerInvestigation/detail.vue 449 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/safeProduction/dangerInvestigation/fileList.vue 566 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/safeProduction/dangerInvestigation/index.vue 423 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/safeProduction/dangerInvestigation/rectify.vue 312 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/safeProduction/dangerInvestigation/view.vue 203 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/safeProduction/hazardSourceLedger/detail.vue 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/safeProduction/hazardSourceLedger/index.vue 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/safeProduction/hazardousMaterialsControl/detail.vue 443 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/safeProduction/hazardousMaterialsControl/index.vue 295 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/safeProduction/safeQualifications/detail.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/safeProduction/safeQualifications/index.vue 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/safeProduction/dangerInvestigation.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,61 @@
// å‘货台账页面接口
import request from "@/utils/request";
// åˆ†é¡µæŸ¥è¯¢
export function dangerInvestigationListPage(query) {
  return request({
    url: "/safeHidden/page",
    method: "get",
    params: query,
  });
}
// æ–°å¢žå®‰å…¨è§„程与资质管理
export function safeHiddenAdd(query) {
    return request({
        url: '/safeHidden',
        method: 'post',
        data: query
    })
}
// ä¿®æ”¹å®‰å…¨è§„程与资质管理
export function safeHiddenUpdate(query) {
    return request({
        url: '/safeHidden',
        method: 'put',
        data: query
    })
}
// åˆ é™¤å®‰å…¨è§„程与资质管理
export function safeHiddenDel(ids) {
    return request({
        url: '/safeHidden/' + ids,
        method: 'delete',
        data: ids
    })
}
// æŸ¥è¯¢é™„件列表
export function fileListPage(query) {
  return request({
    url: "/safeHiddenFile/listPage",
    method: "get",
    params: query,
  });
}
// æ·»åР附件
export function safeHiddenFileAdd(query) {
    return request({
        url: '/safeHiddenFile/add',
        method: 'post',
        data: query
    })
}
// åˆ é™¤é™„ä»¶
export function safeHiddenFileDel(ids) {
    return request({
        url: '/safeHiddenFile/del',
        method: 'delete',
        data: ids
    })
}
src/api/safeProduction/hazardousMaterialsControl.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,33 @@
import request from "@/utils/request";
export function safeHazardRecordListPage(query) {
  return request({
    url: "/safeHazardRecord/page",
    method: "get",
    params: query,
  });
}
export function safeHazardRecordDel(ids) {
    return request({
        url: '/safeHazardRecord/' + ids,
        method: 'delete',
        data: ids
    })
}
// æ–°å¢žå±é™©æºå°è´¦
export function safeHazardRecordAdd(query) {
    return request({
        url: '/safeHazardRecord/borrow',
        method: 'post',
        data: query
    })
}
export function safeHazardRecordUpdate(query) {
    return request({
        url: '/safeHazardRecord/return',
        method: 'put',
        data: query
    })
}
src/pages.json
@@ -717,6 +717,62 @@
        "navigationStyle": "custom"
      }
    },
    {
      "path": "pages/safeProduction/dangerInvestigation/index",
      "style": {
        "navigationBarTitleText": "隐患排查上报",
        "navigationStyle": "custom"
      }
    },
    {
      "path": "pages/safeProduction/dangerInvestigation/detail",
      "style": {
        "navigationBarTitleText": "隐患上报详情",
        "navigationStyle": "custom"
      }
    },
    {
      "path": "pages/safeProduction/dangerInvestigation/view",
      "style": {
        "navigationBarTitleText": "隐患详情",
        "navigationStyle": "custom"
      }
    },
    {
      "path": "pages/safeProduction/dangerInvestigation/rectify",
      "style": {
        "navigationBarTitleText": "隐患整改",
        "navigationStyle": "custom"
      }
    },
    {
      "path": "pages/safeProduction/dangerInvestigation/acceptance",
      "style": {
        "navigationBarTitleText": "隐患验收",
        "navigationStyle": "custom"
      }
    },
    {
      "path": "pages/safeProduction/dangerInvestigation/fileList",
      "style": {
        "navigationBarTitleText": "隐患排查上报附件",
        "navigationStyle": "custom"
      }
    },
    {
      "path": "pages/safeProduction/hazardousMaterialsControl/index",
      "style": {
        "navigationBarTitleText": "危险物料",
        "navigationStyle": "custom"
      }
    },
    {
      "path": "pages/safeProduction/hazardousMaterialsControl/detail",
      "style": {
        "navigationBarTitleText": "危险物料详情",
        "navigationStyle": "custom"
      }
    }
  ],
  "subPackages": [
    {
src/pages/index.vue
@@ -305,11 +305,23 @@
    },
    {
      icon: "/static/images/icon/caigoutaizhang@2x.png",
      label: "危险源管理",
      label: "危险源台账",
    },
    {
      icon: "/static/images/icon/caigoutaizhang@2x.png",
      label: "危险作业",
    },
    {
      icon: "/static/images/icon/xunjianshangchuan@2x.png",
      label: "巡检上传",
    },
    {
      icon: "/static/images/icon/guzhangfenxi@2x.png",
      label: "隐患排查",
    },
    {
      icon: "/static/images/icon/guzhangfenxi@2x.png",
      label: "危险物料",
    },
  ]);
  // ååŒåŠžå…¬åŠŸèƒ½æ•°æ®
@@ -398,10 +410,6 @@
    {
      icon: "/static/images/icon/shbeibaoyang@2x.png",
      label: "设备保养",
    },
    {
      icon: "/static/images/icon/xunjianshangchuan@2x.png",
      label: "巡检上传",
    },
    {
      icon: "/static/images/icon/guzhangfenxi@2x.png",
@@ -678,7 +686,7 @@
          url: "/pages/safeProduction/safeQualifications/index",
        });
        break;
      case "危险源管理":
      case "危险源台账":
        uni.navigateTo({
          url: "/pages/safeProduction/hazardSourceLedger/index",
        });
@@ -688,6 +696,16 @@
          url: "/pages/cooperativeOffice/collaborativeApproval/index8",
        });
        break;
      case "隐患排查":
        uni.navigateTo({
          url: "/pages/safeProduction/dangerInvestigation/index",
        });
        break;
      case "危险物料":
        uni.navigateTo({
          url: "/pages/safeProduction/hazardousMaterialsControl/index",
        });
        break;
      default:
        uni.showToast({
          title: `点击了${item.label}`,
src/pages/safeProduction/dangerInvestigation/acceptance.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,376 @@
<template>
  <view class="danger-investigation-acceptance">
    <PageHeader title="隐患验收"
                @back="goBack" />
    <view class="section">
      <view class="section-title">隐患信息</view>
      <view class="info-item">
        <text class="info-label">隐患编号</text>
        <text class="info-value">{{ form.hiddenCode || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">隐患类型</text>
        <text class="info-value">{{ hidden_danger_type.find(i => String(i.value) === String(form.type))?.label || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">风险等级</text>
        <text class="info-value">{{ form.riskLevel || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">隐患描述</text>
        <text class="info-value">{{ form.hiddenDesc || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">隐患具体位置</text>
        <text class="info-value">{{ form.location || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">上报人</text>
        <text class="info-value">{{ form.createUserName || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">上报时间</text>
        <text class="info-value">{{ form.createTime || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">整改完成期限</text>
        <text class="info-value">{{ form.rectifyTime || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">整改责任人</text>
        <text class="info-value">{{ form.rectifyUserName || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">整改责任人联系方式</text>
        <text class="info-value">{{ form.rectifyUserMobile || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">整改具体措施</text>
        <text class="info-value">{{ form.rectifyMeasures || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">实际整改完成时间</text>
        <text class="info-value">{{ form.rectifyActualTime || '-' }}</text>
      </view>
    </view>
    <u-form @submit="handleSubmit"
            ref="formRef"
            label-width="110">
      <!-- éªŒæ”¶ä¿¡æ¯ -->
      <u-cell-group title="验收信息">
        <u-form-item label="验收时间"
                     prop="verifyTime"
                     border-bottom>
          <u-input v-model="form.verifyTime"
                   placeholder="请选择验收时间"
                   disabled />
        </u-form-item>
        <u-form-item label="验收人"
                     prop="verifyUserName"
                     border-bottom>
          <u-input v-model="form.verifyUserName"
                   disabled
                   placeholder="请输入验收人" />
        </u-form-item>
        <u-form-item label="验收结果"
                     prop="verifyResult"
                     required
                     border-bottom>
          <u-input v-model="verifyResultName"
                   placeholder="请选择验收结果"
                   @click="showVerifyResultSheet"
                   readonly />
          <template #right>
            <up-icon name="arrow-right"
                     @click="showVerifyResultSheet"></up-icon>
          </template>
        </u-form-item>
        <u-form-item label="验收意见"
                     prop="verifyRemark"
                     required
                     border-bottom>
          <u-textarea v-model="form.verifyRemark"
                      placeholder="请输入验收意见"
                      :maxlength="200"
                      count
                      :autoHeight="true" />
        </u-form-item>
      </u-cell-group>
      <!-- æäº¤æŒ‰é’® -->
      <view class="footer-btns">
        <u-button class="cancel-btn"
                  @click="goBack">取消</u-button>
        <u-button class="sign-btn"
                  type="primary"
                  @click="handleSubmit"
                  :loading="loading">提交验收</u-button>
      </view>
    </u-form>
    <!-- æ—¶é—´é€‰æ‹©å™¨ -->
    <up-datetime-picker :show="showTime"
                        v-model="currentTime"
                        @confirm="onTimeConfirm"
                        @cancel="showTime = false"
                        mode="date" />
    <!-- éªŒæ”¶ç»“果选择器 -->
    <up-action-sheet :show="verifyResultSheetVisible"
                     :actions="verifyResultOptions"
                     @select="handleVerifyResultSelect"
                     title="选择验收结果" />
  </view>
</template>
<script setup>
  // æ›¿æ¢ toast æ–¹æ³•
  defineOptions({ name: "danger-investigation-acceptance" });
  const showToast = message => {
    uni.showToast({
      title: message,
      icon: "none",
    });
  };
  import { ref, onMounted } from "vue";
  import PageHeader from "@/components/PageHeader.vue";
  import { safeHiddenUpdate } from "@/api/safeProduction/dangerInvestigation";
  import useUserStore from "@/store/modules/user";
  import dayjs from "dayjs";
  import { onLoad } from "@dcloudio/uni-app";
  import { useDict } from "@/utils/dict";
  const { hidden_danger_type } = useDict("hidden_danger_type");
  const userStore = useUserStore();
  // è¡¨å•数据
  const form = ref({
    id: "",
    hiddenCode: "",
    hiddenDesc: "",
    location: "",
    rectifyTime: "",
    rectifyActualTime: "",
    rectifyResult: "",
    verifyTime: "",
    verifyRemark: "",
    verifyResult: "",
  });
  // é¡µé¢çŠ¶æ€
  const loading = ref(false);
  const formRef = ref(null);
  // æ—¶é—´ç›¸å…³
  const currentTime = ref(Date.now());
  const showTime = ref(false);
  // éªŒæ”¶ç»“果选择器
  const verifyResultSheetVisible = ref(false);
  const verifyResultName = ref("");
  const verifyResultOptions = ref([
    { value: "通过", name: "通过" },
    { value: "不通过", name: "不通过" },
  ]);
  const showVerifyResultSheet = () => {
    verifyResultSheetVisible.value = true;
  };
  const handleVerifyResultSelect = item => {
    form.value.verifyResult = item.value;
    verifyResultName.value = item.name;
    verifyResultSheetVisible.value = false;
  };
  // è¿”回上一页
  const goBack = () => {
    // è¿”回时清除本地存储的数据
    uni.removeStorageSync("dangerInvestigation");
    uni.navigateBack();
  };
  // æ˜¾ç¤ºæ—¶é—´é€‰æ‹©å™¨
  const showTimePicker = () => {
    showTime.value = true;
  };
  // ç¡®è®¤æ—¶é—´é€‰æ‹©
  const onTimeConfirm = e => {
    form.value.verifyTime = dayjs(e.value).format("YYYY-MM-DD");
    currentTime.value = e.value;
    showTime.value = false;
  };
  // æäº¤è¡¨å•
  const handleSubmit = async () => {
    if (!form.value.verifyRemark) {
      showToast("请输入验收意见");
      return;
    }
    if (!form.value.verifyResult) {
      showToast("请选择验收结果");
      return;
    }
    try {
      loading.value = true;
      // ä½¿ç”¨å®‰å…¨æµ…拷贝,避免对象展开在某些运行时抛错
      const source =
        form.value && typeof form.value === "object" ? form.value : {};
      const submitData = {};
      Object.keys(source).forEach(k => {
        submitData[k] = source[k];
      });
      console.log("submitData", submitData);
      const { code } = await safeHiddenUpdate(submitData);
      if (code === 200) {
        showToast("验收提交成功");
        setTimeout(() => {
          goBack();
        }, 500);
      } else {
        loading.value = false;
        showToast("验收提交失败,请重试");
      }
    } catch (e) {
      loading.value = false;
      console.error("提交失败:", e);
      showToast("提交失败,请重试");
    }
  };
  onLoad(() => {
    // ä»Žæœ¬åœ°å­˜å‚¨èŽ·å–éšæ‚£æ•°æ®
    const dangerInvestigation = uni.getStorageSync("dangerInvestigation");
    if (dangerInvestigation && dangerInvestigation.id) {
      form.value = dangerInvestigation;
      console.log("form.value", form.value);
    } else {
      showToast("暂无隐患数据");
    }
  });
  // åˆå§‹åŒ–页面数据
  const initPageData = () => {
    // è®¾ç½®é»˜è®¤éªŒæ”¶æ—¶é—´ä¸ºå½“前时间
    if (!form.value.verifyTime) {
      form.value.verifyTime = dayjs().format("YYYY-MM-DD");
      currentTime.value = Date.now();
    }
    // è®¾ç½®å·²é€‰éªŒæ”¶ç»“果的显示文本
    if (form.value.verifyResult) {
      verifyResultName.value =
        verifyResultOptions.value.find(
          item => item.value === form.value.verifyResult
        )?.name || "";
    }
    // è®¾ç½®éªŒæ”¶äºº
    if (!form.value.verifyUserName) {
      userStore.getInfo().then(res => {
        form.value.verifyUserId = res.user.userId;
        form.value.verifyUserName = res.user.nickName;
      });
    }
    console.log("form.value", form.value);
  };
  onMounted(() => {
    initPageData();
  });
</script>
<style scoped lang="scss">
  @import "@/static/scss/form-common.scss";
  .danger-investigation-acceptance {
    min-height: 100vh;
    background-color: #f8f9fa;
    padding-bottom: 160rpx;
  }
  .footer-btns {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0.75rem 0;
    box-shadow: 0 -0.125rem 0.5rem rgba(0, 0, 0, 0.05);
    z-index: 1000;
  }
  .cancel-btn {
    font-weight: 400;
    font-size: 1rem;
    color: #666;
    background: #f5f5f5;
    border: 1px solid #ddd;
    width: 45%;
    height: 2.5rem;
    border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
  }
  .sign-btn {
    font-weight: 500;
    font-size: 1rem;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    width: 45%;
    height: 2.5rem;
    border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
  }
  .section {
    background-color: #ffffff;
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  }
  .section-title {
    font-size: 16px;
    font-weight: 600;
    color: #333333;
    padding: 16px 16px 12px;
    border-bottom: 1px solid #f0f0f0;
  }
  .info-item {
    display: flex;
    padding: 14px 16px;
    border-bottom: 1px solid #f8f8f8;
    align-items: flex-start;
  }
  .info-item:last-child {
    border-bottom: none;
  }
  .info-label {
    font-size: 14px;
    color: #666666;
    min-width: 80px;
    flex-shrink: 0;
    line-height: 22px;
  }
  .info-value {
    font-size: 14px;
    color: #333333;
    flex: 1;
    line-height: 22px;
    text-align: right;
  }
  .multi-line {
    text-align: left;
    word-break: break-all;
    line-height: 1.6;
  }
  .remark-item {
    padding-bottom: 16px;
  }
</style>
src/pages/safeProduction/dangerInvestigation/detail.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,449 @@
<template>
  <view class="danger-investigation-detail">
    <PageHeader :title="isEdit ? '编辑隐患' : '新增隐患'"
                @back="goBack" />
    <u-form @submit="handleSubmit"
            ref="formRef"
            label-width="110">
      <!-- é𐿂£ä¿¡æ¯ -->
      <u-cell-group title="隐患信息">
        <u-form-item label="隐患编号"
                     prop="hiddenCode"
                     border-bottom>
          <u-input v-model="form.hiddenCode"
                   placeholder="系统自动生成"
                   readonly />
        </u-form-item>
        <u-form-item label="隐患类型"
                     prop="type"
                     required
                     border-bottom>
          <u-input v-model="hiddenTypeName"
                   placeholder="请选择隐患类型"
                   @click="showHiddenTypeSheet"
                   readonly />
          <template #right>
            <up-icon name="arrow-right"
                     @click="showHiddenTypeSheet"></up-icon>
          </template>
        </u-form-item>
        <u-form-item label="风险等级"
                     prop="riskLevel"
                     required
                     border-bottom>
          <u-input v-model="riskLevelName"
                   placeholder="请选择风险等级"
                   @click="showRiskLevelSheet"
                   readonly />
          <template #right>
            <up-icon name="arrow-right"
                     @click="showRiskLevelSheet"></up-icon>
          </template>
        </u-form-item>
        <u-form-item label="隐患描述"
                     prop="hiddenDesc"
                     required
                     border-bottom>
          <u-textarea v-model="form.hiddenDesc"
                      placeholder="请输入隐患描述"
                      :maxlength="200"
                      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
                     border-bottom>
          <u-input v-model="form.rectifyTime"
                   placeholder="请选择整改完成期限"
                   @click="showTimePicker" />
          <template #right>
            <up-icon name="arrow-right"
                     @click="showTimePicker"></up-icon>
          </template>
        </u-form-item>
        <u-form-item label="整改责任人"
                     prop="rectifyUserName"
                     required
                     border-bottom>
          <u-input v-model="form.rectifyUserName"
                   placeholder="请选择整改责任人"
                   @click="showPrincipalSheet"
                   readonly />
          <template #right>
            <up-icon name="arrow-right"
                     @click="showPrincipalSheet"></up-icon>
          </template>
        </u-form-item>
        <u-form-item label="上报人"
                     prop="createUserName"
                     border-bottom>
          <u-input v-model="form.createUserName"
                   disabled
                   placeholder="请输入上报人" />
        </u-form-item>
        <u-form-item label="上报时间"
                     prop="createTime"
                     border-bottom>
          <u-input v-model="form.createTime"
                   disabled
                   placeholder="请输入上报时间" />
        </u-form-item>
      </u-cell-group>
      <!-- æäº¤æŒ‰é’® -->
      <view class="footer-btns">
        <u-button class="cancel-btn"
                  @click="goBack">取消</u-button>
        <u-button class="sign-btn"
                  type="primary"
                  @click="handleSubmit"
                  :loading="loading">{{ isEdit ? '保存修改' : '提交' }}</u-button>
      </view>
    </u-form>
    <!-- æ—¶é—´é€‰æ‹©å™¨ -->
    <up-datetime-picker :show="showTime"
                        v-model="currentTime"
                        @confirm="onTimeConfirm"
                        @cancel="showTime = false"
                        mode="date" />
    <!-- é𐿂£ç±»åž‹é€‰æ‹©å™¨ -->
    <up-action-sheet :show="hiddenTypeSheetVisible"
                     :actions="hiddenTypeOptions"
                     @select="handleHiddenTypeSelect"
                     @close="hiddenTypeSheetVisible = false"
                     title="选择隐患类型" />
    <!-- é£Žé™©ç­‰çº§é€‰æ‹©å™¨ -->
    <up-action-sheet :show="riskLevelSheetVisible"
                     :actions="riskLevelOptions"
                     @select="handleRiskLevelSelect"
                     @close="riskLevelSheetVisible = false"
                     title="选择风险等级" />
    <!-- æ•´æ”¹è´£ä»»äººé€‰æ‹©å™¨ -->
    <up-action-sheet :show="principalSheetVisible"
                     :actions="principalOptions"
                     @select="handlePrincipalSelect"
                     @close="principalSheetVisible = false"
                     title="选择整改责任人" />
  </view>
</template>
<script setup>
  // æ›¿æ¢ toast æ–¹æ³•
  defineOptions({ name: "danger-investigation-detail" });
  const showToast = message => {
    uni.showToast({
      title: message,
      icon: "none",
    });
  };
  import { ref, onMounted } from "vue";
  import PageHeader from "@/components/PageHeader.vue";
  import {
    safeHiddenAdd,
    safeHiddenUpdate,
  } from "@/api/safeProduction/dangerInvestigation";
  import { userListNoPageByTenantId } from "@/api/system/user";
  import useUserStore from "@/store/modules/user";
  import { useDict } from "@/utils/dict";
  import dayjs from "dayjs";
  import { onLoad } from "@dcloudio/uni-app";
  // èŽ·å–å­—å…¸æ•°æ®
  const { hidden_danger_type } = useDict("hidden_danger_type");
  const userStore = useUserStore();
  // è¡¨å•数据
  const form = ref({
    hiddenCode: "",
    type: "",
    riskLevel: "",
    hiddenDesc: "",
    location: "",
    rectifyTime: "",
    rectifyUserName: "",
    rectifyUserMobile: "",
    rectifyMeasures: "",
  });
  // é¡µé¢çŠ¶æ€
  const loading = ref(false);
  const formRef = ref(null);
  const isEdit = ref(false);
  // æ—¶é—´ç›¸å…³
  const currentTime = ref(Date.now());
  const showTime = ref(false);
  // é𐿂£ç±»åž‹é€‰æ‹©å™¨
  const hiddenTypeSheetVisible = ref(false);
  const hiddenTypeName = ref("");
  const hiddenTypeOptions = ref([]);
  const showHiddenTypeSheet = () => {
    hiddenTypeSheetVisible.value = true;
  };
  const handleHiddenTypeSelect = item => {
    form.value.type = item.value;
    hiddenTypeName.value = item.name;
    hiddenTypeSheetVisible.value = false;
  };
  // é£Žé™©ç­‰çº§é€‰æ‹©å™¨
  const riskLevelSheetVisible = ref(false);
  const riskLevelName = ref("");
  const riskLevelOptions = ref([]);
  const showRiskLevelSheet = () => {
    riskLevelSheetVisible.value = true;
  };
  const handleRiskLevelSelect = item => {
    form.value.riskLevel = item.value;
    riskLevelName.value = item.name;
    riskLevelSheetVisible.value = false;
  };
  // æ•´æ”¹è´£ä»»äººé€‰æ‹©å™¨
  const principalSheetVisible = ref(false);
  const userList = ref([]);
  const principalOptions = ref([]);
  const showPrincipalSheet = () => {
    if (principalOptions.value.length === 0) {
      getUserList();
    } else {
      principalSheetVisible.value = true;
    }
  };
  const handlePrincipalSelect = item => {
    form.value.rectifyUserId = item.value;
    form.value.rectifyUserName = item.name;
    form.value.rectifyUserMobile = item.mobile;
    principalSheetVisible.value = false;
  };
  // èŽ·å–ç”¨æˆ·åˆ—è¡¨
  const getUserList = () => {
    userListNoPageByTenantId().then(res => {
      if (res.code === 200) {
        userList.value = res.data;
        principalOptions.value = res.data.map(user => ({
          value: user.userId,
          name: user.nickName,
          mobile: user.phonenumber,
        }));
        principalSheetVisible.value = true;
      }
    });
  };
  // è¿”回上一页
  const goBack = () => {
    // è¿”回时清除本地存储的数据
    uni.removeStorageSync("dangerInvestigation");
    uni.navigateBack();
  };
  // æ˜¾ç¤ºæ—¶é—´é€‰æ‹©å™¨
  const showTimePicker = () => {
    showTime.value = true;
  };
  // ç¡®è®¤æ—¶é—´é€‰æ‹©
  const onTimeConfirm = e => {
    form.value.rectifyTime = dayjs(e.value).format("YYYY-MM-DD");
    currentTime.value = e.value;
    showTime.value = false;
  };
  // æäº¤è¡¨å•
  const handleSubmit = async () => {
    console.log("form.value", form.value);
    if (!form.value.type) {
      showToast("请选择隐患类型");
      return;
    }
    if (!form.value.riskLevel) {
      showToast("请选择风险等级");
      return;
    }
    if (!form.value.hiddenDesc) {
      showToast("请输入隐患描述");
      return;
    }
    if (!form.value.location) {
      showToast("请输入隐患具体位置");
      return;
    }
    if (!form.value.rectifyTime) {
      showToast("请选择整改完成期限");
      return;
    }
    if (!form.value.rectifyUserName) {
      showToast("请选择整改责任人");
      return;
    }
    if (!form.value.rectifyUserMobile) {
      showToast("请输入整改责任人联系方式");
      return;
    }
    try {
      loading.value = true;
      // ä½¿ç”¨å®‰å…¨æµ…拷贝,避免对象展开在某些运行时抛错
      const source =
        form.value && typeof form.value === "object" ? form.value : {};
      const submitData = {};
      Object.keys(source).forEach(k => {
        submitData[k] = source[k];
      });
      console.log("submitData", submitData);
      if (isEdit.value) {
        const { code } = await safeHiddenUpdate(submitData);
        if (code === 200) {
          showToast("修改成功");
          setTimeout(() => {
            goBack();
          }, 500);
        } else {
          loading.value = false;
          showToast("修改失败,请重试");
        }
      } else {
        const { code } = await safeHiddenAdd(submitData);
        if (code === 200) {
          showToast("新增成功");
          setTimeout(() => {
            goBack();
          }, 500);
        } else {
          loading.value = false;
          showToast("新增失败,请重试");
        }
      }
    } catch (e) {
      loading.value = false;
      console.error("提交失败:", e);
      showToast("提交失败,请重试");
    }
  };
  onLoad(() => {
    // ç¼–辑隐患时,从本地存储获取数据
    const dangerInvestigation = uni.getStorageSync("dangerInvestigation");
    if (dangerInvestigation && dangerInvestigation.id) {
      form.value = dangerInvestigation;
      isEdit.value = true;
    } else {
      isEdit.value = false;
    }
    userStore.getInfo().then(res => {
      form.value.createUser = res.user.userId;
      form.value.createUserName = res.user.nickName;
    });
    form.value.createTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
  });
  // åˆå§‹åŒ–页面数据
  const initPageData = () => {
    // è®¾ç½®é»˜è®¤æ•´æ”¹å®ŒæˆæœŸé™ä¸ºå½“前时间
    if (!isEdit.value) {
      form.value.rectifyTime = dayjs().format("YYYY-MM-DD");
      currentTime.value = Date.now();
    }
  };
  onMounted(() => {
    initPageData();
    // åˆå§‹åŒ–选项数据
    hiddenTypeOptions.value = hidden_danger_type.value.map(item => ({
      value: item.value,
      name: item.label,
    }));
    riskLevelOptions.value = [
      {
        value: "重大风险",
        name: "重大风险",
      },
      {
        value: "较大风险",
        name: "较大风险",
      },
      {
        value: "一般风险",
        name: "一般风险",
      },
      {
        value: "低风险",
        name: "低风险",
      },
    ];
    // è®¾ç½®å·²é€‰å€¼çš„æ˜¾ç¤ºæ–‡æœ¬
    if (form.value.type) {
      hiddenTypeName.value =
        hiddenTypeOptions.value.find(item => item.value == form.value.type)
          ?.name || "";
    }
    if (form.value.riskLevel) {
      riskLevelName.value =
        riskLevelOptions.value.find(item => item.value == form.value.riskLevel)
          ?.name || "";
    }
  });
</script>
<style scoped lang="scss">
  @import "@/static/scss/form-common.scss";
  .danger-investigation-detail {
    min-height: 100vh;
    background-color: #f8f9fa;
  }
  .footer-btns {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0.75rem 0;
    box-shadow: 0 -0.125rem 0.5rem rgba(0, 0, 0, 0.05);
    z-index: 1000;
  }
  .cancel-btn {
    font-weight: 400;
    font-size: 1rem;
    color: #666;
    background: #f5f5f5;
    border: 1px solid #ddd;
    width: 45%;
    height: 2.5rem;
    border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
  }
  .sign-btn {
    font-weight: 500;
    font-size: 1rem;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    width: 45%;
    height: 2.5rem;
    border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
  }
</style>
src/pages/safeProduction/dangerInvestigation/fileList.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,566 @@
<template>
  <view class="file-list-page">
    <!-- é¡µé¢å¤´éƒ¨ -->
    <PageHeader title="附件管理"
                @back="goBack" />
    <!-- é™„件列表 -->
    <view class="file-list-container">
      <view v-if="fileList.length > 0"
            class="file-list">
        <view v-for="(file, index) in fileList"
              :key="file.id || index"
              class="file-item">
          <!-- æ–‡ä»¶å›¾æ ‡ -->
          <!-- <view class="file-icon"
                :class="getFileIconClass(file.fileType)">
            <up-icon :name="getFileIcon(file.fileType)"
                     size="24"
                     color="#ffffff" />
          </view> -->
          <!-- æ–‡ä»¶ä¿¡æ¯ -->
          <view class="file-info">
            <text class="file-name">{{ file.name }}</text>
            <!-- <text class="file-meta">{{ formatFileSize(file.fileSize) }} Â· {{ file.uploadTime || file.createTime }}</text> -->
          </view>
          <!-- æ“ä½œæŒ‰é’® -->
          <view class="file-actions">
            <!-- <u-button size="small"
                      type="primary"
                      plain
                      @click="previewFile(file)">预览</u-button> -->
            <u-button size="small"
                      type="info"
                      plain
                      @click="downloadFile(file)">下载并预览</u-button>
            <u-button size="small"
                      type="error"
                      plain
                      @click="confirmDelete(file, index)">删除</u-button>
          </view>
        </view>
      </view>
      <!-- ç©ºçŠ¶æ€ -->
      <view v-else
            class="empty-state">
        <up-icon name="document"
                 size="64"
                 color="#c0c4cc" />
        <text class="empty-text">暂无附件</text>
      </view>
    </view>
    <!-- <a rel="nofollow"
       id="downloadLink"
       href="#"
       style="display:none;">下载文本文件</a> -->
    <!-- ä¸Šä¼ æŒ‰é’® -->
    <view class="upload-button"
          @click="chooseFile">
      <up-icon name="plus"
               size="24"
               color="#ffffff" />
      <text class="upload-text">上传附件</text>
    </view>
  </view>
</template>
<script setup>
  import { ref, onMounted } from "vue";
  import PageHeader from "@/components/PageHeader.vue";
  import config from "@/config";
  import { getToken } from "@/utils/auth";
  // import { saveAs } from "file-saver";
  import {
    listRuleFiles,
    delRuleFile,
  } from "@/api/managementMeetings/rulesRegulationsManagement";
  import {
    safeHiddenFileAdd,
    fileListPage,
    safeHiddenFileDel,
  } from "@/api/safeProduction/dangerInvestigation";
  import { blobValidate } from "@/utils/ruoyi";
  // é™„件列表
  const fileList = ref([]);
  // è¿”回上一页
  const goBack = () => {
    uni.navigateBack();
  };
  // const request = axios.create({
  //   baseURL: "URL.com",
  //   adapter: axiosAdapterUniapp,
  // });
  // èŽ·å–æ–‡ä»¶å›¾æ ‡
  const getFileIcon = fileType => {
    const iconMap = {
      doc: "document",
      docx: "document",
      xls: "grid",
      xlsx: "grid",
      pdf: "document",
      ppt: "copy",
      pptx: "copy",
      txt: "document",
      jpg: "image",
      jpeg: "image",
      png: "image",
      gif: "image",
      zip: "folder",
      rar: "folder",
    };
    return iconMap[fileType.toLowerCase()] || "document";
  };
  // èŽ·å–æ–‡ä»¶å›¾æ ‡æ ·å¼ç±»
  const getFileIconClass = fileType => {
    const colorMap = {
      doc: "blue",
      docx: "blue",
      xls: "green",
      xlsx: "green",
      pdf: "red",
      ppt: "orange",
      pptx: "orange",
      txt: "gray",
      jpg: "purple",
      jpeg: "purple",
      png: "purple",
      gif: "purple",
      zip: "yellow",
      rar: "yellow",
    };
    return colorMap[fileType.toLowerCase()] || "gray";
  };
  // æ ¼å¼åŒ–文件大小
  const formatFileSize = bytes => {
    if (bytes === 0) return "0 B";
    const k = 1024;
    const sizes = ["B", "KB", "MB", "GB"];
    const i = Math.floor(Math.log(bytes) / Math.log(k));
    return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
  };
  // é€‰æ‹©æ–‡ä»¶
  const chooseFile = () => {
    uni.chooseImage({
      count: 9,
      sizeType: ["original", "compressed"],
      sourceType: ["album", "camera"],
      success: res => {
        console.log(res, "选择图片成功");
        uploadFiles(res.tempFiles);
      },
      fail: err => {
        console.error("选择图片失败:", err);
        showToast("选择文件失败");
      },
    });
    // uni.chooseFile({
    //   count: 9,
    //   extension: [
    //     ".doc",
    //     ".docx",
    //     ".xls",
    //     ".xlsx",
    //     ".pdf",
    //     ".ppt",
    //     ".pptx",
    //     ".txt",
    //     ".jpg",
    //     ".jpeg",
    //     ".png",
    //     ".gif",
    //     ".zip",
    //     ".rar",
    //   ],
    //   success: res => {
    //     console.log(res, "选择文件成功");
    //     uploadFiles(res.tempFiles);
    //   },
    //   fail: err => {
    //     showToast("选择文件失败");
    //   },
    // });
  };
  // ä¸Šä¼ æ–‡ä»¶
  const uploadFiles = tempFiles => {
    console.log(tempFiles, "上传文件1");
    tempFiles.forEach((tempFile, index) => {
      // æ˜¾ç¤ºä¸Šä¼ ä¸­æç¤º
      uni.showLoading({
        title: "上传中...",
        mask: true,
      });
      console.log(tempFile, "上传文件2");
      // 1. ç›´æŽ¥ä½¿ç”¨ uni.uploadFile ä¸Šä¼ æ–‡ä»¶
      uni.uploadFile({
        url: config.baseUrl + "/file/upload",
        filePath: tempFile.path,
        name: "file",
        header: {
          Authorization: "Bearer " + getToken(),
        },
        success: uploadRes => {
          uni.hideLoading();
          console.log(uploadRes, "上传文件3");
          try {
            const res = JSON.parse(uploadRes.data);
            console.log(res, "上传文件4");
            if (res.code === 200) {
              // 2. æå–文件信息
              const fileName = tempFile.name
                ? tempFile.name
                : tempFile.path.split("/").pop();
              // const fileType = fileName.split(".").pop();
              // 3. æž„造保存文件信息的参数
              const saveData = {
                name: fileName,
                safeHiddenId: rulesRegulationsManagementId.value,
                url: res.data.tempPath || "",
              };
              console.log(saveData, "保存文件信息参数");
              // 4. è°ƒç”¨ addRuleFile æŽ¥å£ä¿å­˜æ–‡ä»¶ä¿¡æ¯
              safeHiddenFileAdd(saveData)
                .then(addRes => {
                  if (addRes.code === 200) {
                    // 5. æ·»åŠ åˆ°æ–‡ä»¶åˆ—è¡¨
                    const newFile = {
                      ...addRes.data,
                      uploadTime: new Date().toLocaleString(),
                    };
                    // fileList.value.push(newFile);
                    getFileList();
                    showToast("上传成功");
                  } else {
                    showToast("保存文件信息失败");
                  }
                })
                .catch(err => {
                  console.error("保存文件信息失败:", err);
                  showToast("保存文件信息失败");
                });
            } else {
              showToast("文件上传失败");
            }
          } catch (e) {
            console.error("解析上传结果失败:", e);
            showToast("上传失败");
          }
        },
        fail: err => {
          uni.hideLoading();
          console.error("上传失败:", err);
          showToast("上传失败");
        },
      });
    });
  };
  // ä¸‹è½½æ–‡ä»¶
  const downloadFile = file => {
    var url =
      config.baseUrl +
      "/common/download?fileName=" +
      encodeURIComponent(file.url) +
      "&delete=true";
    console.log(url, "url");
    uni
      .downloadFile({
        url: url,
        responseType: "blob",
        header: { Authorization: "Bearer " + getToken() },
      })
      .then(res => {
        let osType = uni.getStorageSync("deviceInfo").osName;
        let filePath = res.tempFilePath;
        if (osType === "ios") {
          uni.openDocument({
            filePath: filePath,
            showMenu: true,
            success: res => {
              resolve(res);
            },
            fail: err => {
              console.log("uni.openDocument--fail");
              reject(err);
            },
          });
        } else {
          uni.saveFile({
            tempFilePath: filePath,
            success: fileRes => {
              uni.showToast({
                icon: "none",
                mask: true,
                title:
                  "文件已保存:Android/data/uni.UNI720216F/apps/__UNI__720216F/" +
                  fileRes.savedFilePath, //保存路径
                duration: 3000,
              });
              setTimeout(() => {
                //打开文档查看
                uni.openDocument({
                  filePath: fileRes.savedFilePath,
                  success: function (res) {
                    resolve(fileRes);
                  },
                });
              }, 3000);
            },
            fail: err => {
              console.log("uni.save--fail");
              reject(err);
            },
          });
        }
        // const isBlob = blobValidate(res.data);
        // if (isBlob) {
        //   const blob = new Blob([res.data], { type: "text/plain" });
        //   const url = URL.createObjectURL(blob);
        //   const downloadLink = document.getElementById("downloadLink");
        //   downloadLink.href = url;
        //   downloadLink.download = file.name;
        //   downloadLink.click();
        //   showToast("下载成功");
        // } else {
        //   showToast("下载失败");
        // }
      })
      .catch(err => {
        console.error("下载失败:", err);
        showToast("下载失败");
      });
  };
  // ç¡®è®¤åˆ é™¤
  const confirmDelete = (file, index) => {
    uni.showModal({
      title: "删除确认",
      content: `确定要删除附件 "${file.name}" å—?`,
      success: res => {
        if (res.confirm) {
          deleteFile(file.id, index);
        }
      },
    });
  };
  // åˆ é™¤æ–‡ä»¶
  const deleteFile = (fileId, index) => {
    uni.showLoading({
      title: "删除中...",
      mask: true,
    });
    safeHiddenFileDel([fileId])
      .then(res => {
        uni.hideLoading();
        if (res.code === 200) {
          // fileList.value.splice(index, 1);
          getFileList();
          showToast("删除成功");
        } else {
          showToast("删除失败");
        }
      })
      .catch(err => {
        uni.hideLoading();
        showToast("删除失败");
      });
  };
  // æ˜¾ç¤ºæç¤º
  const showToast = message => {
    uni.showToast({
      title: message,
      icon: "none",
    });
  };
  const rulesRegulationsManagementId = ref("");
  // é¡µé¢åŠ è½½æ—¶
  onMounted(() => {
    rulesRegulationsManagementId.value = uni.getStorageSync(
      "dangerInvestigationFileId"
    );
    // ä»Ž API èŽ·å–é™„ä»¶åˆ—è¡¨
    getFileList();
    // ä»Žæœ¬åœ°å­˜å‚¨èŽ·å– rulesRegulationsManagementId
  });
  // èŽ·å–é™„ä»¶åˆ—è¡¨
  const getFileList = () => {
    uni.showLoading({
      title: "加载中...",
      mask: true,
    });
    fileListPage({
      safeHiddenId: rulesRegulationsManagementId.value,
      current: -1,
      size: -1,
    })
      .then(res => {
        uni.hideLoading();
        if (res.code === 200) {
          fileList.value = res.data.records || [];
        } else {
          showToast("获取附件列表失败");
        }
      })
      .catch(err => {
        uni.hideLoading();
        showToast("获取附件列表失败");
      });
  };
</script>
<style scoped lang="scss">
  @import "../../../styles/sales-common.scss";
  .file-list-page {
    min-height: 100vh;
    background: #f8f9fa;
    padding-bottom: 100rpx;
  }
  .file-list-container {
    padding: 20rpx;
  }
  .file-list {
    background: #ffffff;
    border-radius: 8rpx;
    overflow: hidden;
    box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  }
  .file-item {
    display: flex;
    align-items: center;
    padding: 20rpx;
    border-bottom: 1rpx solid #f0f0f0;
    &:last-child {
      border-bottom: none;
    }
  }
  .file-icon {
    width: 56rpx;
    height: 56rpx;
    border-radius: 8rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 20rpx;
    &.blue {
      background: #409eff;
    }
    &.green {
      background: #67c23a;
    }
    &.red {
      background: #f56c6c;
    }
    &.orange {
      background: #e6a23c;
    }
    &.gray {
      background: #909399;
    }
    &.purple {
      background: #909399;
    }
    &.yellow {
      background: #e6a23c;
    }
  }
  .file-info {
    flex: 1;
    min-width: 0;
  }
  .file-name {
    display: block;
    font-size: 16px;
    color: #303133;
    margin-bottom: 8rpx;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .file-meta {
    display: block;
    font-size: 12px;
    color: #909399;
  }
  .file-actions {
    display: flex;
    gap: 12rpx;
  }
  .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 100rpx 0;
    background: #ffffff;
    border-radius: 8rpx;
    box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  }
  .empty-text {
    font-size: 14px;
    color: #909399;
    margin-top: 20rpx;
  }
  .upload-button {
    position: fixed;
    bottom: 40rpx;
    right: 40rpx;
    width: 130rpx;
    height: 130rpx;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4rpx 16rpx rgba(102, 126, 234, 0.4);
    z-index: 1000;
  }
  .upload-text {
    font-size: 10px;
    color: #ffffff;
    margin-top: 4rpx;
  }
  .upload-progress {
    padding: 40rpx 0;
  }
  .upload-progress-text {
    display: block;
    text-align: center;
    margin-top: 20rpx;
    font-size: 14px;
    color: #606266;
  }
</style>
src/pages/safeProduction/dangerInvestigation/index.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,423 @@
<template>
  <view class="sales-accoun">
    <!-- ä½¿ç”¨é€šç”¨é¡µé¢å¤´éƒ¨ç»„ä»¶ -->
    <PageHeader title="隐患排查上报"
                @back="goBack" />
    <!-- æœç´¢å’Œç­›é€‰åŒºåŸŸ -->
    <!-- <view class="search-section">
      <view class="search-bar">
        <view class="search-input">
          <up-input class="search-text"
                    placeholder="请输入危险源名称"
                    v-model="customerName"
                    @blur="getList"
                    clearable />
        </view>
        <view class="filter-button"
              @click="getList">
          <u-icon name="search"
                  size="24"
                  color="#999"></u-icon>
        </view>
      </view>
    </view> -->
    <!-- æ‹œè®¿è®°å½•列表 -->
    <view class="ledger-list"
          v-if="visitList.length > 0">
      <view v-for="(item, index) in visitList"
            :key="index">
        <view class="ledger-item"
              :class="{ 'overdue': isOverdue(item.rectifyTime, item.rectifyActualTime) }">
          <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.hiddenCode }}</text>
            </view>
          </view>
          <up-divider></up-divider>
          <view class="item-details"
                @click="viewDetail(item)">
            <view class="detail-row">
              <text class="detail-label">隐患描述</text>
              <text class="detail-value">{{ item.hiddenDesc || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">隐患类型</text>
              <text class="detail-value">{{ hidden_danger_type.find(i => String(i.value) === String(item.type))?.label || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">风险等级</text>
              <u-tag :type="getRiskLevelType(item.riskLevel)">
                {{ item.riskLevel || '-' }}
              </u-tag>
            </view>
            <view class="detail-row">
              <text class="detail-label">隐患具体位置</text>
              <text class="detail-value">{{ item.location || '-' }}</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">{{ item.createTime || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">整改完成期限</text>
              <text class="detail-value">{{ item.rectifyTime || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">整改责任人</text>
              <text class="detail-value">{{ item.rectifyUserName || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">整改责任人联系方式</text>
              <text class="detail-value">{{ item.rectifyUserMobile || '-' }}</text>
            </view>
            <view v-if="item.rectifyActualTime"
                  class="detail-row">
              <text class="detail-label">整改具体措施</text>
              <text class="detail-value">{{ item.rectifyMeasures || '-' }}</text>
            </view>
            <view v-if="item.rectifyActualTime"
                  class="detail-row">
              <text class="detail-label">实际整改完成时间</text>
              <text class="detail-value">{{ item.rectifyActualTime || '-' }}</text>
            </view>
            <view v-if="item.verifyTime"
                  class="detail-row">
              <text class="detail-label">验收意见</text>
              <text class="detail-value">{{ item.verifyRemark || '-' }}</text>
            </view>
            <view v-if="item.verifyTime"
                  class="detail-row">
              <text class="detail-label">验收时间</text>
              <text class="detail-value">{{ item.verifyTime || '-' }}</text>
            </view>
            <view v-if="item.verifyTime"
                  class="detail-row">
              <text class="detail-label">验收人</text>
              <text class="detail-value">{{ item.verifyUserName || '-' }}</text>
            </view>
            <view v-if="item.verifyTime"
                  class="detail-row">
              <text class="detail-label">验收结果</text>
              <text class="detail-value">{{ item.verifyResult || '-' }}</text>
            </view>
          </view>
          <!-- æŒ‰é’®åŒºåŸŸ -->
          <view class="action-buttons">
            <!-- <u-button type="info"
                      size="small"
                      class="action-btn"
                      @click="viewDetail(item)">
              æŸ¥çœ‹è¯¦æƒ…
            </u-button> -->
            <u-button type="warning"
                      size="small"
                      class="action-btn"
                      :disabled="item.isRectify"
                      @click="rectifyVisit(item)">
              æ•´æ”¹
            </u-button>
            <u-button type="success"
                      size="small"
                      class="action-btn"
                      :disabled="!item.rectifyActualTime"
                      @click="acceptanceVisit(item)">
              éªŒæ”¶
            </u-button>
          </view>
          <view class="action-buttons">
            <u-button type="primary"
                      size="small"
                      class="action-btn"
                      @click="editVisit(item)">
              ç¼–辑
            </u-button>
            <u-button type="info"
                      size="small"
                      class="action-btn"
                      @click="viewFileList(item)">
              é™„ä»¶
            </u-button>
            <u-button type="error"
                      size="small"
                      class="action-btn"
                      @click="deleteVisit(item)">
              åˆ é™¤
            </u-button>
          </view>
        </view>
      </view>
    </view>
    <view v-else
          class="no-data">
      <text>暂无拜访记录</text>
    </view>
    <!-- æµ®åŠ¨æ–°å¢žæŒ‰é’® -->
    <view class="fab-button"
          @click="addVisit">
      <up-icon name="plus"
               size="24"
               color="#ffffff"></up-icon>
    </view>
  </view>
</template>
<script setup>
  import { ref, onMounted } from "vue";
  import { onShow } from "@dcloudio/uni-app";
  import PageHeader from "@/components/PageHeader.vue";
  import {
    dangerInvestigationListPage,
    safeHiddenDel,
  } from "@/api/safeProduction/dangerInvestigation";
  import useUserStore from "@/store/modules/user";
  import { useDict } from "@/utils/dict";
  // æ›¿æ¢ toast æ–¹æ³•
  defineOptions({ name: "client-visit-index" });
  const showToast = message => {
    uni.showToast({
      title: message,
      icon: "none",
    });
  };
  const getRiskLevelType = riskLevel => {
    const typeMap = {
      ä½Žé£Žé™©: "info",
      ä¸€èˆ¬é£Žé™©: "info",
      è¾ƒå¤§é£Žé™©: "warning",
      é‡å¤§é£Žé™©: "error",
    };
    return typeMap[riskLevel] || "info";
  };
  import dayjs from "dayjs";
  const userStore = useUserStore();
  // æ£€æŸ¥é𐿂£æ˜¯å¦è¶…期未整改
  const isOverdue = (rectifyTime, rectifyActualTime) => {
    // å¦‚果已经整改完成,则不超期
    if (rectifyActualTime) return false;
    // å¦‚果没有整改期限,则不超期
    if (!rectifyTime) return false;
    const today = dayjs();
    const deadline = dayjs(rectifyTime);
    // å¦‚果当前日期超过整改期限,则超期
    return today.isAfter(deadline, "day");
  };
  // æœç´¢å…³é”®è¯
  const customerName = ref("");
  // æ‹œè®¿è®°å½•数据
  const visitList = ref([]);
  // è¿”回上一页
  const goBack = () => {
    uni.navigateBack();
  };
  const viewFileList = item => {
    uni.setStorageSync("dangerInvestigationFileId", item.id);
    uni.navigateTo({
      url: "/pages/safeProduction/dangerInvestigation/fileList",
    });
  };
  // æŸ¥è¯¢åˆ—表
  const getList = () => {
    showLoadingToast("加载中...");
    const params = {
      current: -1,
      size: -1,
    };
    dangerInvestigationListPage(params)
      .then(res => {
        visitList.value = res.records || res.data?.records || [];
        userStore.getInfo().then(res => {
          visitList.value.forEach(item => {
            console.log(item.rectifyUserId, res.user.userId);
            if (Number(item.rectifyUserId) != Number(res.user.userId)) {
              item.isRectify = true;
            } else {
              item.isRectify = false;
            }
          });
        });
        closeToast();
      })
      .catch(() => {
        closeToast();
        showToast("获取数据失败");
      });
  };
  // æ˜¾ç¤ºåŠ è½½æç¤º
  const showLoadingToast = message => {
    uni.showLoading({
      title: message,
      mask: true,
    });
  };
  // å…³é—­æç¤º
  const closeToast = () => {
    uni.hideLoading();
  };
  // æ–°å¢žé𐿂£
  const addVisit = () => {
    uni.setStorageSync("dangerInvestigation", {});
    uni.navigateTo({
      url: "/pages/safeProduction/dangerInvestigation/detail",
    });
  };
  // ç¼–辑隐患
  const editVisit = item => {
    uni.setStorageSync("dangerInvestigation", item);
    uni.navigateTo({
      url: "/pages/safeProduction/dangerInvestigation/detail",
    });
  };
  // æ•´æ”¹é𐿂£
  const rectifyVisit = item => {
    uni.setStorageSync("dangerInvestigation", item);
    uni.navigateTo({
      url: "/pages/safeProduction/dangerInvestigation/rectify",
    });
  };
  // éªŒæ”¶é𐿂£
  const acceptanceVisit = item => {
    uni.setStorageSync("dangerInvestigation", item);
    uni.navigateTo({
      url: "/pages/safeProduction/dangerInvestigation/acceptance",
    });
  };
  // åˆ é™¤é𐿂£
  const deleteVisit = item => {
    uni.showModal({
      title: "删除确认",
      content: `确定要删除该隐患吗?`,
      success: res => {
        if (res.confirm) {
          deleteClientVisit(item.id);
        }
      },
    });
  };
  const { hidden_danger_type } = useDict("hidden_danger_type");
  // åˆ é™¤é𐿂£è®°å½•
  const deleteClientVisit = id => {
    showLoadingToast("删除中...");
    safeHiddenDel([id])
      .then(() => {
        closeToast();
        showToast("删除成功");
        getList();
      })
      .catch(() => {
        closeToast();
        showToast("删除失败");
      });
  };
  // æŸ¥çœ‹è¯¦æƒ…
  const viewDetail = item => {
    uni.setStorageSync("dangerInvestigation", item);
    uni.navigateTo({
      url: "/pages/safeProduction/dangerInvestigation/view",
    });
  };
  onMounted(() => {
    getList();
  });
  onShow(() => {
    getList();
  });
</script>
<style scoped lang="scss">
  @import "../../../styles/sales-common.scss";
  // é¡µé¢ç‰¹å®šçš„æ ·å¼è¦†ç›–
  .sales-accoun {
    min-height: 100vh;
    background: #f8f9fa;
    position: relative;
    padding-bottom: 80px;
  }
  // ç‰¹å®šçš„图标样式
  .document-icon {
    background: #667eea; // ä¿æŒé¡µé¢ç‰¹æœ‰çš„背景色
  }
  // ç‰¹æœ‰æ ·å¼
  .visit-status {
    display: flex;
    align-items: center;
  }
  .detail-value {
    word-break: break-all; // ä¿ç•™é¡µé¢ç‰¹æœ‰çš„æ–‡æœ¬æ¢è¡Œæ ·å¼
  }
  // ç‰¹å®šçš„æµ®åŠ¨æŒ‰é’®æ ·å¼
  .fab-button {
    background: #667eea; // ä¿æŒé¡µé¢ç‰¹æœ‰çš„背景色
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3); // ä¿æŒé¡µé¢ç‰¹æœ‰çš„阴影效果
  }
  .action-buttons {
    gap: 4px;
  }
  .action-buttons {
    padding: 0 0 10rpx 0;
  }
  // è¶…期未整改的隐患样式
  .overdue {
    border-left: 8rpx solid #ff4d4f;
    background-color: rgba(255, 77, 79, 0.02);
  }
  .overdue .item-header {
    position: relative;
    padding-left: 20rpx;
  }
  .overdue .item-header::after {
    content: "超期";
    position: absolute;
    top: 32rpx;
    right: 20rpx;
    font-size: 24rpx;
    font-weight: 500;
    color: #ff4d4f;
    background-color: rgba(255, 77, 79, 0.1);
    padding: 4rpx 16rpx;
    border-radius: 16rpx;
    border: 1rpx solid rgba(255, 77, 79, 0.3);
  }
  .overdue .detail-row:nth-child(7) .detail-value {
    color: #ff4d4f;
    font-weight: 500;
  }
  .overdue .detail-row {
    padding-left: 20rpx;
  }
</style>
src/pages/safeProduction/dangerInvestigation/rectify.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,312 @@
<template>
  <view class="danger-investigation-rectify">
    <PageHeader title="隐患整改"
                @back="goBack" />
    <view class="section">
      <view class="section-title">隐患信息</view>
      <view class="info-item">
        <text class="info-label">隐患编号</text>
        <text class="info-value">{{ form.hiddenCode || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">隐患类型</text>
        <text class="info-value">{{ hidden_danger_type.find(i => String(i.value) === String(form.type))?.label || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">风险等级</text>
        <text class="info-value">{{ form.riskLevel || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">隐患描述</text>
        <text class="info-value">{{ form.hiddenDesc || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">隐患具体位置</text>
        <text class="info-value">{{ form.location || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">上报人</text>
        <text class="info-value">{{ form.createUserName || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">上报时间</text>
        <text class="info-value">{{ form.createTime || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">整改完成期限</text>
        <text class="info-value">{{ form.rectifyTime || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">整改责任人</text>
        <text class="info-value">{{ form.rectifyUserName || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">整改责任人联系方式</text>
        <text class="info-value">{{ form.rectifyUserMobile || '-' }}</text>
      </view>
    </view>
    <u-form @submit="handleSubmit"
            ref="formRef"
            label-width="130">
      <!-- æ•´æ”¹ä¿¡æ¯ -->
      <u-cell-group title="整改信息">
        <u-form-item label="实际整改完成时间"
                     prop="rectifyActualTime"
                     required
                     border-bottom>
          <u-input v-model="form.rectifyActualTime"
                   placeholder="请选择实际整改完成时间"
                   @click="showTimePicker" />
          <template #right>
            <up-icon name="arrow-right"
                     @click="showTimePicker"></up-icon>
          </template>
        </u-form-item>
        <u-form-item label="整改具体措施"
                     required
                     border-bottom>
          <u-textarea v-model="form.rectifyMeasures"
                      readonly
                      :autoHeight="true" />
        </u-form-item>
      </u-cell-group>
      <!-- æäº¤æŒ‰é’® -->
      <view class="footer-btns">
        <u-button class="cancel-btn"
                  @click="goBack">取消</u-button>
        <u-button class="sign-btn"
                  type="primary"
                  @click="handleSubmit"
                  :loading="loading">提交整改</u-button>
      </view>
    </u-form>
    <!-- æ—¶é—´é€‰æ‹©å™¨ -->
    <up-datetime-picker :show="showTime"
                        v-model="currentTime"
                        @confirm="onTimeConfirm"
                        @cancel="showTime = false"
                        mode="date" />
  </view>
</template>
<script setup>
  // æ›¿æ¢ toast æ–¹æ³•
  defineOptions({ name: "danger-investigation-rectify" });
  const showToast = message => {
    uni.showToast({
      title: message,
      icon: "none",
    });
  };
  import { ref, onMounted } from "vue";
  import PageHeader from "@/components/PageHeader.vue";
  import { safeHiddenUpdate } from "@/api/safeProduction/dangerInvestigation";
  import useUserStore from "@/store/modules/user";
  import dayjs from "dayjs";
  import { onLoad } from "@dcloudio/uni-app";
  import { useDict } from "@/utils/dict";
  const userStore = useUserStore();
  const { hidden_danger_type } = useDict("hidden_danger_type");
  // è¡¨å•数据
  const form = ref({
    id: "",
    hiddenCode: "",
    hiddenDesc: "",
    location: "",
    rectifyTime: "",
    rectifyUserName: "",
    rectifyUserMobile: "",
    rectifyMeasures: "",
    rectifyActualTime: "",
    rectifyResult: "",
  });
  // é¡µé¢çŠ¶æ€
  const loading = ref(false);
  const formRef = ref(null);
  // æ—¶é—´ç›¸å…³
  const currentTime = ref(Date.now());
  const showTime = ref(false);
  // è¿”回上一页
  const goBack = () => {
    // è¿”回时清除本地存储的数据
    uni.removeStorageSync("dangerInvestigation");
    uni.navigateBack();
  };
  // æ˜¾ç¤ºæ—¶é—´é€‰æ‹©å™¨
  const showTimePicker = () => {
    showTime.value = true;
  };
  // ç¡®è®¤æ—¶é—´é€‰æ‹©
  const onTimeConfirm = e => {
    form.value.rectifyActualTime = dayjs(e.value).format("YYYY-MM-DD");
    currentTime.value = e.value;
    showTime.value = false;
  };
  // æäº¤è¡¨å•
  const handleSubmit = async () => {
    if (!form.value.rectifyActualTime) {
      showToast("请选择实际整改完成时间");
      return;
    }
    if (!form.value.rectifyMeasures) {
      showToast("请输入整改具体措施");
      return;
    }
    try {
      loading.value = true;
      // ä½¿ç”¨å®‰å…¨æµ…拷贝,避免对象展开在某些运行时抛错
      const source =
        form.value && typeof form.value === "object" ? form.value : {};
      const submitData = {};
      Object.keys(source).forEach(k => {
        submitData[k] = source[k];
      });
      console.log("submitData", submitData);
      const { code } = await safeHiddenUpdate(submitData);
      if (code === 200) {
        showToast("整改提交成功");
        setTimeout(() => {
          goBack();
        }, 500);
      } else {
        loading.value = false;
        showToast("整改提交失败,请重试");
      }
    } catch (e) {
      loading.value = false;
      console.error("提交失败:", e);
      showToast("提交失败,请重试");
    }
  };
  onLoad(() => {
    // ä»Žæœ¬åœ°å­˜å‚¨èŽ·å–éšæ‚£æ•°æ®
    const dangerInvestigation = uni.getStorageSync("dangerInvestigation");
    if (dangerInvestigation && dangerInvestigation.id) {
      form.value = dangerInvestigation;
      console.log("form.value", form.value);
    } else {
      showToast("暂无隐患数据");
    }
  });
  // åˆå§‹åŒ–页面数据
  const initPageData = () => {
    // è®¾ç½®é»˜è®¤å®žé™…整改完成时间为当前时间
    if (!form.value.rectifyActualTime) {
      form.value.rectifyActualTime = dayjs().format("YYYY-MM-DD");
      currentTime.value = Date.now();
    }
  };
  onMounted(() => {
    initPageData();
  });
</script>
<style scoped lang="scss">
  @import "@/static/scss/form-common.scss";
  .danger-investigation-rectify {
    min-height: 100vh;
    background-color: #f8f9fa;
    padding-bottom: 160rpx;
  }
  .footer-btns {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0.75rem 0;
    box-shadow: 0 -0.125rem 0.5rem rgba(0, 0, 0, 0.05);
    z-index: 1000;
  }
  .cancel-btn {
    font-weight: 400;
    font-size: 1rem;
    color: #666;
    background: #f5f5f5;
    border: 1px solid #ddd;
    width: 45%;
    height: 2.5rem;
    border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
  }
  .sign-btn {
    font-weight: 500;
    font-size: 1rem;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    width: 45%;
    height: 2.5rem;
    border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
  }
  .section {
    background-color: #ffffff;
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  }
  .section-title {
    font-size: 16px;
    font-weight: 600;
    color: #333333;
    padding: 16px 16px 12px;
    border-bottom: 1px solid #f0f0f0;
  }
  .info-item {
    display: flex;
    padding: 14px 16px;
    border-bottom: 1px solid #f8f8f8;
    align-items: flex-start;
  }
  .info-item:last-child {
    border-bottom: none;
  }
  .info-label {
    font-size: 14px;
    color: #666666;
    min-width: 80px;
    flex-shrink: 0;
    line-height: 22px;
  }
  .info-value {
    font-size: 14px;
    color: #333333;
    flex: 1;
    line-height: 22px;
    text-align: right;
  }
  .multi-line {
    text-align: left;
    word-break: break-all;
    line-height: 1.6;
  }
  .remark-item {
    padding-bottom: 16px;
  }
</style>
src/pages/safeProduction/dangerInvestigation/view.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,203 @@
<template>
  <view class="danger-investigation-view">
    <PageHeader title="隐患详情"
                @back="goBack" />
    <!-- å†…容容器 -->
    <view class="content-container">
      <!-- é𐿂£ä¿¡æ¯ -->
      <view class="section">
        <view class="section-title">隐患信息</view>
        <view class="info-item">
          <text class="info-label">隐患编号</text>
          <text class="info-value">{{ form.hiddenCode || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">隐患类型</text>
          <text class="info-value">{{ hidden_danger_type.find(i => String(i.value) === String(form.type))?.label || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">风险等级</text>
          <text class="info-value">{{ form.riskLevel || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">隐患描述</text>
          <text class="info-value">{{ form.hiddenDesc || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">隐患具体位置</text>
          <text class="info-value">{{ form.location || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">上报人</text>
          <text class="info-value">{{ form.createUserName || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">上报时间</text>
          <text class="info-value">{{ form.createTime || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">整改完成期限</text>
          <text class="info-value">{{ form.rectifyTime || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">整改责任人</text>
          <text class="info-value">{{ form.rectifyUserName || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">整改责任人联系方式</text>
          <text class="info-value">{{ form.rectifyUserMobile || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">整改具体措施</text>
          <text class="info-value">{{ form.rectifyMeasures || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">实际整改完成时间</text>
          <text class="info-value">{{ form.rectifyActualTime || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">验收时间</text>
          <text class="info-value">{{ form.verifyTime || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">验收人</text>
          <text class="info-value">{{ form.verifyUserName || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">验收结果</text>
          <text class="info-value">{{ form.verifyResult || '-' }}</text>
        </view>
        <view class="info-item">
          <text class="info-label">验收意见</text>
          <text class="info-value">{{ form.verifyRemark || '-' }}</text>
        </view>
      </view>
    </view>
  </view>
</template>
<script setup>
  // æ›¿æ¢ toast æ–¹æ³•
  const showToast = message => {
    uni.showToast({
      title: message,
      icon: "none",
    });
  };
  import { ref, onMounted } from "vue";
  import PageHeader from "@/components/PageHeader.vue";
  import useUserStore from "@/store/modules/user";
  import { onLoad } from "@dcloudio/uni-app";
  import { useDict } from "@/utils/dict";
  const { hidden_danger_type } = useDict("hidden_danger_type");
  const userStore = useUserStore();
  // è¡¨å•数据
  const form = ref({
    hiddenCode: "",
    hiddenType: "",
    riskLevel: "",
    hiddenDesc: "",
    location: "",
    createUserName: "",
    createTime: "",
    rectifyTime: "",
    rectifyUserName: "",
    rectifyUserMobile: "",
    rectifyMeasures: "",
    rectifyActualTime: "",
    rectifyResult: "",
    acceptanceTime: "",
    acceptanceOpinion: "",
    verifyResult: "",
  });
  // è¿”回上一页
  const goBack = () => {
    // è¿”回时清除本地存储的数据
    uni.removeStorageSync("dangerInvestigation");
    uni.navigateBack();
  };
  // åˆå§‹åŒ–页面数据
  const initPageData = () => {
    // ä»Žæœ¬åœ°å­˜å‚¨èŽ·å–éšæ‚£è¯¦æƒ…
    const row = uni.getStorageSync("dangerInvestigation");
    if (row) {
      form.value = { ...row };
    } else {
      showToast("暂无隐患数据");
    }
  };
  onMounted(() => {
    initPageData();
  });
</script>
<style scoped lang="scss">
  @import "@/static/scss/form-common.scss";
  .danger-investigation-view {
    min-height: 100vh;
    background-color: #f8f9fa;
  }
  .content-container {
    padding: 16px;
  }
  .section {
    background-color: #ffffff;
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  }
  .section-title {
    font-size: 16px;
    font-weight: 600;
    color: #333333;
    padding: 16px 16px 12px;
    border-bottom: 1px solid #f0f0f0;
  }
  .info-item {
    display: flex;
    padding: 14px 16px;
    border-bottom: 1px solid #f8f8f8;
    align-items: flex-start;
  }
  .info-item:last-child {
    border-bottom: none;
  }
  .info-label {
    font-size: 14px;
    color: #666666;
    min-width: 80px;
    flex-shrink: 0;
    line-height: 22px;
  }
  .info-value {
    font-size: 14px;
    color: #333333;
    flex: 1;
    line-height: 22px;
    text-align: right;
  }
  .multi-line {
    text-align: left;
    word-break: break-all;
    line-height: 1.6;
  }
  .remark-item {
    padding-bottom: 16px;
  }
</style>
src/pages/safeProduction/hazardSourceLedger/detail.vue
@@ -117,16 +117,19 @@
    <up-action-sheet :show="typeSheetVisible"
                     :actions="typeOptions"
                     @select="handleTypeSelect"
                     @close="typeSheetVisible = false"
                     title="选择危险源类型" />
    <!-- é£Žé™©ç­‰çº§é€‰æ‹©å™¨ -->
    <up-action-sheet :show="riskLevelSheetVisible"
                     :actions="riskLevelOptions"
                     @select="handleRiskLevelSelect"
                     @close="riskLevelSheetVisible = false"
                     title="选择风险等级" />
    <!-- ç®¡æŽ§è´£ä»»äººé€‰æ‹©å™¨ -->
    <up-action-sheet :show="principalSheetVisible"
                     :actions="principalOptions"
                     @select="handlePrincipalSelect"
                     @close="principalSheetVisible = false"
                     title="选择管控责任人" />
  </view>
</template>
src/pages/safeProduction/hazardSourceLedger/index.vue
@@ -26,7 +26,8 @@
          v-if="visitList.length > 0">
      <view v-for="(item, index) in visitList"
            :key="index">
        <view class="ledger-item">
        <view class="ledger-item"
              :class="{ 'high-risk': item.riskLevel === '重大风险' }">
          <view class="item-header">
            <view class="item-left">
              <view class="document-icon">
@@ -287,5 +288,43 @@
    background: #667eea; // ä¿æŒé¡µé¢ç‰¹æœ‰çš„背景色
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3); // ä¿æŒé¡µé¢ç‰¹æœ‰çš„阴影效果
  }
  // é‡å¤§é£Žé™©ç‚¹çš„醒目警示标识
  .high-risk {
    border-left: 8rpx solid #ff4d4f;
    box-shadow: 0 2rpx 12rpx rgba(255, 77, 79, 0.2);
    position: relative;
    background-color: rgba(255, 77, 79, 0.02);
  }
  .high-risk .item-header {
    position: relative;
    padding-left: 20rpx;
  }
  .high-risk .item-header::after {
    // content: "重大风险";
    position: absolute;
    top: 16rpx;
    right: 20rpx;
    font-size: 24rpx;
    font-weight: 500;
    color: #ff4d4f;
    background-color: rgba(255, 77, 79, 0.1);
    padding: 4rpx 16rpx;
    border-radius: 16rpx;
    border: 1rpx solid rgba(255, 77, 79, 0.3);
  }
  .high-risk .detail-row:nth-child(3) .u-tag {
    font-size: 26rpx;
    padding: 6rpx 16rpx;
    border-radius: 16rpx;
    font-weight: 500;
  }
  .high-risk .detail-row {
    padding-left: 20rpx;
  }
</style>
src/pages/safeProduction/hazardousMaterialsControl/detail.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,443 @@
<template>
  <view class="hazard-source-detail">
    <PageHeader :title="isEdit ? '归还' : '领用危险源'"
                @back="goBack" />
    <u-form @submit="handleSubmit"
            ref="formRef"
            label-width="110">
      <!-- å±é™©æºä¿¡æ¯ -->
      <u-cell-group v-if="!isEdit"
                    title="危险源信息">
        <u-form-item v-if="!isEdit"
                     label="危险源名称"
                     prop="name"
                     required
                     border-bottom>
          <u-input v-model="form.name"
                   placeholder="请选择危险源"
                   @click="showHazardSourceSheet"
                   readonly />
          <template #right>
            <up-icon name="arrow-right"
                     @click="showHazardSourceSheet"></up-icon>
          </template>
        </u-form-item>
        <u-form-item label="危险源编码"
                     prop="code"
                     border-bottom>
          <u-input v-model="form.code"
                   disabled
                   placeholder="自动带出"
                   readonly />
        </u-form-item>
        <u-form-item v-if="!isEdit"
                     label="危险源类型"
                     prop="type"
                     border-bottom>
          <u-input v-model="form.type"
                   disabled
                   placeholder="自动带出"
                   readonly />
        </u-form-item>
        <u-form-item v-if="!isEdit"
                     label="风险等级"
                     prop="riskLevel"
                     border-bottom>
          <u-input v-model="form.riskLevel"
                   disabled
                   placeholder="自动带出"
                   readonly />
        </u-form-item>
        <u-form-item v-if="!isEdit"
                     label="所在位置"
                     prop="location"
                     border-bottom>
          <u-input v-model="form.location"
                   disabled
                   placeholder="自动带出"
                   readonly />
        </u-form-item>
        <u-form-item v-if="!isEdit"
                     label="领用时间"
                     prop="applyTime"
                     border-bottom>
          <u-input v-model="form.applyTime"
                   disabled />
        </u-form-item>
        <u-form-item v-if="!isEdit"
                     label="领用人"
                     prop="applyUserName"
                     border-bottom>
          <u-input v-model="form.applyUserName"
                   disabled />
        </u-form-item>
        <u-form-item v-if="!isEdit"
                     label="领用用途"
                     prop="applyPurpose"
                     required
                     border-bottom>
          <u-input v-model="form.applyPurpose"
                   placeholder="请输入领用用途" />
        </u-form-item>
        <u-form-item v-if="!isEdit"
                     label="领用数量"
                     prop="applyQty"
                     required
                     border-bottom>
          <u-input v-model="form.applyQty"
                   type="number"
                   @blur="validateApplyQty"
                   min="1"
                   placeholder="请输入领用数量" />
        </u-form-item>
      </u-cell-group>
      <u-cell-group v-if="isEdit"
                    title="归还信息">
        <u-form-item label="归还人"
                     prop="returnUserName"
                     border-bottom>
          <u-input v-model="form.returnUserName"
                   disabled />
        </u-form-item>
        <u-form-item label="归还时间"
                     prop="returnTime"
                     border-bottom>
          <u-input v-model="form.returnTime"
                   disabled />
        </u-form-item>
        <u-form-item label="归还情况说明"
                     prop="returnRemark"
                     required
                     border-bottom>
          <u-textarea v-model="form.returnRemark"
                      placeholder="请输入归还情况说明"
                      :rows="4"
                      :autoHeight="true" />
        </u-form-item>
      </u-cell-group>
      <!-- æäº¤æŒ‰é’® -->
      <view class="footer-btns">
        <u-button class="cancel-btn"
                  @click="goBack">取消</u-button>
        <u-button class="sign-btn"
                  type="primary"
                  @click="handleSubmit"
                  :loading="loading">{{ isEdit ? '归还' : '领用' }}</u-button>
      </view>
    </u-form>
    <!-- å±é™©æºé€‰æ‹©å™¨ -->
    <up-action-sheet :show="hazardSourceSheetVisible"
                     :actions="hazardSourceOptions"
                     @select="handleHazardSourceSelect"
                     @close="hazardSourceSheetVisible = false"
                     title="选择危险源" />
    <!-- æ—¶é—´é€‰æ‹©å™¨ -->
    <up-datetime-picker :show="applyTimeVisible"
                        v-model="applyTime"
                        @confirm="onApplyTimeConfirm"
                        @cancel="applyTimeVisible = false"
                        mode="datetime" />
    <up-datetime-picker :show="returnTimeVisible"
                        v-model="returnTime"
                        @confirm="onReturnTimeConfirm"
                        @cancel="returnTimeVisible = false"
                        mode="date" />
  </view>
</template>
<script setup>
  // æ›¿æ¢ toast æ–¹æ³•
  defineOptions({ name: "hazard-source-detail" });
  const showToast = message => {
    uni.showToast({
      title: message,
      icon: "none",
    });
  };
  import { ref, onMounted } from "vue";
  import PageHeader from "@/components/PageHeader.vue";
  import {
    safeHazardRecordAdd,
    safeHazardRecordUpdate,
  } from "@/api/safeProduction/hazardousMaterialsControl";
  import { safeHazardListPage } from "@/api/safeProduction/hazardSourceLedger";
  import useUserStore from "@/store/modules/user";
  import dayjs from "dayjs";
  import { onLoad } from "@dcloudio/uni-app";
  const userStore = useUserStore();
  // è¡¨å•数据
  const form = ref({
    name: "",
    code: "",
    type: "",
    riskLevel: "",
    location: "",
    applyPurpose: "",
    applyTime: "",
    applyQty: "",
    returnTime: "",
    returnRemark: "",
    safeHazardId: "",
  });
  // é¡µé¢çŠ¶æ€
  const loading = ref(false);
  const formRef = ref(null);
  const isEdit = ref(false);
  // å±é™©æºé€‰æ‹©å™¨
  const hazardSourceSheetVisible = ref(false);
  const hazardSourceOptions = ref([]);
  const hazardSourceList = ref([]);
  const showHazardSourceSheet = () => {
    if (hazardSourceOptions.value.length === 0) {
      getHazardSourceList();
    } else {
      hazardSourceSheetVisible.value = true;
    }
  };
  const stockQty = ref(0);
  const handleHazardSourceSelect = item => {
    const hazardSource = hazardSourceList.value.find(h => h.id === item.value);
    if (hazardSource) {
      form.value.name = hazardSource.name;
      form.value.code = hazardSource.code;
      form.value.type = hazardSource.type;
      form.value.riskLevel = hazardSource.riskLevel;
      form.value.location = hazardSource.location;
      form.value.safeHazardId = hazardSource.id;
      stockQty.value = hazardSource.stockQty || 0;
    }
    hazardSourceSheetVisible.value = false;
  };
  const validateApplyQty = () => {
    if (!form.value.applyQty) {
      showToast("请输入领用数量");
      return false;
    }
    if (isNaN(form.value.applyQty)) {
      showToast("领用数量必须是数字");
      form.value.applyQty = 0;
      return false;
    }
    if (form.value.applyQty < 0) {
      showToast("领用数量必须大于等于1");
      form.value.applyQty = 0;
      return false;
    }
    if (form.value.applyQty > stockQty.value) {
      showToast("领用数量不能大于库存数量");
      form.value.applyQty = 0;
      return false;
    }
    return true;
  };
  // èŽ·å–å±é™©æºåˆ—è¡¨
  const getHazardSourceList = () => {
    const params = {
      current: -1,
      size: -1,
    };
    safeHazardListPage(params).then(res => {
      if (res.code === 200) {
        hazardSourceList.value = res.records || res.data?.records || [];
        // è¿‡æ»¤æŽ‰åº“存数量小于等于0的选项
        const validHazardSources = hazardSourceList.value.filter(
          item => item.stockQty > 0
        );
        hazardSourceOptions.value = validHazardSources.map(item => ({
          value: item.id,
          name: item.name,
          subname: `库存: ${item.stockQty}`,
        }));
        hazardSourceSheetVisible.value = true;
      }
    });
  };
  // æ—¶é—´é€‰æ‹©å™¨
  const applyTimeVisible = ref(false);
  const applyTime = ref(Date.now());
  const showApplyTimePicker = () => {
    applyTimeVisible.value = true;
  };
  const onApplyTimeConfirm = e => {
    form.value.applyTime = dayjs(e.value).format("YYYY-MM-DD HH:mm:ss");
    applyTime.value = e.value;
    applyTimeVisible.value = false;
  };
  const returnTimeVisible = ref(false);
  const returnTime = ref(Date.now());
  const showReturnTimePicker = () => {
    returnTimeVisible.value = true;
  };
  const onReturnTimeConfirm = e => {
    form.value.returnTime = dayjs(e.value).format("YYYY-MM-DD");
    returnTime.value = e.value;
    returnTimeVisible.value = false;
  };
  // è¿”回上一页
  const goBack = () => {
    // è¿”回时清除本地存储的数据
    uni.removeStorageSync("hazardousMaterialsControl");
    uni.navigateBack();
  };
  // æäº¤è¡¨å•
  const handleSubmit = async () => {
    if (!form.value.safeHazardId) {
      showToast("请选择危险源");
      return;
    }
    if (!form.value.applyPurpose) {
      showToast("请输入领用用途");
      return;
    }
    if (!form.value.applyQty) {
      showToast("请输入领用数量");
      return;
    }
    if (isEdit.value) {
      if (!form.value.returnTime) {
        showToast("请选择归还时间");
        return;
      }
      if (!form.value.returnRemark) {
        showToast("请输入归还情况说明");
        return;
      }
    }
    try {
      loading.value = true;
      // ä½¿ç”¨å®‰å…¨æµ…拷贝,避免对象展开在某些运行时抛错
      const source =
        form.value && typeof form.value === "object" ? form.value : {};
      const submitData = {};
      Object.keys(source).forEach(k => {
        submitData[k] = source[k];
      });
      console.log("submitData", submitData);
      if (isEdit.value) {
        const { code } = await safeHazardRecordUpdate(submitData);
        if (code === 200) {
          showToast("归还成功");
          setTimeout(() => {
            goBack();
          }, 500);
        } else {
          loading.value = false;
          showToast("归还失败,请重试");
        }
      } else {
        const { code } = await safeHazardRecordAdd(submitData);
        if (code === 200) {
          showToast("领用成功");
          setTimeout(() => {
            goBack();
          }, 500);
        } else {
          loading.value = false;
          showToast("领用失败,请重试");
        }
      }
    } catch (e) {
      loading.value = false;
      console.error("提交失败:", e);
      showToast("提交失败,请重试");
    }
  };
  onLoad(() => {
    // ç¼–辑危险源时,从本地存储获取数据
    const hazardousMaterials = uni.getStorageSync("hazardousMaterialsControl");
    console.log("hazardousMaterials", hazardousMaterials);
    if (hazardousMaterials.id) {
      form.value = hazardousMaterials;
      isEdit.value = true;
      userStore.getInfo().then(res => {
        form.value.returnUserId = res.user.userId;
        form.value.returnUserName = res.user.nickName;
      });
      console.log("form.value", form.value);
    } else {
      userStore.getInfo().then(res => {
        form.value.applyUserId = res.user.userId;
        form.value.applyUserName = res.user.nickName;
      });
      isEdit.value = false;
    }
  });
  onMounted(() => {
    // è®¾ç½®é»˜è®¤æ—¶é—´
    if (!isEdit.value) {
      form.value.applyTime = dayjs().format("YYYY-MM-DD");
      applyTime.value = Date.now();
    } else {
      form.value.returnTime = dayjs().format("YYYY-MM-DD");
      returnTime.value = Date.now();
    }
  });
</script>
<style scoped lang="scss">
  @import "@/static/scss/form-common.scss";
  .client-visit {
    min-height: 100vh;
    background: #f8f9fa;
    padding-bottom: 5rem;
  }
  .footer-btns {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0.75rem 0;
    box-shadow: 0 -0.125rem 0.5rem rgba(0, 0, 0, 0.05);
    z-index: 1000;
  }
  .cancel-btn {
    font-weight: 400;
    font-size: 1rem;
    color: #666;
    background: #f5f5f5;
    border: 1px solid #ddd;
    width: 45%;
    height: 2.5rem;
    border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
  }
  .sign-btn {
    font-weight: 500;
    font-size: 1rem;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    width: 45%;
    height: 2.5rem;
    border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
  }
  .location-icon {
    color: #1989fa;
    font-size: 1.2rem;
  }
</style>
src/pages/safeProduction/hazardousMaterialsControl/index.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,295 @@
<template>
  <view class="sales-accoun">
    <!-- ä½¿ç”¨é€šç”¨é¡µé¢å¤´éƒ¨ç»„ä»¶ -->
    <PageHeader title="危险物料管控"
                @back="goBack" />
    <!-- æœç´¢å’Œç­›é€‰åŒºåŸŸ -->
    <view class="search-section">
      <view class="search-bar">
        <view class="search-input">
          <up-input class="search-text"
                    placeholder="请输入危险源名称"
                    v-model="customerName"
                    @blur="getList"
                    clearable />
        </view>
        <view class="filter-button"
              @click="getList">
          <u-icon name="search"
                  size="24"
                  color="#999"></u-icon>
        </view>
      </view>
    </view>
    <!-- æ‹œè®¿è®°å½•列表 -->
    <view class="ledger-list"
          v-if="visitList.length > 0">
      <view v-for="(item, index) in visitList"
            :key="index">
        <view class="ledger-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.materialRecordCode }}</text>
            </view>
          </view>
          <up-divider></up-divider>
          <view class="item-details">
            <view class="detail-row">
              <text class="detail-label">危险源名称</text>
              <text class="detail-value">{{ item.name || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">危险源编码</text>
              <text class="detail-value">{{ item.code || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">危险源类型</text>
              <text class="detail-value">{{ hazard_source_type.find(i => i.value === item.type)?.label || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">风险等级</text>
              <u-tag :type="getRiskLevelType(item.riskLevel)">
                {{ item.riskLevel || '-' }}
              </u-tag>
            </view>
            <view class="detail-row">
              <text class="detail-label">所在位置</text>
              <text class="detail-value">{{ item.location || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">领用用途</text>
              <text class="detail-value">{{ item.applyPurpose || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">领用时间</text>
              <text class="detail-value">{{ item.applyTime || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">领用数量</text>
              <text class="detail-value">{{ item.applyQty || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">归还时间</text>
              <text class="detail-value">{{ item.returnTime || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">归还人</text>
              <text class="detail-value">{{ item.returnUserName || '-' }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">归还情况说明</text>
              <text class="detail-value">{{ item.returnRemark || '-' }}</text>
            </view>
          </view>
          <!-- æŒ‰é’®åŒºåŸŸ -->
          <view class="action-buttons">
            <!-- <u-button type="info"
                      size="small"
                      class="action-btn"
                      @click="viewDetail(item)">
              æŸ¥çœ‹è¯¦æƒ…
            </u-button> -->
            <u-button type="primary"
                      size="small"
                      class="action-btn"
                      :disabled="item.returnUserId"
                      @click="editVisit(item)">
              å½’还
            </u-button>
            <u-button type="error"
                      size="small"
                      class="action-btn"
                      @click="deleteVisit(item)">
              åˆ é™¤
            </u-button>
          </view>
        </view>
      </view>
    </view>
    <view v-else
          class="no-data">
      <text>暂无拜访记录</text>
    </view>
    <!-- æµ®åŠ¨æ–°å¢žæŒ‰é’® -->
    <view class="fab-button"
          @click="addVisit">
      <up-icon name="plus"
               size="24"
               color="#ffffff"></up-icon>
    </view>
  </view>
</template>
<script setup>
  import { ref, onMounted } from "vue";
  import { onShow } from "@dcloudio/uni-app";
  import PageHeader from "@/components/PageHeader.vue";
  import {
    safeHazardRecordListPage,
    safeHazardRecordDel,
  } from "@/api/safeProduction/hazardousMaterialsControl";
  import useUserStore from "@/store/modules/user";
  import { useDict } from "@/utils/dict";
  // æ›¿æ¢ toast æ–¹æ³•
  defineOptions({ name: "client-visit-index" });
  const showToast = message => {
    uni.showToast({
      title: message,
      icon: "none",
    });
  };
  const getRiskLevelType = riskLevel => {
    const typeMap = {
      ä½Žé£Žé™©: "info",
      ä¸€èˆ¬é£Žé™©: "info",
      è¾ƒå¤§é£Žé™©: "warning",
      é‡å¤§é£Žé™©: "error",
    };
    return typeMap[riskLevel] || "info";
  };
  import dayjs from "dayjs";
  const userStore = useUserStore();
  // æœç´¢å…³é”®è¯
  const customerName = ref("");
  // æ‹œè®¿è®°å½•数据
  const visitList = ref([]);
  // è¿”回上一页
  const goBack = () => {
    uni.navigateBack();
  };
  // æŸ¥è¯¢åˆ—表
  const getList = () => {
    showLoadingToast("加载中...");
    const params = {
      current: -1,
      size: -1,
      name: customerName.value,
    };
    safeHazardRecordListPage(params)
      .then(res => {
        visitList.value = res.records || res.data?.records || [];
        closeToast();
      })
      .catch(() => {
        closeToast();
        showToast("获取数据失败");
      });
  };
  // æ˜¾ç¤ºåŠ è½½æç¤º
  const showLoadingToast = message => {
    uni.showLoading({
      title: message,
      mask: true,
    });
  };
  // å…³é—­æç¤º
  const closeToast = () => {
    uni.hideLoading();
  };
  // æ–°å¢žå±é™©æº
  const addVisit = () => {
    uni.setStorageSync("hazardousMaterialsControl", {});
    uni.navigateTo({
      url: "/pages/safeProduction/hazardousMaterialsControl/detail",
    });
  };
  // ç¼–辑危险源
  const editVisit = item => {
    uni.setStorageSync("hazardousMaterialsControl", item);
    uni.navigateTo({
      url: "/pages/safeProduction/hazardousMaterialsControl/detail",
    });
  };
  // åˆ é™¤å±é™©æº
  const deleteVisit = item => {
    uni.showModal({
      title: "删除确认",
      content: `确定要删除该记录吗?`,
      success: res => {
        if (res.confirm) {
          deleteClientVisit(item.id);
        }
      },
    });
  };
  const { hazard_source_type } = useDict("hazard_source_type");
  const { risk_level } = useDict("risk_level");
  // åˆ é™¤å±é™©æºè®°å½•
  const deleteClientVisit = id => {
    showLoadingToast("删除中...");
    safeHazardRecordDel([id])
      .then(() => {
        closeToast();
        showToast("删除成功");
        getList();
      })
      .catch(() => {
        closeToast();
        showToast("删除失败");
      });
  };
  // æŸ¥çœ‹è¯¦æƒ…
  const viewDetail = item => {
    uni.setStorageSync("hazardSourceLedger", item);
    uni.navigateTo({
      url: "/pages/safeProduction/hazardSourceLedger/view",
    });
  };
  onMounted(() => {
    getList();
  });
  onShow(() => {
    getList();
  });
</script>
<style scoped lang="scss">
  @import "../../../styles/sales-common.scss";
  // é¡µé¢ç‰¹å®šçš„æ ·å¼è¦†ç›–
  .sales-accoun {
    min-height: 100vh;
    background: #f8f9fa;
    position: relative;
    padding-bottom: 80px;
  }
  // ç‰¹å®šçš„图标样式
  .document-icon {
    background: #667eea; // ä¿æŒé¡µé¢ç‰¹æœ‰çš„背景色
  }
  // ç‰¹æœ‰æ ·å¼
  .visit-status {
    display: flex;
    align-items: center;
  }
  .detail-value {
    word-break: break-all; // ä¿ç•™é¡µé¢ç‰¹æœ‰çš„æ–‡æœ¬æ¢è¡Œæ ·å¼
  }
  // ç‰¹å®šçš„æµ®åŠ¨æŒ‰é’®æ ·å¼
  .fab-button {
    background: #667eea; // ä¿æŒé¡µé¢ç‰¹æœ‰çš„背景色
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3); // ä¿æŒé¡µé¢ç‰¹æœ‰çš„阴影效果
  }
</style>
src/pages/safeProduction/safeQualifications/detail.vue
@@ -83,6 +83,7 @@
    <up-action-sheet :show="typeSheetVisible"
                     :actions="typeOptions"
                     @select="handleTypeSelect"
                     @close="typeSheetVisible = false"
                     title="选择规程资质类型" />
  </view>
</template>
src/pages/safeProduction/safeQualifications/index.vue
@@ -26,7 +26,8 @@
          v-if="visitList.length > 0">
      <view v-for="(item, index) in visitList"
            :key="index">
        <view class="ledger-item">
        <view class="ledger-item"
              :class="{ 'expiring-soon': isExpiringSoon(item.effectiveTime) }">
          <view class="item-header">
            <view class="item-left">
              <view class="document-icon">
@@ -127,6 +128,17 @@
  import dayjs from "dayjs";
  const userStore = useUserStore();
  // æ£€æŸ¥èµ„质是否即将到期(到期前15天)
  const isExpiringSoon = effectiveTime => {
    if (!effectiveTime) return false;
    const today = dayjs();
    const expireDate = dayjs(effectiveTime);
    const daysDiff = expireDate.diff(today, "day");
    return daysDiff >= 0 && daysDiff <= 15;
  };
  // æœç´¢å…³é”®è¯
  const customerName = ref("");
@@ -259,5 +271,20 @@
    background: #667eea; // ä¿æŒé¡µé¢ç‰¹æœ‰çš„背景色
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3); // ä¿æŒé¡µé¢ç‰¹æœ‰çš„阴影效果
  }
  // å³å°†åˆ°æœŸçš„资质卡片样式
  .expiring-soon {
    border: 2rpx solid #ff4d4f;
    box-shadow: 0 2rpx 16rpx rgba(255, 77, 79, 0.2);
  }
  .expiring-soon .item-header {
    background-color: rgba(255, 77, 79, 0.05);
  }
  .expiring-soon .detail-row:last-child .detail-value {
    color: #ff4d4f;
    font-weight: 500;
  }
</style>