Newer
Older
xc-business-system / src / views / business / measure / item / components / eleventh / templateDetail.vue
<!-- 第11套:微波衰减标准装置 -->
<script lang="ts" setup name="TemplateDetailEleventh">
import { ElMessage } from 'element-plus'
import type { IList } from './templateDetail-interface'
import type { dictType } from '@/global'
import { getDictByCode } from '@/api/system/dict'
import { calc } from '@/utils/useCalc'
import { useCheckList } from '@/commonMethods/useCheckList'
import { calculate, recalculate } from '@/api/business/measure/caculate'
import type { TableColumn } from '@/components/NormalTable/table_interface'

const props = defineProps({
  pageType: {
    type: String,
    default: 'add',
  },
  itemCategoryName: {
    type: String,
    require: true,
  }, // 设备检定项分类名称
  belongStandardEquipment: { // 检校标准装置code
    type: String,
    require: true,
  },
  list: {
    type: Array as any,
  },
  form: { // 检定项表单
    type: Object as any,
  },
  itemId: { // 检定项id
    type: String,
    default: '',
  },
})
const tableLoading = ref(false)
const list = ref<IList[]>([])
const checkoutList = ref<IList[]>([]) // 多选
// ----------------------------------------表头------------------------------------------------
const columns = ref<TableColumn[]>([ // 时基
  { text: '检定项目', value: 'params', align: 'center', required: true },
  { text: '频率', value: 'nominalValue', align: 'center', required: true },
  { text: '频率单位', value: 'nominalValue', align: 'center', required: true },
  { text: '标称值', value: 'nominalValue', align: 'center', required: true },
  { text: '标称值单位', value: 'nominalValue', align: 'center', required: true },
  { text: 'U(k=2)', value: 'nominalValue', align: 'center', required: true },
  { text: '技术指标', value: 'nominalValue', align: 'center', required: true },
])

// --------------------------------表格操作---------------------------------------------------
// 多选
const handleSelectionChange = (e: any) => {
  checkoutList.value = e
}

/**
 * 增加行公共方法
 * @param list 要操作的数组
 * @param title 操作的表格
 */
const addRow = (list: IList[], title: string) => {
  // if (checkList(list, `${title}表格`)) {
  //   if (list.length) { // 增加行时默认上一行数据
  //     list.push({
  //       id: '',
  //       checkPoint: list[list.length - 1].checkPoint, //	核查点(直接存字典value)
  //       checkType: list[list.length - 1].checkType, //	核查类型
  //       cycleNumber: list[list.length - 1].cycleNumber, //	循环次数
  //       equipmentId: list[list.length - 1].equipmentId, //	配套设备id
  //       itemCategoryId: list[list.length - 1].itemCategoryId, //	核查项分类id(能够确定是哪个标准装置)
  //       params: list[list.length - 1].params, //	核查项目(直接存字典value)
  //       remark: list[list.length - 1].remark, //	核查项备注(每个数据存储的核查项备注相同,前端取列表中一个即可)
  //       resolution: list[list.length - 1].resolution, //		分辨力
  //       testType: list[list.length - 1].testType, // 核查点类型(直接存字典value)
  //       unit: list[list.length - 1].unit, //	单位(直接存字典value)
  //       urel: list[list.length - 1].urel, //	测量标准相对扩展不确定度urel
  //     })
  //   }
  //   else {
  //     list.push({
  //       checkPoint: '', //	核查点
  //       checkType: '', //	核查类型(直接存字典value,多个逗号分隔)
  //       cycleNumber: 6, //	循环次数
  //       equipmentId: infoId.value, //	配套设备id
  //       itemCategoryId: form.value.itemCategoryId, //	核查项分类id(能够确定是哪个标准装置)
  //       params: '', //	核查项目(直接存字典value)
  //       remark: '', //	核查项备注
  //       resolution: 0.0001, //	分辨力
  //       testType: title, //	核查点类型(直接存字典value)
  //       unit: '', //	单位(直接存字典value)
  //       urel: 0, //	测量标准相对扩展不确定度urel
  //     })
  //   }
  // }
}
/**
 * 删除行公共方法
 * @param checkoutList 选中的数组
 * @param list 操作的数组
 */
const delRow = (checkoutList: IList[], list: IList[]) => {
  if (!checkoutList.length) {
    ElMessage.warning('请选中要删除的行')
  }
  else {
    list = list.filter((item: any) => {
      return !checkoutList.includes(item)
    })
  }
}

// ---------------------------------------------校验---------------------------------------------------
// 校验表格(点击保存的时候用、生成标准器示值)
const checkList = () => {
  // return useCheckList(list.value, columns.value, '检定项表格')
}
// ------------------------------------------------------------------------------------------------
// 点击计算结果--上方表格计算
const calculateDataTop = () => {

}
// 点击生成辅助接地电阻--下面表格计算
const calculateDataBottom = () => {

}
// -----------------------------------------------------------------------------------------------------

// watch(() => props.list, (newVal) => { // 检定项表格
//   if (newVal) {
//     list.value = [...newVal]
//   }
// })

// defineExpose({ list })
</script>

<template>
  <div style="padding: 0 10px;">
    <el-checkbox v-model="form.appearance" :checked="true" :disabled="pageType === 'detail'">
      外观及功能性检查
    </el-checkbox>
    <el-checkbox v-model="form.sj" :checked="true" :disabled="pageType === 'detail'">
      衰减量
    </el-checkbox>
  </div>

  <detail-block title="">
    <template v-if="pageType !== 'detail'" #btns>
      <el-button type="primary" @click="addRow(list)">
        增加行
      </el-button>
      <el-button type="info" @click="delRow(checkoutList, list)">
        删除行
      </el-button>
    </template>
    <el-table
      :data="list"
      border
      style="width: 100%;"
      @selection-change="handleSelectionChange"
    >
      <el-table-column v-if="pageType !== 'detail'" type="selection" width="38" />
      <el-table-column align="center" label="序号" width="80" type="index" />
      <el-table-column
        v-for="item in columns"
        :key="item.value"
        :prop="item.value"
        :label="item.text"
        :width="item.width"
        align="center"
      >
        <template #header>
          <span v-show="item.required" style="color: red;">*</span><span>{{ item.text }}</span>
        </template>
      </el-table-column>
    </el-table>
  </detail-block>
</template>