<template>
  <div>
    <!-- 签名弹窗 -->
    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="signForm" :model="form" :rules="rules" label-width="120px">
        <el-row>
          <el-col :span="24" v-if="showDate">
            <el-form-item :label="$t('page.business.study.study.jysj')" prop="startDate">
              <el-date-picker v-model="dateArr" clearable type="daterange" range-separator="-" :start-placeholder="$t('form.startDate')"
            :end-placeholder="$t('form.endDate')" value-format="yyyy-MM-dd" style="width: 100%" @change="changeDate" />
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item :label="$t('form.qmyy')" prop="qmyy">
              <el-input type="text" v-model="form.qmyy" maxlength="50" disabled
                :placeholder="$t('form.placeholderInput')" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item :label="$t('form.remark')" prop="remark">
              <el-input type="textarea" v-model="form.remark" :rows="2" maxlength="500"
                :placeholder="$t('form.placeholderInput')">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item :label="$t('form.signer')">
              <el-input type="text" v-model="form.qmrMc" maxlength="50" disabled
                :placeholder="$t('form.placeholderInput')" />
            </el-form-item>
          </el-col>
          <!-- <el-col :span="24" v-if="$i18n.locale === 'zh_CN'">
            <el-form-item :label="$t('form.signer')">
              <el-input type="text" v-model="form.qmrMc" maxlength="50" disabled
                :placeholder="$t('form.placeholderInput')" />
            </el-form-item>
          </el-col>
          <el-col :span="24" v-else>
            <el-form-item :label="$t('form.signer')">
              <el-input type="text" v-model="form.qmrMcEn" maxlength="50" disabled
                :placeholder="$t('form.placeholderInput')" />
            </el-form-item>
          </el-col> -->
          <el-col :span="24">
            <el-form-item :label="$t('form.password')" prop="qmrmm">
              <el-input type="password" v-model="form.qmrmm" maxlength="20" :placeholder="$t('form.placeholderInput')" autocomplete="off" auto-complete="new-password" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="save">{{ $t('form.confirm') }}</el-button>
        <el-button @click="cancel">{{ $t('form.cancel') }}</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "Sign",
  components: {  },
  data() {
    return {
      title:'',
      open: false,
      form: {
        qmyy:'',
        remark:'',
        qmrId:'',
        qmrMc:'',
        qmrMcEn:'',
        qmrmm:'',

        startDate:'',
        endDate:''
      },
      dateArr:[],
      showDate:false,
      rules: {
        qmrmm: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        startDate: [{
          required: true,
          message: ' ',
          trigger: 'change'
        }]
      }
    }
  },
  computed: {
  },
  created() {
  },
  methods: {
    show(title,qmyy,showDate) {
      this.showDate = showDate==undefined?false:showDate
      this.dateArr = []
      this.title = title
      this.form = {
        qmyy:qmyy,
        remark:'',
        qmrId:this.$store.getters.id,
        qmrMc:this.$store.getters.nickName,
        qmrMcEn:this.$store.getters.name,
        qmrmm:'',
        startDate:'',
        endDate:''
      }
      this.resetForm("signForm")
      this.open = true
    },
    cancel() {
      this.open = false
    },
    changeDate(val){
      this.form.startDate = val && val.length>0?val[0]:''
      this.form.endDate = val && val.length>1?val[1]:''
    },
    save() {
      this.$refs["signForm"].validate(valid => {
        if (valid) {
          this.$emit('callback',this.form)
        }
      })
    }
  }
}
</script>
