zhangwencui
9 小时以前 eea8cb3bbe6379755410dffb774bd14e389612c2
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
<template>
  <view class="emergency-plan-view">
    <!-- 使用通用页面头部组件 -->
    <PageHeader title="应急预案详情"
                @back="goBack" />
    <!-- 详情内容 -->
    <view class="detail-content"
          v-if="currentPlan">
      <!-- 基本信息 -->
      <view class="info-section">
        <!-- <view class="section-title">
          <text class="title-text">{{ currentPlan.planName }}</text>
        </view> -->
        <view class="info-grid">
          <view class="info-item">
            <text class="info-label">应急预案编码</text>
            <text class="info-value">{{ currentPlan.planCode || '-' }}</text>
          </view>
          <view class="info-item">
            <text class="info-label">应急预案名称</text>
            <text class="info-value">{{ currentPlan.planName || '-' }}</text>
          </view>
          <view class="info-item">
            <text class="info-label">预案类型</text>
            <u-tag :type="getPlanTypeTagType(currentPlan.planType)">
              {{ emergencyPlanTypeLabel(currentPlan.planType) }}
            </u-tag>
          </view>
          <view class="info-item">
            <text class="info-label">发布生效时间</text>
            <text class="info-value">{{ currentPlan.publishTime || '-' }}</text>
          </view>
          <view class="info-item">
            <text class="info-label">核心责任人</text>
            <text class="info-value">{{ currentPlan.coreResponsorUserName || '-' }}</text>
          </view>
          <view class="info-item">
            <text class="info-label">备注</text>
            <text class="info-value">{{ currentPlan.remark || '-' }}</text>
          </view>
        </view>
      </view>
      <!-- 适用范围 -->
      <view class="scope-section">
        <view class="section-header">
          <text class="section-heading">适用范围</text>
        </view>
        <view class="scope-tags">
          <u-tag v-for="(scope, index) in applyScopeList"
                 :key="index"
                 type="primary"
                 size="small"
                 class="scope-tag">
            {{ scope }}
          </u-tag>
        </view>
      </view>
      <!-- 应急处置步骤 -->
      <view class="steps-section">
        <view class="section-header">
          <text class="section-heading">应急处置步骤</text>
        </view>
        <view class="steps-list"
              v-if="execStepsList.length > 0">
          <view v-for="(step, index) in execStepsList"
                :key="index"
                class="step-item">
            <view class="step-number">{{ index + 1 }}</view>
            <view class="step-content">
              <text class="step-title">{{ step.step }}</text>
              <text class="step-description">{{ step.description }}</text>
            </view>
          </view>
        </view>
        <view class="no-steps"
              v-else>
          <text>暂无应急处置步骤</text>
        </view>
      </view>
    </view>
    <!-- 空状态 -->
    <view class="empty-state"
          v-else>
      <text>暂无应急预案信息</text>
    </view>
  </view>
</template>
 
