<template>
<div v-if="mty== 'fmt101' || mty == 'fmt102'||mty == 'fmt104'"> 
  <el-row :gutter="20">
    <!-- <el-col :span="6">
      <el-form-item v-bind:error="tagValue[2].s1" label-position="top">
        <c-select size="small" v-model="tagValue[0].s1" placeholder="D/C" @change="handleChange"
        style="width:100%" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s1') !== -1">
          <el-option label="C" value="C"></el-option>
          <el-option label="D" value="D"></el-option>
        </c-select>
      </el-form-item>
    </el-col> -->
    <el-col :span="18">
      <el-form-item v-bind:error="tagValue[2].s2">
        <el-input size="small" v-model="tagValue[0].s2" placeholder="Account" :maxlength="34"
        @blur="handleChange"  style="width:100%"
        :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s2') !== -1">
          <template slot="prepend">/</template>
        </el-input>
      </el-form-item>
    </el-col>
  </el-row>
  <el-row>
  <el-form-item v-bind:error="tagValue[2].s3">
    <el-input size="small" v-model="tagValue[0].s3" placeholder="Location" :maxlength="35" @blur="handleChange"
    :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s3') !== -1">
    </el-input>
  </el-form-item>
  </el-row>
</div>
<div v-else>
    <el-row :gutter="20">
    <el-col :span="6">
      <el-form-item v-bind:error="tagValue[2].s1" label-position="top">
        <c-select size="small" v-model="tagValue[0].s1" placeholder="D/C" @change="handleChange"
        style="width:100%" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s1') !== -1">
          <el-option label="C" value="C"></el-option>
          <el-option label="D" value="D"></el-option>
        </c-select>
      </el-form-item>
    </el-col>
    <el-col :span="18">
      <el-form-item v-bind:error="tagValue[2].s2">
        <el-input size="small" v-model="tagValue[0].s2" placeholder="Account" :maxlength="34"
        @blur="handleChange"  style="width:100%"
        :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s2') !== -1">
          <template slot="prepend">/</template>
        </el-input>
      </el-form-item>
    </el-col>
  </el-row>
  <el-row>
  <el-form-item v-bind:error="tagValue[2].s3">
    <el-input size="small" v-model="tagValue[0].s3" placeholder="Location" :maxlength="35" @blur="handleChange"
    :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s3') !== -1">
    </el-input>
  </el-form-item>
  </el-row>
</div>
</template>
<script>
export default {
  props: {
    tag: {
      type: String,
      default: ''
    },
     mty: {
      type: String,
      default: ''
    },
    pattern: {
      type: Object,
      default: () => {}
    }
  },
  data: function () {
    return {
      tagValue: [{
        s1: '',
        s2: '',
        s3: '',
      },
      '',
      {
        s1: '',
        s2: '',
        s3: ''
      }]
    }
  },
  created: function () {
    if (this.pattern.tagValue == undefined || JSON.stringify(this.pattern.tagValue) == '[{},null]') {
      this.pattern.tagValue = this.tagValue
    } else {
      this.tagValue = this.pattern.tagValue
    }
  },
  methods: {
    handleChange: function () {
      // 触发校验
      let obj = this.pattern.tagValue[0]
      let mval = ""
      if(obj.s1)
          mval =  '/' + obj.s1 
      if(obj.s2)
          mval =  mval +'/' + obj.s2 
      if(obj.s3)
          mval = mval?`${mval}\r\n${obj.s3}`:obj.s3
      this.pattern.tagValue[1] = mval
      this.$emit('validate')
    }
  }
}
</script>