111
啊鑫
2025-07-21 2b0e70bb88ced210dbc693a4d2ded2d658b1da02
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
<template>
  <view class="container">
    <!-- 标题 + 输入框 -->
    <view class="input-section">
      <text class="label">设备编码:</text>
      <input
        ref="scannerInput"
        type="text"
        v-model="scanResult"
        class="input-box"
        placeholder="请扫描二维码"
        :focus="inputFocus"
        @confirm="handleScan"
      />
    </view>
 
    <!-- 表单区域 -->
    <view class="form-section">
      <view class="form-item">
        <text class="form-label">设备名称:</text>
        <input v-model="deviceName" class="form-input" placeholder="请输入设备名称" />
      </view>
      <view class="form-item">
        <text class="form-label">点检编号:</text>
        <input v-model="planNo" class="form-input" placeholder="请输入点检编号" />
      </view>
      <view class="form-item">
        <text class="form-label">点检人:</text>
        <input v-model="inspector" class="form-input" placeholder="点检人" readonly />
      </view>
    </view>
 
    <!-- 点检内容和点检结果表格 -->
    <view class="list-container" style="margin-top: 40rpx;">
      <uni-table ref="table" border emptyText="暂无点检记录">
        <uni-tr>
          <uni-th align="center" style="color: #FFFFFF; background-color: lightskyblue;">序号</uni-th>
          <uni-th align="center" style="color: #FFFFFF; background-color: lightskyblue;">点检内容</uni-th>
          <uni-th align="center" style="color: #FFFFFF; background-color: lightskyblue;">点检结果</uni-th>
        </uni-tr>
        <uni-tr v-for="(item, index) in inspectionItems" :key="index">
          <uni-td align="center">{{ index + 1 }}</uni-td>
          <uni-td align="center">
            <input class="form-input" v-model="item.content" placeholder="请输入点检内容" />
          </uni-td>
          <uni-td align="center">
            <picker :range="['合格','不合格']" :value="getPickerIndex(item.result)" @change="e => onPickerChange(index, e)">
              <view class="form-input">{{ item.result || '请选择结果' }}</view>
            </picker>
          </uni-td>
        </uni-tr>
      </uni-table>
    </view>
 
    <!-- 提交并清除按钮 -->
    <button class="submit-button" @click="submitData">提交数据</button>
  </view>
</template>
 
<script>
export default {
  data() {
    return {
      scanResult: '',
      inputFocus: true,
      deviceName: '',
      deviceNo: '',
      inspector: '',
      inspectionItems: []
    };
  },
  mounted() {
    const username = this.$loginInfo?.account;
    if (username) {
      this.inspector = username;
    } else {
      console.warn('未获取到登录用户信息');
    }
  },
  methods: {
    handleScan() {
      this.refreshResult();
    },
    refreshResult() {
      if (!this.scanResult) {
        uni.showToast({ title: '请先扫描条码', icon: 'none' });
        return;
      }
 
      this.$post({
        url: "/MesEqMaintain/getDjDetail",
        data: { eqNo: this.scanResult }
      }).then(res => {
        if (res && res.status === 0 && res.data?.tbBillList?.result) {
          const result = res.data.tbBillList.result;
          const eqList = result.eqInfoList || [];
 
          if (eqList.length > 0) {
            this.deviceName = eqList[0].eqName;
            this.planNo = eqList[0].planNo;
          }
 
          this.inspectionItems = (result.mesEqKeepsType02List || []).map(item => ({
            id: item.id || '',
            content: item.eqMain || '',
            result: item.eqEnd || '',
            eqEnd: item.eqEnd || ''
          }));
 
        } else {
          this.inspectionItems = [];
          this.deviceName = '';
          this.planNo = '';
          uni.showToast({ title: '无相关点检记录', icon: 'none' });
        }
      }).catch(err => {
        console.error('接口请求失败:', err);
        uni.showToast({ title: '请求失败', icon: 'none' });
      });
    },
    getPickerIndex(val) {
      return ['合格', '不合格'].indexOf(val);
    },
    onPickerChange(index, e) {
      const options = ['合格', '不合格'];
      this.inspectionItems[index].result = options[e.detail.value];
    },
    submitData() {
      const dataToSend = this.inspectionItems.map(item => ({
        id: item.id,
        content: item.content,
        result: item.result
      }));
 
      console.log('即将发送的点检结果数据:', dataToSend);
 
      this.$post({
        url: "/MesEqMaintain/UpDateDjDetail",
        data: {
          userNo: this.$loginInfo?.account,
          releaseNo: this.planNo,
          inspectionItems: dataToSend
        }
      }).then(res => {
        if (res && res.status === 0) {
          this.scanResult = '';
          this.inspectionItems = [];
          this.inputFocus = false;
          this.$nextTick(() => { this.inputFocus = true; });
          this.deviceName = '';
          this.planNo = '';
          uni.showToast({ title: '数据提交成功', icon: 'success' });
        } else {
          uni.showToast({ title: '数据提交失败', icon: 'none' });
        }
      }).catch(err => {
        console.error('数据提交接口请求失败:', err);
        uni.showToast({ title: '数据提交失败', icon: 'none' });
      });
    }
  }
};
</script>
 
<style scoped>
    .container {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 80rpx 40rpx;
        background-color: #f9f9f9;
        min-height: 100vh;
        box-sizing: border-box;
    }
 
    .input-section {
        display: flex;
        flex-direction: row;
        align-items: center;
        width: 100%;
        justify-content: center;
        margin-bottom: 40rpx;
    }
 
    .label {
        font-weight: bold;
        font-size: 34rpx;
        margin-right: 20rpx;
    }
 
    .input-box {
        flex: 1;
        height: 90rpx;
        font-size: 30rpx;
        border: 1px solid #ccc;
        border-radius: 16rpx;
        padding-left: 20rpx;
        background-color: #fff;
        box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
    }
 
    .result {
        font-size: 30rpx;
        color: #2c7;
        margin-bottom: 40rpx;
        text-align: center;
    }
 
    .clear-button {
        width: 100%;
        height: 90rpx;
        line-height: 90rpx;
        font-size: 32rpx;
        border-radius: 16rpx;
        background-color: #ff4d4f;
        color: #fff;
        margin-bottom: 40rpx;
    }
 
    .submit-button {
        width: 100%;
        height: 90rpx;
        line-height: 90rpx;
        font-size: 32rpx;
        border-radius: 16rpx;
        background-color: #ff4d4f;
        color: #fff;
        margin-bottom: 40rpx;
    }
 
    .form-section {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 30rpx;
    }
 
    .form-item {
        display: flex;
        align-items: center;
        padding: 0 20rpx;
    }
 
    .form-label {
        width: 180rpx;
        font-size: 30rpx;
        font-weight: bold;
    }
 
    .form-input {
        flex: 1;
        height: 80rpx;
        border: 1px solid #ccc;
        border-radius: 12rpx;
        padding-left: 20rpx;
        font-size: 28rpx;
        background-color: #fff;
    }
</style>