yyb
2026-05-16 a466b9aef571d4c7bd024dc0f0923a567da06998
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
<template>
  <view class="repair-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">{{ detail.deviceName || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">规格型号</text>
        <text class="info-value">{{ detail.deviceModel || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">报修日期</text>
        <text class="info-value">{{ formatDate(detail.repairTime) || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">报修人</text>
        <text class="info-value">{{ detail.repairName || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">维修人</text>
        <text class="info-value">{{ detail.maintenanceName || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">维修项目</text>
        <text class="info-value">{{ detail.machineryCategory || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">故障现象</text>
        <text class="info-value multi-line">{{ detail.remark || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">维修结果</text>
        <text class="info-value multi-line">{{ detail.maintenanceResult || '-' }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">维修日期</text>
        <text class="info-value">{{ formatDateTime(detail.maintenanceTime) || '-' }}</text>
      </view>
    </view>
    <!-- 验收表单 -->
    <u-form ref="formRef"
            :model="form"
            label-width="110">
      <u-cell-group title="验收信息">
        <u-form-item label="验收人"
                     prop="acceptanceName"
                     required
                     border-bottom>
          <u-input v-model="form.acceptanceName"
                   disabled
                   placeholder="验收人" />
        </u-form-item>
        <u-form-item label="验收时间"
                     prop="acceptanceTime"
                     required
                     border-bottom>
          <u-input v-model="form.acceptanceTime"
                   placeholder="请选择验收时间"
                   readonly
                   @click="showDatePicker = true" />
          <template #right>
            <u-icon name="arrow-right"
                    @click="showDatePicker = true"></u-icon>
          </template>
        </u-form-item>
        <u-form-item label="验收备注"
                     prop="acceptanceRemark"
                     required
                     border-bottom>
          <u-textarea v-model="form.acceptanceRemark"
                      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="save-btn"
                  type="primary"
                  @click="handleSubmit"
                  :loading="loading">验收确认</u-button>
      </view>
    </u-form>
    <up-datetime-picker :show="showDatePicker"
                        v-model="pickerDateValue"
                        mode="datetime"
                        title="选择验收时间"
                        @confirm="onDateConfirm"
                        @cancel="showDatePicker = false" />
  </view>
</template>
 
<script setup>
  import { ref, onMounted } from "vue";
  import { onLoad } from "@dcloudio/uni-app";
  import PageHeader from "@/components/PageHeader.vue";
  import { repairAcceptance, getRepairById } from "@/api/equipmentManagement/repair";
  import useUserStore from "@/store/modules/user";
  import dayjs from "dayjs";
 
  defineOptions({ name: "repair-acceptance" });
 
  const showToast = message => {
    uni.showToast({ title: message, icon: "none" });
  };
 
  const userStore = useUserStore();
  const loading = ref(false);
  const showDatePicker = ref(false);
  const pickerDateValue = ref(Date.now());
  const repairId = ref("");
  const detail = ref({});
 
  const form = ref({
    id: "",
    acceptanceName: "",
    acceptanceTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
    acceptanceRemark: "",
  });
 
  const formatDate = dateStr => {
    if (!dateStr) return "";
    return dayjs(dateStr).format("YYYY-MM-DD");
  };
 
  const formatDateTime = dateStr => {
    if (!dateStr) return "";
    return dayjs(dateStr).format("YYYY-MM-DD HH:mm:ss");
  };
 
  const canAccept = item => {
    const currentName = userStore.nickName || userStore.name || "";
    return currentName && item.acceptanceName === currentName;
  };
 
  const loadDetail = async id => {
    try {
      const cached = uni.getStorageSync("repairDetail");
      if (cached) {
        detail.value = typeof cached === "string" ? JSON.parse(cached) : cached;
      }
      if (id && (!detail.value?.id || detail.value.id != id)) {
        const { code, data } = await getRepairById(id);
        if (code == 200) {
          detail.value = data;
        }
      }
      if (!canAccept(detail.value)) {
        showToast("仅指定验收人可进行验收");
        setTimeout(() => uni.navigateBack(), 1500);
        return;
      }
      form.value.id = detail.value.id;
      form.value.acceptanceName = detail.value.acceptanceName || "";
    } catch (e) {
      showToast("获取报修信息失败");
    }
  };
 
  const onDateConfirm = e => {
    form.value.acceptanceTime = dayjs(e.value).format("YYYY-MM-DD HH:mm:ss");
    pickerDateValue.value = e.value;
    showDatePicker.value = false;
  };
 
  const handleSubmit = async () => {
    if (!form.value.acceptanceTime?.trim()) {
      showToast("请选择验收时间");
      return;
    }
    if (!form.value.acceptanceRemark?.trim()) {
      showToast("请输入验收备注");
      return;
    }
    try {
      loading.value = true;
      const { code } = await repairAcceptance({
        id: form.value.id,
        acceptanceTime: form.value.acceptanceTime,
        acceptanceRemark: form.value.acceptanceRemark,
      });
      if (code == 200) {
        showToast("验收成功");
        uni.removeStorageSync("repairDetail");
        setTimeout(() => uni.navigateBack(), 500);
      } else {
        loading.value = false;
      }
    } catch (e) {
      loading.value = false;
      showToast("验收提交失败");
    }
  };
 
  const goBack = () => {
    uni.removeStorageSync("repairDetail");
    uni.navigateBack();
  };
 
  onLoad(options => {
    if (options.id) {
      repairId.value = options.id;
    }
  });
 
  onMounted(async () => {
    if (!userStore.nickName) {
      await userStore.getInfo().catch(() => {});
    }
    if (repairId.value) {
      loadDetail(repairId.value);
    }
  });
</script>
 
<style scoped lang="scss">
  @import "@/static/scss/form-common.scss";
 
  .repair-acceptance {
    min-height: 100vh;
    background-color: #f8f9fa;
    padding-bottom: 160rpx;
  }
 
  .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;
  }
 
  .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;
  }
 
  .save-btn {
    font-weight: 500;
    font-size: 1rem;
    color: #fff;
    background: linear-gradient(140deg, #00baff 0%, #006cfb 100%);
    border: none;
    width: 45%;
    height: 2.5rem;
    border-radius: 2.5rem;
  }
</style>