|
|
|
|
@ -20,7 +20,18 @@
|
|
|
|
|
</view>
|
|
|
|
|
<view class="info-row">
|
|
|
|
|
<text class="info-label">{{ t('equipmentLedger.deviceStatus') }}</text>
|
|
|
|
|
<text :class="['info-value', getStatusClass(detailData?.deviceStatus)]">{{ getStatusText(detailData?.deviceStatus) }}</text>
|
|
|
|
|
<picker
|
|
|
|
|
class="status-picker-wrap"
|
|
|
|
|
:range="statusChangeLabels"
|
|
|
|
|
:value="getStatusChangeIndex(detailData?.deviceStatus)"
|
|
|
|
|
:disabled="!detailData || statusUpdating"
|
|
|
|
|
@change="onStatusChange"
|
|
|
|
|
>
|
|
|
|
|
<view class="status-picker">
|
|
|
|
|
<text :class="['info-value', 'status-value', getStatusClass(detailData?.deviceStatus)]">{{ getStatusText(detailData?.deviceStatus) }}</text>
|
|
|
|
|
<uni-icons type="bottom" size="14" color="#8a9099"></uni-icons>
|
|
|
|
|
</view>
|
|
|
|
|
</picker>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="info-row">
|
|
|
|
|
<text class="info-label">{{ t('equipmentLedger.deviceType') }}</text>
|
|
|
|
|
@ -149,12 +160,14 @@ import { ref, computed } from 'vue'
|
|
|
|
|
import { onLoad } from '@dcloudio/uni-app'
|
|
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
|
import NavBar from '@/components/common/NavBar.vue'
|
|
|
|
|
import { getDeviceLedger } from '@/api/mes/deviceLedger'
|
|
|
|
|
import { getDeviceLedger, updateDeviceLedger } from '@/api/mes/deviceLedger'
|
|
|
|
|
import { getDeviceTypeTree } from '@/api/mes/deviceType'
|
|
|
|
|
import { DICT_TYPE, getDictLabel, initAllDict } from '@/utils/dict'
|
|
|
|
|
import useDictStore from '@/store/modules/dict'
|
|
|
|
|
import request from '@/utils/request'
|
|
|
|
|
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
const dictStore = useDictStore()
|
|
|
|
|
const detailId = ref(undefined)
|
|
|
|
|
const detailData = ref(null)
|
|
|
|
|
const deviceTypeList = ref([])
|
|
|
|
|
@ -162,6 +175,7 @@ const activeTab = ref('check')
|
|
|
|
|
const inspectionList = ref([])
|
|
|
|
|
const maintainList = ref([])
|
|
|
|
|
const repairList = ref([])
|
|
|
|
|
const statusUpdating = ref(false)
|
|
|
|
|
|
|
|
|
|
const tabs = computed(() => [
|
|
|
|
|
{ key: 'check', label: t('equipmentLedger.checkHistory') },
|
|
|
|
|
@ -169,6 +183,15 @@ const tabs = computed(() => [
|
|
|
|
|
{ key: 'repair', label: t('equipmentLedger.repairHistory') }
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
const statusOptions = computed(() => {
|
|
|
|
|
const dicts = dictStore.getDict(DICT_TYPE.MES_TZ_STATUS) || []
|
|
|
|
|
return dicts
|
|
|
|
|
.filter(item => item?.value !== null && item?.value !== undefined && String(item.value) !== '')
|
|
|
|
|
.map(item => ({ label: item.label, value: item.value }))
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const statusChangeLabels = computed(() => statusOptions.value.map(item => item.label))
|
|
|
|
|
|
|
|
|
|
const scheduledText = computed(() => {
|
|
|
|
|
const val = detailData.value?.isSchedueld ?? detailData.value?.isScheduled
|
|
|
|
|
return Number(val) === 1 ? t('equipmentLedger.yes') : t('equipmentLedger.no')
|
|
|
|
|
@ -265,10 +288,38 @@ function getStatusText(status) {
|
|
|
|
|
|
|
|
|
|
function getStatusClass(status) {
|
|
|
|
|
const s = String(status)
|
|
|
|
|
if (s === '0' || s === '1') return 'text-success'
|
|
|
|
|
if (s === '0') return 'text-success'
|
|
|
|
|
if (s === '1') return 'text-warning'
|
|
|
|
|
return 'text-danger'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getStatusChangeIndex(status) {
|
|
|
|
|
const idx = statusOptions.value.findIndex(item => String(item.value) === String(status))
|
|
|
|
|
return idx >= 0 ? idx : 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function onStatusChange(e) {
|
|
|
|
|
if (!detailData.value?.id) {
|
|
|
|
|
uni.showToast({ title: t('equipmentLedger.noId'), icon: 'none' })
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
const nextOption = statusOptions.value[Number(e?.detail?.value || 0)]
|
|
|
|
|
if (!nextOption || String(nextOption.value) === String(detailData.value.deviceStatus)) return
|
|
|
|
|
|
|
|
|
|
const oldStatus = detailData.value.deviceStatus
|
|
|
|
|
detailData.value.deviceStatus = nextOption.value
|
|
|
|
|
statusUpdating.value = true
|
|
|
|
|
try {
|
|
|
|
|
await updateDeviceLedger({ id: detailData.value.id, deviceStatus: nextOption.value })
|
|
|
|
|
uni.showToast({ title: t('functionCommon.updateSuccess'), icon: 'success' })
|
|
|
|
|
} catch (err) {
|
|
|
|
|
detailData.value.deviceStatus = oldStatus
|
|
|
|
|
uni.showToast({ title: t('functionCommon.saveFailed'), icon: 'none' })
|
|
|
|
|
} finally {
|
|
|
|
|
statusUpdating.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getResultText(result) {
|
|
|
|
|
if (result === 'PASS' || result === 'pass' || result === 'OK' || result === 'ok' || result === 1 || result === '1') return t('equipmentLedger.resultPass')
|
|
|
|
|
if (result === 'FAIL' || result === 'fail' || result === 'NG' || result === 'ng' || result === 0 || result === '0') return t('equipmentLedger.resultFail')
|
|
|
|
|
@ -348,7 +399,7 @@ function formatDateTime(value) {
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.page-container { min-height: 100vh; background-color: #f0f2f5; }
|
|
|
|
|
.fixed-header { position: sticky; top: 0; z-index: 10; }
|
|
|
|
|
.detail-scroll { height: calc(100vh - 120rpx); }
|
|
|
|
|
// .detail-scroll { height: calc(100vh - 120rpx); }
|
|
|
|
|
.content-section { padding: 0 24rpx 24rpx; }
|
|
|
|
|
.info-card { margin-top: 20rpx; background: #ffffff; border-radius: 20rpx; padding: 28rpx; box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05); }
|
|
|
|
|
.card-title { font-size: 32rpx; color: #1a3a5c; font-weight: 700; margin-bottom: 18rpx; }
|
|
|
|
|
@ -356,6 +407,9 @@ function formatDateTime(value) {
|
|
|
|
|
.info-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 18rpx 0; border-bottom: 1rpx solid #edf0f3; }
|
|
|
|
|
.info-label { font-size: 27rpx; color: #8a9099; width: 220rpx; }
|
|
|
|
|
.info-value { flex: 1; text-align: right; font-size: 28rpx; color: #30363d; line-height: 1.45; }
|
|
|
|
|
.status-picker-wrap { flex: 1; }
|
|
|
|
|
.status-picker { flex: 1; display: flex; align-items: center; justify-content: flex-end; gap: 8rpx; }
|
|
|
|
|
.status-value { flex: 0 1 auto; }
|
|
|
|
|
.text-success { color: #52c41a; }
|
|
|
|
|
.text-danger { color: #ff4d4f; }
|
|
|
|
|
.text-warning { color: #faad14; }
|
|
|
|
|
|