<template>
  <!-- <a-spin :spinning="confirmLoading"> -->
    <j-form-container>
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-divider orientation="left"> <span>基本信息</span> </a-divider>
          <a-col :span="24">
            <a-form-model-item label="联锁条件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="interlockConditionData">
              <a-cascader
                v-model="model.interlockConditionData"
                :options="tagDataOptions"
                :fieldNames="customFieldNames"
                :show-search="true"
                :filter-option="filter"
                expand-trigger="hover"
                placeholder="请选择点位"/>
                <!-- :display-render="displayRender" -->
                <!-- @change="dianwerChange" -->
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="联锁设定值" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="interlockSetValue">
              <a-input v-model="model.interlockSetValue" placeholder="请输入联锁设定值"></a-input>
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="24">
            <a-form-model-item label="当前值" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="currentValueData">
              <a-cascader
                v-model="model.currentValueData"
                :options="tagDataOptions"
                :fieldNames="customFieldNames"
                expand-trigger="hover"
                placeholder="请选择当前值"/>
            </a-form-model-item>
          </a-col> -->
          <a-col :span="24">
            <a-form-model-item label="输入卡件状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="inputStatusData">
              <a-radio-group name="radioGroup" v-model="model.inputStatusRadio" @change="statusRadioChange">
                <a-radio :value="'0'"> 默认正常 </a-radio>
                <a-radio :value="'1'"> 位号读取 </a-radio>
              </a-radio-group>
              <template v-if="model.inputStatusRadio === '0'">
                <a-input v-model="model.inputStatusDefault" disabled></a-input>
              </template>
              <template v-if="model.inputStatusRadio === '1'">
                <a-cascader
                  v-model="model.inputStatusData"
                  :options="tagDataOptions"
                  :fieldNames="customFieldNames"
                  :show-search="true"
                  :filter-option="filter"
                  expand-trigger="hover"
                  placeholder="请选择输入卡件状态"
                  />
              </template>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="输出卡件状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="outputStatusData">
              <a-radio-group name="radioGroup" v-model="model.outputStatusRadio" @change="statusRadioChange">
                <a-radio :value="'0'"> 默认正常 </a-radio>
                <a-radio :value="'1'"> 位号读取 </a-radio>
              </a-radio-group>
              <template v-if="model.outputStatusRadio === '0'">
                <a-input v-model="model.outputStatusDefault" disabled></a-input>
              </template>
              <template v-if="model.outputStatusRadio === '1'">
                <a-cascader
                  v-model="model.outputStatusData"
                  :options="tagDataOptions"
                  :fieldNames="customFieldNames"
                  :show-search="true"
                  :filter-option="filter"
                  expand-trigger="hover"
                  placeholder="请选择输出卡件状态"
                />
              </template>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="MP状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="mpStatusData">
              <a-radio-group name="radioGroup" v-model="model.mpStatusRadio" @change="statusRadioChange">
                <a-radio :value="'0'"> 默认正常 </a-radio>
                <a-radio :value="'1'"> 位号读取 </a-radio>
              </a-radio-group>
              <template v-if="model.mpStatusRadio === '0'">
                <a-input v-model="model.mpStatusDefault" disabled></a-input>
              </template>
              <template v-if="model.mpStatusRadio === '1'">
                <a-cascader
                  v-model="model.mpStatusData"
                  :options="tagDataOptions"
                  :fieldNames="customFieldNames"
                  :show-search="true"
                  :filter-option="filter"
                  expand-trigger="hover"
                  placeholder="请选择MP状态"
                />
              </template>
            </a-form-model-item>
          </a-col>
          <!-- 仪表状态开始 -->
          <a-divider orientation="left"> <span>仪表状态</span> </a-divider>
          <a-col :span="24">
            <a-form-model-item label="仪表状态判定依据" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="instrumentStatusJuge">
              <a-radio-group name="radioGroup" v-model="model.instrumentStatusJuge">
                <!-- @change="instrumentStatusJugeChange" -->
                <a-radio :value="'3'"> 默认正常 </a-radio>
                <a-radio :value="'0'"> 位号读取 </a-radio>
                <a-radio :value="'1'"> 高低限判断 </a-radio>
                <a-radio :value="'2'"> 突变超限判断 </a-radio>
              </a-radio-group>
            </a-form-model-item>
          </a-col>
          <template v-if="model.instrumentStatusJuge === '3'">
            <a-col :span="24">
              <a-input v-model="model.instrumentStatusDefault" disabled></a-input>
            </a-col>
          </template>
          <template v-if="model.instrumentStatusJuge === '0'">
            <a-col :span="24">
              <a-form-model-item label="仪表位号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="instrumentStatusData">
                <a-cascader
                v-model="model.instrumentStatusData"
                :options="tagDataOptions"
                :fieldNames="customFieldNames"
                :show-search="true"
                :filter-option="filter"
                expand-trigger="hover"
                placeholder="请选择仪表位号"/>
              </a-form-model-item>
            </a-col>
          </template>
          <template v-if="model.instrumentStatusJuge === '1'">
            <a-col :span="24">
              <a-form-model-item label="原始模拟量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ysmnlData">
                <a-cascader
                  v-model="model.ysmnlData"
                  :options="tagDataOptions"
                  :fieldNames="customFieldNames"
                  :show-search="true"
                  :filter-option="filter"
                  expand-trigger="hover"
                  placeholder="请选择原始模拟量"
                />
              </a-form-model-item>
            </a-col>
            <a-col :span="24">
              <a-form-model-item label="系统" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="instrumentGDXT">
                <a-radio-group name="radioGroup" v-model="model.instrumentGDXT" @change="instrumentGDXTChange">
                  <a-radio value="Tricon"> Tricon </a-radio>
                  <a-radio value="TSxPlus"> TSxPlus </a-radio>
                </a-radio-group>
              </a-form-model-item>
            </a-col>
            <a-col :span="24">
              <a-form-model-item label="高限值" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="upperLimitGd">
                <!-- <a-auto-complete :data-source="['4258', '61948']" v-model="model.upperLimit" placeholder="请输入高限"></a-auto-complete> -->
                <a-input v-model="model.upperLimitGd" placeholder="请输入高限"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="24">
              <a-form-model-item label="低限值" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lowerLimitGd">
                <!-- <a-auto-complete :data-source="['737', '10722']" v-model="model.lowerLimit" placeholder="请输入低限"></a-auto-complete> -->
                <a-input v-model="model.lowerLimitGd" placeholder="请输入低限"></a-input>
              </a-form-model-item>
            </a-col>
          </template>
          <template v-if="model.instrumentStatusJuge === '2'">
            <a-col :span="24">
              <a-form-model-item label="原始模拟量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ysmnlData">
                <a-cascader
                  v-model="model.ysmnlData"
                  :options="tagDataOptions"
                  :fieldNames="customFieldNames"
                  :show-search="true"
                  :filter-option="filter"
                  expand-trigger="hover"
                  placeholder="请选择原始模拟量"
                />
              </a-form-model-item>
            </a-col>
            <a-col :span="24">
              <a-form-model-item label="系统" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="instrumentTBXT">
                <a-radio-group name="radioGroup" v-model="model.instrumentTBXT" @change="instrumentTBXTChange">
                  <a-radio value="Tricon"> Tricon </a-radio>
                  <a-radio value="TSxPlus"> TSxPlus </a-radio>
                </a-radio-group>
              </a-form-model-item>
            </a-col>
            <a-col :span="24">
              <a-form-model-item label="突变判断公式" :labelCol="labelCol" :wrapperCol="wrapperCol" class="red-star-form-item">
                <div style="display: flex;">
                  <div style="width: 30px;text-align: center;">( </div>
                  <a-form-model-item prop="upperLimitTb">
                    <!-- <a-auto-complete :data-source="['4095', '59577']" v-model="model.upperLimit" placeholder="请输入高限"></a-auto-complete> -->
                    <a-input v-model="model.upperLimitTb" placeholder="请输入高限"></a-input>
                  </a-form-model-item>
                  <div style="width: 30px;text-align: center;"> - </div>
                  <a-form-model-item prop="lowerLimitTb">
                    <!-- <a-auto-complete :data-source="['819', '11915']" v-model="model.lowerLimit" placeholder="请输入低限"></a-auto-complete> -->
                    <a-input v-model="model.lowerLimitTb" placeholder="请输入低限"></a-input>
                  </a-form-model-item>
                  <div style="width: 60px;text-align: center;">）* </div>
                  <a-form-model-item prop="thresholdValueN">
                    <a-input v-model="model.thresholdValueN" placeholder="请输入阈值"></a-input>
                    <!-- <a-auto-complete :data-source="['1']" v-model="model.thresholdValueN" placeholder="请输入阈值"></a-auto-complete> -->
                  </a-form-model-item>
                  <div style="width: 30px;text-align: center;"> % </div>
                </div>
              </a-form-model-item>
            </a-col>
            <!-- <a-col :span="24">
              <a-form-model-item label="高限值" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="upperLimit">
                <a-input v-model="model.upperLimit" placeholder="请输入高限"></a-input>
            </a-form-model-item>
            </a-col>
            <a-col :span="24">
              <a-form-model-item label="低限值" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lowerLimit">
                <a-input v-model="model.lowerLimit" placeholder="请输入低限"></a-input>
              </a-form-model-item>
            </a-col> -->
            <!-- <a-col :span="24"> -->
              <!-- <a-form-model-item label="阈值" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="thresholdValueN">
                <a-input v-model="model.thresholdValueN" suffix="%" placeholder="请输入阈值"></a-input> -->
                <!-- addon-after="%" -->
              <!-- </a-form-model-item> -->
            <!-- </a-col> -->
            <a-col :span="24">
              <a-form-model-item label="突变判断时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="thresholdTime">
                <a-input v-model="model.thresholdTime" suffix="S" placeholder="请输入时间"></a-input>
                <!-- suffix="S" -->
              </a-form-model-item>
            </a-col>
          </template>
          <a-col :span="24">
            <a-form-model-item label="描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="description">
              <a-input v-model="model.description" placeholder="请输入描述"></a-input>
            </a-form-model-item>
          </a-col>
          <!-- 仪表状态结束 -->

          <!-- 是否旁路 -->
          <a-divider orientation="left"> <span>旁路状态</span> </a-divider>
          <a-col :span="24">
            <a-form-model-item label="是否有旁路" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ifBypass">
              <a-radio-group name="radioGroup" v-model="model.ifBypass">
                <!--  :default-value="model.ifBypass" -->
                <a-radio :value="'0'"> 否 </a-radio>
                <a-radio :value="'1'"> 是 </a-radio>
              </a-radio-group>
            </a-form-model-item>
          </a-col>
          <template v-if="model.ifBypass === '1'">
            <a-col :span="24">
              <a-form-model-item label="旁路" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bypassData">
                <a-cascader
                v-model="model.bypassData"
                :options="tagDataOptions"
                :fieldNames="customFieldNames"
                :show-search="true"
                :filter-option="filter"
                expand-trigger="hover"
                placeholder="请选择旁路"/>
              </a-form-model-item>
            </a-col>
          </template>
          <template v-if="model.ifBypass === '0'">
            <a-col :span="24">
              <a-form-model-item label="旁路状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bypassNo">
                <a-input v-model="model.bypassNo" disabled></a-input>
                <!-- placeholder="无旁路" :default-value="bypassNo" -->
                <!-- <a-select v-model="model.bypassNo">
                  <a-select-option value="0"> 0 </a-select-option>
                  <a-select-option value="1"> 1 </a-select-option>
                </a-select> -->
              </a-form-model-item>
            </a-col>
          </template>
        </a-row>
      </a-form-model>
    </j-form-container>
  <!-- </a-spin> -->
</template>

<script>
  import { httpAction, getAction, postAction } from '@/api/manage'

  export default {
    name: 'InterlockConditionForm',
    props: {
      // 该系统设置的默认值
      itSystemDefaultValue: {
        type: Object,
        default: function(){
          return {} // 使用工厂函数返回默认值
        }
      },
      // 所有位号
      tagDataOptions: {
        type: Array,
        default: function(){
          return [] // 使用工厂函数返回默认值
        }
      },
    },
    data () {
      return {
        model:{
          inputStatusRadio: '0', // 输入卡件状态单选默认-默认值
          inputStatusDefault: null, // 输入卡件状态默认值默认参数
          outputStatusRadio: '0', // 输出卡件状态单选默认-默认值
          outputStatusDefault: null, // 输出卡件状态默认值默认参数
          mpStatusRadio: '0', // MP状态单选默认-默认值
          mpStatusDefault: null, // MP状态默认值默认参数
          instrumentStatusJuge: '3', // 仪表判定依据-默认正常
          instrumentStatusDefault: null, // 仪表状态默认值默认参数
          instrumentGDXT: '',
          instrumentTBXT: '',
          upperLimitGd: null,
          lowerLimitGd: null,
          upperLimitTb: null,
          lowerLimitTb: null,
          thresholdValueN: '1',
          ifBypass: '1', // 是否有旁路-是
          bypassNo: null, // 旁路默认值
          bypass: null, // MP状态默认值默认参数
        },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        // confirmLoading: true,
        validatorRules: {
          interlockConditionData: [{
            required: true, message: '请选择联锁条件!',
          }],
          // instrumentStatusJuge: [{
          //   required: true, message: '请选择仪表状态判定依据!',
          // }],
          instrumentStatusData: [{
            required: true, message: '请选择仪表状态!',
          }],
          // 高低限
          ysmnlData: [{
            required: true, message: '请选择原始模拟量!',
          }],
          upperLimitGd: [{
            required: true, message: '请输入高限值!',
          }],
          lowerLimitGd: [{
            required: true, message: '请输入低限值!',
          }],
          upperLimitTb: [{
            required: true, message: '请输入高限值!',
          }],
          lowerLimitTb: [{
            required: true, message: '请输入低限值!',
          }],
          // 突变超限
          tbGongshi: [
            // { required: true, message: '', },
            { required: true, message: '请输入高限值!', },
            { required: true, message: '请输入低限值!', },
            { required: true, message: '请输入阈值!', },
          ],
          thresholdTime: [{
            required: true, message: '请输入时间!',
          }],
          thresholdValueN: [{
            required: true, message: '请输入阈值!',
          }],

          // interlockSetValue: [{
          //   required: true, message: '请输入联锁设定值!',
          // }],
          // currentValueData: [{
          //   required: true, message: '请选择当前值!',
          // }],
          ifBypass: [{
            required: true, message: '请选择是否旁路!',
          }],
          bypassData: [{
            required: true, message: '请选择旁路!',
          }],
          bypassNo: [{
            required: true, message: '请选择旁路状态!',
          }],
          // inputStatusData: [{
          //   required: true, message: '请选择!',
          // }],
          // outputStatusData: [{
          //   required: true, message: '请选择输出卡件状态!',
          // }],
          // mpStatusData: [{
          //   required: true, message: '请选择MP状态!',
          // }],
        },
        url: {
          interLockSelect: '/sys/dict/loadTreeData',
          add: "/summary/interlockSummary/add",
          edit: "/summary/interlockSummary/edit",
          queryById: "/summary/interlockSummary/queryById",
          getTagInfo: "/iotedgeCollectData/iotedgeCollectData/getTagInfo"
        },
        customFieldNames: {
          label: 'name',
          value: 'info',
          children: 'children'
        },
        // tagDataOptions: [],
      }
    },
    created () {
      // this.getTagInfo()
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      statusRadioChange(e){
      //   console.log(e)
      //   console.log(this.model.inputStatusRadio)
        // this.$set(this.model, 'inputStatusRadio', e.target.value)
        this.model = {...this.model}
      },
      // 级联选择过滤搜索
      filter(inputValue, path) {
        return path.some(option => (option.label).toLowerCase().indexOf(inputValue.toLowerCase()) > -1);
      },
      // 设置状态默认值和初始化值
      setDefaultValue(){
        // this.$set(this.model, 'inputStatusDefault', this.itSystemDefaultValue.controlSystemStatusNormal)
        var controlSystemStatusDefault = this.itSystemDefaultValue.controlSystemStatusNormalName +'('+ this.itSystemDefaultValue.controlSystemStatusNormal+')'
        this.model.inputStatusDefault = controlSystemStatusDefault
        this.model.outputStatusDefault = controlSystemStatusDefault
        this.model.mpStatusDefault = controlSystemStatusDefault
        // 仪表状态
        this.model.instrumentStatusDefault = this.itSystemDefaultValue.instrumentStatusNormalName +'('+ this.itSystemDefaultValue.instrumentStatusNormal+')'
        this.model.bypassNo = this.itSystemDefaultValue.bypassYesName +'('+ this.itSystemDefaultValue.bypassYes +')'
        // 初始化
        this.model.thresholdValueN = '1'
      },
      // 获取所有位号
      // getTagInfo(){
      //   postAction(this.url.getTagInfo).then(res => {
      //     console.log(res)
      //     this.tagDataOptions = res.result
      //     this.confirmLoading = false
      //   })
      // },
      // displayRender({ labels }) {
      //   // 设置显示最有一位
      //   return labels[labels.length - 1];
      // },
      // 点位选择改变
      dianwerChange(e){
        console.log(e)
      },
      // 点位状态依据改变时
      // instrumentStatusJugeChange(e){
      //   console.log(e)
      //   this.model.upperLimit = null
      //   this.model.lowerLimit = null
      // },
      // 高低限判断系统参考改变
      instrumentGDXTChange(e){
        if(e.target.value === 'Tricon'){
          this.model.upperLimitGd = '4258'
          this.model.lowerLimitGd = '737'
        }
        if(e.target.value === 'TSxPlus'){
          this.model.upperLimitGd = '61948'
          this.model.lowerLimitGd = '10722'
        }
      },
      instrumentTBXTChange(e){
        if(e.target.value === 'Tricon'){
          this.model.upperLimitTb = '4095'
          this.model.lowerLimitTb = '819'
        }
        if(e.target.value === 'TSxPlus'){
          this.model.upperLimitTb = '59577'
          this.model.lowerLimitTb = '11915'
        }
      },
      add () {
        // 设置状态默认值
        this.setDefaultValue()
      },
      edit (record) {
        // console.log(record)
        this.model = Object.assign({}, record);
        // 联锁条件
        this.model.interlockConditionData = [record.interlockConditionDeviceId, record.interlockConditionModuleName, record.interlockConditionTag+'&'+record.interlockCondition]
        // 仪表状态
        if(record.instrumentStatusJuge === '0'){
          // 仪表状态-仪表状态位号
          this.model.instrumentStatusData = [record.instrumentStatusDeviceId, record.instrumentStatusModuleName, record.instrumentStatusTag+'&'+record.instrumentStatusValue]
        }
        if(this.model.instrumentStatusJuge === '1' || this.model.instrumentStatusJuge === '2'){
          // 仪表状态-原始模拟量位号
          this.model.ysmnlData = [record.ysmnlDeviceId, record.ysmnlModuleName, record.ysmnlTag+'&'+record.ysmnlValue]
        }
        if(this.model.instrumentStatusJuge === '1'){
          // 高低限赋值--依据转换后还保持刚刚的选择
          this.model.upperLimitGd = record.upperLimit
          this.model.lowerLimitGd = record.lowerLimit
        }
        if(this.model.instrumentStatusJuge === '2'){
          this.model.upperLimitTb = record.upperLimit
          this.model.lowerLimitTb = record.lowerLimit
          // 仪表状态-阈值Math.round解决相乘会出现很多小数的情况
          this.model.thresholdValueN = Math.round(parseInt(record.thresholdValue)*100)
          // this.model.thresholdValueN = (parseInt(record.thresholdValue)*100).toFixed(0)
        }
        // 当前值
        // this.model.currentValueData = [record.currentValueDeviceId, record.currentValueModuleName, record.currentValueTag+'&'+record.currentValue]
        // 旁路
        if(record.ifBypass === '0'){
          this.model.bypassNo = record.bypass
        }
        if(record.ifBypass === '1'){
          this.model.bypassNo = '0'
          this.model.bypassData = [record.bypassDeviceId, record.bypassModuleName, record.bypassTag+'&'+record.bypass]
        }
        // 输入卡件状态
        this.model.inputStatusRadio = record.inputStatusTag ? '1' : '0'
        if(record.inputStatusTag){
          this.model.inputStatusData = [record.inputStatusDeviceId, record.inputStatusModuleName, record.inputStatusTag+'&'+record.inputStatus]
        }
        // 输出卡件状态
        this.model.outputStatusRadio = record.outputStatusTag ? '1' : '0'
        if(record.outputStatusTag){
          this.model.outputStatusData = [record.outputStatusDeviceId, record.outputStatusModuleName, record.outputStatusTag+'&'+record.outputStatus]
        }
        // MP状态
        this.model.mpStatusRadio = record.mpStatusTag ? '1' : '0'
        if(record.mpStatusTag){
          this.model.mpStatusRadio = '1'
          this.model.mpStatusData = [record.mpStatusDeviceId, record.mpStatusModuleName, record.mpStatusTag+'&'+record.mpStatus]
        }
        this.setDefaultValue()
      },
      submitForm () {
        // const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            // 拆分级联选择器的数据传递后端使用-设备id、模块名称、点位、值
            // var conditionTableData = {}
            // 联锁条件
            this.model.interlockConditionDeviceId = this.model.interlockConditionData[0]
            this.model.interlockConditionModuleName = this.model.interlockConditionData[1]
            this.model.interlockConditionTag = (this.model.interlockConditionData[2].split('&'))[0]
            this.model.interlockCondition = (this.model.interlockConditionData[2].split('&'))[1]
            // 仪表状态
            if(this.model.instrumentStatusJuge === '0'){
              // 仪表状态-仪表状态位号
              this.model.instrumentStatusDeviceId = this.model.instrumentStatusData[0]
              this.model.instrumentStatusModuleName = this.model.instrumentStatusData[1]
              this.model.instrumentStatusTag = (this.model.instrumentStatusData[2].split('&'))[0]
              this.model.instrumentStatusValue = (this.model.instrumentStatusData[2].split('&'))[1]
            }
            if(this.model.instrumentStatusJuge === '1' || this.model.instrumentStatusJuge === '2'){
              // 仪表状态-原始模拟量位号
              this.model.ysmnlDeviceId = this.model.ysmnlData[0]
              this.model.ysmnlModuleName = this.model.ysmnlData[1]
              this.model.ysmnlTag = (this.model.ysmnlData[2].split('&'))[0]
              this.model.ysmnlValue = (this.model.ysmnlData[2].split('&'))[1]
            }
            if(this.model.instrumentStatusJuge === '1'){
              // 根据状态给后端高低限赋值
              this.model.upperLimit = this.model.upperLimitGd
              this.model.lowerLimit = this.model.lowerLimitGd
            }
            if(this.model.instrumentStatusJuge === '2'){
              this.model.upperLimit = this.model.upperLimitTb
              this.model.lowerLimit = this.model.lowerLimitTb
              // 仪表状态-阈值--设置thresholdValueN是防止自身转换出现问题
              this.model.thresholdValue = parseInt(this.model.thresholdValueN)/100
            }
            
            // 当前值
            // this.model.currentValueDeviceId = this.model.currentValueData[0]
            // this.model.currentValueModuleName = this.model.currentValueData[1]
            // this.model.currentValueTag = (this.model.currentValueData[2].split('&'))[0]
            // this.model.currentValue = (this.model.currentValueData[2].split('&'))[1]

            // 旁路位号
            if(this.model.ifBypass === '0'){
              // 否
              // this.model.bypass = this.model.bypassNo
              this.model.bypass = this.itSystemDefaultValue.bypassYes
            }
            if(this.model.ifBypass === '1'){
              // 是
              this.model.bypassDeviceId = this.model.bypassData[0]
              this.model.bypassModuleName = this.model.bypassData[1]
              this.model.bypassTag = (this.model.bypassData[2].split('&'))[0]
              this.model.bypass = (this.model.bypassData[2].split('&'))[1]
            }
            
            // 输入卡件状态
            if(this.model.inputStatusRadio === '1' && this.model.inputStatusData && this.model.inputStatusData.length  > 0){
              // 传位号
              this.model.inputStatusDeviceId = this.model.inputStatusData[0]
              this.model.inputStatusModuleName = this.model.inputStatusData[1]
              this.model.inputStatusTag = (this.model.inputStatusData[2].split('&'))[0]
              this.model.inputStatus = (this.model.inputStatusData[2].split('&'))[1]
            } else {
              this.model.inputStatusDeviceId = null
              this.model.inputStatusModuleName = null
              this.model.inputStatusTag = null
              // 由于需要变成正常(0)的状态，且默认是正常，所以直接用系统的正常状态赋值
              // 如果需要改成下拉选择，就得换个方式写了
              // this.model.inputStatus = this.model.inputStatusDefault
              this.model.inputStatus = this.itSystemDefaultValue.controlSystemStatusNormal
            }
            
            // 输出卡件状态
            if(this.model.outputStatusRadio === '1' && this.model.outputStatusData && this.model.outputStatusData.length  > 0){
              this.model.outputStatusDeviceId = this.model.outputStatusData[0]
              this.model.outputStatusModuleName = this.model.outputStatusData[1]
              this.model.outputStatusTag = (this.model.outputStatusData[2].split('&'))[0]
              this.model.outputStatus = (this.model.outputStatusData[2].split('&'))[1]
            } else {
              this.model.outputStatusDeviceId = null
              this.model.outputStatusModuleName = null
              this.model.outputStatusTag = null
              this.model.outputStatus = this.itSystemDefaultValue.controlSystemStatusNormal
            }

            // MP状态
            if(this.model.mpStatusRadio === '1' && this.model.mpStatusData && this.model.mpStatusData.length  > 0){
              this.model.mpStatusDeviceId = this.model.mpStatusData[0]
              this.model.mpStatusModuleName = this.model.mpStatusData[1]
              this.model.mpStatusTag = (this.model.mpStatusData[2].split('&'))[0]
              this.model.mpStatus = (this.model.mpStatusData[2].split('&'))[1]
            } else {
              this.model.mpStatusDeviceId = null
              this.model.mpStatusModuleName = null
              this.model.mpStatusTag = null
              this.model.mpStatus = this.itSystemDefaultValue.controlSystemStatusNormal
            }
            console.log(this.model)
            this.$emit('ok', this.model)
          }
         
        })
      },
    }
  }
</script>
<style lang="less">
  .red-star-form-item{
    margin-bottom: 0;
    .ant-form-item-label {
      ::before {
        display: inline-block;
        margin-right: 4px;
        color: #ff4d4f;
        font-size: 14px;
        font-family: SimSun, sans-serif;
        line-height: 1;
        content: '*';
      }
    }
  }
</style>