<template>
  <div>
    <div class="head-container">
      <el-input v-model="searchData.condition.name" placeholder="请输入库房名称" style="width: 200px"></el-input>
      <el-button @click="getData(1)" style="margin-left: 20px" ghost icon="search" :color="imgColor">查询</el-button>
    </div>
    <el-table :header-cell-style="{backgroundColor: '#f5f7fa',color: '#000',fontSize: '18px',fontWeight: '600'}" height="600" :data="basicData" border style="width: 100%;">
      <el-table-column type="index" label="序号" align="center" width="70"/>
      <el-table-column prop="name" label="库房名称" align="center"/>
      <el-table-column prop="code" label="库房代码" align="center"/>
    </el-table>
    <el-pagination
      style="left: 40%;margin-top: 6px;"
      background
      @current-change="handleCurrentChange"
      :current-page="searchData.pageNo"
      :page-size="searchData.pageSize"
      layout="total, prev, pager, next"
      :total="total"
    />
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { postAction } from '@/api/manage'
import { ElMessage } from 'element-plus'
const searchData = ref({
  condition: {
    name: undefined,
    storeCodeList: JSON.parse(sessionStorage.getItem("storeList"))
  }
})
const basicData = ref([])
const imgColor = ref()

const getData = async () => {
  const res = await postAction(window._CONFIG['serverURL'] + '/store/list', searchData.value)
  if (res.code !== 99200) return ElMessage.error(res.message)
  basicData.value = res.data
}


const handleCurrentChange =  (val) => {
  searchData.value.pageNo = val
  getData()
}

onMounted(() => {
  if (sessionStorage.getItem('bgColor')) {
    imgColor.value = sessionStorage.getItem('bgColor')
  } else {
    sessionStorage.setItem('bgColor', '#1f8a36')
  }
});

getData()
 
</script>

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