<template>
  <div>
    <!-- 签名弹窗 -->
    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :title="title" :visible.sync="open" width="500px" @close="close" append-to-body>
      <el-form ref="formEditSignForm" :model="form" :rules="rules" label-width="120px">
        <el-row>
          <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.reason')" 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')" show-password />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">{{ $t('form.cancel') }}</el-button>
        <el-button type="primary" @click="save">{{ $t('form.confirm') }}</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { public_checkPassword } from '@/api/business/public/public'
export default {
  name: "FormEditSign",
  components: {  },
  data() {
    return {
      title:this.$t('form.modify'),
      open: false,
      form: {
        qmyy:'',
        remark:'',
        qmrId:'',
        qmrMc:'',
        qmrMcEn:'',
        qmrmm:'',
      },
      isChecked:false,
      rules: {
        qmrmm: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        remark: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }]
      }
    }
  },
  computed: {
  },
  created() {
  },
  methods: {
    show() {
      this.form = {
        qmyy:this.$t('form.modifyRecord'),
        remark:'',
        qmrId:this.$store.getters.id,
        qmrMc:this.$store.getters.nickName,
        qmrMcEn:this.$store.getters.name,
        qmrmm:'',
      }
      this.isChecked = false
      this.resetForm("formEditSignForm")
      this.open = true
    },
    cancel() {
      this.open = false
    },
    close(){
      if(!this.isChecked){
        this.$emit('cancel')
      }
    },
    save() {
      this.$refs["formEditSignForm"].validate(valid => {
        if (valid) {
          this.$modal.loading()
          public_checkPassword(this.form).then(response => {
            this.isChecked = true
            this.$emit('callback',this.form)
            this.open = false
          }).catch(()=>{
          }).finally(()=>{
            this.$modal.closeLoading()
          })
        }
      })
    }
  }
}
</script>
