<template>
  <div>
    <!-- 审核编辑弹窗 -->
    <el-dialog :title="$t('page.business.resource.mjy.shbj')" :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.mjy.mc')" prop="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.mjy.bh')" prop="glyj">
              <el-input type="text" v-model="form.bh" maxlength="50" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.mjy.nd')" prop="nd">
              <el-input type="text" v-model="form.nd" maxlength="50" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.mjy.nddw')" prop="nddw">
              <el-input type="text" v-model="form.nddw" maxlength="50" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.mjy.sxrq')" prop="sxrq">
              <el-input type="text" v-model="form.sxrq" maxlength="50" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.mjy.cctj')" prop="cctj">
              <el-input type="text" v-model="form.cctj" maxlength="50" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.mjy.ccwz')" prop="ccwz">
              <el-input type="text" v-model="form.ccwz" maxlength="50" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item :label="$t('page.business.resource.mjy.xgr')">
              <el-input type="text" v-model="form.bjrMc" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item :label="$t('page.business.resource.mjy.xgbz')" prop="bjbz">
              <el-input type="text" v-model="form.bjbz" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('form.qmyy')" prop="qmyyMc">
              <el-input type="text" :value="form.qmyyMc" maxlength="50" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('form.signer')">
              <el-input type="text" v-model="nickName" 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.password')" prop="qmrmm">
              <el-input type="password" v-model="form.qmrmm" 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.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-form>
      <div slot="footer" class="dialog-footer" style="text-align: center;">
        <el-button type="danger" @click="save(1)">{{ $t('form.reject') }}</el-button>
        <el-button type="primary" @click="save(10)">{{ $t('form.approve') }}</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { shbj, info } from "@/api/business/mjy/mjy"
import { mapGetters } from 'vuex'
import SelectList from "./SelectList";

export default {
  name: "Shbj",
  components: { SelectList },
  data() {
    return {
      open: false,
      form: {},
      rules: {
        qmyyMc: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        mc: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        bh: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        nd: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        nddw: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        sxrq: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        cctj: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        ccwz: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        qmrmm: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
      }
    }
  },
  computed: {
    ...mapGetters([
      'nickName','name'
    ]),
  },
  created() {
  },
  methods: {
    cancel() {
      this.open = false
    },
    reset() {
      this.form = {
        id: null,
        mc: null,
        bh: null,
        nd: null,
        nddw: null,
        sxrq: null,
        cctj: null,
        ccwz: null,
        qmrmm: null,
        bjrMc: null,
        bjbz: null,
        qmyy: null,
        qmyyMc: this.$t('page.business.resource.mjy.tyjjbj'),
        remark: ''
      }
      this.resetForm("form")
    },
    show(row) {
      this.reset()
      this.$modal.loading()
      info({ id: row.id }).then(response => {
        this.form.id = response.data.id
        this.form.mc = response.data.mcbj
        this.form.bh = response.data.bh
        this.form.nd = response.data.ndbj
        this.form.nddw = response.data.nddwbj
        this.form.sxrq = response.data.sxrqbj
        this.form.cctj = response.data.cctjbj
        this.form.ccwz = response.data.ccwzbj
        this.form.bjbz = response.data.bjbz
        this.form.bjrMc = response.data.bjrMc
        this.open = true
        this.$modal.closeLoading()
      })
    },
    save(qmyy) {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.$modal.loading()
          this.form.qmyy=qmyy
          shbj(this.form).then(response => {
            this.open = false
            this.$emit('callback')
            this.$modal.closeLoading()
          }).finally(() => {
            this.$modal.closeLoading()
          })
        }
      })
    }
  }
}
</script>
