gaoluyang
2 天以前 e449a5408265e4bd1f6c66f5be28a42efac444ee
src/pages/equipmentManagement/deviceInfo/index.vue
@@ -6,9 +6,18 @@
    <view class="info-card">
      <view class="card-header">
        <text class="card-title">基本信息</text>
        <text class="device-status">正常</text>
        <text
          class="device-status"
          :class="deviceInfo.status === 1 ? 'status-enabled' : 'status-disabled'"
        >
          {{ deviceInfo.status === 1 ? '启用' : '停用' }}
        </text>
      </view>
      <view class="card-content">
        <view class="info-row">
          <text class="label">设备编号:</text>
          <text class="value">{{ deviceInfo.uniqueCode || '--' }}</text>
        </view>
        <view class="info-row">
          <text class="label">设备名称:</text>
          <text class="value">{{ deviceInfo.deviceName || '--' }}</text>
@@ -18,12 +27,99 @@
          <text class="value">{{ deviceInfo.deviceModel || '--' }}</text>
        </view>
        <view class="info-row">
          <text class="label">生产厂家:</text>
          <text class="value">{{ deviceInfo.supplierName || '--' }}</text>
          <text class="label">设备品牌:</text>
          <text class="value">{{ deviceInfo.deviceBrand || '--' }}</text>
        </view>
        <view class="info-row">
          <text class="label">设备类型:</text>
          <text class="value">{{ deviceInfo.type || '--' }}</text>
        </view>
        <view class="info-row">
          <text class="label">出厂编号:</text>
          <text class="value">{{ deviceInfo.factoryNumber || '--' }}</text>
        </view>
        <view class="info-row">
          <text class="label">存放位置:</text>
          <text class="value">{{ deviceInfo.storageLocation || '--' }}</text>
        </view>
        <view class="info-row">
          <text class="label">责任人:</text>
          <text class="value">{{ deviceInfo.responsiblePerson || '--' }}</text>
        </view>
        <view class="info-row">
          <text class="label">单位:</text>
          <text class="value">{{ deviceInfo.unit || '--' }}</text>
        </view>
        <view class="info-row">
          <text class="label">建档日期:</text>
          <text class="value">{{ formatDate(deviceInfo.filingDate) }}</text>
        </view>
      </view>
    </view>
    <!-- 采购信息 -->
    <view class="info-card">
      <view class="card-header">
        <text class="card-title">采购信息</text>
      </view>
      <view class="card-content">
        <view class="info-row">
          <text class="label">供应商:</text>
          <text class="value">{{ deviceInfo.supplierName || '--' }}</text>
        </view>
        <view class="info-row">
          <text class="label">制造厂商:</text>
          <text class="value">{{ deviceInfo.manufacturer || '--' }}</text>
        </view>
        <view class="info-row">
          <text class="label">购置日期:</text>
          <text class="value">{{ formatDate(deviceInfo.purchaseDate) }}</text>
        </view>
        <view class="info-row">
          <text class="label">资产原值:</text>
          <text class="value">{{ deviceInfo.originalAssetValue ?? '--' }}</text>
        </view>
      </view>
    </view>
    <!-- 技术参数 -->
    <view class="info-card">
      <view class="card-header">
        <text class="card-title">技术参数</text>
      </view>
      <view class="card-content">
        <view class="info-row">
          <text class="label">主要技术参数:</text>
          <text class="value">{{ deviceInfo.technicalParameters || '--' }}</text>
        </view>
        <view class="info-row">
          <text class="label">主要用途:</text>
          <text class="value">{{ deviceInfo.mainPurpose || '--' }}</text>
        </view>
      </view>
    </view>
    <!-- 运行管理 -->
    <view class="info-card">
      <view class="card-header">
        <text class="card-title">运行管理</text>
      </view>
      <view class="card-content">
        <view class="info-row">
          <text class="label">启用日期:</text>
          <text class="value">{{ formatDate(deviceInfo.activationDate) }}</text>
        </view>
        <view class="info-row">
          <text class="label">预计运行时间:</text>
          <text class="value">{{ formatDate(deviceInfo.planRuntimeTime) }}</text>
        </view>
        <view class="info-row">
          <text class="label">启用折旧:</text>
          <text class="value">{{ deviceInfo.isDepr === 1 ? '是' : '否' }}</text>
        </view>
        <view v-if="deviceInfo.isDepr === 1" class="info-row">
          <text class="label">每年折旧金额:</text>
          <text class="value">{{ deviceInfo.annualDepreciationAmount ?? '--' }}</text>
        </view>
      </view>
    </view>
