<template>
  <div class="app-container">
    <!-- 钥匙发放弹窗 -->
    <el-dialog :title="$t('page.business.resource.zcg.ysff')" :visible.sync="open" width="1000px" append-to-body
      :close-on-click-modal="false">
      <el-form ref="form" :model="form" :rules="rules" label-width="170px" v-if="open">
        <div class="sbzdtcma"> <input type="text"> <input type="password"> </div>
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.zcg.zcg')" prop="mc">
              <el-input type="text" v-model="form.mc" maxlength="50" disabled
                :placeholder="$t('form.placeholderInput')" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.zcg.glyj')" prop="glyj">
              <el-input type="text" v-model="form.glyj" maxlength="500" :placeholder="$t('form.placeholderInput')" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('form.qmyy')" prop="qmyy">
              <el-input type="text" :value="form.qmyy" maxlength="50" disabled
                :placeholder="$t('form.placeholderInput')" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item :label="$t('form.remark')" prop="remark">
              <el-input type="textarea" v-model="form.remark" :rows="5" maxlength="500"
                :placeholder="$t('form.placeholderInput')">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.zcg.lqr1Id')" prop="lqr1Id">
              <SelectDeptUser v-model="form.lqr1Id" key="lqr1Id" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.zcg.lqr1mm')" prop="lqr1mm">
              <el-input type="password" v-model="form.lqr1mm" maxlength="20" :placeholder="$t('form.placeholderInput')" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.zcg.lqr2Id')" prop="lqr2Id">
              <SelectDeptUser v-model="form.lqr2Id" key="lqr2Id" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.zcg.lqr2mm')" prop="lqr2mm">
              <el-input type="password" v-model="form.lqr2mm" maxlength="20" :placeholder="$t('form.placeholderInput')" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.zcg.ffr')">
              <el-input type="text" v-model="nickName" maxlength="50" disabled
                :placeholder="$t('form.placeholderInput')" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.zcg.ffrmm')" prop="ffrmm">
              <el-input type="password" v-model="form.ffrmm" maxlength="20" :placeholder="$t('form.placeholderInput')" />
            </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>
import { zcg_ysff } from "@/api/business/zcg/zcg"
import { mapGetters } from 'vuex'
import SelectDeptUser from '@/views/business/comps/select/SelectDeptUser';

export default {
  name: "ZcgYsff",
  components: { SelectDeptUser },
  data() {
    return {
      open: false,
      form: {},
      rules: {
        glyj: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        lqr1Id: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        lqr2Id: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        lqr1mm: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        lqr2mm: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        ffrmm: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
      }
    }
  },
  computed: {
    ...mapGetters([
      'nickName','name'
    ]),
  },
  created() {
  },
  methods: {
    cancel() {
      this.open = false
    },
    reset() {
      this.form = {
        id: null,
        mc: null,
        glyj: null,
        qmyy: this.$t('page.business.resource.zcg.qysff'),
        remark: null,
        lqr1Id: null,
        lqr2Id: null,
        lqr1mm: null,
        lqr2mm: null,
        ffrmm: null
      }
      this.resetForm("form")
    },
    show(row) {
      this.reset()
      this.form.id = row.id
      this.form.mc = row.mc
      this.open = true
    },
    save() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.$modal.loading()
          zcg_ysff(this.form).then(response => {
            this.open = false
            this.$emit('callback')
            this.$modal.closeLoading()
          }).finally(() => {
            this.$modal.closeLoading()
          })
        }
      })
    }
  }
}
</script>
