/**
  // author：jiana
  // time:2025-04-23
  // desc:运单管理
*/
<template>
  <div class="unPlaceShip">
    <Card>
      <!-- 筛选 -->
      <Row :gutter="8">
        <Col span="10">
          供应商名称 <Input v-model="filtInfoData.shopName" placeholder="请输入供应商名称" style="width:80%"/>
        </Col>
        <Col span="2">
          <Button type="primary" @click="getData">查询</Button>
        </Col>
        <Col span="2">
          <Button @click="resetData">重置</Button>
        </Col>
      </Row>
    </Card>
    <Card style="margin-top:20px;">
      <Row>
        <Col span="12">
          已拒绝列表
        </Col>
      </Row>
      <!-- 表格部分 -->
      <el-table v-loading="loading" :data="TabData.data" border style="width: 100%;margin-top:20px;">
        <el-table-column label="供应商名称" prop="supplierName" width="160" align="center"></el-table-column>
        <el-table-column label="仓库名称" width="150" prop="name" align="center"/>
        <el-table-column label="仓库地址" width="150" prop="address" align="center"/>
        <el-table-column label="经度" width="150" prop="longitude" align="center"></el-table-column>
        <el-table-column label="维度" prop="latitude" width="150"  align="center"></el-table-column>
        <el-table-column label="添加时间" width="160" align="center">
          <template #default="scope">
            {{ moment(scope.row.addTime).format('yyyy-MM-DD hh:mm:ss') || '暂无'}}
          </template>
        </el-table-column>
        <el-table-column label="操作" width="150"  fixed="right" align="center">
          <template  #default="scope">
            <Button class="opt_btn" size="small" type="primary" ghost @click="lookInfo(scope.row)">查看地址</Button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <div class="page_style">
        <Page :total="TabData.total" :model-value="currentPage" show-elevator show-total @on-change="changePage" />
      </div>
    </Card>
    <!-- 查看地址 -->
    <Modal v-model="showInfo" width="60%" title="查看地址">
     <mapMark v-if="showInfo" :markInfo="markInfo"></mapMark>
    </Modal>
  </div>
</template>

<script>
import { defineComponent, ref ,reactive, onMounted} from 'vue'
import { tms } from '@/request/api'
import { Message,Modal,Spin,Input } from 'view-ui-plus'
import moment from 'moment'
import {useRoute} from 'vue-router'
import mapMark from "./mapMark.vue"
export default defineComponent({
  components:{
    mapMark
  },
  setup() {
    const route = useRoute()
    let filtInfoData = reactive({ // 搜索
      limit:10,offset:0,status:2,shopName:''
    })

    let TabData = ref([])  // 列表数据

    let loading = ref(false)
    //获取列表内容
    async function getData(){
      loading.value = true
      await tms.warehouseList(filtInfoData).then(res =>{
        if (res.code == 0) {
          TabData.value = res
        }
      })
      loading.value = false
    }
    //重置
    function resetData(){
      filtInfoData.offset = 0
      filtInfoData.limit = 10
      filtInfoData.shopName = ''
      filtInfoData.status = 2
      getData()
    }

    let currentPage = ref(1)
    //更改页码
    function changePage (page) {
      if(TabData.value.limit){
        filtInfoData.offset = (page -1) *  TabData.value.limit  //更新偏移量
        currentPage = page  //切换当前页码
        getData() 
      }
    }
    
    const showInfo = ref(false)
    let markInfo =  reactive({
      longitude:'',latitude:''
    })
    //查看地址
    function lookInfo(data){
      markInfo.longitude = data.longitude
      markInfo.latitude = data.latitude
      showInfo.value = true
    }
    onMounted(()=>{
      getData() 
    })

    return {
      getData,changePage,moment,TabData,filtInfoData,
      loading,resetData,showInfo,lookInfo,markInfo
    }
  },
})
</script>

<style lang="scss" scoped>
.unPlaceShip{
  padding: 1em;
  .opt_btn{margin-bottom:3px; margin-right: 3px;}
  .page_style{
    text-align: right; margin-top: 1em;
    // background-color: var(--system-container-background);
  }
}
</style>