Newer
Older
xc-business-system / src / views / business / manager / sendReceive / components / measureItem.vue
<!-- 检定项信息 -->
<script name="SendReceiveDetailMeasureItem" lang="ts" setup>
import { ElLoading } from 'element-plus'
import { getDetailBaseInfo } from '@/api/business/manager/sendReceive'
import { getInfo as getItemInfo, getItemList } from '@/api/business/measure/item'
import templateDetailAddRowPattern from '@/views/business/measure/item/components/first/templateDetailAddRowPattern.vue'
import templateDetailCreatePattern from '@/views/business/measure/item/components/first/templateDetailCreatePattern.vue'
import templateDetailThird from '@/views/business/measure/item/components/third/templateDetail.vue'
import templateDetailFourth from '@/views/business/measure/item/components/fourth/templateDetail.vue'

const props = defineProps({
  pageType: { // 页面类型
    type: String,
    default: 'detail',
  },
  equipmentId: { // 设备id
    type: String,
    required: true,
  },
})
const itemList = ref([]) as any // 检定项列表
// ---------------------------------------获取详情------------------------------------------------

// 处理返回数据
function solveResponseData(response: any, belongStandardEquipment: string) {
  let list
  if (belongStandardEquipment === '1') { // 第一套:多功能校准源
    list = response.measureItemDataCalibratorList // 检定项表格
  }
  if (belongStandardEquipment === '3') { // 第3套:多功能电气安全校准器
    list = response.measureItemDataElectricalSafetyList // 检定项表格
  }
  else if (belongStandardEquipment === '4') { // 第四套:0.02级活塞式压力计
    list = response.measureItemDataPistonGaugeList // 检定项表格
  }
  return list
}

// 获取检定项
const getInfo = () => {
  const loading = ElLoading.service({
    lock: true,
    background: 'rgba(255, 255, 255, 0.8)',
  })
  // 获取设备名称、设备型号、辅助字段
  getDetailBaseInfo({ equipmentId: props.equipmentId }).then((res) => {
    // 检定项列表请求参数
    const listQuery = {
      dataSync: '', // 检定项数据是否同步
      deviceName: res.data.equipmentName, // 设备名称
      deviceType: '', // 设备分类
      helpInstruction: res.data.helpInstruction, // 辅助字段
      model: res.data.model, // 型号规格
      syncTimeEnd: '', // 自动检定系统最新同步时间结束
      syncTimeStart: '', // 自动检定系统最新同步时间开始
      limit: 20,
      offset: 1,
    }
    // 查询检定项列表
    getItemList(listQuery).then((response) => {
      itemList.value = response.data.rows
      // 获取检定项详情
      itemList.value.forEach((item: any) => {
        /**
         * 获取检定项详情
         * @param id 检定项id
         * @param itemCategoryName 检定项分类名称
         * @param belongStandardEquipment 检校标准装置名称
         */
        if (item.id && item.itemCategoryName && item.belongStandardEquipment) {
          getItemInfo({ id: item.id, itemCategoryName: item.itemCategoryName, belongStandardEquipment: item.belongStandardEquipment }).then((res) => {
            item.detailList = solveResponseData(res.data, item.belongStandardEquipment)
            if (item.belongStandardEquipment === '1' || item.belongStandardEquipment === '3') {
              item.appearanceFunctionCheck = `${res.data.appearanceFunctionCheck}` === '1'// 外观
            }
            item.itemRemark = res.data.itemRemark // 检定项备注
            loading.close()
          })
        }
      })
    })
  })
}
onMounted(() => {
  nextTick(() => {
    getInfo()
  })
})
</script>

<template>
  <div v-for="(item, index) in itemList" :key="index">
    <detail-block title="检定项信息">
      <el-form
        ref="ruleFormRef"
        :model="item"
        label-width="120"
        label-position="right"
        style="margin-bottom: 20px;"
      >
        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="设备分类:">
              <el-input
                v-model="item.deviceTypeName"
                :placeholder="pageType === 'detail' ? ' ' : '设备分类'"
                disabled
                class="input"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="检校标准装置:">
              <el-input
                v-model="item.belongStandardEquipmentName"
                :placeholder="pageType === 'detail' ? ' ' : '检校标准装置'"
                disabled
                class="input"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="设备检定项分类:">
              <el-input
                v-model="item.itemCategoryName"
                :placeholder="pageType === 'detail' ? ' ' : '设备检定项分类'"
                disabled
                class="input"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <!-- 第一套:多功能校准源标准装置--字典:1 -->
      <el-checkbox v-if="item.belongStandardEquipment === '1'" v-model="item.appearanceFunctionCheck" style="margin-left: 20px;" disabled>
        外观及功能检查
      </el-checkbox>
      <!-- 检定项表格(增加行模式) -->
      <template-detail-add-row-pattern v-if="item.belongStandardEquipment === '1' && item.itemCategoryName === '数字多用表(手持)' || item.itemCategoryName === '数字多用表(台式)' || item.itemCategoryName === '多功能电力参数测量仪' || item.itemCategoryName === '钳形电流表' || item.itemCategoryName === '指针式万用表'" :list="item.detailList" page-type="detail" :item-category-name="item.itemCategoryName" />
      <!-- 检定项表格(生成检定点模式) -->
      <template-detail-create-pattern v-if="item.belongStandardEquipment === '1' && item.itemCategoryName === '交流电压表' || item.itemCategoryName === '交流电流表' || item.itemCategoryName === '直流电压表' || item.itemCategoryName === '直流电流表' || item.itemCategoryName === '75mV电流表'" :list="item.detailList" page-type="detail" :item-category-name="item.itemCategoryName" />
      <template-detail-third
        v-if="item.belongStandardEquipment === '3'"
        page-type="detail"
        :item-category-name="item.itemCategoryName"
        :belong-standard-equipment="item.belongStandardEquipment"
        :list="item.detailList"
        :form="{ appearanceFunctionCheck: item.appearanceFunctionCheck }"
      />

      <!-- 第四套: 0.02级活塞式压力计标准装置--字典:4 -->
      <template-detail-fourth
        v-if="item.belongStandardEquipment === '4'"
        :item-category-name="item.itemCategoryName"
        :belong-standard-equipment="item.belongStandardEquipment"
        :list="item.detailList"
        page-type="detail"
      />

      <!-- 检定项备注 -->
      <el-form
        :model="item"
        label-width="120"
        label-position="right"
        style="margin-top: 20px;"
      >
        <el-row>
          <el-col :span="12">
            <el-form-item label="检定项备注:">
              <el-input
                v-model="item.itemRemark"
                class="full-width-input"
                autosize
                type="textarea"
                :placeholder="pageType === 'detail' ? ' ' : '检定项备注'"
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </detail-block>
  </div>
</template>