<template>
  <div>
    <!-- 取出弹窗 -->
    <el-dialog :title="$t('page.business.resource.gyzj.quchu')" :visible.sync="open" width="800px" append-to-body
      :close-on-click-modal="false">
      <el-form ref="form" :model="form" :rules="rules" label-width="120px" 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.gyzj.mc')">
              <el-input type="text" v-model="form.mc" maxlength="50" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.gyzj.bh')">
              <el-input type="text" v-model="form.bh" maxlength="50" disabled />
            </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.gyzj.qmr1Id')">
              <el-input type="text" v-model="nickName" maxlength="50" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.gyzj.qmr1Id') + $t('form.password')" prop="qmr1mm">
              <el-input type="password" v-model="form.qmr1mm" 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.gyzj.qmr2Id')" prop="qmr2Id">
              <SelectDeptUser v-model="form.qmr2Id" key="qmr2Id" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.gyzj.qmr2Id') + $t('form.password')" prop="qmr2mm">
              <el-input type="password" v-model="form.qmr2mm" maxlength="20"
                :placeholder="$t('form.placeholderInput')" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item :label="$t('form.qmyy')" prop="qmyy">
              <el-input type="text" :value="form.qmyyMc" maxlength="50" disabled />
            </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 { qc } from "@/api/business/gyzj/gyzj"
import { mapGetters } from 'vuex'
import SelectDeptUser from '@/views/business/comps/select/SelectDeptUser';
import BusinessSelect from '@/views/business/comps/select/BusinessSelect';

export default {
  name: "Qc",
  components: { SelectDeptUser, BusinessSelect },
  data() {
    return {
      isBatch: false,
      ids: [],
      selectList: [],
      open: false,
      form: {},
      rules: {
        qmr1Id: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        qmr1mm: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        qmr2Id: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        qmr2mm: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }]
      }
    }
  },
  computed: {
    ...mapGetters([
      'nickName', 'name'
    ]),
  },
  created() {
  },
  methods: {
    cancel() {
      this.open = false
    },
    reset() {
      this.form = {
        id: null,
        mc:'',
        bh:'',
        remark: '',
        qmr1Id: '',
        qmr1mm: '',
        qmr2Id: '',
        qmr2mm: '',
        remark: '',
        qmyyMc: this.$t('page.business.resource.gyzj.quchu'),
      }
      this.resetForm("form")
    },
    show(row) {
      this.reset()
      this.form.id = row.resourceId
      this.form.bh = row.bh
      this.form.mc = row.mc
      this.open = true
    },
    save() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.$modal.loading()
          qc(this.form).then(response => {
            this.open = false
            this.$emit('callback')
            this.$modal.closeLoading()
          }).finally(() => {
            this.$modal.closeLoading()
          })
        }
      })
    }
  }
}
</script>