@@ -49,25 +145,94 @@
        </view>
      </view>
    </view>
    <!-- 报修记录 -->
    <view class="info-card">
      <view class="card-header">
        <text class="card-title">报修记录</text>
      </view>
      <view class="card-content">
        <view v-if="repairRecords.length === 0" class="empty-tip">暂无报修记录</view>
        <view v-else class="change-record" v-for="(item, index) in repairRecords" :key="index">
          <view class="record-header">
            <text class="record-time">{{ formatDate(item.repairTime) }}</text>
            <text class="record-status" :class="item.status === 1 ? 'status-approved' : 'status-rejected'">
              {{ item.status === 1 ? '完结' : '待维修' }}
            </text>
          </view>
          <view class="record-reason">报修人:{{ item.repairName || '--' }} 维修人:{{ item.maintenanceName || '--' }}</view>
          <view class="record-reason">维修项目:{{ item.machineryCategory || '--' }}</view>
          <view class="record-reason">故障现象:{{ item.remark || '--' }}</view>
          <view class="record-reason">维修结果:{{ item.maintenanceResult || '--' }}</view>
        </view>
      </view>
    </view>
    <!-- 保养记录 -->
    <view class="info-card">
      <view class="card-header">
        <text class="card-title">保养记录</text>
      </view>
      <view class="card-content">
        <view v-if="upkeepRecords.length === 0" class="empty-tip">暂无保养记录</view>
        <view v-else class="change-record" v-for="(item, index) in upkeepRecords" :key="index">
          <view class="record-header">
            <text class="record-time">{{ formatDate(item.maintenancePlanTime) }}</text>
            <text class="record-status" :class="item.status === 1 ? 'status-approved' : 'status-rejected'">
              {{ item.status === 1 ? '完结' : '待保养' }}
            </text>
          </view>
          <view class="record-reason">保养项目:{{ item.machineryCategory || '--' }}</view>
          <view class="record-reason">保养人:{{ item.maintenancePerson || '--' }} 录入人:{{ item.createUserName || '--' }}</view>
          <view class="record-reason">实际保养日期:{{ formatDate(item.maintenanceActuallyTime) }}</view>
        </view>
      </view>
    </view>
  </view>
</template>
<script setup>
import { ref, reactive } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import dayjs from 'dayjs'
import PageHeader from '@/components/PageHeader.vue'
import { getDeviceInfo } from '@/api/equipmentManagement/deviceInfo'
import { listStatusChangeRecord } from '@/api/device/statusChangeRecord'
import { getRepairPage } from '@/api/equipmentManagement/repair'
import { getUpkeepPage } from '@/api/equipmentManagement/upkeep'
import { unwrapList } from '@/utils/list'
const deviceInfo = reactive({
  uniqueCode: '',
  deviceName: '',
  deviceModel: '',
  deviceBrand: '',
  type: '',
  factoryNumber: '',
  storageLocation: '',
  responsiblePerson: '',
  filingDate: '',
  supplierName: '',
  manufacturer: '',
  purchaseDate: '',
  originalAssetValue: null,
  unit: '',
  technicalParameters: '',
  mainPurpose: '',
  status: null,
  activationDate: '',
  planRuntimeTime: '',
  isDepr: 2,
  annualDepreciationAmount: null,
})
const changeRecords = ref([])
const recordsLoading = ref(false)
const repairRecords = ref([])
const upkeepRecords = ref([])
// 后端日期多带时分秒,这里统一只显示到日
const formatDate = (d) => (d ? dayjs(d).format('YYYY-MM-DD') : '--')
const statusText = (s) => (s == 1 ? '启用' : '停用')
@@ -112,6 +277,18 @@
  uni.navigateBack()
}
// 报修/保养列表接口只提供 deviceName 过滤(与管理端一致,无 deviceId 维度)
const fetchDeviceHistory = async (deviceName) => {
  if (!deviceName) return
  const params = { current: -1, size: -1, deviceName }
  const [repair, upkeep] = await Promise.all([
    getRepairPage(params).catch(() => null),
    getUpkeepPage(params).catch(() => null),
  ])
  repairRecords.value = unwrapList(repair)
  upkeepRecords.value = unwrapList(upkeep)
}
onLoad((options) => {
  const deviceId = options?.deviceId || ''
  if (!deviceId) {
@@ -119,6 +296,9 @@
    return
  }
  fetchDeviceInfo(deviceId)
    // 履历里的报修/保养记录要等基本信息拿到设备名称后才能查
    .then(() => fetchDeviceHistory(deviceInfo.deviceName))
    .catch(() => {})
  fetchChangeRecords(deviceId)
})
</script>
@@ -161,6 +341,14 @@
  background: #52c41a;
}
.status-enabled {
  background: #52c41a;
}
.status-disabled {
  background: #bfbfbf;
}
.card-content {
  padding: 16px 20px;
}
@@ -176,8 +364,10 @@
}
.label {
  width: 88px;
  /* 「主要技术参数:」比原来最长的标签更宽,改成按内容撑开,避免换行或截断 */
  min-width: 88px;
  flex-shrink: 0;
  white-space: nowrap;
  color: #666666;
  font-size: 14px;
}