<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <el-form
          :inline="true"
          class="demo-form-inline"
          label-position="right"
          label-width="80px"
          label-suffix=":"
        >
          <el-form-item label="所属仓库">
            <el-select
              v-model="query.stor_id"
              clearable
              size="mini"
              placeholder="全部"
              class="filter-item"
              @change="crud.toQuery"
            >
              <el-option
                v-for="item in storlist"
                :key="item.stor_id"
                :label="item.stor_name"
                :value="item.stor_id"
              />
            </el-select>
          </el-form-item>

          <el-form-item label="创建时间">
            <el-date-picker
              v-model="query.createTime"
              type="daterange"
              value-format="yyyy-MM-dd HH:mm:ss"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :default-time="['00:00:00', '23:59:59']"
              @change="crud.toQuery"
            />
          </el-form-item>

          <el-form-item label="业务类型">
            <el-select
              v-model="query.bill_type"
              clearable
              filterable
              size="mini"
              placeholder="业务类型"
              class="filter-item"
              @change="crud.toQuery"
            >
              <el-option
                v-for="item in dict.ST_INV_OUT_TYPE"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="厚度幅宽">
            <el-input
              v-model="query.with"
              size="mini"
              clearable
              placeholder="例如：68*9.5"
              @keyup.enter.native="crud.toQuery"
            />
          </el-form-item>
          <el-form-item label="客户名称">
            <el-input
              v-model="query.customer_name"
              size="mini"
              clearable
              placeholder="客户、编码"
              @keyup.enter.native="crud.toQuery"
            />
          </el-form-item>
          <rrOperation />
        </el-form>
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表格渲染-->
      <el-table
        ref="table"
        v-loading="crud.loading"
        size="mini"
        :data="crud.data"
        highlight-current-row
        style="width: 100%;"
      >
        <el-table-column show-overflow-tooltip prop="stor_name" label="仓库" :min-width="flexWidth('stor_name',crud.data,'仓库')" />
        <el-table-column show-overflow-tooltip prop="sect_name" label="库区" :min-width="flexWidth('sect_name',crud.data,'库区')" />
        <el-table-column show-overflow-tooltip prop="bill_type" :formatter="bill_typeFormat" label="业务类型" :min-width="flexWidth('bill_type',crud.data,'业务类型')" />
        <el-table-column show-overflow-tooltip prop="vbeln" label="交货单号" :min-width="flexWidth('vbeln',crud.data,'交货单号')" />
        <el-table-column show-overflow-tooltip prop="cust_name" label="物流公司" :min-width="flexWidth('cust_name',crud.data,'物流公司')" />
        <el-table-column show-overflow-tooltip prop="estimated_freight" label="运费" :formatter="crud.formatNum2" :min-width="flexWidth('estimated_freight',crud.data,'运费')" />
        <el-table-column show-overflow-tooltip prop="box_no" label="木箱号" :min-width="flexWidth('box_no',crud.data,'木箱号')" />
        <el-table-column show-overflow-tooltip prop="material_code" label="物料编码" :min-width="flexWidth('material_code',crud.data,'物料编码')" />
        <el-table-column show-overflow-tooltip prop="material_name" label="物料名称" :min-width="flexWidth('material_name',crud.data,'物料名称')" />
        <el-table-column show-overflow-tooltip prop="pcsn" label="子卷号" :min-width="flexWidth('pcsn',crud.data,'子卷号')" />
        <el-table-column show-overflow-tooltip prop="sap_pcsn" label="sap批次" :min-width="flexWidth('sap_pcsn',crud.data,'sap批次')" />
        <el-table-column show-overflow-tooltip prop="net_weight" label="净重" :formatter="crud.formatNum2" :min-width="flexWidth('net_weight',crud.data,'净重')" />
        <el-table-column show-overflow-tooltip prop="qty_unit_name" label="单位" :min-width="flexWidth('qty_unit_name',crud.data,'单位')" />
        <el-table-column show-overflow-tooltip prop="customer_name" label="客户编码" :min-width="flexWidth('customer_name',crud.data,'客户编码')" />
        <el-table-column show-overflow-tooltip prop="customer_description" label="发货客户名称" :min-width="flexWidth('customer_description',crud.data,'客户名称')" />
        <el-table-column show-overflow-tooltip prop="sale_order_name" label="销售订单" :min-width="flexWidth('sale_order_name',crud.data,'销售订单')" />
        <el-table-column show-overflow-tooltip prop="input_time" label="出库日期" :min-width="flexWidth('input_time',crud.data,'出库日期')" />
        <el-table-column show-overflow-tooltip prop="width" label="产品规格" :min-width="flexWidth('width',crud.data,'产品规格')" />
        <el-table-column show-overflow-tooltip prop="thickness" label="产品厚度" :min-width="flexWidth('thickness',crud.data,'产品厚度')" />
        <el-table-column show-overflow-tooltip prop="mass_per_unit_area" label="单位面积" :formatter="crud.formatNum2" :min-width="flexWidth('mass_per_unit_area',crud.data,'单位面积')" />
        <el-table-column show-overflow-tooltip prop="input_optname" label="制单人" :min-width="flexWidth('input_optname',crud.data,'制单人')" />
        <el-table-column show-overflow-tooltip prop="remark" label="备注" :min-width="flexWidth('remark',crud.data,'备注')" />
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import CRUD, { crud, header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import DateRangePicker from '@/components/DateRangePicker/index'
import crudUserStor from '@/views/wms/basedata/st/userStor/userStor'
import crudOutbillquery from '@/views/wms/stat/outbillquery/outbillquery'

export default {
  name: 'OutQuery',
  components: { crudOperation, rrOperation, udOperation, pagination, DateRangePicker },
  cruds() {
    return CRUD({
      title: '',
      optShow: { add: false, reset: true },
      idField: 'iostorinv_id',
      url: '/api/out/OutQuery',
      crudMethod: { ...crudOutbillquery }
    })
  },
  mixins: [presenter(), header(), crud()],
  // 数据字典
  dicts: ['io_bill_status', 'ST_INV_OUT_TYPE'],
  data() {
    return {
      height: document.documentElement.clientHeight - 180 + 'px;',
      storlist: []
    }
  },
  mounted: function() {
    const that = this
    window.onresize = function temp() {
      that.height = document.documentElement.clientHeight - 180 + 'px;'
    }
  },
  created() {
    crudUserStor.getUserStor().then(res => {
      this.storlist = res
    })
  },
  methods: {
    bill_typeFormat(row, column) {
      return this.dict.label.ST_INV_OUT_TYPE[row.bill_type]
    },
    [CRUD.HOOK.beforeRefresh]() {
    }
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
::v-deep .el-dialog__body {
  padding-top: 10px;
}
</style>
