<template>
  <div class="app-container">
    <div>
      <!-- 筛选条件 -->
      <Collapse :screen-form="searchForm">
        <template #right_btn>
          <el-button size="mini" @click="clearFn">清空</el-button>
          <el-button size="mini" type="primary" @click="searchFn">搜索</el-button>
        </template>
        <template #search>
          <el-form ref="searchForm" :model="searchForm" label-width="100px" size="mini" label-position="left">
            <el-row :gutter="20">
              <el-col :xs="24" :sm="12" :lg="6">
                <el-form-item label="仓库名称" prop="correspondName">
                  <el-input v-model="searchForm.correspondName" placeholder="请输入经销商名称"></el-input>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :sm="12" :lg="6">
                <el-form-item label="物料名称" prop="materialName">
                  <el-input v-model="searchForm.materialName" placeholder="请输入经销商名称"></el-input>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :sm="12" :lg="6">
                <el-form-item label="物料编码" prop="materialNumber">
                  <el-input v-model="searchForm.materialNumber" placeholder="请输入经销商名称"></el-input>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :sm="12" :lg="6">
                <el-form-item label="规格型号" prop="specification">
                  <el-input v-model="searchForm.specification" placeholder="请输入经销商名称"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </template>
      </Collapse>

      <!-- 按钮 -->
      <div class="btn-group clearfix">
        <div class="fl"></div>
        <div class="fr">
          <ExportButton :exUrl="'stock/startAcc/stockExport'" :exParams="exParams" />
        </div>
      </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 align="left" label="仓库名称" prop="stockName" min-width="160" show-overflow-tooltip>
            </el-table-column>
            <el-table-column align="left" label="存货类别" prop="categoryName" min-width="160" show-overflow-tooltip>
            </el-table-column>
            <el-table-column align="left" label="物料编码" prop="materialNumber" min-width="160" show-overflow-tooltip>
            </el-table-column>
            <el-table-column
              align="left"
              label="产品编码"
              prop="materialOldNumber"
              min-width="160"
              show-overflow-tooltip
            >
            </el-table-column>
            <el-table-column align="left" label="物料名称" prop="materialName" min-width="160" show-overflow-tooltip>
            </el-table-column>
            <el-table-column align="left" label="规格型号" prop="spec" min-width="160" show-overflow-tooltip>
            </el-table-column>
            <el-table-column align="left" label="广州可用数量" prop="gzOnNumber" min-width="160" show-overflow-tooltip>
            </el-table-column>
            <el-table-column align="left" label="佛山可用数量" prop="fsOnNumber" min-width="160" show-overflow-tooltip>
            </el-table-column>
            <el-table-column
              align="left"
              label="广州开单未提数量"
              prop="gzNeverNumber"
              min-width="160"
              show-overflow-tooltip
            >
            </el-table-column>
            <el-table-column
              align="left"
              label="佛山开单未提数量"
              prop="fsNeverNumber"
              min-width="160"
              show-overflow-tooltip
            >
            </el-table-column>
            <el-table-column align="left" label="广州结存数量" prop="gzNumber" min-width="160" show-overflow-tooltip>
            </el-table-column>
            <el-table-column align="left" label="佛山结存数量" prop="fsNumber" min-width="160" show-overflow-tooltip>
            </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="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="listTotal"
          >
          </el-pagination>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { stockStartAccStock } from '@/api/guangFoInventory'
export default {
  components: {},
  data() {
    return {
      currentPage: 1, // 当前页码
      pageSize: 10, // 每页数量
      listTotal: 0, // 列表
      listLoading: false, // 列表加载loading
      searchForm: {
        correspondName: '',
        materialName: '',
        materialNumber: '',
        specification: ''
      },
      dataList: [],
      statusList: [],
      currentStatus: ''
    }
  },
  computed: {
    exParams() {
      return {
        ...this.searchForm
      }
    }
  },
  async created() {
    await this.getList({ pageNumber: 1, pageSize: 10 })
  },
  methods: {
    // 更改每页数量
    handleSizeChange(val) {
      this.pageSize = val
      this.getList({
        ...this.searchForm,
        pageNumber: this.currentPage,
        pageSize: this.pageSize
      })
    },
    // 更改当前页
    handleCurrentChange(val) {
      this.currentPage = val
      this.getList({
        ...this.searchForm,
        pageNumber: this.currentPage,
        pageSize: this.pageSize
      })
    },
    //搜索功能
    async searchFn() {
      await this.getList({
        ...this.searchForm,
        pageNumber: 1,
        pageSize: this.pageSize
      })
    },
    //重置
    clearFn() {
      this.$refs.searchForm.resetFields()
    },
    //获取列表数据
    async getList(data) {
      const res = await stockStartAccStock(data)
      this.dataList = res.data.records
      this.listTotal = res.data.total
    }
  }
}
</script>

<style lang="scss" scoped>
.selectStyle {
  width: 100%;
}
::v-deep .el-textarea__inner {
  resize: none;
}
::v-deep .el-form {
  .inputStyle {
    width: 80%;
  }
}
::v-deep .dialog-footer {
  display: flex;
  justify-content: center;
}
::v-deep .el-dialog__header {
  background-color: #dddddd;
}
.inp {
  margin: 0 12px;
}

.right {
  margin-top: 12px;
  float: right;
}

.table {
  margin-top: 12px;
}
.search {
  display: flex;
  margin-top: 12px;
  ::v-deep .el-input {
    width: 50%;
    margin-right: 12px;
  }
}
.import-btn {
  display: inline-block;
  margin-left: 10px;
}
</style>
