<style scoped lang="scss">

</style>
<template>
  <div class="system-dialog-container">
    <el-dialog
        :title="state.dialog.title"
        v-model="state.dialog.isShowDialog"
        width="860px"
        draggable
        destroy-on-close
        :close-on-click-modal="false"
        align-center>
      <el-form
          inline
          :model="state.ruleForm"
          :rules="state.rules"
          label-position="top"
          ref="formRef"
          size="default"
          label-width="100px"
          class="mt5">
        <div class="sub-group-bottom">基本参数</div>
        <el-form-item label="配置名称" prop="name" class="w100">
          <el-input
              v-model="state.ruleForm.name"
              placeholder="配置名称"
              clearable
              class="w100">
          </el-input>
        </el-form-item>
        <el-form-item label="配置备注" prop="remark" class="w100">
          <el-input
              v-model="state.ruleForm.remark"
              placeholder="配置备注"
              clearable
              type="textarea"
              :rows="3"
              maxlength="500"
              show-word-limit
              class="w100">
          </el-input>
        </el-form-item>

        <div class="sub-group-bottom">选项参数</div>
        <el-form-item label="工作模式（0：全天暂停营业 1:全天营业 2:按时间段营业）" prop="workMode" class="w100">
          <el-input v-model="state.ruleForm.workMode" placeholder="0：全天暂停营业 1:全天营业 2:按时间段营业" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="灯光工作模式（0：全天关 1:全天开 2:按时间段）" prop="lightMode" class="w100">
          <el-input v-model="state.ruleForm.lightMode" placeholder="0：全天关 1:全天开 2:按时间段" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="维护模式（0：正常，1：维护）" prop="maintenanceMode" class="w100">
          <el-input v-model="state.ruleForm.maintenanceMode" placeholder="0：正常模式，1：维护模式" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="屏幕类型（0:不支持视频，1:支持视频）" prop="screenType" class="w100">
          <el-input v-model="state.ruleForm.screenType" placeholder="0:不支持视频，1:支持视频" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="水流量传感器（0：未安装，1：已安装）" prop="sensorWater" class="w100">
          <el-input v-model="state.ruleForm.sensorWater" placeholder="0=未安装，1=已安装" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="镀膜功能开关（0：关，1：开）" prop="coatMode" class="w100">
          <el-input v-model="state.ruleForm.coatMode" placeholder="0=关，1=开" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="吹气功能开关（0：关，1：开）" prop="blowMode" class="w100">
          <el-input v-model="state.ruleForm.blowMode" placeholder="0=关，1=开" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="屏幕左下方文本" prop="userMessage1" class="wd300">
          <el-input v-model="state.ruleForm.userMessage1" placeholder="屏幕左下方文本" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="屏幕右下方文本" prop="userMessage2" class="wd300">
          <el-input v-model="state.ruleForm.userMessage2" placeholder="屏幕右下方文本" clearable class="w100"/>
        </el-form-item>

        <div class="sub-group-bottom">收费策略</div>
        <el-form-item label="车位免费时间(秒，0-86400，1800=30分钟)" prop="spaceTimeoutSeconds" class="w100">
          <el-input-number v-model="state.ruleForm.spaceTimeoutSeconds" placeholder="车位免费时间（秒）" :min="0" :max="86400" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="车位超时收费方式（0：只收超时费，1：收全部时间费）" prop="spaceTimeoutMode" class="w100">
          <el-input v-model="state.ruleForm.spaceTimeoutMode" placeholder="0=只收超时费，1=收全部时间费" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="最低消费(元，0=不限制)" prop="amountMinLimit" class="wd300">
          <el-input-number v-model="state.ruleForm.amountMinLimit" placeholder="最低消费（元）" :min="0" :precision="2" :step="0.1" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="最高消费/预付金额(元，0=不限制)" prop="prepayMoney" class="wd300">
          <el-input-number v-model="state.ruleForm.prepayMoney" placeholder="最高消费/预付金额（元）" :min="0" :precision="2" :step="1" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="快速开机金额(元，0=关闭)" prop="quickOpenMoney" class="wd300">
          <el-input-number v-model="state.ruleForm.quickOpenMoney" placeholder="按键直接开机金额（元），0=关闭" :min="0" :precision="2" :step="1" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="空闲超时策略（0：超时后关机，1：超时后倒计时扣费）" prop="idleTimeoutStrategy" class="w100">
          <el-input v-model="state.ruleForm.idleTimeoutStrategy" placeholder="0=超时关机，1=超时扣费" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="不操作设备启用收费" prop="priceCountdown" class="w100">
          <el-input-number v-model="state.ruleForm.priceCountdown" placeholder="一段时间不操作设备启用收费" :min="0" clearable class="w100"/>
        </el-form-item>

        <div class="sub-group-bottom">时间参数</div>
        <el-form-item label="自动启动（有流量时自动启动水泵）" prop="motorFlowOn" class="wd300">
          <ext-boolean v-model="state.ruleForm.motorFlowOn" placeholder="有流量时自动启动水泵" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="自动关闭（无流量时自动关闭水泵）" prop="motorFlowOff" class="wd300">
          <ext-boolean v-model="state.ruleForm.motorFlowOff" placeholder="无流量时自动关闭水泵" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="启动延时(毫秒，推荐5000)" prop="motorOnDelay" class="w100">
          <el-input-number v-model="state.ruleForm.motorOnDelay" placeholder="电机启动最少要开多少毫秒" :min="100" :max="30000" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="关闭延时(毫秒，推荐1000)" prop="motorOffDelay" class="w100">
          <el-input-number v-model="state.ruleForm.motorOffDelay" placeholder="电机每次关闭最少关多少毫秒" :min="100" :max="5000" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="关闭灵敏度(毫秒，推荐10000)" prop="motorOnInterval" class="w100">
          <el-input-number v-model="state.ruleForm.motorOnInterval" placeholder="多久收不到流量信号就关闭电机" :min="100" :max="30000" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="空闲超时关机(秒)" prop="idleTimeout" class="w100">
          <el-input-number v-model="state.ruleForm.idleTimeout" placeholder="空闲超时关机，0=关闭" :min="0" :max="86400" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="空闲超时提示音倒计时(秒)" prop="noticeThresholdIdle" class="w100">
          <el-input-number v-model="state.ruleForm.noticeThresholdIdle" placeholder="倒计时不足此秒数时发出提示音" :min="0" :max="86400" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="操作超时关机(秒)" prop="operationTimeout" class="w100">
          <el-input-number v-model="state.ruleForm.operationTimeout" placeholder="操作超时强制结束订单，0=不限制" :min="0" :max="86400" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="操作超时提示音倒计时(秒)" prop="noticeThresholdOperation" class="w100">
          <el-input-number v-model="state.ruleForm.noticeThresholdOperation" placeholder="剩余时间不足此秒数时发出提示" :min="0" :max="86400" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="洗车结束后账单显示时长(秒)" prop="billDelay" class="w100">
          <el-input-number v-model="state.ruleForm.billDelay" placeholder="费用明细页面显示多久" :min="0" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="照明时间段1" prop="lightTimePeriod1" class="w100">
          <el-input v-model="state.ruleForm.lightTimePeriod1" placeholder='例："18:00 - 22:00"' clearable class="w100"/>
        </el-form-item>
        <el-form-item label="照明时间段2" prop="lightTimePeriod2" class="w100">
          <el-input v-model="state.ruleForm.lightTimePeriod2" placeholder='例："18:00 - 08:00"' clearable class="w100"/>
        </el-form-item>
        <el-form-item label="营业时间段1" prop="workTimePeriod1" class="w100">
          <el-input v-model="state.ruleForm.workTimePeriod1" placeholder='例："08:00 - 12:00"' clearable class="w100"/>
        </el-form-item>
        <el-form-item label="营业时间段2" prop="workTimePeriod2" class="w100">
          <el-input v-model="state.ruleForm.workTimePeriod2" placeholder='例："14:00 - 21:00"' clearable class="w100"/>
        </el-form-item>
        <el-form-item label="水龙头自动关闭延时(秒，0=禁止)" prop="tapOnDelay" class="w100">
          <el-input-number v-model="state.ruleForm.tapOnDelay" placeholder="打开水龙头后多少秒自动关闭" :min="0" :max="86400" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="视频播放延时(秒)" prop="videoPlayDelay" class="w100">
          <el-input-number v-model="state.ruleForm.videoPlayDelay" placeholder="设备空闲多久开始循环播放广告视频" :min="0" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="视频源（0:内置，1:TF卡，2:U盘）" prop="videoSource" class="w100">
          <el-input v-model="state.ruleForm.videoSource" placeholder="0:内置视频，1:TF卡，2:U盘" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="工作指示灯关闭延时(秒)" prop="workLightDelay" class="w100">
          <el-input-number v-model="state.ruleForm.workLightDelay" placeholder="关机后延时多少秒关闭工作指示灯，0=立刻关" :min="0" :max="86400" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="时区设置（分钟，北京时间=480）" prop="timezone" class="w100">
          <el-input-number v-model="state.ruleForm.timezone" placeholder="时区设置，范围±720" :min="-720" :max="720" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="用户输入信息页" prop="userInputMode" class="w100">
          <el-input v-model="state.ruleForm.userInputMode" placeholder="用户输入信息页（自动洗车机版本）" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="登录超时时间" prop="loginTimeout" class="w100">
          <el-input-number v-model="state.ruleForm.loginTimeout" placeholder="登录超时时间" :min="0" clearable class="w100"/>
        </el-form-item>

        <div class="sub-group-bottom">电机扩展配置</div>
        <el-form-item label="清水泡沫联动（0：关，1：开）" prop="foamLinkMode" class="w100">
          <el-input v-model="state.ruleForm.foamLinkMode" placeholder="0=关，1=开（开泡沫同时开清水）" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="根据流量收费（0：关，1：开）" prop="motorFeeFlow" class="w100">
          <el-input v-model="state.ruleForm.motorFeeFlow" placeholder="0=关，1=开（有流量才收费）" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="照明继电器复用（0：照明，1：远程控制）" prop="lightAltMode" class="w100">
          <el-input v-model="state.ruleForm.lightAltMode" placeholder="0=照明继电器，1=远程控制继电器" clearable class="w100"/>
        </el-form-item>

        <div class="sub-group-bottom">声音参数</div>
        <el-form-item label="提示音音量（0-100）" prop="soundVolume" class="wd300">
          <el-input-number :min="0" :max="100" v-model="state.ruleForm.soundVolume" placeholder="提示音音量" clearable class="w100"/>
        </el-form-item>
        <div class="sub-group-bottom" style="font-size:13px;color:#909399;margin-bottom:8px;">-- 开机语音 --</div>
        <el-form-item label="按键开机提示音" prop="ttsOpenByButton" class="wd300">
          <el-input v-model="state.ruleForm.ttsOpenByButton" placeholder="按键开机提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="网络开机提示音" prop="ttsOpenByNetwork" class="wd300">
          <el-input v-model="state.ruleForm.ttsOpenByNetwork" placeholder="网络开机提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="刷卡开机提示音" prop="ttsOpenByCard" class="wd300">
          <el-input v-model="state.ruleForm.ttsOpenByCard" placeholder="刷卡开机提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="投币开机提示音" prop="ttsOpenByCoin" class="wd300">
          <el-input v-model="state.ruleForm.ttsOpenByCoin" placeholder="投币开机提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <div class="sub-group-bottom" style="font-size:13px;color:#909399;margin-bottom:8px;">-- 关机语音 --</div>
        <el-form-item label="按键关机提示音" prop="ttsCloseByButton" class="wd300">
          <el-input v-model="state.ruleForm.ttsCloseByButton" placeholder="按键关机提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="刷卡关机提示音" prop="ttsCloseByCard" class="wd300">
          <el-input v-model="state.ruleForm.ttsCloseByCard" placeholder="刷卡关机提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="网络关机提示音" prop="ttsCloseByNetwork" class="wd300">
          <el-input v-model="state.ruleForm.ttsCloseByNetwork" placeholder="网络关机提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="空闲超时关机提示音" prop="ttsCloseByIdleTimeout" class="wd300">
          <el-input v-model="state.ruleForm.ttsCloseByIdleTimeout" placeholder="空闲超时关机提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="操作超时关机提示音" prop="ttsCloseByOperationTimeout" class="wd300">
          <el-input v-model="state.ruleForm.ttsCloseByOperationTimeout" placeholder="操作超时关机提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="余额不足关机提示音" prop="ttsCloseByNoBalance" class="wd300">
          <el-input v-model="state.ruleForm.ttsCloseByNoBalance" placeholder="余额不足关机提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="系统错误关机提示音" prop="ttsCloseBySysError" class="wd300">
          <el-input v-model="state.ruleForm.ttsCloseBySysError" placeholder="系统错误关机提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <div class="sub-group-bottom" style="font-size:13px;color:#909399;margin-bottom:8px;">-- 功能语音 --</div>
        <el-form-item label="打开清水" prop="ttsWaterOn" class="wd300">
          <el-input v-model="state.ruleForm.ttsWaterOn" placeholder="打开清水提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="关闭清水" prop="ttsWaterOff" class="wd300">
          <el-input v-model="state.ruleForm.ttsWaterOff" placeholder="关闭清水提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="打开泡沫" prop="ttsFoamOn" class="wd300">
          <el-input v-model="state.ruleForm.ttsFoamOn" placeholder="打开泡沫提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="关闭泡沫" prop="ttsFoamOff" class="wd300">
          <el-input v-model="state.ruleForm.ttsFoamOff" placeholder="关闭泡沫提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="打开吸尘" prop="ttsCleanerOn" class="wd300">
          <el-input v-model="state.ruleForm.ttsCleanerOn" placeholder="打开吸尘器提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="关闭吸尘" prop="ttsCleanerOff" class="wd300">
          <el-input v-model="state.ruleForm.ttsCleanerOff" placeholder="关闭吸尘器提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="打开水龙头" prop="ttsTapOn" class="wd300">
          <el-input v-model="state.ruleForm.ttsTapOn" placeholder="打开水龙头提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="关闭水龙头" prop="ttsTapOff" class="wd300">
          <el-input v-model="state.ruleForm.ttsTapOff" placeholder="关闭水龙头提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="打开消毒" prop="ttsUserExtOn" class="wd300">
          <el-input v-model="state.ruleForm.ttsUserExtOn" placeholder="打开消毒提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="关闭消毒" prop="ttsUserExtOff" class="wd300">
          <el-input v-model="state.ruleForm.ttsUserExtOff" placeholder="关闭消毒提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <div class="sub-group-bottom" style="font-size:13px;color:#909399;margin-bottom:8px;">-- 登录语音 --</div>
        <el-form-item label="用户登录" prop="ttsAlertUserLogin" class="wd300">
          <el-input v-model="state.ruleForm.ttsAlertUserLogin" placeholder="用户登录提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="登录超时" prop="ttsAlertUserLoginTimeout" class="wd300">
          <el-input v-model="state.ruleForm.ttsAlertUserLoginTimeout" placeholder="登录超时提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="未输入账号" prop="ttsAlertAccountRequired" class="wd300">
          <el-input v-model="state.ruleForm.ttsAlertAccountRequired" placeholder="未输入账号提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="未输入密码" prop="ttsAlertPasswordRequired" class="wd300">
          <el-input v-model="state.ruleForm.ttsAlertPasswordRequired" placeholder="未输入密码提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="账号长度错误" prop="ttsAlertAccountLenError" class="wd300">
          <el-input v-model="state.ruleForm.ttsAlertAccountLenError" placeholder="账号长度错误提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="密码长度错误" prop="ttsAlertPasswordLenError" class="wd300">
          <el-input v-model="state.ruleForm.ttsAlertPasswordLenError" placeholder="密码长度错误提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <div class="sub-group-bottom" style="font-size:13px;color:#909399;margin-bottom:8px;">-- 其他提示音 --</div>
        <el-form-item label="系统启动" prop="ttsAlertSysBoot" class="wd300">
          <el-input v-model="state.ruleForm.ttsAlertSysBoot" placeholder="系统启动提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="空闲模式" prop="ttsAlertIdleMode" class="wd300">
          <el-input v-model="state.ruleForm.ttsAlertIdleMode" placeholder="空闲模式提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="非营业时间" prop="ttsAlertSleepMode" class="wd300">
          <el-input v-model="state.ruleForm.ttsAlertSleepMode" placeholder="非营业时间段提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="配置查看模式" prop="ttsAlertConfigMode" class="wd300">
          <el-input v-model="state.ruleForm.ttsAlertConfigMode" placeholder="配置查看模式提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="维护模式" prop="ttsAlertMaintenanceMode" class="wd300">
          <el-input v-model="state.ruleForm.ttsAlertMaintenanceMode" placeholder="维护模式提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="无水" prop="ttsAlertNoWater" class="wd300">
          <el-input v-model="state.ruleForm.ttsAlertNoWater" placeholder="无水提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="无泡沫" prop="ttsAlertNoFoam" class="wd300">
          <el-input v-model="state.ruleForm.ttsAlertNoFoam" placeholder="无泡沫提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="电机热保护" prop="ttsAlertMotorError" class="wd300">
          <el-input v-model="state.ruleForm.ttsAlertMotorError" placeholder="电机热保护提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="空闲超时关机前" prop="ttsAlertIdleRemainTime" class="wd300">
          <el-input v-model="state.ruleForm.ttsAlertIdleRemainTime" placeholder="空闲超时关机前提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="操作超时关机前" prop="ttsAlertOperationRemainTime" class="wd300">
          <el-input v-model="state.ruleForm.ttsAlertOperationRemainTime" placeholder="操作超时关机前提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>
        <el-form-item label="用户投币后" prop="ttsAlertInsertCoin" class="wd300">
          <el-input v-model="state.ruleForm.ttsAlertInsertCoin" placeholder="用户投币后提示音" clearable maxlength="50" class="w100"/>
        </el-form-item>

        <div class="sub-group-bottom">单价设置（元/分钟）</div>
        <el-form-item label="清水单价" prop="priceWater" class="wd300">
          <el-input-number v-model="state.ruleForm.priceWater" placeholder="清水单价（元/分钟）" :min="0" :precision="2" :step="0.1" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="泡沫单价" prop="priceFoam" class="wd300">
          <el-input-number v-model="state.ruleForm.priceFoam" placeholder="泡沫单价（元/分钟）" :min="0" :precision="2" :step="0.1" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="吸尘单价" prop="priceCleaner" class="wd300">
          <el-input-number v-model="state.ruleForm.priceCleaner" placeholder="吸尘单价（元/分钟）" :min="0" :precision="2" :step="0.1" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="洗手单价" prop="priceTap" class="wd300">
          <el-input-number v-model="state.ruleForm.priceTap" placeholder="洗手单价（元/分钟）" :min="0" :precision="2" :step="0.1" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="消毒单价" prop="priceUserExt" class="wd300">
          <el-input-number v-model="state.ruleForm.priceUserExt" placeholder="扩展项目单价（元/分钟）" :min="0" :precision="2" :step="0.1" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="镀膜单价" prop="priceCoat" class="wd300">
          <el-input-number v-model="state.ruleForm.priceCoat" placeholder="镀膜单价（元/分钟）" :min="0" :precision="2" :step="0.1" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="吹气单价" prop="priceBlow" class="wd300">
          <el-input-number v-model="state.ruleForm.priceBlow" placeholder="吹气单价（元/分钟）" :min="0" :precision="2" :step="0.1" clearable class="w100"/>
        </el-form-item>
        <el-form-item label="场地费单价" prop="priceSpace" class="wd300">
          <el-input-number v-model="state.ruleForm.priceSpace" placeholder="场地费单价（元/分钟）" :min="0" :precision="2" :step="0.1" clearable class="w100"/>
        </el-form-item>

      </el-form>

      <template #footer>
					<span class="dialog-footer">
						<el-button @click="onCancel" size="default">取 消</el-button>
						<el-button :loading="state.btnLoading" type="primary" @click="onSubmit" size="default">{{ state.dialog.submitTxt }}</el-button>
					</span>
      </template>
    </el-dialog>
  </div>
