<template>
  <el-dialog
    title="发货单导入"
    append-to-body
    :visible.sync="dialogVisible"
    destroy-on-close
    :show-close="true"
    width="500px"
    v-loading.fullscreen.lock="fullscreenLoading"
    @close="close"
  >
    <div class="head-container">
      <div>
        <!-- 搜索 -->
        <el-form ref="form" :model="form1" :rules="rules" size="mini" label-width="110px">
          <el-form-item label="日期区间：" prop="createTime">
            <el-date-picker
              v-model="form.createTime"
              type="daterange"
              value-format="yyyy-MM-dd"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            />
          </el-form-item>
          <el-form-item label="发货单号:" prop="bill_code">
            <el-input v-model="form.bill_code" style="width: 350px;"/>
          </el-form-item>
        </el-form>
        <el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="queryStruct">确认
        </el-button>
      </div>
    </div>
  </el-dialog>
</template>

<script>

import CRUD, {header, presenter} from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import pagination from '@crud/Pagination'
import DateRangePicker from '@/components/DateRangePicker/index'
import crudSap from '@/api/wms/ext/sap'

export default {
  name: 'importOrder',
  components: {rrOperation, pagination, DateRangePicker},
  cruds() {
  },
  mixins: [presenter(), header()],
  props: {
    dialogShow: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      fullscreenLoading: false,
      dialogVisible: false,
      form: {}
    }
  },
  watch: {
    dialogShow: {
      handler(newValue, oldValue) {
        this.dialogVisible = newValue
      }
    }
  },
  methods: {
    close() {
      this.form = {}
      this.$emit('update:dialogShow', false)
      this.$emit('tableChanged', this.rows)
    },
    queryStruct() {
      debugger
      this.fullscreenLoading = true
      if (this.form.createTime) {
        this.form.date_begin = this.form.createTime[0]
        this.form.date_end = this.form.createTime[1]
      }
      crudSap.getDeliveryNote(this.form).then(res => {
        this.crud.notify(res.message, CRUD.NOTIFICATION_TYPE.SUCCESS)
        this.fullscreenLoading = false
      }).catch(() => {
        this.fullscreenLoading = false
      })
    }
  }
}
</script>

