<style>
.bg {
  background-color: blue;
  height: 1px;
  border: 0;
}

.app-row {
  background-color: white;
  padding: 10px 10px 0 10px;
  border-bottom: 1px solid rgba(235, 235, 235, 0.5);
}

.search_input {
  border: 0;
  outline: none;
}

.font {
  font: 15px PingFang-SC-Medium;
  color: #666666;
}

.input-font {
  font: 15px PingFang-SC-Medium;
  color: #333333;
}

.btn-font {
  font: 600 16px PingFang-SC-Bold;
  color: #499EDF;
}

.btn-color {
  background-color: #FFFFFF;
  border-radius: 10px;
  border: 1px solid #499EDF;
}

.app-text {
  font-size: 12px;
}

.panel-self {
  border-radius: 10px;
  border: 1px solid #499EDF;
  background-color: #F8F8F8;
}

.yybtn-color {
  background-color: #499edf;
  border-radius: 4px;
  border: 1px solid #499EDF;
  color: #FFFFFF;
  font: 14px PingFang-SC-Bold;
}

.qxbtn-color {
  background-color: #FFFFFF;
  border-radius: 4px;
  color: #499edf;
  font: 14px PingFang-SC-Bold;
  border: 1px solid #499EDF;
}

/* 星级用户 → 橙黄边框 */
.panel-orange {
  border: 2px solid #FFA940 !important; /* 橙黄色 */
  border-radius: 10px;
}

/* 行业内用户 → 天蓝色边框 */
.panel-sky {
  border: 2px solid #40A9FF !important; /* 天蓝色 */
  border-radius: 10px;
}

/* 职工用户 → 绿色边框 */
.panel-green {
  border: 2px solid #52C41A !important; /* 绿色 */
  border-radius: 10px;
}
</style>

<style scoped>
form .app-row {
  height: 46px;
}

#check /deep/ .nav-tabs {
  background-color: #fff;
  border-bottom: 1px solid #ddd;
}

#check /deep/ .nav-tabs > li {
  width: 25%;
  text-align: center;
}

#check /deep/ .nav-tabs > li > a {
  margin-right: 0;
  border: none;
  color: #666;
  padding: 12px 0;
}

#check /deep/ .nav-tabs > li.active > a {
  color: #499EDF;
  border-bottom: 2px solid #499EDF;
  background-color: transparent;
}

.panel-body.row {
  display: flex;
  flex-wrap: wrap;
  padding-top: 15px;
}

.panel-body.row::before, .panel-body.row::after {
  display: none;
}

.info-suffix-inline {
  position: absolute;
  left: 0;
  top: 100%;
  font-size: 11px;
  color: #999;
  white-space: nowrap;
  line-height: 1;
  padding-top: 2px;
  z-index: 1;
}

.form-group-flex {
  display: flex;
  align-items: center;
  margin-bottom: 25px; /* 增加间距以容纳 info-suffix-inline */
  float: none !important; /* 禁用浮动，防止干扰 flex */
  min-height: 34px; /* 保证即便没内容也有高度 */
}

.form-group-flex label {
  width: 160px; /* 微调宽度，平衡长短标签 */
  flex-shrink: 0;
  margin-bottom: 0;
  font-weight: normal;
  text-align: right; /* 标签右对齐 */
  padding-right: 10px;
  line-height: 1.2;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
}

.form-group-flex input,
.form-group-flex .v-select {
  flex-grow: 1;
  width: 100%; /* 确保填满剩余空间 */
}

.form-group-flex textarea {
  flex-grow: 1;
}

.form-group-flex span {
  margin-left: 5px;
  white-space: nowrap; /* 防止单位换行 */
}

