liding
2026-09-28 f03cf23f3acbd5582a16c263aa6bf83b260ec906
src/views/business/inspectionTask/components/InspectionWord.vue
@@ -33,11 +33,6 @@
                style="width: 90px" @change="m => subOtherForm(m, 'temperature')"></el-input>
              <span class="template-panel__unit">℃</span>
            </el-form-item>
            <el-form-item label="湿度:">
              <el-input v-model="currentOtherForm.humidity" :disabled="state > 1" placeholder="" size="small"
                style="width: 90px" @change="m => subOtherForm(m, 'humidity')"></el-input>
              <span class="template-panel__unit">%RH</span>
            </el-form-item>
            <el-form-item label="检测时间:">
              <el-date-picker v-model="currentOtherForm.detectionTime" :disabled="state > 1" type="date"
                value-format="yyyy-MM-dd" placeholder="请选择日期" size="small" style="width: 160px"
@@ -115,9 +110,9 @@
                      </el-select>
                    </template>
                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '计算值' && state == 1"><span
                        :style="`font-family:${n.v.ff} !important;`">{{ toFixed(n.v.v, n.v.ct) }}</span></template>
                        :style="`font-family:${n.v.ff} !important;`">{{ n.v.v }}</span></template>
                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '最终值' && state == 1">
                      <span :style="`font-family:${n.v.ff} !important;`">{{ toFixed(n.v.v, n.v.ct) }}</span>
                      <span :style="`font-family:${n.v.ff} !important;`">{{ n.v.v }}</span>
                    </template>
                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '样品编号'">
                      <div :title="currentSample.sampleCode"
@@ -383,7 +378,7 @@
      numOptions: [],
      temperatureOptions: [],
      wareTableData: [],
      // 检测条件按模板 id 分组:{ [templateId]: { temperature, humidity, detectionTime, detectionPlace, deviceIds } }
      // 检测条件按模板 id 分组:{ [templateId]: { temperature, detectionTime, detectionPlace, deviceIds } }
      otherForm: {},
      deviceOptions: [],
      equipForm: {
@@ -465,7 +460,6 @@
    currentOtherForm() {
      return this.otherForm[this.currentTable] || {
        temperature: null,
        humidity: null,
        detectionTime: null,
        detectionPlace: null,
        deviceIds: [],
@@ -512,7 +506,6 @@
        conditionList.forEach(item => {
          this.$set(this.otherForm, item.templateId, {
            temperature: item.temperature != null ? item.temperature : null,
            humidity: item.humidity != null ? item.humidity : null,
            detectionTime: item.detectionTime != null ? item.detectionTime : null,
            detectionPlace: item.detectionPlace != null ? item.detectionPlace : null,
            deviceIds: Array.isArray(item.deviceIds) ? [...item.deviceIds] : [],
@@ -577,7 +570,7 @@
            if (this.tableLists && this.tableLists.length > 0) {
              this.tableList = null;
              this.tableList = this.tableLists.filter(m => m.templateId == val1)
              // 模板集合可能变化,补齐温度、湿度槽位
              // 模板集合可能变化,补齐温度槽位
              this.tableLists.forEach(m => this.ensureOtherForm(m.templateId))
              // 对模板进行处理
              this.handleTableData()
@@ -910,7 +903,7 @@
        this.tableList = null;
        this.tableList = [this.tableLists[0]]
        this.currentTable = this.tableLists[0].templateId;
        // 补齐每个模板的温度、湿度槽位
        // 补齐每个模板的温度槽位
        this.tableLists.forEach(m => this.ensureOtherForm(m.templateId))
        // 处理页面列表数据
        this.handleTableData()
@@ -941,7 +934,7 @@
        this.tableList = [this.tableLists[0]]
        this.currentTable = this.tableLists[0].templateId;
        this.currentSample.insProduct = this.HaveJson(list)
        // 补齐每个模板的温度、湿度槽位
        // 补齐每个模板的温度槽位
        this.tableLists.forEach(m => this.ensureOtherForm(m.templateId))
        // 处理页面列表数据
        this.handleTableData()
@@ -1242,13 +1235,6 @@
    getValue(v) {
      // 对页面展示数据进行处理,@,代表换行
      let str = v.v ? v.v : (v.v === 0 ? v.v : (v.ct && v.ct.s ? v.ct.s.length > 0 && v.ct.s[0].v.replace(new RegExp('\n', 'g'), '<br/>').replace(new RegExp('@', 'g'), '<br/>') : ''))
      // 对数据保留小数点进行处理
      if (v.ct && v.ct.fa && v.ct.fa.includes('.') && str) {
        let num = 0
        let str0 = v.ct.fa.split('.')[1]
        num = str0.length
        str = Number(str).toFixed(num)
      }
      if (v.v && typeof v.v == 'string' && v.v.includes('@')) {
        str = v.v.replace(new RegExp('@', 'g'), '<br/>')
      }
@@ -1435,7 +1421,6 @@
      if (!this.otherForm[templateId]) {
        this.$set(this.otherForm, templateId, {
          temperature: null,
          humidity: null,
          detectionTime: null,
          detectionPlace: null,
          deviceIds: [],
@@ -1469,7 +1454,6 @@
      this.tableLists.forEach(m => {
        const form = this.otherForm[m.templateId] || {}
        if (!form.temperature) missing.push(`请填写「${m.templateName}」的温度`)
        if (!form.humidity) missing.push(`请填写「${m.templateName}」的湿度`)
        if (!form.detectionTime) missing.push(`请选择「${m.templateName}」的检测时间`)
        if (!form.detectionPlace) missing.push(`请填写「${m.templateName}」的检测地点`)
        if (!form.deviceIds || form.deviceIds.length === 0) {
@@ -1739,26 +1723,6 @@
      }).catch(error => {
      })
    },
    /**
     * 将数值v保留ct.fa中'##'后的指定小数位数,并返回格式化后的字符串。
     *
     * @param v 要格式化的数值
     * @param ct 包含格式化配置的对象
     * @param ct.fa 格式化配置字符串,若包含'##'则按照其后的内容确定小数位数
     * @returns 格式化后的字符串或原始数值(若配置不符合要求)
     */
    toFixed(v, ct) {
      if (v && ct && ct.fa) {
        if (ct.fa.includes('.')) {
          let num = ct.fa.slice(4).length
          return Number(v).toFixed(num)
        } else {
          return v
        }
      } else {
        return v
      }
    }
  }
}