</template>

<script setup lang="ts" name="DeviceConfigDialog">
import {defineAsyncComponent, reactive, onMounted, ref} from 'vue';
import {Msg} from "/@/utils/message";
import {$body, $get, $post} from "/@/utils/request";
import u from '/@/utils/u'
import ExtBoolean from "/@/components/form/ExtBoolean.vue";


// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh']);
const formRef = ref();
//定义初始变量，重置使用
const initState = () => ({
  ruleForm: {
    id: null
  },
  btnLoading: false,
  dialog: {
    isShowDialog: false,
    type: '',
    title: '',
    submitTxt: '',
  },
  rules: {
    name:[u.validator.required],
    remark:[u.validator.required]
  },
})

// 定义变量内容
const state = reactive(initState());


// 打开弹窗
const open = (action: string = 'add', row: any) => {
  state.dialog.title = u.dialog.actions[action].title + "『洗车设备参数配置表』"
  state.dialog.submitTxt = u.dialog.actions[action].btn + "『洗车设备参数配置表』"
  state.dialog.isShowDialog = true;
  if (action !== 'add') {
    loadData(row.id);
  } else {
    state.ruleForm = Object.assign(state.ruleForm, row);
  }
};
// 关闭弹窗
const onClose = () => {
  state.dialog.isShowDialog = false;
  Object.assign(state, initState())
};
// 取消
const onCancel = () => {
  onClose();
};
// 以分为单位存储的价格字段（UI 显示为元）
const moneyFields = ['priceBlow', 'priceCleaner', 'priceCoat', 'priceFoam', 'priceSpace', 'priceTap', 'priceUserExt', 'priceWater', 'quickOpenMoney', 'amountMinLimit', 'prepayMoney'];

// 提交
const onSubmit = () => {
  formRef.value.validate((v: boolean) => {
    if (v) {
      state.btnLoading = true;
      const ruleForm = { ...state.ruleForm };
      moneyFields.forEach(f => {
        if (ruleForm[f] != null && ruleForm[f] !== '') ruleForm[f] = Math.round(Number(ruleForm[f]) * 100);
      });
      const url = !!state.ruleForm.id ? "device-config/modify" : "device-config/add"
      $body(url, ruleForm).then(() => {
        state.btnLoading = false;
        Msg.message('操作成功');
        console.log('submit!')
        onClose();
        emit('refresh');
      })
    } else {
      state.btnLoading = false;
      Msg.message('请先完整填写表单', 'error');
    }
  })
};

const handleFormChange = (formData: any) => {
  console.log(formData)
}

// 初始化数据
const loadData = (shortId: string) => {
  $post(`device-config/${shortId}`).then((res: any) => {
    moneyFields.forEach(f => {
      if (res[f] != null) res[f] = (res[f] / 100).toFixed(2);
    });
    state.ruleForm = res;
  })
}

// 暴露变量
defineExpose({
  open
});


</script>
