<template>
  <uni-card style="height: 100%" spacing="0">
    <view class="content">
      <up-row class="flex-wrap">
        <up-col :span="gridCol"
          >使用部门：
          <text class="value">{{ acceptInfo.useDept }}</text>
        </up-col>
        <up-col :span="gridCol"
          >到货日期：
          <text class="value">{{ acceptInfo.deviceCode }}</text>
        </up-col>
        <up-col :span="gridCol"
          >安装调试：
          <text class="value">{{ acceptInfo.installStatus }}</text>
        </up-col>
        <up-col :span="gridCol"
          >验收结果：
          <text class="value">{{ acceptInfo.acceptResult }}</text>
        </up-col>
      </up-row>

      <wf-comment :commentWf="commentWf" />
    </view>
  </uni-card>
</template>

<script setup>
import { ref, reactive, onMounted, onBeforeMount } from 'vue'
import { acceptDetailList } from '@/nx/api/deviceInfo'
import { useGridCol } from '@/nx/hooks/useGridCol'
import nx from '@/nx'
const { gridCol } = useGridCol([700], [6, 4])
const acceptSchema = [
  {
    label: '使用部门',
    field: 'useDept'
  },

  {
    label: '到货日期',
    field: 'arrivalDate'
  },
  {
    label: '验收日期',
    field: 'acceptDate'
  },
  {
    label: '安装调试',
    field: 'installStatus'
  },
  {
    label: '验收结果',
    field: 'acceptResult'
  },
  {
    label: '验收状态',
    field: 'acceptStatus'
  },
  {
    label: '备注',
    field: 'remark'
  }
]

onMounted(() => {
  const { id, deviceName } = nx.$store('biz').deviceInfo
  getDetailInfo(id)
})
let acceptInfo = ref({})
let commentWf = ref([])
async function getDetailInfo(id) {
  const res = await acceptDetailList({
    deviceBusInfoId: id
  })
  if (res.length > 0) {
    let info = res[0]
    acceptInfo.value = info
    if (info.commentJson) {
      try {
        commentWf.value = JSON.parse(info.commentJson)
      } catch (error) {
        uni.showToast({
          title: '解析数据错误',
          icon: 'none'
        })
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.content {
  font-size: 18px;
  color: #000;
  .u-col {
    padding: 10px;
  }
  .value {
    color: #666;
    font-size: 16px;
  }
}
</style>
