G<template>
  <div>
    <!-- 试验间-更换笼具弹窗 -->
    <el-dialog :title="$t('page.business.study.studyRoom.ghlj')" :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.study.studyRoom.syqy')" prop="syqy">
              <SelectTestArea v-model="form.syqy" :readonly="true"/>
            </el-form-item>
          </el-col>
          <!-- 饲养间号 -->
          <el-col :span="12">
            <el-form-item :label="$t('page.business.study.studyRoom.syjh')" prop="syjh">
              <SelectRoom v-model="form.syjh" :testArea="form.syqy" :readonly="true"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <!-- 动物种属 -->
          <el-col :span="12">
            <el-form-item :label="$t('page.business.study.studyRoom.dwzs')" prop="dwzs">
              <SelectAnimalSpecies v-model="form.dwzs" :readonly="true"/>
            </el-form-item>
          </el-col>
          <!-- 笼具 -->
          <el-col :span="12">
            <el-form-item :label="$t('page.business.study.studyRoom.longju')" prop="lj">
              <SelectCage v-model="form.lj" :animalSpecies="form.dwzs"/>
            </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.qmyy" maxlength="50" disabled
                :placeholder="$t('form.placeholderInput')" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <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="12">
            <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-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 { studyRoom_update } from "@/api/business/study/studyRoom"
import { mapGetters } from 'vuex'
import BusinessSelect from '@/views/business/comps/select/BusinessSelect';
import SelectTestArea from '@/views/business/comps/select/SelectTestArea';
import SelectRoom from '@/views/business/comps/select/SelectRoom';
import SelectAnimalSpecies from '@/views/business/comps/select/SelectAnimalSpecies';
import SelectCage from '@/views/business/comps/select/SelectCage';
export default {
  name: "BjSyj",
  components: { BusinessSelect, SelectTestArea, SelectRoom, SelectCage, SelectAnimalSpecies },
  data() {
    return {
      open: false,
      form: {},
      rules: {
        syqy: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        syjh: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        dwzs: [{
          required: true,
          message: ' ',
          trigger: 'blur'
        }],
        lj: [{
          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,
        syqy: null,
        syjh: null,
        dwzs: null,
        lj: null,
        qmrmm: '',
        qmyy: '更换笼具',
        bjbz: ''
      }
      this.resetForm("form")
    },
    show(row) {
      this.reset()
      this.form.id = row.id
      this.form.syqy = row.syqy
      this.form.syjh = row.syjh
      this.form.dwzs = row.dwzs
      this.form.lj = row.lj
      this.form.qmyy = '更换笼具'
      this.open = true
    },
    save() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          studyRoom_update(this.form).then(response => {
            this.open = false
            this.$emit('callback')
          })
        }
      })
    }
  }
}
</script>
