<!--
 * @Author: zwq
 * @Date: 2020-12-29 16:37:56
 * @LastEditors: zwq
 * @LastEditTime: 2022-03-16 09:49:10
 * @Description:
-->
<template>
  <el-dialog
    :title="$t('module.basicData.Warehouse.PerformTaskManual')"
    :visible.sync="visible"
  >
    <el-row :gutter="10">
      <el-form
        ref="dataForm"
        :model="dataForm"
        size="medium"
        label-width="170px"
        label-position="left"
      >
        <el-col :span="12">
          <el-row>
            <el-col :span="24">
              <el-form-item :label="$t('module.basicData.Warehouse.TaskBoxNumber')" prop="taskCode">
                <el-select
                  v-model="dataForm.taskCode"
                  :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.Warehouse.StorageBoxNumber')])"
                  clearable
                  filterable
                  :style="{width: '100%'}"
                >
                  <el-option
                    v-for="(item, index) in storageBoxList"
                    :key="index"
                    :label="item.code"
                    :value="item.code"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item :label="$t('module.basicData.Warehouse.FullBoxNumber')" prop="orderName">
                <el-input v-model="dataForm.orderName" :style="{width: '100%'}" />
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item :label="$t('module.basicData.Warehouse.ExecutionOperation')" prop="fullCode">
                <el-select
                  v-model="dataForm.fullCode"
                  :placeholder="$i18nForm(['placeholder.input', $t('module.art.processList.processName')])"
                  clearable
                  filterable
                  :style="{width: '100%'}"
                >
                  <el-option
                    v-for="(item, index) in processArr"
                    :key="index"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item :label="$t('module.basicData.Warehouse.TaskStatus')" prop="TaskStatus">
                <el-select
                  v-model="dataForm.TaskStatus"
                  :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.Warehouse.TaskStatus')])"
                  clearable
                  filterable
                  :style="{width: '100%'}"
                >
                  <el-option
                    v-for="(item, index) in TaskStatusArr"
                    :key="index"
                    :label="item.dataName"
                    :value="item.dataCode"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item :label="$t('module.basicData.ScrapInfo.remark')" prop="remark">
                <el-input v-model="dataForm.remark" :style="{width: '100%'}" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="12">
          <el-row>
            <el-col :span="24">
              <el-form-item :label="$t('module.basicData.Warehouse.TaskLocation')" prop="createTime">
                <el-input v-model="dataForm.createTime" :style="{width: '100%'}" />
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item :label="$t('module.basicData.Warehouse.FullBoxStartLocation')" prop="taskType">
                <el-input v-model="dataForm.taskType" :style="{width: '100%'}" />
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item :label="$t('module.basicData.Warehouse.Priority')" prop="emptyCode">
                <el-input v-model="dataForm.emptyCode" :style="{width: '100%'}" />
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item :label="$t('module.basicData.Warehouse.NextOperation')" prop="anotherCurrLocation">
                <el-select
                  v-model="dataForm.anotherCurrLocation"
                  :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.Warehouse.NextOperation')])"
                  clearable
                  filterable
                  :style="{width: '100%'}"
                >
                  <el-option
                    v-for="(item, index) in processArr"
                    :key="index"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </el-col>
      </el-form>
    </el-row>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">{{ 'btn.cancel' | i18nFilter }}</el-button>
      <el-button type="primary" @click="visible = false">{{ $t('module.basicData.Warehouse.PerformTaskManual') | i18nFilter }} </el-button>
    </span>
  </el-dialog>
</template>

<script>
// import { CurrentTaskDetail } from '@/api/basicData/Warehouse/HistoricalTask'
import { list } from '@/api/art-manage/process'
import { dataDictionaryDataList } from '@/api/basicData/dataDictionary'
import { StorageBoxRackCode } from '@/api/basicData/Warehouse/StorageBoxInfo'

export default {
  data() {
    return {
      visible: false,
      processArr: [],
      TaskStatusArr: [],
      storageBoxList: [],
      dataForm: {
        id: '',
        taskCode: undefined,
        orderName: undefined,
        fullCode: undefined,
        TaskStatus: undefined,
        remark: undefined,
        field119: undefined,
        createTime: undefined,
        taskType: undefined,
        emptyCode: undefined,
        anotherCurrLocation: undefined,
        field121: undefined,
        taskSource: undefined,
        anotherCurrProcessCode: undefined,
        anotherNextProcessCode: undefined,
        anotherTargetLocation: undefined,
        field126: undefined
      }
    }
  },
  methods: {
    init(id) {
      this.dataForm.id = id
      this.visible = true
      const lparams = {
        current: 1,
        size: 999
      }
      list(lparams).then(response => {
        if (response.data.records) {
          this.processArr = response.data.records
        } else {
          this.processArr.splice(0, this.list.length)
        }
        this.total = response.data.total
      })
      StorageBoxRackCode(lparams).then(res => {
        this.storageBoxList = res.data.records
      })
      dataDictionaryDataList({
        current: 1,
        size: 999,
        dictTypeId: '6'
      }).then(response => {
        if (response.data.records) {
          this.TaskStatusArr = response.data.records
        } else {
          this.TaskStatusArr.splice(0, this.scrapsArr.length)
        }
      })
      this.$nextTick(() => {
        this.$refs['dataForm'].resetFields()
      })
    }
  }
}
</script>
