G<template>
  <div>
    <!-- 审核修改库存弹窗 -->
    <el-dialog :title="$t('page.business.zykgl.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">
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.zykgl.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.zykgl.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.zykgl.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.zykgl.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.zykgl.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.zykgl.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="qmyy">
              <el-select v-model="form.qmyy" :placeholder="$t('form.placeholderSelect')" >
                <el-option  label="同意修改库存" :value="10" />
                <el-option  label="拒绝修改库存" :value="1" />
              </el-select>
            </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="primary" @click="save">{{ $t('form.confirm') }}</el-button>
        <el-button @click="cancel">{{ $t('form.cancel') }}</el-button>
      </div>
    </el-dialog>
  </div>
</template>

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

export default {
  name: "Mjybj",
  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'
        }]
      }
    }
  },
  computed: {
    ...mapGetters([
      'nickName'
    ]),
  },
  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: '同意修改库存',
        remark: ''
      }
      this.resetForm("form")
    },
    show(row) {
      this.reset()
      this.$modal.loading()
      mjy_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() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          mjy_shxgkc(this.form).then(response => {
            this.open = false
            this.$emit('callback')
          })
        }
      })
    }
  }
}
</script>
