<template>
  <!-- 供应商采购订单 已出库 -->
  <div class="common-box">
    <el-form :model="listQuery" ref="queryForm" :inline="true">
      <el-form-item label="采购单号" prop="id">
        <el-input v-model="listQuery.id" placeholder="请输入采购单号"></el-input>
      </el-form-item>
      <el-form-item label="医院名称" prop="branchName">
        <el-input v-model="listQuery.branchName" placeholder="请输入医院名称"></el-input>
      </el-form-item>
      <el-form-item label="采购时间" prop="docmkDate">
        <el-date-picker
          v-model="listQuery.docmkDate"
          type="daterange"
          range-separator="至"
          :editable="false"
          value-format="yyyy-MM-dd"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
          style="width: 230px"
        />
      </el-form-item>
      <!-- <el-form-item label="当前状态" prop="stas">
                <el-select
                    v-model="listQuery.stas"
                    placeholder="请选择"
                    clearable
                >
                    <el-option
                        v-for="item in stasOptions"
                        :key="item.value"
                        :label="item.lable"
                        :value="item.value"
                    ></el-option>
                </el-select>
            </el-form-item> -->
      <el-form-item>
        <el-button type="primary" @click="getData('search')">查询 </el-button>
        <el-button @click="reset">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table
      v-loading="listLoading"
      element-loading-text="加载中"
      :data="list"
      fit
      stripe
      border
    >
      <template slot="empty">
        <img src="@/assets/nopage.png" alt />
        <p>暂无数据</p>
      </template>
      <el-table-column fixed type="index" label="序号" width="60" />
      <el-table-column label="订单编号" prop="id" />
      <el-table-column label="订单种类" prop="detlCnt" />
      <el-table-column label="订单总数量" prop="qtySum" />
      <el-table-column label="剩余出库量" prop="delvCnt" />
      <el-table-column label="订单总金额" prop="purcAmt" />
      <el-table-column label="医院名称" prop="branchName" />
      <el-table-column label="部门名称" prop="deptName" />
      <el-table-column label="采购员" prop="docmker" />
      <el-table-column label="采购时间" prop="docmkDate" width="140" />
      <el-table-column label="状态" prop="stas">
        <!-- <template #default="{ row }">
              <span v-if="row.stas == 'A'">未受理</span>
              <span v-if="row.stas == 'B'">未出库</span>
              <span v-if="row.stas == 'R'">被驳回</span>
              <span v-if="row.stas == 'C'">已出库</span>
              <span v-if="row.stas == 'D'">部分出库</span>
              <span v-if="row.stas == 'Y'">已入库</span>
              <span v-if="row.stas == 'P'">部分入库</span>
            </template> -->
      </el-table-column>
      <el-table-column label="操作" width="100">
        <template slot-scope="scope">
          <el-button type="text" @click="handleDetail(scope.row)">详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!--分页-->
    <yl-pagination
      v-show="total > 0"
      :total="total"
      :page.sync="listQuery.current"
      :limit.sync="listQuery.size"
      @pagination="getData"
    />
  </div>
</template>

<script>
import ylPagination from "@/components/yl-pagination";
import { getSplerDelvOrdPage } from "@/api/orderManage-sup/index";
export default {
  components: {
    ylPagination,
  },
  data() {
    return {
      listQuery: {
        current: 1,
        size: 10,
        purcOrdId: "",
        docmkDateStart: "",
        docmkDateEnd: "",
        docmkDate: [],
        purcOrdStas: "",
      },
      stasOptions: [
        { value: "C", lable: "已出库" },
        { value: "D", lable: "部分出库" },
        { value: "Y", lable: "已入库" },
        { value: "P", lable: "部分入库" },
      ],
      dd1: [
        { value: 0, name: "订单类型1" },
        { value: 1, name: "订单类型2" },
      ],
      listLoading: false,
      list: [],
      total: 0,
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    getData(type) {
      if (type == "search") {
        this.listQuery.current = 1;
      }
      this.listLoading = true;
      this.listQuery.docmkDateStart = this.listQuery.docmkDate[0];
      this.listQuery.docmkDateEnd = this.listQuery.docmkDate[1];
      getSplerDelvOrdPage(this.listQuery)
        .then((res) => {
          this.list = res.data.records;
          this.total = res.data.total;
          this.listLoading = false;
        })
        .catch((err) => {
          this.listLoading = false;
        });
    },
    reset() {
      this.$refs.queryForm.resetFields();
      this.getData();
    },
    // 详情
    handleDetail(row) {
      console.log(row);
      this.$router.push({
        name: "alreadyDetail",
        query: {
          delvOrdId: row.delvOrdId,
          purcOrdId: row.purcOrdId,
          detlCnt: row.detlCnt,
          orgName: row.orgName,
          docmker: row.docmker,
          docmkDate: row.docmkDate,
          purcOrdStas: row.purcOrdStas,
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped></style>