.full-width {
  width: 100% !important;
}
</style>
<template>
  <div class="flex auto" style="background-color: #f6fbff">
    <div class="auto">
      <label>验收单</label>
    </div>
    <div id="check" class="RegulatorType auto">
      <tabset v-ref:tabs :close="false">
        <tab header="验收信息">
          <div class="panel panel-default">
            <div class="panel-heading">验收信息</div>
            <div class="panel-body row">
              <div class="col-xs-6 form-group-flex">
                <label>卡号：</label>
                <div style="display: flex; flex-grow: 1; align-items: center;">
                  <input v-model="model.card_no" type="text" class="form-control" style="flex: 1; min-width: 0;">
                  <button class="btn btn-default" @click="findUser" style="margin-left: 5px; padding: 6px 8px;">查找
                  </button>
                </div>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>用户姓名：</label>
                <input v-model="model.user_name" type="text" class="form-control">
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>用户电话：</label>
                <input v-model="model.user_phone" type="text" class="form-control">
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>燃气负责人：</label>
                <input v-model="model.gas_manager" type="text" class="form-control">
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>安全员联系电话：</label>
                <input v-model="model.safety_manager_phone" type="text" class="form-control">
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>用气单位全称：</label>
                <input v-model="model.company_full_name" type="text" class="form-control">
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>详细地址：</label>
                <input v-model="model.detailed_address" type="text" class="form-control">
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>验收用气区域（点）：</label>
                <v-select v-model="model.gas_area" :options="options.gas_area" :value-single="true" placeholder="请选择"
                          class="full-width"></v-select>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>所属区域：</label>
                <v-select v-model="model.affiliated_area" :options="options.affiliated_area" :value-single="true"
                          placeholder="请选择" class="full-width"></v-select>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>施工单位：</label>
                <v-select v-model="model.construction_company" :options="options.construction_company"
                          :value-single="true" placeholder="请选择" class="full-width"></v-select>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>施工方联系人：</label>
                <input v-model="model.construction_contact" type="text" class="form-control">
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>施工方联系电话：</label>
                <input v-model="model.construction_phone" type="text" class="form-control">
              </div>
            </div>
          </div>
        </tab>

        <tab header="基本信息">
          <div class="panel panel-default">
            <div class="panel-heading">基本信息</div>
            <div class="panel-body row">
              <div class="col-xs-6 form-group-flex">
                <label>用气性质：</label>
                <v-select v-model="model.gas_nature" :options="options.gas_nature" :value-single="true"
                          placeholder="请选择" class="full-width"></v-select>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>用户类型：</label>
                <v-select v-model="model.user_type" :value.sync="model.user_type" :options="options.user_type"
                          :value-single="true"
                          placeholder="请选择" class="full-width"></v-select>
              </div>
              <div class="col-xs-6 form-group-flex" v-show="isEqual(model.user_type, '锅炉')">
                <label>锅炉设备用途：</label>
                <v-select v-model="model.boiler_usage" :options="options.boiler_usage" :multiple="true"
                          placeholder="可多选" class="full-width"></v-select>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>室内管道总长：</label>
                <input v-model="model.indoor_pipeline_length" type="text" class="form-control">
                <span>米</span>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>表前明细：</label>
                <input v-model="model.pre_meter_details" type="text" class="form-control">
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>室内球阀总数量：</label>
                <input v-model="model.indoor_ball_valve_quantity" type="text" class="form-control">
                <span>个</span>
              </div>
            </div>
          </div>
        </tab>

        <tab header="低压验收信息">
          <div class="panel panel-default">
            <div class="panel-heading">低压验收信息</div>
            <div class="panel-body row">
              <div class="col-xs-6 form-group-flex">
                <label>验收时间：</label>
                <input v-model="model.acceptance_time" type="datetime-local" class="form-control">
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>外观状态：</label>
                <v-select v-model="model.appearance_status" :options="options.appearance_status" :value-single="true"
                          placeholder="请选择" class="full-width"></v-select>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>挂压次数：</label>
                <v-select v-model="model.pressure_test_count" :options="options.pressure_test_count"
                          :value-single="true" placeholder="请选择" class="full-width"></v-select>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>挂压时长：</label>
                <input v-model="model.pressure_test_duration" type="text" class="form-control">
                <span>分钟</span>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>挂压数据：≥</label>
                <input v-model="model.pressure_test_data" type="text" class="form-control">
                <span>Pa</span>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>气密性试验：</label>
                <v-select v-model="model.air_tightness_test" :options="options.air_tightness_test" :value-single="true"
                          placeholder="请选择" class="full-width"></v-select>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>熄火保护状态：</label>
                <v-select v-model="model.flameout_protection_status" :options="options.flameout_protection_status"
                          :value-single="true" placeholder="请选择" class="full-width"></v-select>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>暗厨情况：</label>
                <v-select v-model="model.dark_kitchen_situation" :options="options.dark_kitchen_situation"
                          :value-single="true" placeholder="请选择" class="full-width"></v-select>
              </div>
            </div>
          </div>

          <div class="panel panel-default">
            <div class="panel-heading">计量表信息
              <button class="btn btn-default" style="margin-left: 10px;" @click="addMeter">添加计量表</button>
            </div>
            <div class="panel-body row">
              <div v-for="(meter, idx) in model.meters" class="col-xs-12"
                   style="border: 1px solid #eee; border-radius: 6px; padding: 10px; margin-bottom: 10px;">
                <div class="col-xs-12" style="text-align: right; margin-bottom: 10px;">
                  <button class="btn btn-default" @click="removeMeter(idx)">删除</button>
                </div>
                <div class="col-xs-6 form-group-flex">
                  <label>卡号：</label>
                  <div style="display: flex; flex-grow: 1; align-items: center;">
                    <input v-model="model.card_no" type="text" class="form-control">
                    <button class="btn btn-default" @click="findUser" style="margin-left: 5px; padding: 6px 8px;">查找
                    </button>
                  </div>
                </div>
                <div class="col-xs-6 form-group-flex">
                  <label>基表编号：</label>
                  <input v-model="meter.base_meter_no" type="text" class="form-control">
                </div>
                <div class="col-xs-6 form-group-flex">
                  <label>安装底数：</label>
                  <input v-model="meter.new_meter_reading" type="text" class="form-control">
                </div>
                <div class="col-xs-6 form-group-flex">
                  <label>基表类型：</label>
                  <v-select v-model="meter.base_meter_type" :value.sync="meter.base_meter_type"
                            :options="options.base_meter_type" :value-single="true"
                            class="full-width"></v-select>
                </div>
                <div class="col-xs-6 form-group-flex">
                  <label>基表型号：</label>
                  <v-select v-model="meter.base_meter_model" :options="options.base_meter_model" :value-single="true"
                            class="full-width"></v-select>
                </div>
                <div class="col-xs-6 form-group-flex">
                  <label>基表厂家：</label>
                  <v-select v-model="meter.base_meter_manufacturer" :options="options.base_meter_manufacturer"
                            :value-single="true" class="full-width"></v-select>
                </div>
                <div class="col-xs-12" style="border-top: 1px dashed #ddd; margin: 10px 0;"></div>
                <div class="col-xs-6 form-group-flex"
                     v-show="isEqual(meter.base_meter_type, '罗茨') || isEqual(meter.base_meter_type, '涡轮')">
                  <label>表前编码：</label>
                  <input v-model="meter.pre_meter_code" type="text" class="form-control">
                </div>
                <div class="col-xs-6 form-group-flex"
                     v-show="isEqual(meter.base_meter_type, '罗茨') || isEqual(meter.base_meter_type, '涡轮')">
                  <label>表具编码：</label>
                  <input v-model="meter.meter_code" type="text" class="form-control">
                </div>
                <div class="col-xs-6 form-group-flex" v-show="isEqual(meter.base_meter_type, '皮膜')">
                  <label>表封编码：</label>
                  <input v-model="meter.meter_seal_code" type="text" class="form-control">
                </div>
                <div class="col-xs-6 form-group-flex">
                  <label>计数器编码：</label>
                  <input v-model="meter.counter_code" type="text" class="form-control">
                </div>
                <div class="col-xs-6 form-group-flex">
                  <label>小表钢封码：</label>
                  <input v-model="meter.small_meter_steel_seal_code" type="text" class="form-control">
                </div>
              </div>
            </div>
          </div>

          <div class="panel panel-default">
            <div class="panel-heading">表后管道信息</div>
            <div class="panel-body row">
              <div class="col-xs-6 form-group-flex">
                <label>表后管道规格：</label>
                <v-select v-model="model.post_meter_pipe_spec" :options="options.post_meter_pipe_spec" :multiple="true"
                          class="full-width"></v-select>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>表后管材质：</label>
                <v-select v-model="model.post_meter_pipe_material" :options="options.post_meter_pipe_material"
                          :value-single="true" class="full-width"></v-select>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>表后管道长度：</label>
                <input v-model="model.post_meter_pipe_length" type="text" class="form-control">
                <span>米</span>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>阀门型号：</label>
                <v-select v-model="model.valve_model" :options="options.valve_model" :multiple="true"
                          class="full-width"></v-select>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>阀门材质：</label>
                <v-select v-model="model.valve_material" :options="options.valve_material" :value-single="true"
                          class="full-width"></v-select>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>阀门数量：</label>
                <input v-model="model.valve_quantity" type="text" class="form-control">
                <span>个</span>
              </div>
            </div>
          </div>

          <div class="panel panel-default">
            <div class="panel-heading">用气设备信息
              <button class="btn btn-default" style="margin-left: 10px;" @click="addEquipment">添加设备</button>
            </div>
            <div class="panel-body row">
              <div v-for="(eq, idx) in model.equipments" class="col-xs-12"
                   style="border: 1px solid #eee; border-radius: 6px; padding: 10px; margin-bottom: 10px;">
                <div class="col-xs-12" style="text-align: right; margin-bottom: 10px;">
                  <button class="btn btn-default" @click="removeEquipment(idx)">删除</button>
                </div>
                <div class="col-xs-6 form-group-flex">
                  <label>设备类型：</label>
                  <v-select v-model="eq.equipment_type" :value.sync="eq.equipment_type" :options="options.equipment_type" :value-single="true"
                            class="full-width"></v-select>
                </div>
                <div class="col-xs-6 form-group-flex">
                  <label>生产厂家：</label>
                  <v-select v-model="eq.manufacturer" :options="options.manufacturer" :value-single="true"
                            class="full-width"></v-select>
                </div>
                <div class="col-xs-6 form-group-flex">
                  <label>用途：</label>
                  <input v-model="eq.usage" type="text" class="form-control">
                </div>
                <div class="col-xs-6 form-group-flex">
                  <label>设备功率：</label>
                  <input v-model="eq.power_value" type="text" class="form-control">
                  <span>{{ getEquipmentUnit(eq.equipment_type) }}</span>
                </div>
              </div>
            </div>
          </div>

          <div class="panel panel-default">
            <div class="panel-heading">报警器信息</div>
            <div class="panel-body row">
              <div class="col-xs-6 form-group-flex">
                <label>生产厂家：</label>
                <v-select v-model="model.alarm_manufacturer" :options="options.manufacturer" :value-single="true"
                          class="full-width"></v-select>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>探头数量：</label>
                <input v-model="model.alarm_probe_count" type="text" class="form-control">
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>安装时间：</label>
                <input v-model="model.alarm_install_date" type="date" class="form-control" @change="updateAlarmExpire">
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>到期时间：</label>
                <input v-model="model.alarm_expire_date" type="date" class="form-control" disabled>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>电磁阀型号DN：</label>
                <v-select v-model="model.alarm_valve_dn" :options="options.valve_model" :value-single="true"
                          class="full-width"></v-select>
              </div>
            </div>
          </div>

          <div class="panel panel-default">
            <div class="panel-heading">其他</div>
            <div class="panel-body row">
              <div class="col-xs-6 form-group-flex">
                <label>安全教育宣传发放：</label>
                <v-select v-model="model.safety_education_brochure" :options="options.safety_education_brochure"
                          :value-single="true" class="full-width"></v-select>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>钢丝锁及表封安装：</label>
                <v-select v-model="model.wire_lock_and_meter_seal" :options="options.wire_lock_and_meter_seal"
                          :value-single="true" class="full-width"></v-select>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>计量表油量：</label>
                <input v-model="model.meter_oil_level" type="text" class="form-control">
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>跑表5分钟试验1：</label>
                <v-select v-model="model.meter_run_test_5min_1" :options="options.meter_run_test" :value-single="true"
                          class="full-width"></v-select>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>跑表5分钟试验2：</label>
                <v-select v-model="model.meter_run_test_5min_2" :options="options.meter_run_test" :value-single="true"
                          class="full-width"></v-select>
              </div>
            </div>
          </div>

          <div class="panel panel-default">
            <div class="panel-heading">验收结论</div>
            <div class="panel-body row">
              <div class="col-xs-6 form-group-flex">
                <label>验收是否通过：</label>
                <v-select v-model="model.acceptance_passed" :options="options.acceptance_passed" :value-single="true"
                          class="full-width"></v-select>
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>客户姓名：</label>
                <input v-model="model.customer_name" type="text" class="form-control">
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>验收日期：</label>
                <input v-model="model.acceptance_date" type="date" class="form-control">
              </div>
              <div class="col-xs-6 form-group-flex">
                <label>验收人员：</label>
                <v-select v-model="model.acceptance_personnel" :options="options.acceptance_personnel"
                          :value-single="true" class="full-width"></v-select>
              </div>
            </div>
          </div>
        </tab>
      </tabset>
    </div>
  </div>
  <back-page :need-back='true' @flag="$back()"></back-page>
