From 629fbedba493197f7a8659dd3715f8f4c007618f Mon Sep 17 00:00:00 2001 From: kyy <3283105747@qq.com> Date: 星期四, 17 七月 2025 08:21:49 +0800 Subject: [PATCH] 设备点检 --- pages/Device/Spotcheck.vue | 259 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 259 insertions(+), 0 deletions(-) diff --git a/pages/Device/Spotcheck.vue b/pages/Device/Spotcheck.vue new file mode 100644 index 0000000..0fd86b9 --- /dev/null +++ b/pages/Device/Spotcheck.vue @@ -0,0 +1,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> \ No newline at end of file -- Gitblit v1.9.3