<template>
  <el-form ref="formContinue" :rules="rules" label-width="110px" :model="form">
    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item label="产线" prop="proLineId">
          <el-select
            v-model="form.proLineId"
            placeholder="产线"
            style="width: 100%"
          >
            <el-option
              v-for="item in productionLineList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="玻璃架工位" prop="glassRackStation">
          <el-select
            v-model="form.glassRackStation"
            placeholder="玻璃架工位"
            style="width: 100%"
          >
            <el-option
              v-for="item in locationList"
              :key="item.dataCode"
              :label="item.dataName"
              :value="item.dataName"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>
<script>
import { unloadPalletContinuePack } from '@/api/productionScheduling'
export default {
  name: 'OffShelfPackagingContinue',
  data() {
    return {
      form: {
        id: '',
        proLineId: '',
        glassRackStation: ''
      },
      rules: {
        proLineId: [
          { required: true, message: '请选择产线', trigger: 'change' }
        ],
        glassRackStation: [
          { required: true, message: '玻璃架工位', trigger: 'change' }
        ]
      },
      locationList: JSON.parse(localStorage.getItem('publicList'))
        .glassRackStationVoList,
      productionLineList: JSON.parse(localStorage.getItem('publicList'))
        .proLineVoList
    }
  },
  methods: {
    init(id) {
      this.form.id = id
    },
    submitForm() {
      this.$refs['formContinue'].validate((valid) => {
        if (valid) {
          unloadPalletContinuePack({ ...this.form }).then((res) => {
            if (res.code === 0) {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500
              })
              this.$emit('successSubmit2')
            }
          })
        } else {
          return false
        }
      })
    },
    formClear() {
      this.$refs.formContinue.resetFields()
    }
  }
}
</script>
