<template>
  <div>
    <el-dialog
      title="批量修改"
      :visible.sync="batchFormVisible"
      :before-close="close"
      width="66%"
    >
      <el-form inline ref="form" label-position="top" :model="formData" :rules="rules">
        <div>
          <el-form-item label="批次属性" prop="lotCode">
            <PublicQuery
              title="批次属性"
              single
              cfgKey="bdWmsLot"
              baseUrl="/bd_web/bdweb"
              :valueField.sync="formData.lotCode"></PublicQuery>
          </el-form-item>
          <el-form-item label="上架库位拣货规则" prop="reserveCode">
            <el-select v-model="formData.reserveCode">
              <el-option label="人工指定库位" value="MAN"></el-option>
              <el-option label="收货前计算库位-一步收货" value="B_RCV_ONE"></el-option>
              <el-option label="收货前计算库位-两步收货" value="B_RCV_TWO"></el-option>
              <el-option label="收货时计算库位" value="RCV"></el-option>
              <el-option label="上架时计算库位" value="PA"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="上架规则" prop="paRule">
            <PublicQuery
              title="上架规则"
              single
              cfgKey="bdWmsPaRule"
              baseUrl="/bd_web/bdweb"
              :valueField.sync="formData.paRule"></PublicQuery>
          </el-form-item>
          <el-form-item label="上架库区" prop="paZone">
            <PublicQuery
              title="上架库区"
              single
              cfgKey="bdWmsZone"
              baseUrl="/bd_web/bdweb"
              :valueField.sync="formData.paZone"></PublicQuery>
          </el-form-item>
          <el-form-item label="上架库位" prop="paLoc">
            <PublicQuery
              title="上架库位"
              single
              cfgKey="bdWmsLoc"
              baseUrl="/bd_web/bdweb"
              :valueField.sync="formData.paLoc"></PublicQuery>
          </el-form-item>
          <el-form-item label="库存周转规则" prop="rotationRule">
            <PublicQuery
              title="库存周转规则"
              single
              cfgKey="bdWmsRotationRule"
              baseUrl="/bd_web/bdweb"
              :valueField.sync="formData.rotationRule"></PublicQuery>
          </el-form-item>
          <el-form-item label="预配规则" prop="preallocRule">
            <PublicQuery
              title="预配规则"
              single
              cfgKey="bdWmsPreallocRule"
              baseUrl="/bd_web/bdweb"
              :valueField.sync="formData.preallocRule"></PublicQuery>
          </el-form-item>
          <el-form-item label="分配规则" prop="allocRule">
            <PublicQuery
              title="分配规则"
              single
              cfgKey="bdWmsAllocRule"
              baseUrl="/bd_web/bdweb"
              :valueField.sync="formData.allocRule"></PublicQuery>
          </el-form-item>
          <el-form-item label="库存上限EA" prop="maxLimit">
            <el-input v-model="formData.maxLimit"></el-input>
          </el-form-item>
          <el-form-item label="库存下限EA" prop="minLimit">
            <el-input v-model="formData.minLimit"></el-input>
          </el-form-item>
          <el-form-item label="商品ABC" prop="abc">
            <el-select v-model="formData.abc">
              <el-option label="A" value="A"></el-option>
              <el-option label="B" value="B"></el-option>
              <el-option label="C" value="C"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="循环级别" prop="cycleCode">
            <PublicQuery
              title="循环级别"
              single
              cfgKey="bdWmsCycle"
              baseUrl="/bd_web/bdweb"
              :valueField.sync="formData.cycleCode"></PublicQuery>
          </el-form-item>
          <el-form-item label="是否效期控制" prop="isValidity">
            <el-select v-model="formData.isValidity">
              <el-option label="是" value="Y"></el-option>
              <el-option label="否" value="N"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="周期类型" prop="lifeType">
            <el-select v-model="formData.lifeType">
              <el-option label="生产日期" value="P"></el-option>
              <el-option label="失效日期" value="E"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="入库效期(天数)" prop="inLifeDays">
            <el-input v-model="formData.inLifeDays"></el-input>
          </el-form-item>
          <el-form-item label="出库效期(天数)" prop="outLifeDays">
            <el-input v-model="formData.outLifeDays"></el-input>
          </el-form-item>
          <el-form-item label="是否质检管理" prop="isQc">
            <el-select v-model="formData.isQc">
              <el-option label="是" value="Y"></el-option>
              <el-option label="否" value="N"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="质检阶段" prop="qcPhase" :rules="formData.isQc==='N'?[]:rules.qcPhase">
            <el-select v-model="formData.qcPhase" :disabled="formData.isQc==='N'">
              <el-option label="收货前" value="RCV"></el-option>
              <el-option label="收货后上架前" value="PA"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="质检规则" prop="qcRule" :rules="formData.isQc==='N'?[]:rules.qcRule">
            <PublicQuery
              title="质检规则"
              single
              :disabled="formData.isQc==='N'"
              cfgKey="bdWmsQcRule"
              baseUrl="/bd_web/bdweb"
              :valueField.sync="formData.qcRule"></PublicQuery>
          </el-form-item>
          <el-form-item label="质检项" prop="itemGroupCode" :rules="formData.isQc==='N'?[]:rules.itemGroupCode">
            <PublicQuery
              title="质检项"
              single
              :disabled="formData.isQc==='N'"
              cfgKey="bdWmsQcItem"
              baseUrl="/bd_web/bdweb"
              :valueField.sync="formData.itemGroupCode"></PublicQuery>
          </el-form-item>
          <el-form-item label="是否允许超收" prop="isOverRcv">
            <el-select v-model="formData.isOverRcv">
              <el-option label="是" value="Y"></el-option>
              <el-option label="否" value="N"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="超收百分比" prop="overRcvPct">
            <el-input v-model="formData.overRcvPct"></el-input>
          </el-form-item>
          <el-form-item label="费率组" prop="rateGroup">
            <PublicQuery
              title="费率组"
              single
              cfgKey="bdWmsRateGroup"
              baseUrl="/bd_web/bdweb"
              :valueField.sync="formData.rateGroup"></PublicQuery>
          </el-form-item>
          <el-form-item label="越库级别" prop="cdClass">
            <el-select v-model="formData.cdClass">
              <el-option label="半越库" value="PART"></el-option>
              <el-option label="全越库" value="FULL"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="是否附件" prop="isParent">
            <el-select v-model="formData.isParent">
              <el-option label="是" value="Y"></el-option>
              <el-option label="否" value="N"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="是否启用" prop="isEnable">
            <el-select v-model="formData.isEnable">
              <el-option label="是" value="Y"></el-option>
              <el-option label="否" value="N"></el-option>
            </el-select>
          </el-form-item>
        </div>
      </el-form>
      <div class="more-query-btn">
        <el-button v-auth="50300030101" type="primary" @click="handleConfirm">确认修改</el-button>
        <el-button v-auth="50300030101" type="primary" @click="handleReset">重置</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  data () {
    return {
      formData: { isQc: 'N' },
      rules: {
        qcPhase: [{ required: true, message: '质检阶段必填', trigger: 'change' }],
        qcRule: [{ required: true, message: '质检规则必填', trigger: 'change' }],
        itemGroupCode: [{ required: true, message: '质检项必填', trigger: 'change' }],
      }
    }
  },
  props: {
    batchFormVisible: Boolean,
    rows: Array
  },
  mounted () {

  },
  methods: {
    close () {
      this.$emit('close')
    },

    // 确认
    handleConfirm () {
      this.$emit('handleBatchConfirm', this.formData, this.rows)
    },

    // 确认并添加
    handleReset () {
      this.$refs.form.resetFields()
    },
  },

  watch: {
    locData: {
      handler (item) {

      },
      deep: true
    },
  }
}
</script>
