<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <el-form
          size="mini"
          :inline="true"
          class="demo-form-inline"
          label-position="right"
          label-width="80px"
          label-suffix=":"
        >

          <el-form-item label="日期">
            <label slot="label">日&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;期:</label>
            <el-date-picker
              style="width: 210px"
              size="mini"
              v-model="query.createTime"
              type="daterange"
              value-format="yyyy-M-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-input
              v-model="query.material_code"
              clearable
              placeholder="物料编码、名称"
              @keyup.enter.native="crud.toQuery"
            />
          </el-form-item>

          <el-form-item label="订单编号">
            <el-input
              v-model="query.vbillcode"
              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"
        :data="crud.data"
        :max-height="550"
        size="mini"
        style="width: 100%;"
        @selection-change="crud.selectionChangeHandler"
      >
        <el-table-column prop="vbillcode" label="订单编号" min-width="100" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-link type="warning" @click="openReceive(scope.row)">{{ scope.row.vbillcode }}</el-link>
          </template>
        </el-table-column>
        <el-table-column prop="create_date" label="订单日期" width="150px" show-overflow-tooltip />
        <el-table-column prop="contract_no" label="合同编码" width="120px" show-overflow-tooltip/>
        <el-table-column prop="supp_name" label="供应商" min-width="220" show-overflow-tooltip/>
        <el-table-column prop="material_code" label="物料编码" min-width="150" show-overflow-tooltip />
        <el-table-column prop="material_name" label="物料名称" min-width="150" show-overflow-tooltip />
        <el-table-column prop="price_tax" label="单价含税" min-width="120" :formatter="crud.formatNum3" show-overflow-tooltip/>
        <el-table-column prop="price" label="单价不含税" min-width="120" :formatter="crud.formatNum3" show-overflow-tooltip/>
        <el-table-column prop="qty" label="重量" show-overflow-tooltip :formatter="crud.formatNum3" />
        <el-table-column prop="money" label="金额" width="120px" :formatter="crud.formatNum3" show-overflow-tooltip/>
        <el-table-column prop="allqty" label="到货重量" :formatter="crud.formatNum3" show-overflow-tooltip/>
        <el-table-column prop="notqty" label="未到货重量" :formatter="crud.formatNum3" show-overflow-tooltip/>
        <el-table-column prop="ivt_qty" label="待检重量" :formatter="crud.formatNum3" show-overflow-tooltip/>
        <el-table-column prop="input_time" label="最后一次到货时间" min-width="140" show-overflow-tooltip/>
        <el-table-column prop="honor_time" label="合同要求履约时间" min-width="140" show-overflow-tooltip/>
        <el-table-column prop="delayDay" label="延迟天数" show-overflow-tooltip/>
        <el-table-column prop="honour_days" label="资金计划履约天数" width="150px" show-overflow-tooltip/>
        <el-table-column prop="allqty" label="累计到货重量" :formatter="crud.formatNum3" width="150px" show-overflow-tooltip/>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
    <ReceiveDialog :dialog-show.sync="receiveDialog" :open-param="openParam"/>
  </div>
</template>

<script>
import CRUD, { crud, header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import pagination from '@crud/Pagination'
import crudOperation from '@crud/CRUD.operation'
import crudOrderproc from '@/api/wms/pcs/orderproc'
import DateRangePicker from '@/components/DateRangePicker'
import ReceiveDialog from '@/views/wms/statistics/ledgerQuery/ReceiveDialog'

export default {
  name: 'LedgerQuery',
  components: { pagination, rrOperation, crudOperation, DateRangePicker, ReceiveDialog},
  mixins: [presenter(), header(), crud()],
  cruds() {
    return CRUD({
      title: '台账',
      url: 'api/purchaseorderproc/ledgerQuery',
      idField: 'id',
      sort: 'id,desc',
      props: {
        // 每页数据条数
        size: 20
      },
      optShow: {
        add: false,
        edit: false,
        del: false,
        download: false,
        reset: true
      },
      crudMethod: { ...crudOrderproc }
    })
  },

  data() {
    return {
      openParam: '',
      receiveDialog: false
    }
  },
  created() {
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    },
    hand(value) {
      this.crud.toQuery()
    },
    openReceive(row) {
      this.openParam = row.vbillcode
      this.receiveDialog = true
    }
  }
}
</script>

<style scoped>

</style>
