<!-- 基本信息 -->
<script lang="ts" setup name="baseInfo">
import { ElLoading, ElMessage, ElMessageBox } from 'element-plus'
import type { FormInstance, FormRules } from 'element-plus'
import type { PropType } from 'vue'
import type { deptType, fixedAssetsType, selectType } from '../standingBook-interface'
import showPhoto from '@/views/system/tool/showPhoto.vue'
import { UploadFile } from '@/api/measure/file'
import { getDictByCode } from '@/api/system/dict'
import { getUserList } from '@/api/system/user'
import { getDeptTreeList } from '@/api/system/dept'
import { assetsAddApi, assetsUpdateApi } from '@/api/device/standingBook'
import comTreeSelect from '@/views/system/user/selecTree.vue'
import { toTreeList } from '@/utils/structure'
import type { userType } from '@/views/system/user/user-interface'
import countries from '@/components/AddressSelect/country-code.json'
const props = defineProps({
  title: {
    type: String,
    require: true,
  },
  name: {
    type: String,
    require: true,
  },
  row: {
    type: Object as PropType <fixedAssetsType>,
    default: () => ({}),
  },
  showAssetsItem: {
    type: Boolean,
    default: true,
  },
})
const $router = useRouter()
const ruleFormRef = ref<FormInstance>() // from组件
const title = ref(props.title)
const isDetail = ref(false)
const ruleForm = ref<fixedAssetsType>({
  assetNo: '', // 资产编号
  compulsoryVerification: '', // 强制检定
  assetType: '', // 资产类型
  assetSource: '', // 资产来源
  equipmentNo: '', // 设备编号
  equipmentName: '', // 设备名称
  labelBind: '', // 标签绑定
  modelNo: '', // 型号
  equipmentSpecifications: '', // 设备规格
  equipmentType: '', // 设备类型
  equipmentCategory: '', // 设备类别
  capitalSource: '', // 资本来源
  managerLevel: '', // 管理级别
  purpose: '', // 用途
  technicalLevel: '', // 技术水平
  intactState: '', // 完好状态
  manufacturerCountry: '', // 厂家国别
  manufacturer: '', // 生产厂家
  overallDimension: '', // 外形尺寸
  manufacturingNo: '', // 出厂编号
  manufacturingDate: '', // 出厂年月
  cardEstablishmentDate: '', // 立卡年月
  weight: '', // 重量
  enableDate: '', // 启用年月
  singlePrice: '', // 单价
  installIncidentalExpenses: '', //	安装及杂费
  originValue: '', //	原值
  useDept: '', //	使用部门
  installPlace: '', //	安装地点
  depreciationPeriod: '', //	折旧年限
  depreciationMethod: '', //	折旧方法
  attribute: '', //	属性
  majorCategory: '', //	专业分类
  presentOriginValue: '', //	目前原值
  managerState: '1', //	管理状态
  fileList: [] as any[], //	说明书
  remark: '', //	备注
  mesureType: '', //	检定方式
  mesureRange: '', //	测量范围
  uncertainty: '', //	不确定度
  usePerson: '', //	使用人
  mesureDept: '', //	检定部门
  mesureDeptName: '', // 检定部门名称
  mesureCycle: 24, //	检定周期
  mesureDate: '', //	检定日期
  validDate: '', //	有效日期
  mesureResult: '', //	检定结果
  abc: '', //	ABC
  isCalibrationTestEquipment: '', //	是否是技术指标需要校准检定的设备
  isMeasureAccount: '', //	是否是测量工装台账
  isStandardSupportEquipment: '', //		是否标准配套设备
  isFixedAssets: '1', // 是否加入固定资产台账
  id: '',
  supportStandardEquipmentName: '',
  supportStandardEquipmentNo: '',
  version: '',
}) // 表单
const rules = ref<FormRules>({
  assetType: [{ required: true, message: '资产类型必填', trigger: 'blur' }],
  equipmentName: [{ required: true, message: '设备名称必填', trigger: 'blur' }],
  manufacturer: [{ required: true, message: '生产厂家必填', trigger: 'blur' }],
  manufacturingNo: [{ required: true, message: '出厂编号必填', trigger: 'blur' }],
  weight: [{ required: false, message: '重量(吨)必填', trigger: 'blur' },
    { pattern: /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/, message: '要求只能为数字', trigger: ['blur', 'change'] }],
  originValue: [{ required: false, message: '原值必填', trigger: 'blur' },
    { pattern: /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/, message: '要求只能为数字', trigger: ['blur', 'change'] }],
  presentOriginValue: [{ required: false, message: '目前原值必填', trigger: 'blur' },
    { pattern: /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/, message: '要求只能为数字', trigger: ['blur', 'change'] }],
  depreciationPeriod: [{ required: false, message: '折旧年限必填', trigger: 'blur' },
    { pattern: /^([0]|[1-9][0-9]*)$/, message: '要求为正整数或0', trigger: ['blur', 'change'] }],
  singlePrice: [{ required: false, message: '单价(元)必填', trigger: 'blur' },
    { pattern: /(^[0-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/, message: '要求不小于0，且最多保留两位小数', trigger: ['blur', 'change'] }],
  installIncidentalExpenses: [{ required: false, message: '安装及杂费(元)必填', trigger: 'blur' },
    { pattern: /(^[0-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/, message: '要求不小于0，且最多保留两位小数', trigger: ['blur', 'change'] }],
  // manufacturingDate: [{ required: true, message: '出厂年月必填', trigger: 'blur' }],
  modelNo: [{ required: true, message: '型号必填', trigger: 'blur' }],
  abc: [{ required: true, message: 'ABC必填', trigger: 'blur' }],
  // cardEstablishmentDate: [{ required: true, message: '立卡年月必填', trigger: 'blur' }],
  // enableDate: [{ required: true, message: '启用日期必填', trigger: 'blur' }],
  mesureCycle: [{ required: true, message: '检定周期必填', trigger: 'blur' }],
  // validDate: [{ required: true, message: '有效日期必填', trigger: 'blur' }],
  isMeasureAccount: [{ required: true, message: '必填', trigger: 'blur' }],
  isStandardSupportEquipment: [{ required: true, message: '必填', trigger: 'blur' }],
  isCalibrationTestEquipment: [{ required: true, message: '必填', trigger: 'blur' }],
}) // 表单验证规则
const assetTypeList = ref<selectType[]>([]) // 资产类型
const ABCList = ref<selectType[]>([]) // ABC
const mesureTypeList = ref<selectType[]>([]) // 检定方式
const majorCategoryList = ref<selectType[]>([]) // 专业分类
const equipmentCategoryList = ref<selectType[]>([]) // 设备类别
const mesureResultList = ref<selectType[]>([]) //  检定结果
const equipmentTypeList = ref<selectType[]>([]) // 设备类型
const managerLevelList = ref<selectType[]>([]) // 管理级别
const depreciationMethodList = ref<selectType[]>([]) // 折旧方法
const managerStateList = ref<selectType[]>([]) // 管理状态
const capitalSourceList = ref<selectType[]>([]) // 资本来源
const usePersonList = ref<userType[]>([]) // 使用人列表
const useDeptList = ref<deptType[]>([]) // 使用部门列表
const isWhether = ref<selectType[]>([
  {
    name: '是',
    id: 'shi',
    value: '1',
  },
  {
    name: '否',
    id: 'fou',
    value: '0',
  },
])
const deptProps = reactive({
  parent: 'pid', value: 'id', label: 'name', children: 'children',
})

// 获取下拉框数
const fetchData = () => {
// 获取资产类型
  getDictByCode('assetType').then((response) => {
    assetTypeList.value = response.data
  })
  // 获取ABC
  getDictByCode('ABC').then((response) => {
    ABCList.value = response.data
  })
  // 获取检定方式
  getDictByCode('measureType').then((response) => {
    mesureTypeList.value = response.data
  })
  // 获取专业分类
  getDictByCode('majorCategory').then((response) => {
    majorCategoryList.value = response.data
  })
  // 获取检定结果
  getDictByCode('mesureResult').then((response) => {
    mesureResultList.value = response.data
  })
  // 获取设备类别
  getDictByCode('equipmentCategory').then((response) => {
    equipmentCategoryList.value = response.data
  })
  // 获取设备类型
  getDictByCode('equipmentType').then((response) => {
    equipmentTypeList.value = response.data
  })
  // 获取管理级别
  getDictByCode('managerLevel').then((response) => {
    managerLevelList.value = response.data
  })
  // 获取折旧方法
  getDictByCode('depreciationMethod').then((response) => {
    depreciationMethodList.value = response.data
  })
  // 获取管理状态
  getDictByCode('managerState').then((response) => {
    managerStateList.value = response.data
  })
  // 获取资本来源
  getDictByCode('capitalSource').then((response) => {
    capitalSourceList.value = response.data
  })
  // 获取用户列表
  getUserList({ offset: 1, limit: 99999 }).then((res) => {
    usePersonList.value = res.data.rows
  })
  // 获取部门列表
  getDeptTreeList().then((res) => {
    // 转成树结构
    useDeptList.value = toTreeList(res.data, '0', true)
  })
}
// 重置
const resetData = () => {
  ruleForm.value = {
    assetNo: '', // 资产编号
    assetType: '', // 资产类型
    assetSource: '', // 资产来源
    equipmentNo: '', // 设备编号
    equipmentName: '', // 设备名称
    labelBind: '', // 标签绑定
    modelNo: '', // 型号
    equipmentSpecifications: '', // 设备规格
    equipmentType: '', // 设备类型
    equipmentCategory: '', // 设备类别
    capitalSource: '', // 资本来源
    managerLevel: '', // 管理级别
    purpose: '', // 用途
    technicalLevel: '', // 技术水平
    intactState: '', // 完好状态
    manufacturerCountry: '', // 厂家国别
    manufacturer: '', // 生产厂家
    overallDimension: '', // 外形尺寸
    manufacturingNo: '', // 出厂编号
    manufacturingDate: '', // 出厂年月
    cardEstablishmentDate: '', // 立卡年月
    weight: '', // 重量
    enableDate: '', // 启用年月
    singlePrice: '', // 单价
    installIncidentalExpenses: '', //	安装及杂费
    originValue: '', //	原值
    useDept: '', //	使用部门
    installPlace: '', //	安装地点
    depreciationPeriod: '', //	折旧年限
    depreciationMethod: '', //	折旧方法
    attribute: '', //	属性
    majorCategory: '', //	专业分类
    presentOriginValue: '', //	目前原值
    managerState: '1', //	管理状态
    fileList: [], //	说明书
    remark: '', //	备注
    mesureType: '', //	检定方式
    mesureRange: '', //	测量范围
    uncertainty: '', //	不确定度
    usePerson: '', //	使用人
    mesureDept: '', //	检定部门
    mesureCycle: 24, //	检定周期
    mesureDate: '', //	检定日期
    validDate: '', //	有效日期
    mesureResult: '', //	检定结果
    abc: '', //	ABC
    isCalibrationTestEquipment: '', //	是否是技术指标需要校准检定的设备
    isMeasureAccount: '', //	是否是测量工装台账
    isStandardSupportEquipment: '', //		是否标准配套设备
    isFixedAssets: '1', // 是否加入固定资产台账
    id: '',
    supportStandardEquipmentName: '',
    supportStandardEquipmentNo: '',
    version: '',
  }
  ruleForm.value.assetType = props.name !== '固定资产' ? '1' : ''
}
// 提交-父组件调用
const submitForm = () => {
  ruleFormRef.value?.validate((valid: boolean) => {
    if (valid) {
      ElMessageBox.confirm(
        '确认保存吗？',
        '提示',
        {
          confirmButtonText: '确认',
          cancelButtonText: '取消',
          type: 'warning',
        },
      ).then(() => {
        if (props.title == 'add') {
          assetsAddApi(ruleForm.value).then((res) => {
            ElMessage.success('保存成功')
            $router.go(-1)
          })
        }
        else if (props.title == 'edit') {
          assetsUpdateApi(ruleForm.value).then((res) => {
            ElMessage.success('保存成功')
            $router.go(-1)
          })
        }
      })
    }
  })
}
defineExpose({ submitForm })

const fileRef = ref() // 文件上传input
const onFileChange = (event: any) => {
  // 原生上传
  // console.log(event.target.files)
  if (event.target.files?.length !== 0) {
    // 创建formdata对象
    const fd = new FormData()
    fd.append('multipartFile', event.target.files[0])
    const loading = ElLoading.service({
      lock: true,
      background: 'rgba(255, 255, 255, 0.8)',
    })
    UploadFile(fd).then((res) => {
      if (res.code === 200) {
        console.log(res.data[0])
        // 重置当前验证
        ruleForm.value.fileList = []
        ruleForm.value.fileList.push({
          assetId: '',
          fileName: res.data[0],
          minioFileName: res.data[0],
          // id: '',
        })
        ruleFormRef.value?.clearValidate('minioFileName')
        ElMessage.success('文件上传成功')
        loading.close()
      }
      else {
        ElMessage.error(res.message)
        loading.close()
      }
    })
  }
}
const upload = () => {
  fileRef.value.click()
}

watch(() => props.row, (newVal) => {
  if (props.title !== 'add' && newVal) {
    ruleForm.value = newVal as fixedAssetsType
  }
  ruleFormRef.value?.resetFields()
})

watch(() => props.title, (newVal) => {
  if (newVal == 'add') {
    resetData()
    if (props.name == '校准检定设备') {
      ruleForm.value.isCalibrationTestEquipment = '1'
    }
    else if (props.name === '测量工装') {
      ruleForm.value.isMeasureAccount = '1'
    }
    else if (props.name === '标准配套设备') {
      ruleForm.value.isStandardSupportEquipment = '1'
    }
  }
  title.value = newVal
  isDetail.value = newVal == 'detail'
}, { immediate: true })
onMounted(() => {
  fetchData()
})
</script>

<template>
  <div class="body-container">
    <el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" label-position="right" label-width="110px" class="form" :class="[title === 'detail' ? 'isDetail' : '']" :disabled="isDetail" :hide-required-asterisk="title === 'detail'">
      <el-row :gutter="24" class="marg">
        <el-col v-if="showAssetsItem" :span="6">
          <el-form-item label="资产编号" prop="assetNo">
            <el-input v-model.trim="ruleForm.assetNo" placeholder="系统自动生成" disabled />
          </el-form-item>
        </el-col>
        <el-col v-if="showAssetsItem" :span="6">
          <el-form-item label="资产类型" prop="assetType">
            <el-select v-model="ruleForm.assetType" :placeholder="title === 'detail' ? '' : '资产类型'" :disabled="title === 'detail'" clearable style="width: 100%;">
              <el-option v-for="item in assetTypeList" :key="item.id" :label="item.name" :value="item.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="设备编号" prop="equipmentNo">
            <el-input v-model.trim="ruleForm.equipmentNo" placeholder="系统自动生成" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="设备名称" prop="equipmentName">
            <el-input v-model.trim="ruleForm.equipmentName" :placeholder="title === 'detail' ? '' : '设备名称'" :disabled="isDetail" />
          </el-form-item>
        </el-col>
        <el-col v-if="!showAssetsItem" :span="6">
          <el-form-item label="" label-width="50">
            <el-checkbox v-model="ruleForm.isFixedAssets" true-label="1" :false-label="0" label="加入固定资产台账" :disabled="isDetail" />
          </el-form-item>
        </el-col>
        <el-col v-if="!showAssetsItem && ruleForm.isFixedAssets === '1'" :span="6">
          <el-form-item label="资产编号" prop="assetNo">
            <el-input v-model.trim="ruleForm.assetNo" placeholder="系统自动生成" disabled />
          </el-form-item>
        </el-col>
      </el-row>
      <!-- 只有资产类型是固定资产3的时候不显示 -->
      <el-row v-if="ruleForm.assetType !== '3'" :gutter="24" class="marg">
        <el-col :span="6">
          <el-form-item label="生产厂家" :prop="ruleForm.assetType !== '3' ? '' : 'manufacturer'">
            <el-input v-model.trim="ruleForm.manufacturer" :placeholder="title === 'detail' ? '' : '生产厂家'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="厂家国别" prop="manufacturerCountry">
            <el-select v-model="ruleForm.manufacturerCountry" :placeholder="title === 'detail' ? ' ' : '厂家国别'" :disabled="title === 'detail'" clearable style="width: 100%;" filterable>
              <el-option v-for="country of countries" :key="country.code" :label="country.CNName" :value="country.code" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="出厂编号" :prop="ruleForm.assetType !== '3' ? '' : 'manufacturingNo'">
            <el-input v-model.trim="ruleForm.manufacturingNo" :placeholder="title === 'detail' ? '' : '出厂编号'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="出厂年月" prop="manufacturingDate">
            <el-date-picker
              v-model="ruleForm.manufacturingDate" type="month" format="YYYY-MM" value-format="YYYY-MM-DD HH:mm:ss" :disabled="title === 'detail'"
              :placeholder="title === 'detail' ? '' : '出厂年月'"
              style="width: 100%;"
            />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="24" class="marg">
        <el-col v-if="ruleForm.assetType !== '3'" :span="6">
          <el-form-item label="型号" :prop="ruleForm.assetType !== '3' ? '' : 'modelNo'">
            <el-input v-model.trim="ruleForm.modelNo" :placeholder="title === 'detail' ? '' : '型号'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
        <el-col v-if="ruleForm.assetType !== '3'" :span="6">
          <el-form-item label="管理状态" prop="managerState">
            <el-select v-model="ruleForm.managerState" :placeholder="title === 'detail' ? '' : '管理状态'" :disabled="title === 'detail'" clearable style="width: 100%;">
              <el-option v-for="item in managerStateList" :key="item.id" :label="item.name" :value="item.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col v-if="ruleForm.assetType === '1'" :span="6">
          <!-- 只有测量设备显示ABC -->
          <el-form-item label="ABC" prop="abc">
            <el-select v-model="ruleForm.abc" :placeholder="title === 'detail' ? '' : 'ABC'" :disabled="title === 'detail'" style="width: 100%;">
              <el-option v-for="item in ABCList" :key="item.id" :label="item.name" :value="item.name" />
            </el-select>
          </el-form-item>
        </el-col>

        <el-col v-if="ruleForm.assetType === '1'" :span="6">
          <el-form-item label="测量范围" prop="mesureRange">
            <el-input v-model.trim="ruleForm.mesureRange" :placeholder="title === 'detail' ? '' : '测量范围'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
        <el-col v-if="ruleForm.assetType === '1'" :span="6">
          <el-form-item label="不确定度" prop="uncertainty">
            <el-input v-model.trim="ruleForm.uncertainty" :placeholder="title === 'detail' ? '' : '不确定度'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
        <el-col v-if="showAssetsItem" :span="6">
          <el-form-item v-if="ruleForm.assetType !== '3'" label="立卡年月" prop="cardEstablishmentDate">
            <el-date-picker
              v-model="ruleForm.cardEstablishmentDate" type="date" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" :disabled="title === 'detail'"
              :placeholder="title === 'detail' ? '' : '立卡年月'"
              style="width: 100%;"
            />
          </el-form-item>
          <!-- <el-form-item v-if="!showAssetsItem" label="原值" prop="originValue">
            <el-input v-model.trim="ruleForm.originValue" :placeholder="title === 'detail' ? '' : '原值'" :disabled="title === 'detail'" />
          </el-form-item> -->
        </el-col>
        <el-col v-if="ruleForm.assetType !== '3'" :span="6">
          <el-form-item label="启用日期" prop="enableDate">
            <el-date-picker
              v-model="ruleForm.enableDate" type="date" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" :disabled="title === 'detail'"
              :placeholder="title === 'detail' ? '' : '启用日期'"
              style="width: 100%;"
            />
          </el-form-item>
        </el-col>
        <el-col v-if="ruleForm.assetType === '1'" :span="6">
          <el-form-item label="检定方式" prop="mesureType">
            <el-select v-model="ruleForm.mesureType" :placeholder="title === 'detail' ? ' ' : '检定方式'" :disabled="title === 'detail'" style="width: 100%;">
              <el-option v-for="item in mesureTypeList" :key="item.id" :label="item.name" :value="item.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col v-if="ruleForm.assetType === '1'" :span="6">
          <el-form-item label="强制检定" prop="compulsoryVerification">
            <el-select v-model="ruleForm.compulsoryVerification" :placeholder="title === 'detail' ? ' ' : '强制检定'" :disabled="title === 'detail'" style="width: 100%;">
              <el-option label="是" value="1" />
              <el-option label="否" value="0" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col v-if="ruleForm.assetType === '1'" :span="6">
          <el-form-item label="检定周期(月)" prop="mesureCycle">
            <el-input-number v-model="ruleForm.mesureCycle" style="width: 100%;" :min="12" :max="60" :step="12" :disabled="title === 'detail'" />
            <!-- <el-select v-model="ruleForm.mesureCycle" :placeholder="title === 'detail' ? '' : '检定周期'" clearable style="width: 100%;">
              <el-option v-for="item in mesureCycleList" :key="item.id" :label="item.name" :value="item.value" />
            </el-select> -->
          </el-form-item>
        </el-col>
        <el-col v-if="ruleForm.assetType === '1'" :span="6">
          <el-form-item label="使用部门" prop="useDept">
            <dept-select v-model="ruleForm.useDept" :data="useDeptList" :placeholder="title === 'detail' ? ' ' : '使用部门'" />
          </el-form-item>
        </el-col>
        <el-col v-if="ruleForm.assetType === '1'" :span="6">
          <el-form-item label="使用人" prop="usePerson">
            <el-select v-model="ruleForm.usePerson" filterable :placeholder="title === 'detail' ? ' ' : '使用人'" :disabled="title === 'detail'" style="width: 100%;">
              <el-option v-for="item in usePersonList" :key="item.id" :label="item.name" :value="item.id" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col v-if="showAssetsItem" :span="6">
          <el-form-item v-if="ruleForm.assetType !== '3'" label="专业分类" prop="majorCategory">
            <el-select v-model="ruleForm.majorCategory" :placeholder="title === 'detail' ? '' : '专业分类'" :disabled="title === 'detail'" style="width: 100%;">
              <el-option v-for="item in majorCategoryList" :key="item.id" :label="item.name" :value="item.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col v-if="ruleForm.assetType === '1'" :span="6">
          <el-form-item label="检定部门" prop="mesureDeptName">
            <el-input v-model.trim="ruleForm.mesureDeptName" :placeholder="title === 'detail' ? '' : '检定部门'" :disabled="title === 'detail'" />
          </el-form-item>
          <!-- <el-form-item label="检定部门" prop="mesureDept">
            <dept-select v-model="ruleForm.mesureDept" :data="useDeptList" placeholder="检定部门" />
          </el-form-item> -->
        </el-col>
        <el-col v-if="ruleForm.assetType === '1'" :span="6">
          <el-form-item label="检定日期" prop="mesureDate">
            <el-date-picker
              v-model="ruleForm.mesureDate" type="date" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" :disabled="title === 'detail'"
              :placeholder="title === 'detail' ? '' : '检定日期'"
              style="width: 100%;"
            />
          </el-form-item>
        </el-col>
        <el-col v-if="ruleForm.assetType === '1'" :span="6">
          <el-form-item label="有效日期" prop="validDate">
            <el-date-picker
              v-model="ruleForm.validDate" type="date" format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" :disabled="title === 'detail'"
              :placeholder="title === 'detail' ? '' : '有效日期'"
              style="width: 100%;"
            />
          </el-form-item>
        </el-col>
        <el-col v-if="ruleForm.assetType === '1'" :span="6">
          <el-form-item label="检定结果" prop="mesureResult">
            <el-select v-model="ruleForm.mesureResult" :placeholder="title === 'detail' ? ' ' : '检定结果'" :disabled="title === 'detail'" style="width: 100%;">
              <el-option v-for="item in mesureResultList" :key="item.id" :label="item.name" :value="item.value" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row v-if="ruleForm.assetType === '1'" :gutter="24" class="marg">
        <el-col :span="8">
          <el-form-item label="是否是技术指标需要校准/检定的设备" prop="isCalibrationTestEquipment" label-width="280px">
            <el-select v-model="ruleForm.isCalibrationTestEquipment" :placeholder="title === 'detail' ? '' : '是/否'" :disabled="title === 'detail'" style="width: 100%;">
              <el-option v-for="item in isWhether" :key="item.id" :label="item.name" :value="item.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="是否是测量工装台账" prop="isMeasureAccount" label-width="260px">
            <el-select v-model="ruleForm.isMeasureAccount" :placeholder="title === 'detail' ? '' : '是/否'" :disabled="title === 'detail'" style="width: 100%;">
              <el-option v-for="item in isWhether" :key="item.id" :label="item.name" :value="item.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="是否标准配套设备" prop="isStandardSupportEquipment" label-width="260px">
            <el-select v-model="ruleForm.isStandardSupportEquipment" :placeholder="title === 'detail' ? '' : '是/否'" :disabled="title === 'detail'" style="width: 100%;">
              <el-option v-for="item in isWhether" :key="item.id" :label="item.name" :value="item.value" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <!-- 资产类型3是固定资产 -->
      <el-row v-if="showAssetsItem || ruleForm.isFixedAssets === '1'" :gutter="24" class="marg">
        <!-- 资产类型：1测量设备、2办公用品、3固定资产、255其他 -->
        <el-col :span="6">
          <el-form-item label="资产来源" prop="assetSource">
            <el-input v-model.trim="ruleForm.assetSource" :placeholder="title === 'detail' ? '' : '资产来源'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="设备规格" prop="equipmentSpecifications">
            <el-input v-model.trim="ruleForm.equipmentSpecifications" :placeholder="title === 'detail' ? '' : '设备规格'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="设备类别" prop="equipmentCategory">
            <el-select v-model="ruleForm.equipmentCategory" :placeholder="title === 'detail' ? ' ' : '设备类别'" :disabled="title === 'detail'" style="width: 100%;">
              <el-option v-for="item in equipmentCategoryList" :key="item.id" :label="item.name" :value="item.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="设备类型" prop="equipmentType">
            <el-select v-model="ruleForm.equipmentType" :placeholder="title === 'detail' ? ' ' : '设备类型'" :disabled="title === 'detail'" style="width: 100%;">
              <el-option v-for="item in equipmentTypeList" :key="item.id" :label="item.name" :value="item.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="资本来源" prop="capitalSource">
            <el-select v-model="ruleForm.capitalSource" :placeholder="title === 'detail' ? ' ' : '资本来源'" :disabled="title === 'detail'" style="width: 100%;">
              <el-option v-for="item in capitalSourceList" :key="item.id" :label="item.name" :value="item.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="管理级别" prop="managerLevel">
            <el-select v-model="ruleForm.managerLevel" :placeholder="title === 'detail' ? ' ' : '管理级别'" :disabled="title === 'detail'" style="width: 100%;">
              <el-option v-for="item in managerLevelList" :key="item.id" :label="item.name" :value="item.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="用途" prop="purpose">
            <el-input v-model.trim="ruleForm.purpose" :placeholder="title === 'detail' ? '' : '用途'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="技术水平" prop="technicalLevel">
            <el-input v-model.trim="ruleForm.technicalLevel" :placeholder="title === 'detail' ? '' : '技术水平'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="完好状态" prop="intactState">
            <el-input v-model.trim="ruleForm.intactState" :placeholder="title === 'detail' ? '' : '完好状态'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="外形尺寸" prop="overallDimension">
            <el-input v-model.trim="ruleForm.overallDimension" :placeholder="title === 'detail' ? '' : '外形尺寸'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="重量(吨)" prop="weight">
            <el-input v-model.trim="ruleForm.weight" :placeholder="title === 'detail' ? '' : '重量'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="单价(元)" prop="singlePrice">
            <el-input v-model.trim="ruleForm.singlePrice" :placeholder="title === 'detail' ? '' : '单价'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="安装及杂费(元)" prop="installIncidentalExpenses">
            <el-input v-model.trim="ruleForm.installIncidentalExpenses" :placeholder="title === 'detail' ? '' : '安装及杂费'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="安装地点" prop="installPlace">
            <el-input v-model.trim="ruleForm.installPlace" :placeholder="title === 'detail' ? '' : '安装地点'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="原值" prop="originValue">
            <el-input v-model.trim="ruleForm.originValue" :placeholder="title === 'detail' ? '' : '原值'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="目前原值" prop="presentOriginValue">
            <el-input v-model.trim="ruleForm.presentOriginValue" :placeholder="title === 'detail' ? '' : '目前原值'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="折旧年限" prop="depreciationPeriod">
            <el-input v-model.trim="ruleForm.depreciationPeriod" :placeholder="title === 'detail' ? '' : '折旧年限'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="折旧方法" prop="depreciationMethod">
            <el-select v-model="ruleForm.depreciationMethod" :placeholder="title === 'detail' ? ' ' : '折旧方法'" :disabled="title === 'detail'" style="width: 100%;">
              <el-option v-for="item in depreciationMethodList" :key="item.id" :label="item.name" :value="item.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="属性" prop="attribute">
            <el-input v-model.trim="ruleForm.attribute" :placeholder="title === 'detail' ? ' ' : '属性'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="24" class="marg">
        <el-col :span="12">
          <el-form-item label="备注" prop="remark">
            <el-input v-model.trim="ruleForm.remark" :rows="3" type="textarea" autosize :placeholder="title === 'detail' ? ' ' : '备注'" :disabled="title === 'detail'" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="24" class="marg">
        <el-col :span="6">
          <el-form-item label="标签绑定" prop="labelBind">
            <el-input v-model.trim="ruleForm.labelBind" disabled :placeholder="title === 'detail' ? ' ' : '请点击扫描'" clearable>
              <template #append>
                <el-button type="primary" size="small">
                  扫描
                </el-button>
              </template>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="24" class="marg">
        <el-col :span="24">
          <el-form-item label="说明书" prop="minioFileName">
            <show-photo v-if="ruleForm.fileList.length > 0" :minio-file-name="ruleForm.fileList[0]?.minioFileName || ''" />
            <input ref="fileRef" style="width: 0;overflow: hidden;" type="file" @change="onFileChange">
            <el-button v-if="!isDetail" type="primary" :style="{ 'margin-left': ruleForm.fileList.length > 0 ? '20px' : '0px' }" @click="upload">
              {{ ruleForm.fileList[0]?.minioFileName ? '更换' : '上传' }}
            </el-button>
            <span v-if="isDetail && ruleForm.fileList.length === 0">暂无</span>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<style lang="scss" scoped>
// 样式
</style>
