<template>
  <div>
    <!-- 审核编辑弹窗 -->
    <el-dialog :title="$t('page.business.resource.gsp.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">
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.gsp.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.gsp.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.gsp.ph')" prop="nd">
              <el-input type="text" v-model="form.ph" maxlength="50" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.gsp.gg')" prop="nddw">
              <el-input type="text" v-model="form.gg" maxlength="50" disabled >
                <template slot="append">{{ form.ggdw }}</template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.gsp.yxq')" prop="sxrq">
              <el-input type="text" v-model="form.yxq" maxlength="50" disabled />
            </el-form-item>
          </el-col>
           <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.gsp.jsrq')" prop="cctj">
              <el-input type="text" v-model="form.jsrq" 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.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="qmyy">
              <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="2" maxlength="500"
                :placeholder="$t('form.placeholderInput')">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <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/gsp/gsp"
import { mapGetters } from 'vuex'

export default {
  name: "Shbj",
  data() {
    return {
      open: false,
      form: {},
      rules: {
        qmyy: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        qmrmm: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
      }
    }
  },
  computed: {
    ...mapGetters([
      'nickName'
    ]),
  },
  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.gsp.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.ph = response.data.phbj
        this.form.gg = response.data.ggbj
        this.form.ggdw = response.data.ggdwbj
        this.form.yxq = response.data.yxqbj
        this.form.jsrq = response.data.jsrqbj
        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.$modal.closeLoading()
            this.$emit('callback')
          }).finally(() => {
            this.$modal.closeLoading()
          })
        }
      })
    }
  }
}
</script>