<script setup>
  import { ref, onMounted, computed } from "vue";
  import { onShow } from "@dcloudio/uni-app";
  import PageHeader from "@/components/PageHeader.vue";
  import { useDict } from "@/utils/dict";
 
  // 替换 toast 方法
  defineOptions({ name: "emergency-plan-view" });
  const showToast = message => {
    uni.showToast({
      title: message,
      icon: "none",
    });
  };
 
  // 当前应急预案
  const currentPlan = ref(null);
 
  // 应急处置步骤列表
  const execStepsList = ref([]);
 
  // 适用范围列表
  const applyScopeList = ref([]);
 
  // 应急预案类型选项
  const { emergency_plan_type } = useDict("emergency_plan_type");
  const emergencyPlanTypeOptions = computed(
    () => emergency_plan_type?.value || []
  );
 
  // 获取预案类型标签类型
  const getPlanTypeTagType = planType => {
    const typeMap = {
      emergency: "warning",
      fire: "danger",
      natural: "info",
      accident: "error",
    };
    return typeMap[planType] || "info";
  };
 
  // 获取预案类型标签文本
  const emergencyPlanTypeLabel = val => {
    const item = emergencyPlanTypeOptions.value.find(
      i => String(i.value) === String(val)
    );
    return item ? item.label : val;
  };
 
  // 初始化数据
  const initData = () => {
    const emergencyPlan = uni.getStorageSync("emergencyPlan") || {};
    if (emergencyPlan.id) {
      currentPlan.value = emergencyPlan;
 
      // 处理适用范围
      if (emergencyPlan.applyScope) {
        const scopes = emergencyPlan.applyScope.split(",");
        applyScopeList.value = scopes.map(scope => {
          const scopeMap = {
            all: "全体员工",
            manager: "管理层",
            hr: "人事部门",
            finance: "财务部门",
            tech: "技术部门",
          };
          return scopeMap[scope] || scope;
        });
      } else {
        applyScopeList.value = [];
      }
 
      // 处理应急处置步骤
      if (emergencyPlan.execSteps) {
        try {
          execStepsList.value = JSON.parse(emergencyPlan.execSteps);
        } catch (e) {
          execStepsList.value = [];
        }
      } else {
        execStepsList.value = [];
      }
    } else {
      currentPlan.value = null;
      applyScopeList.value = [];
      execStepsList.value = [];
      showToast("未找到应急预案信息");
    }
  };
 
  // 返回上一页
  const goBack = () => {
    uni.navigateBack();
  };
 
  onMounted(() => {
    initData();
  });
 
  onShow(() => {
    initData();
  });
</script>
 
<style scoped lang="scss">
  @import "../../../styles/sales-common.scss";
 
  .emergency-plan-view {
    min-height: 100vh;
    background: #f8f9fa;
    padding-bottom: 32px;
  }
 
  .detail-content {
    padding: 20px;
  }
 
  // 信息 section
  .info-section {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  }
 
  .section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
  }
 
  .title-text {
    font-size: 18px;
    font-weight: 600;
    color: #303133;
    flex: 1;
  }
 
  .type-tag {
    margin-left: 16px;
  }
 
  .info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }
 
  .info-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
 
  .info-label {
    font-size: 14px;
    color: #909399;
  }
 
  .info-value {
    font-size: 14px;
    color: #303133;
    word-break: break-all;
  }
 
  // 适用范围 section
  .scope-section {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  }
 
  .section-header {
    margin-bottom: 16px;
  }
 
  .section-heading {
    font-size: 16px;
    font-weight: 600;
    color: #303133;
    border-left: 4px solid #2979ff;
    padding-left: 16px;
  }
 
  .scope-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
  }
 
  .scope-tag {
    margin-bottom: 8px;
  }
 
  // 应急处置步骤 section
  .steps-section {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  }
 
  .steps-list {
    margin-top: 16px;
  }
 
  .step-item {
    display: flex;
    margin-bottom: 24px;
    position: relative;
  }
 
  .step-item::before {
    content: "";
    position: absolute;
    left: 15px;
    top: 40px;
    bottom: -24px;
    width: 2px;
    background-color: #eaeaea;
  }
 
  .step-item:last-child::before {
    display: none;
  }
 
  .step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #2979ff;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    flex-shrink: 0;
    margin-top: 4px;
  }
 
  .step-content {
    flex: 1;
  }
 
  .step-title {
    font-size: 16px;
    font-weight: 600;
    color: #303133;
    display: block;
    margin-bottom: 8px;
  }
 
  .step-description {
    font-size: 14px;
    color: #606266;
    line-height: 1.5;
    word-break: break-all;
  }
 
  .no-steps {
    padding: 40px;
    text-align: center;
    color: #909399;
    font-size: 14px;
    background-color: #f8f9fa;
    border-radius: 8px;
  }
 
  // 空状态
  .empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60vh;
    font-size: 16px;
    color: #909399;
  }
</style>