<template>
  <div>
    <!-- 审核修改库存弹窗 -->
    <el-dialog :title="$t('page.business.resource.mjy.shxgkc')" :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="mcbj">
              <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.kc')" prop="kcbj">
              <el-input type="number" v-model="form.kcbj" maxlength="50" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.mjy.kcdw')" prop="kcdwbj">
              <el-input type="text" v-model="form.kcdwbj" 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.kcbjrMc" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item :label="$t('page.business.resource.mjy.xgbz')" prop="kcbjbz">
              <el-input type="text" v-model="form.kcbjbz" 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 { shxgkc, info } from "@/api/business/mjy/mjy"
import { mapGetters } from 'vuex'
import SelectList from "./SelectList";

export default {
  name: "Shxgkc",
  components: { SelectList },
  data() {
    return {
      open: false,
      form: {},
      rules: {
        kcbj: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        kcdwbj: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        qmrmm: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        qmyyMc: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }]
      }
    }
  },
  computed: {
    ...mapGetters([
      'nickName','name'
    ]),
  },
  created() {
  },
  methods: {
    cancel() {
      this.open = false
    },
    reset() {
      this.form = {
        id: null,
        mc: null,
        bh: null,
        kcbj: null,
        kcdwbj: null,
        qmrmm: null,
        kcbjrMc: null,
        kcbjbz: null,
        qmyy: null,
        qmyyMc: this.$t('page.business.resource.mjy.tyjjxgkc'),
        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.mc
        this.form.bh = response.data.bh
        this.form.kcbj = response.data.kcbj
        this.form.kcdwbj = response.data.kcdwbj
        this.form.kcbjbz = response.data.kcbjbz
        this.form.kcbjrMc = response.data.kcbjrMc
        this.open = true
        this.$modal.closeLoading()
      })
    },
    save(qmyy) {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.$modal.loading()
          this.form.qmyy=qmyy
          shxgkc(this.form).then(response => {
            this.open = false
            this.$emit('callback')
            this.$modal.closeLoading()
          }).finally(() => {
            this.$modal.closeLoading()
          })
        }
      })
    }
  }
}
</script>
