<template>
  <div class="app-container">
    <div v-if="isShow">
      <!-- 筛选条件 -->
      <div>
        <el-form
          ref="screenForm"
          :model="screenForm"
          label-width="70px"
          size="mini"
          label-position="left"
        >
          <el-row :gutter="20">
            <el-col :xs="24" :sm="12" :lg="6">
              <el-form-item label="名称" prop="name">
                <el-input
                  placeholder="请输入名称"
                  v-model="screenForm.name"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :lg="18" class="tr">
              <el-form-item label="">
                <el-button size="mini" @click="resetScreenForm"
                  >清空</el-button
                >
                <el-button size="mini" type="primary" @click="submitScreenForm"
                  >搜索</el-button
                >
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div class="mymain-container">
        <div class="table">
          <el-table
            v-loading="listLoading"
            :data="dataList"
            element-loading-text="Loading"
            border
            fit
            highlight-current-row
            stripe
          >
            <!-- <el-table-column
              type="selection"
              align="left"
              min-width="100"
            ></el-table-column> -->
            <el-table-column
              align="left"
              label="编码"
              prop="number"
              min-width="160"
              show-overflow-tooltip
              label-class-name="bianma"
              class-name="fontstyle"
            ></el-table-column>
            <el-table-column
              align="left"
              label="名称"
              prop="name"
              min-width="160"
              show-overflow-tooltip
            ></el-table-column>
            <el-table-column
              align="left"
              label="仓库地址"
              prop="address"
              min-width="160"
              show-overflow-tooltip
            ></el-table-column>
            <el-table-column
              align="left"
              label="仓库负责人"
              prop="principalName"
              min-width="160"
              show-overflow-tooltip
            ></el-table-column>
            <el-table-column
              align="left"
              label="仓库属性"
              prop="stockProperty"
              min-width="160"
              show-overflow-tooltip
            ></el-table-column>
            <el-table-column
              align="left"
              label="第三方仓储类型"
              prop="gysStockNumber"
              min-width="160"
              show-overflow-tooltip
            ></el-table-column>
            <el-table-column
              align="left"
              label="数据状态"
              prop="documentStatus"
              min-width="100"
              show-overflow-tooltip
            ></el-table-column>
            <el-table-column
              align="left"
              label="允许即时库存负库存"
              prop="allowMinusQty"
              min-width="100"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <el-tag
                  size="mini"
                  type="success"
                  v-if="scope.row.allowMinusQty !== 'false'"
                  >是</el-tag
                >
                <el-tag size="mini" type="danger" v-else>否</el-tag>
              </template>
            </el-table-column>
            <el-table-column
              align="left"
              label="启用仓位管理"
              prop="openLocation"
              min-width="100"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <el-tag size="mini" type="success" v-if="scope.row.openLocation !== 'false'"
                  >是</el-tag
                >
                <el-tag size="mini" type="danger" v-else>否</el-tag>
              </template>
            </el-table-column>
            <el-table-column
              align="left"
              label="不参与可发量统计"
              prop="notExpQty"
              min-width="100"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <el-tag size="mini" type="success" v-if="scope.row.notExpQty !== 'false'"
                  >是</el-tag
                >
                <el-tag size="mini" type="danger" v-else>否</el-tag>
              </template>
            </el-table-column>
            <el-table-column
              align="left"
              label="参与预警"
              prop="availableAlert"
              min-width="100"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <el-tag size="mini"
                  type="success"
                  v-if="scope.row.availableAlert !== 'false'"
                  >是</el-tag
                >
                <el-tag size="mini" type="danger" v-else>否</el-tag>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="操作"
              fixed="right"
              prop="caozuo"
              min-width="160"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <el-button
                  type="text"
                  class="textColor"
                  @click="hanleDetail(scope.row.id)"
                  >详情</el-button
                >
                <!-- <el-button
                  type="text"
                  class="textColor"
                  @click="editFn(scope.row.id, scope.row)"
                  >编辑</el-button
                >
                <el-popconfirm
                  confirm-button-text="好的"
                  cancel-button-text="不用了"
                  icon="el-icon-info"
                  icon-color="red"
                  title="内容确定删除吗？"
                  @onConfirm="hanleDelete(scope.row.id)"
                >
                  <el-button
                    slot="reference"
                    type="text"
                    class="textColor el-popover-left"
                    >删除</el-button
                  >
                </el-popconfirm> -->
              </template>
            </el-table-column>
          </el-table>
        </div>
        <!-- 分页 -->
        <div class="fr">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[10, 20, 30, 50]"
            :page-size="10"
            layout="total, sizes, prev, pager, next, jumper"
            :total="listTotal"
          >
          </el-pagination>
        </div>
      </div>
    </div>
    <WarehouseListDetail v-else :detail="detail" />
  </div>
</template>

<script>
import { getList, getStockDetail } from '@/api/basic_data/warehouse'
import Mixin from '@/mixin/index'
import WarehouseListDetail from './components/warehouse_list-detail.vue'

export default {
  mixins: [Mixin],
  data() {
    return {
      isShow: true,
      screenForm: {
        // 筛选表单数据
        name: "", // 名称
      },
      detail: {},
    };
  },
  components: {
    WarehouseListDetail,
  },

  methods: {
    editFn() {
      this.isShow = false;
    },
    getList() {
      this.listLoading = true;
      let params = {
        pageNum: this.currentPage,
        pageSize: this.pageSize,
        name: this.screenForm.name,
      };
      getList(params).then((res) => {
        this.dataList = res.data.records;
        this.listTotal = res.data.total;
        this.listLoading = false;
      });
    },
    //查看详情
    hanleDetail(id) {
      getStockDetail({ id }).then((res) => {
        this.detail = res.data;
      });
      this.isShow = false
    },
  },
};
</script>
