<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>
|