<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="上传服务器名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="serverName">
              <a-input v-model="model.serverName" placeholder="请输入上传服务器名"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="传感器ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sensorId">
              <a-input v-model="model.sensorId" placeholder="请输入传感器ID"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="status">
              <a-input-number v-model="model.status" placeholder="请输入状态" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="报警字段名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="statusname">
              <a-textarea v-model="model.statusname" rows="4" placeholder="请输入报警字段名" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="操作模式（维护）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data1">
              <a-input-number v-model="model.data1" placeholder="请输入操作模式（维护）" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="操作模式（手动）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data2">
              <a-input-number v-model="model.data2" placeholder="请输入操作模式（手动）" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="操作模式（自动）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data3">
              <a-input-number v-model="model.data3" placeholder="请输入操作模式（自动）" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="端洗选择" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data4">
              <a-input-number v-model="model.data4" placeholder="请输入端洗选择" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="预冷状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data5">
              <a-input-number v-model="model.data5" placeholder="请输入预冷状态" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="预湿状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data6">
              <a-input-number v-model="model.data6" placeholder="请输入预湿状态" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="左冲洗上升限位一" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data7">
              <a-input-number v-model="model.data7" placeholder="请输入左冲洗上升限位一" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="左冲洗上升限位二" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data8">
              <a-input-number v-model="model.data8" placeholder="请输入左冲洗上升限位二" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="左冲洗下降限位一" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data9">
              <a-input-number v-model="model.data9" placeholder="请输入左冲洗下降限位一" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="左冲洗下降限位二" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data10">
              <a-input-number v-model="model.data10" placeholder="请输入左冲洗下降限位二" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="左冲洗前端限位一" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data11">
              <a-input-number v-model="model.data11" placeholder="请输入左冲洗前端限位一" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="左冲洗前端限位二" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data12">
              <a-input-number v-model="model.data12" placeholder="请输入左冲洗前端限位二" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="左冲洗后端限位一" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data13">
              <a-input-number v-model="model.data13" placeholder="请输入左冲洗后端限位一" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="左冲洗后端限位二" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data14">
              <a-input-number v-model="model.data14" placeholder="请输入左冲洗后端限位二" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="右冲洗上升限位一" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data15">
              <a-input-number v-model="model.data15" placeholder="请输入右冲洗上升限位一" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="右冲洗上升限位二" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data16">
              <a-input-number v-model="model.data16" placeholder="请输入右冲洗上升限位二" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="右冲洗下降限位一" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data17">
              <a-input-number v-model="model.data17" placeholder="请输入右冲洗下降限位一" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="右冲洗下降限位二" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data18">
              <a-input-number v-model="model.data18" placeholder="请输入右冲洗下降限位二" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="右冲洗前端限位一" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data19">
              <a-input-number v-model="model.data19" placeholder="请输入右冲洗前端限位一" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="右冲洗前端限位二" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data20">
              <a-input-number v-model="model.data20" placeholder="请输入右冲洗前端限位二" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="右冲洗后端限位一" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data21">
              <a-input-number v-model="model.data21" placeholder="请输入右冲洗后端限位一" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="右冲洗后端限位二" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data22">
              <a-input-number v-model="model.data22" placeholder="请输入右冲洗后端限位二" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="初刷工位弧刷状态（就位、工作）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data23">
              <a-input-number v-model="model.data23" placeholder="请输入初刷工位弧刷状态（就位、工作）" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="左侧洗初后刷限位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data24">
              <a-input-number v-model="model.data24" placeholder="请输入左侧洗初后刷限位" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="左侧洗初前刷限位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data25">
              <a-input-number v-model="model.data25" placeholder="请输入左侧洗初前刷限位" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="初刷工位喷水状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data26">
              <a-input-number v-model="model.data26" placeholder="请输入初刷工位喷水状态" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="次刷工位弧刷工作状态（就位、工作）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data27">
              <a-input-number v-model="model.data27" placeholder="请输入次刷工位弧刷工作状态（就位、工作）" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="左侧洗次后刷限位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data28">
              <a-input-number v-model="model.data28" placeholder="请输入左侧洗次后刷限位" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="左侧洗次前刷限位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data29">
              <a-input-number v-model="model.data29" placeholder="请输入左侧洗次前刷限位" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="次刷工位喷水状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data30">
              <a-input-number v-model="model.data30" placeholder="请输入次刷工位喷水状态" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="初冲状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data31">
              <a-input-number v-model="model.data31" placeholder="请输入初冲状态" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="精刷工位弧刷工作状态（就位、工作）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data32">
              <a-input-number v-model="model.data32" placeholder="请输入精刷工位弧刷工作状态（就位、工作）" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="左侧洗精后刷限位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data33">
              <a-input-number v-model="model.data33" placeholder="请输入左侧洗精后刷限位" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="左侧洗精前刷限位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data34">
              <a-input-number v-model="model.data34" placeholder="请输入左侧洗精前刷限位" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="精刷工位喷水状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data35">
              <a-input-number v-model="model.data35" placeholder="请输入精刷工位喷水状态" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="终冲状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data36">
              <a-input-number v-model="model.data36" placeholder="请输入终冲状态" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="吹干状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data37">
              <a-input-number v-model="model.data37" placeholder="请输入吹干状态" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="清洗完毕状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data38">
              <a-input-number v-model="model.data38" placeholder="请输入清洗完毕状态" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="同意洗车状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data39">
              <a-input-number v-model="model.data39" placeholder="请输入同意洗车状态" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="同意出库状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data40">
              <a-input-number v-model="model.data40" placeholder="请输入同意出库状态" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="列车入库状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data41">
              <a-input-number v-model="model.data41" placeholder="请输入列车入库状态" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="列车出库状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data42">
              <a-input-number v-model="model.data42" placeholder="请输入列车出库状态" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="模拟洗车信号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data43">
              <a-input-number v-model="model.data43" placeholder="请输入模拟洗车信号" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="清洗完毕信号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data44">
              <a-input-number v-model="model.data44" placeholder="请输入清洗完毕信号" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="预湿泵故障" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data45">
              <a-input-number v-model="model.data45" placeholder="请输入预湿泵故障" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="回水泵故障" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data46">
              <a-input-number v-model="model.data46" placeholder="请输入回水泵故障" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="清水泵故障" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data47">
              <a-input-number v-model="model.data47" placeholder="请输入清水泵故障" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="软水泵故障" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data48">
              <a-input-number v-model="model.data48" placeholder="请输入软水泵故障" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="计量泵1故障" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data49">
              <a-input-number v-model="model.data49" placeholder="请输入计量泵1故障" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="计量泵2故障" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data50">
              <a-input-number v-model="model.data50" placeholder="请输入计量泵2故障" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="侧刷电机1故障" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data51">
              <a-input-number v-model="model.data51" placeholder="请输入侧刷电机1故障" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="侧刷电机2故障" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data52">
              <a-input-number v-model="model.data52" placeholder="请输入侧刷电机2故障" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="侧刷电机3故障" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data53">
              <a-input-number v-model="model.data53" placeholder="请输入侧刷电机3故障" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="侧刷电机4故障" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data54">
              <a-input-number v-model="model.data54" placeholder="请输入侧刷电机4故障" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="侧刷电机5故障" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data55">
              <a-input-number v-model="model.data55" placeholder="请输入侧刷电机5故障" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="侧刷电机6故障" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data56">
              <a-input-number v-model="model.data56" placeholder="请输入侧刷电机6故障" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="侧刷电机7故障" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data57">
              <a-input-number v-model="model.data57" placeholder="请输入侧刷电机7故障" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="侧刷电机8故障" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data58">
              <a-input-number v-model="model.data58" placeholder="请输入侧刷电机8故障" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="侧刷电机9故障" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data59">
              <a-input-number v-model="model.data59" placeholder="请输入侧刷电机9故障" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="运行状态（运行）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data60">
              <a-input-number v-model="model.data60" placeholder="请输入运行状态（运行）" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="运行状态（故障）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data61">
              <a-input-number v-model="model.data61" placeholder="请输入运行状态（故障）" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="预留1" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data62">
              <a-input-number v-model="model.data62" placeholder="请输入预留1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="预留2" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data63">
              <a-input-number v-model="model.data63" placeholder="请输入预留2" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="预留3" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="data64">
              <a-input-number v-model="model.data64" placeholder="请输入预留3" style="width: 100%" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'ZiyangXcjOnlineForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/zyxcj/ziyangXcjOnline/add",
          edit: "/zyxcj/ziyangXcjOnline/edit",
          queryById: "/zyxcj/ziyangXcjOnline/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>