<template>
  <div>
    <el-card class="el-card">
      <el-form :model="filterQuery" class="query-form" size="mini" label-width="100px" v-show="showSearch">
        <el-row>
          <el-col :span="8">
            <el-form-item class="query-form-item" label="单号:">
              <el-input v-model="filterQuery.orderIdFk" placeholder="请输入单号" style="width: 90%" clearable="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item class="query-form-item" label="往来单位:">
              <el-input v-model="filterQuery.fromCorpName" placeholder="请输入往来单位" style="width: 90%" clearable="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item class="query-form-item" label="物资名称:">
              <el-input v-model="filterQuery.coName" placeholder="请输入物资名称" style="width: 90%" clearable="true"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item class="query-form-item" label="规格型号:">
              <el-input v-model="filterQuery.spec" placeholder="请输入规格型号" style="width: 90%" clearable="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item class="query-form-item" label="批次号:">
              <el-input v-model="filterQuery.batchNo" placeholder="请输入批次号" style="width: 90%" clearable="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item class="query-form-item" label="创建时间:">
              <el-date-picker
                :picker-options="pickerOptions"
                v-model="actDateRange"
                type="daterange"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy-MM-dd"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                style="width: 90%"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div class="top-right-btn">
        <el-button-group>
          <el-button icon="el-icon-view" type="primary" @click="hideSearch">显示/隐藏搜索栏</el-button>
          <el-button
            type="primary"
            icon="el-icon-refresh"
            @click="onReset"
          >重置
          </el-button>
          <el-button type="primary" icon="el-icon-search" @click="onSubmit"
          >查询
          </el-button
          >
        </el-button-group>
      </div>
      <el-divider style="margin: 15px"></el-divider>
      <el-table v-loading="loading" :data="list" style="width: 100%" highlight-current-row border>
        <el-table-column label="序号" type="index"></el-table-column>
        <el-table-column label="单据号" prop="orderIdFk"></el-table-column>
        <el-table-column label="单据类型" prop="billTypeName"></el-table-column>
        <el-table-column label="往来单位" prop="fromCorpName"show-overflow-tooltip></el-table-column>
        <el-table-column label="物资名称，" prop="coName"show-overflow-tooltip></el-table-column>
        <el-table-column label="规格型号" prop="spec"></el-table-column>
        <el-table-column label="批次号" prop="batchNo"></el-table-column>
<!--        <el-table-column label="入库数量" prop="count"></el-table-column>-->
        <el-table-column label="数量" prop="reCount" show-overflow-tooltip ></el-table-column>
      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        :limit.sync="filterQuery.limit"
        :page.sync="filterQuery.page"
        @pagination="getList"
      ></pagination>
    </el-card>
  </div>
</template>

<script>
import { getResultDetailList, getResultOrderList } from '@/api/inout/orderDetailResult'

export default {
  name: "supInoutSearchOrder",
  data() {
    return {
      showSearch: true,
      list:{},
      filterQuery: {
        id: "",
        orderIdFk: null,
        fromCorpName: null,
        coName: null,
        spec: null,
        batchNo: null,
        page: 1,
        limit: 10,
        startTime: null,
        endTime: null,
      },
      loading:false,
      total:0,
      customerId: this.$store.getters.customerId,
      actDateRange: [],
      auditDateRange: [],
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
    };
  },
  components: {},
  methods: {
    onReset() {
      this.$router.push({
        path: "",
      });
      this.filterQuery = {
        id: "",
        orderIdFk: null,
        fromCorpName: null,
        coName: null,
        spec: null,
        batchNo: null,
        page: 1,
        limit: 10,
        startTime: null,
        endTime: null,
      };
      this.getList();
    },
    onSubmit() {
      this.loading = true;
      if (this.actDateRange !== null) {
        this.filterQuery.startTime = this.actDateRange[0];
        this.filterQuery.endTime = this.actDateRange[1];
      } else {
        this.filterQuery.startTime = null;
        this.filterQuery.endTime = null;
      }
      this.filterQuery.page = 1;
      this.getList();
    },
    hideSearch() {
      this.showSearch = !this.showSearch;
    },
    getList(){
      this.loading = true;
      getResultOrderList(this.filterQuery)
        .then((response) => {
          if (response.code === 20000) {
            this.list = response.data.list || [];
            this.total = response.data.total || 0;
          } else {
            this.$message.error(response.message);
          }
          this.loading = false;
        })
        .catch(() => {
          this.loading = false;
          this.list = [];
          this.total = 0;
        });
    },
  }
  ,
  mounted() {
    document.body.ondrop = function (event) {
      event.preventDefault();
      event.stopPropagation();
    };
  }
  ,
  created() {
    this.getList();
  }
  ,
}
;
</script>

<style type="text/scss" lang="scss">
</style>

