<template>
  <div>
    <!-- 确认入库弹窗 -->
    <el-dialog :title="$t('page.business.resource.gyzj.qrrk')" :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="12">
            <el-form-item :label="$t('page.business.resource.gyzj.sxrq')">
              <el-input type="text" v-model="form.sxrq" maxlength="50" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.gyzj.nd')">
              <el-input type="text" v-model="form.nd" maxlength="50" disabled> <template slot="append">{{ form.nddw
              }}</template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.gyzj.zytj')" prop="rkzytj">
              <BusinessSelect v-model="form.rkzytj" dictType="business_zytj"></BusinessSelect>
            </el-form-item>
          </el-col>
           <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.gyzj.rkwz')" prop="rkwz">
              <BusinessSelect v-model="form.rkwz" dictType="business_rkwz"></BusinessSelect>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
            <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.gyzj.rktj')" prop="rktj">
              <BusinessSelect v-model="form.rktj" dictType="business_rktj"></BusinessSelect>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.gyzj.rkl')" prop="rkl">
              <el-input type="number" v-model="form.rkl" maxlength="50" :placeholder="$t('form.placeholderInput')">
                <template slot="append">{{ form.ckldw }}</template>
              </el-input>
            </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="form.qmr1Mc" maxlength="50" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.gyzj.qmr2Id')">
              <el-input type="text" v-model="form.qmr2Mc" maxlength="50" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.gyzj.jsr1Id')">
              <el-input type="text" v-model="nickName" maxlength="50" :placeholder="$t('form.placeholderInput')"
                disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.gyzj.jsr1Id') + $t('form.password')" prop="jsr1mm">
              <el-input type="password" v-model="form.jsr1mm" 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.jsr2Id')" prop="jsr2Id">
              <SelectDeptUser v-model="form.jsr2Id" key="jsr2Id" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.gyzj.jsr2Id') + $t('form.password')" prop="jsr2mm">
              <el-input type="password" v-model="form.jsr2mm" 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" 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 { rk, info } 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: "Gh",
  components: { SelectDeptUser,BusinessSelect },
  data() {
    return {
      isBatch: false,
      ids: [],
      selectList: [],
      open: false,
      form: {},
      rules: {
        rkwz: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        rktj: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        rkzytj: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        rkl: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        jsr1Id: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        jsr1mm: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        jsr2Id: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        jsr2mm: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }]
      }
    }
  },
  computed: {
    ...mapGetters([
      'nickName','name'
    ]),
  },
  created() {
  },
  methods: {
    cancel() {
      this.open = false
    },
    reset() {
      this.form = {
        qmyy: null,
        rkl:null,
        qmyyMc: this.$t('page.business.resource.gyzj.tyjjrk'),
      }
      this.resetForm("form")
    },
    show(row) {
      this.reset()
      let that = this
      info({ id: row.id }).then(response => {
        that.form = _.merge({},this.form,response.data)
        this.form.rkl=this.form.kc
        that.open = true
      })
    },
    save(qmyy) {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.$modal.loading()
          this.form.qmyy=qmyy
          rk(this.form).then(response => {
            this.open = false
            this.$emit('callback')
            this.$modal.closeLoading()
          }).finally(() => {
            this.$modal.closeLoading()
          })
        }
      })
    }
  }
}
</script>
