<template>
<div>
  <el-form-item v-bind:error="tagValue[2].s1" :required="pattern.status=='M' || tagValue[1]?true:false">
    <c-input-format size="small" v-model="tagValue[0].s1" :maxRows="4" :maxCols="35" placeholder="Name and Address" @blur="handleChange" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s1') !== -1">
    </c-input-format>
  </el-form-item>
  <el-form-item v-bind:error="tagValue[2].s2" :required="pattern.status=='M' || tagValue[1]?true:false">
    <el-select size="small" v-model="tagValue[0].s2" placeholder="Code" @change="handleChange" style="width: 100%" :disabled="pattern.tagFlag && pattern.tagFlag.indexOf('s2') !== -1">
      <el-option label="BY ACCEPTANCE" value="BY ACCEPTANCE"></el-option>
      <el-option label="BY DEF PAYMENT" value="BY DEF PAYMENT"></el-option>
      <el-option label="BY MIXED PYMT" value="BY MIXED PYMT"></el-option>
      <el-option label="BY NEGOTIATION" value="BY NEGOTIATION"></el-option>
      <el-option label="BY PAYMENT" value="BY PAYMENT"></el-option>
    </el-select>
  </el-form-item>
</div>
</template>
<script>

export default {
  props: {
    tag: {
      type: String,
      default: ''
    },
    pattern: {
      type: Object,
      default: () => {}
    }
  },
  data: function () {
    return {
      dialogVisible: false,
      tagValue: [{
        s1: '',
        s2: ''
      },
      '',
      {
        s1: '',
        s2: ''
      }]
    }
  },
  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 =  `${obj.s1}\r\n${obj.s2}`
      this.pattern.tagValue[1] = mval
      this.$emit('validate')
    }
  }
}
</script>