<template>
  <div class="app-container">
    <el-table v-loading="loading" :data="stockDate">
      <el-table-column type="index" label="序号" align="center" />
      <el-table-column label="货主" align="center" prop="fcorpid" />
      <el-table-column label="提单号" align="center">
        <template slot-scope="scope">
          <div @click="goPage(scope.row)">{{ scope.row.fMblno }}</div>
        </template>
      </el-table-column>
      <el-table-column label="货物属性" align="center" prop="fBusinessType" />
      <el-table-column label="属性详情" align="center" prop="fMarks" />
      <el-table-column label="业务类型" align="center" prop="fBilltype" />
      <el-table-column label="业务日期" align="center" prop="fBsdate" />
      <el-table-column label="贸易方式" align="center" prop="fTrademodeid" />
      <el-table-column label="件数" align="center">
        <template slot-scope="scope">
          <div v-if="scope.row.fBilltype == '入库'">{{ scope.row.fQtyRK }}</div>
          <div v-if="scope.row.fBilltype == '出库'">{{ scope.row.fQtyCK }}</div>
          <div v-if="scope.row.fBilltype == '调拨'">{{ scope.row.fQtyDB }}</div>
          <div v-if="scope.row.fBilltype == '货权转移'">
            {{ scope.row.fQtyHZ }}
          </div>
          <div v-if="scope.row.fBilltype == '货物通关'">
            {{ scope.row.fQtyTG }}
          </div>
        </template>
      </el-table-column>
      <el-table-column label="毛重" align="center">
        <template slot-scope="scope">
          <div v-if="scope.row.fBilltype == '入库'">
            {{ scope.row.fGrossweightRK }}
          </div>
          <div v-if="scope.row.fBilltype == '出库'">
            {{ scope.row.fGrossweightCK }}
          </div>
          <div v-if="scope.row.fBilltype == '调拨'">
            {{ scope.row.fGrossweightDB }}
          </div>
          <div v-if="scope.row.fBilltype == '货权转移'">
            {{ scope.row.fGrossweightHZ }}
          </div>
          <div v-if="scope.row.fBilltype == '货物通关'">
            {{ scope.row.fGrossweightTG }}
          </div>
        </template>
      </el-table-column>
      <el-table-column label="净重" align="center">
        <template slot-scope="scope">
          <div v-if="scope.row.fBilltype == '入库'">
            {{ scope.row.fNetweightRK }}
          </div>
          <div v-if="scope.row.fBilltype == '出库'">
            {{ scope.row.fNetweightCK }}
          </div>
          <div v-if="scope.row.fBilltype == '调拨'">
            {{ scope.row.fNetweightDB }}
          </div>
          <div v-if="scope.row.fBilltype == '货权转移'">
            {{ scope.row.fNetweightHZ }}
          </div>
          <div v-if="scope.row.fBilltype == '货物通关'">
            {{ scope.row.fNetweightTG }}
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { detailStock } from "@/api/warehouseBusiness/warehouseInStock";

import { listCorps } from "@/api/basicdata/corps";

import { listWarehouse } from "@/api/basicdata/warehouse";

import { listGoods } from "@/api/basicdata/goods";

import { listUser, queryUserVal } from "@/api/system/user";

export default {
  name: "Warehousebills",
  components: {},
  data() {
    return {
      stockDate: [],
      // 遮罩层
      loading: true,
    };
  },
  created() {
    detailStock({
      fWarehouseLocationid: this.$route.query.fWarehouseLocationid,
      fTrademodeids: this.$route.query.fTrademodeids,
      fBusinessType: this.$route.query.fBusinessType,
      fGoodsid: this.$route.query.fGoodsid,
      fCorpIds: this.$route.query.fCorpIds,
      fMarks: this.$route.query.fMarks,
      fMblno: this.$route.query.fMblno,
    }).then((response) => {
      this.loading = false;
      console.log(response);
      this.stockDate = response.rows;
    });
  },
  methods: {
    //跳转审批页面
    goPage(row) {
      switch (row.fBilltype) {
        case "入库": {
          this.$router.push({
            path: "/business/inStock",
            query: { id: row.fId },
          });
          break;
        }
        case "出库": {
          this.$router.push({
            path: "/business/outStock",
            query: { id: row.fId },
          });
          break;
        }
        case "调拨": {
          this.$router.push({
            path: "/business/stockTransfer",
          });
          break;
        }
        case "货权转移": {
          this.$router.push({
            path: "/business/stockTransfer",
          });
          break;
        }
        case "货物通关": {
          this.$router.push({
            path: "/business/cargoClearance",
          });
          break;
        }
        default: {
          return this.$message.error("未知错误，无状态");
        }
      }
    },
  },
};
</script>
