<template>
  <div>
  <el-dialog
    title="生成上架任务"
    v-if="goodsFormVisible"
    :visible.sync="goodsFormVisible"
    :before-close="close"
    width="66%">
        <div class="formBox">
            <el-checkbox v-model="radio1" label="是否生成上架" @change="handleCheckbox"></el-checkbox>
        </div>
        <div class="formBox">
          <el-radio-group v-model="radio2">
            <div class="formBox"><el-radio label="推荐分配库位" :disabled="radio4"></el-radio></div>
            <div class="formBox"><el-radio label="上架规则计算库位" :disabled="radio5"></el-radio></div>
          </el-radio-group>
        </div>
         <el-button v-auth="50300030101" type="primary" @click="handleConfirm">确认</el-button>
  </el-dialog>
  </div>
</template>

<script>
export default {
  data () {
    return {
      radio1: false,
      radio2: '',
      radio4: true,
      radio5: true
    }
  },
  props: {
    goodsFormVisible: Boolean,
    selectedIds: Array
  },
  methods: {
    close () {
      this.$emit('processClosse')
    },
    handleCheckbox (val) {
      this.radio4 = false
      this.radio5 = false
      if (val === false) {
        this.radio4 = true
        this.radio5 = true
      }
    },
    handleConfirm () {
      const isCreatePaTask = this.radio1
      let isAllocLoc = 'N'
      const createPaType = { createPaType: '0' }
      if (isCreatePaTask && createPaType.createPaType === '0') {
        isAllocLoc = 'Y'
      }
      let kitTasks = this.selectedIds
      for (var index = 0; index < kitTasks.length; index++) {
        kitTasks[index].isAllocLoc = isAllocLoc
        kitTasks[index].isTaskPa = isCreatePaTask ? 'Y' : 'N'
      }
      const url = this.$API.maintain.KitTaskPickingList.cancelPicking
      const param = { kitTasks: JSON.stringify(kitTasks) }
      this.$https.post(url, param).then(res => {
        this.$emit('getList', this.query)
      })
    }
  }
}
</script>
<style>
.formBox{
  margin-bottom: 10px
}
</style>
