<template>
  <div>
    <!-- 处置试剂弹窗 -->
    <el-dialog :title="$t('page.business.resource.sj.cz')" :visible.sync="open" width="500px" append-to-body
      :close-on-click-modal="false">
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <template>
          <el-row>
            <el-col :span="24">
              <el-form-item :label="$t('page.business.resource.sj.mc')" prop="mc">
                <el-input type="text" v-model="form.mc" 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('page.business.resource.sj.bh')" prop="glyj">
                <el-input type="text" v-model="form.bh" 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('page.business.resource.sj.sjczfs')" prop="czfs">
                <BusinessSelect v-model="form.czfs" dictType="business_czfs"></BusinessSelect>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item :label="$t('page.business.resource.sj.czl')" prop="czl">
                <el-input type="number" v-model="form.czl" maxlength="50" :placeholder="$t('form.placeholderInput')">
                  <template slot="append">{{ form.kcdw }}</template>
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item :label="$t('page.business.resource.sj.yuanyin')" prop="remark">
                <el-input type="textarea" :rows="2" v-model="form.remark" maxlength="500"
                  :placeholder="$t('form.placeholderInput')" />
              </el-form-item>
            </el-col>
          </el-row>
        </template>
        <el-row>
          <el-col :span="24">
            <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="24">
            <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">
              <div class="sbzdtcma"> <input type="text"></div>
              <el-input type="password" @contextmenu.native.prevent @copy.native.prevent @cut.native.prevent v-model="form.qmrmm" maxlength="20"  autocomplete="off" auto-complete="new-password" show-password
                :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 { sj_cz } from "@/api/business/sj/sj"
import { mapGetters } from 'vuex'
import SelectList from "./SelectList";
import BusinessSelect from '@/views/business/comps/select/BusinessSelect';
export default {
  name: "SjCz",
  components: { SelectList, BusinessSelect },
  data() {
    return {
      ids: [],
      selectList: [],
      open: false,
      form: {},
      rules: {
        czfs: [
          { required: true, message: this.$t('page.business.resource.sj.sjczfs') + this.$t('form.notEmpty'), trigger: "change" },
          { min: 0, max: 50, message: this.$t('page.business.resource.sj.sjczfs') + this.$t('form.lengthLimit') + '50', trigger: 'blur' }
        ],
        czl: [
          { required: true, message: this.$t('page.business.resource.sj.czl') + this.$t('form.notEmpty'), trigger: "change" },
        ],
        remark: [
          { required: true, message: this.$t('page.business.resource.sj.yuanyin') + this.$t('form.notEmpty'), trigger: "change" },
        ],
        qmrmm: [
          { required: true, message: this.$t('form.signerPsw') + this.$t('form.notEmpty'), trigger: "change" },
        ]

      }
    }
  },
  computed: {
    ...mapGetters([
      'nickName','name'
    ]),
  },
  created() {
  },
  methods: {
    cancel() {
      this.open = false
    },
    reset() {
      this.form = {
        id: null,
        ids: null,
        mc: null,
        bh: null,
        qmyy: this.$t('page.business.resource.sj.cz'),
        kcdw: '',
        qmrmm: null
      }
      this.resetForm("form")
    },
    show(row) {
      this.reset()
      this.isBatch = false
      this.form.ids = []
      this.selectList = []
      this.form.id = row.id
      this.form.mc = row.mc
      this.form.bh = row.bh
      this.form.kcdw = row.kcdw
      this.open = true
    },
    save() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          sj_cz(this.form).then(response => {
            this.open = false
            this.$modal.msgSuccess(this.$t('form.operationSuccess'))
            this.$emit('callback')
          })
        }
      })
    }
  }
}
</script>
