zhangwencui
12 小时以前 34af9a2cd41fb88985d05d57e9fa425bc98990cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<template>
  <view class="account-detail">
    <PageHeader title="整改" @back="goBack" />
    <up-form :model="form" label-width="110">
      <up-form-item label="整改说明" required>
        <up-textarea v-model="form.rectifyDesc" placeholder="请输入" auto-height />
      </up-form-item>
    </up-form>
 
    <FooterButtons :loading="loading" confirmText="保存" @cancel="goBack" @confirm="handleSubmit" />
  </view>
</template>
 
<script setup>
  import { ref } from "vue";
  import { onLoad } from "@dcloudio/uni-app";
  import PageHeader from "@/components/PageHeader.vue";
  import FooterButtons from "@/components/FooterButtons.vue";
  import { updateInspectionHazard } from "@/api/safeProduction/lineInspection";
 
  const loading = ref(false);
  const hazardId = ref(null);
 
  const form = ref({
    rectifyDesc: "",
  });
 
  const goBack = () => {
    uni.navigateBack();
  };
 
  const handleSubmit = () => {
    const rectifyDesc = String(form.value.rectifyDesc || "").trim();
    if (!rectifyDesc) {
      uni.showToast({ title: "请输入整改说明", icon: "none" });
      return;
    }
    if (!hazardId.value) return;
 
    loading.value = true;
    updateInspectionHazard({ id: hazardId.value, status: "已整改", rectifyDesc })
      .then(() => {
        uni.showToast({ title: "整改成功", icon: "success" });
        uni.$emit("lineInspection:hazardsRefresh");
        goBack();
      })
      .catch(() => {
        uni.showToast({ title: "整改失败", icon: "none" });
      })
      .finally(() => {
        loading.value = false;
      });
  };
 
  onLoad(options => {
    if (options?.data) {
      try {
        const obj = JSON.parse(decodeURIComponent(options.data));
        hazardId.value = obj?.row?.id;
      } catch (e) {}
    }
  });
</script>
 
<style scoped lang="scss">
  @import "@/static/scss/form-common.scss";
</style>