</template>

<script>
import LocalPagedList from './LocalPagedList'
import Vue from 'vue'
import {PagedList} from 'vue-client'
import * as Util from '../Util'

export default {
  title: "AcceptanceCheck",
  data() {
    return {
      model: {
        // 验收信息
        card_no: '7000000000',
        user_name: '****',
        user_phone: '13*********',
        gas_manager: '',
        safety_manager_phone: '13*********',
        company_full_name: '',
        detailed_address: '',
        gas_area: '',
        affiliated_area: '',
        construction_company: '',
        construction_company_other: '',
        construction_contact: '',
        construction_phone: '13*********',

        // 基本信息
        gas_nature: '',
        gas_nature_other: '',
        user_type: '',
        user_type_other: '',
        boiler_usage: [],
        boiler_usage_other: '',
        indoor_pipeline_length: '',
        pre_meter_details: '',
        indoor_ball_valve_quantity: '',

        // 低压验收信息
        acceptance_time: (function () {
          const d = new Date()
          const yyyy = d.getFullYear()
          const mm = ('0' + (d.getMonth() + 1)).slice(-2)
          const dd = ('0' + d.getDate()).slice(-2)
          const hh = ('0' + d.getHours()).slice(-2)
          const mi = ('0' + d.getMinutes()).slice(-2)
          return `${yyyy}-${mm}-${dd}T${hh}:${mi}`
        })(),
        appearance_status: '',
        pressure_test_count: '',
        pressure_test_duration: '',
        pressure_test_data: '',
        air_tightness_test: '',
        flameout_protection_status: '',
        dark_kitchen_situation: '',
        gas_area_other: '',
        affiliated_area_other: '',

        // 计量表信息（多块）
        meters: [
          {
            base_meter_no: '',
            new_meter_reading: '',
            base_meter_type: '',
            base_meter_model: '',
            base_meter_manufacturer: '',
            pre_meter_code: '',
            meter_code: '',
            meter_seal_code: '',
            counter_code: '',
            small_meter_steel_seal_code: ''
          }
        ],

        // 表后管道信息
        post_meter_pipe_spec: [],
        post_meter_pipe_material: '',
        post_meter_pipe_length: '',
        valve_model: [],
        valve_material: '',
        valve_quantity: '',

        // 用气设备信息
        equipments: [
          {
            equipment_type: '',
            manufacturer: '',
            usage: '',
            power_value: ''
          }
        ],

        // 其他
        safety_education_brochure: '',
        wire_lock_and_meter_seal: '',
        meter_oil_level: '',
        meter_run_test_5min_1: '',
        meter_run_test_5min_2: '',
        acceptance_passed: '',
        customer_name: '',
        acceptance_date: '',
        acceptance_personnel: '',
        // 报警器信息
        alarm_manufacturer: '',
        alarm_probe_count: '',
        alarm_install_date: '',
        alarm_expire_date: '',
        alarm_valve_dn: '',
      },
      // 下拉选项
      options: {
        gas_area: ['锅炉房', '餐厅', '厂房', '直燃机', '其他'].map(v => ({label: v, value: v})),
        affiliated_area: ['长安', '航天', '高新', '雁塔', '曲江', '其他'].map(v => ({label: v, value: v})),
        gas_nature: ['工业', '商业', '公福', '民用', '合表', '其他'].map(v => ({label: v, value: v})),
        user_type: ['餐饮', '锅炉', '直燃机', '生产线', '加气站', '壁挂锅炉', '其他'].map(v => ({label: v, value: v})),
        boiler_usage: ['采暖', '热水', '洗浴', '生产', '开水', '混用', '其他'].map(v => ({label: v, value: v})),
        construction_company: ['施工单位A', '施工单位B', '施工单位C', '其他'].map(v => ({label: v, value: v})),
        appearance_status: ['合格', '不合格'].map(v => ({label: v, value: v})),
        pressure_test_count: ['1', '2', '3', '4', '其他'].map(v => ({label: v, value: v})),
        air_tightness_test: ['合格', '不合格'].map(v => ({label: v, value: v})),
        flameout_protection_status: ['合格', '不合格'].map(v => ({label: v, value: v})),
        dark_kitchen_situation: ['是', '否'].map(v => ({label: v, value: v})),
        base_meter_type: ['罗茨', '涡轮', '皮膜'].map(v => ({label: v, value: v})),
        base_meter_model: ['表型1', '表型2'].map(v => ({label: v, value: v})),
        base_meter_manufacturer: ['厂家1', '厂家2'].map(v => ({label: v, value: v})),
        post_meter_pipe_spec: ['DN15', 'DN20', 'DN25', 'DN32', 'DN40', 'DN50'].map(v => ({label: v, value: v})),
        post_meter_pipe_material: ['材质1', '材质2'].map(v => ({label: v, value: v})),
        valve_model: ['DN15', 'DN20', 'DN25', 'DN32', 'DN40', 'DN50'].map(v => ({label: v, value: v})),
        valve_material: ['材质1', '材质2'].map(v => ({label: v, value: v})),
        equipment_type: ['灶具', '壁挂锅炉', '锅炉', '直燃机', '生产线'].map(v => ({label: v, value: v})),
        manufacturer: ['厂家1', '厂家2'].map(v => ({label: v, value: v})),
        safety_education_brochure: ['已发', '未发'].map(v => ({label: v, value: v})),
        wire_lock_and_meter_seal: ['已安装', '未安装'].map(v => ({label: v, value: v})),
        meter_run_test: ['正常', '异常'].map(v => ({label: v, value: v})),
        acceptance_passed: ['通过', '不通过'].map(v => ({label: v, value: v})),
        acceptance_personnel: ['张三', '李四', '王五'].map(v => ({label: v, value: v})),
      }
    }
  },
  methods: {
    findUser() {
      // 查找用户逻辑
      console.log('查找卡号:', this.model.card_no);
    },
    getVal(val) {
      if (Array.isArray(val)) return val.map(v => (typeof v === 'object' && v !== null ? v.value : v));
      return typeof val === 'object' && val !== null ? val.value : val;
    },
    isEqual(val, target) {
      const v = this.getVal(val);
      return v == target;
    },
    addMeter() {
      this.model.meters.push({
        base_meter_no: '',
        new_meter_reading: '',
        base_meter_type: null,
        base_meter_model: null,
        base_meter_manufacturer: null,
        pre_meter_code: '',
        meter_code: '',
        meter_seal_code: '',
        counter_code: '',
        small_meter_steel_seal_code: ''
      })
    },
    removeMeter(index) {
      this.model.meters.splice(index, 1)
    },
    addEquipment() {
      this.model.equipments.push({
        equipment_type: null,
        manufacturer: null,
        usage: '',
        power_value: ''
      })
    },
    removeEquipment(index) {
      this.model.equipments.splice(index, 1)
    },
    getEquipmentUnit(typeVal) {
      const t = this.getVal(typeVal)
      if (t === '灶具') return '眼'
      if (t === '壁挂锅炉') return 'KW'
      if (t === '锅炉') return '蒸吨'
      if (t === '直燃机') return 'KW'
      if (t === '生产线') return 'KW'
      return ''
    },
    updateAlarmExpire() {
      if (this.model.alarm_install_date) {
        const d = new Date(this.model.alarm_install_date)
        d.setFullYear(d.getFullYear() + 3)
        const yyyy = d.getFullYear()
        const mm = ('0' + (d.getMonth() + 1)).slice(-2)
        const dd = ('0' + d.getDate()).slice(-2)
        this.model.alarm_expire_date = `${yyyy}-${mm}-${dd}`
      } else {
        this.model.alarm_expire_date = ''
      }
    }
  }
};
</script>
