<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-row>
        <el-form-item label="箱号" prop="fNo">
          <el-input
            v-model="queryParams.fNo"
            style="width: 240px"
            placeholder="请输入箱号"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
          <el-form-item label="地点" prop="fUpdateaddress">
            <el-select
              style="width: 240px"
              v-model="queryParams.fUpdateaddress"
              placeholder="请输入地点"
              clearable
              size="small"
              filterable
              :remote-method="addressMethod"
            >
              <el-option
                v-for="item in this.addressOptions"
                :key="item.fId"
                :label="item.fName"
                :value="item.fId">
                <span style="float: left; color: #8492a6; font-size: 13px">{{ item.typesName }}</span>
                <span style="float: right;">{{ item.fName }}</span>
              </el-option>
            </el-select>
          </el-form-item>
      </el-row>
    </el-form>

    <el-row :gutter="10" class="mb8">
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="corpsList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column type="index" width="55" label="行号" align="center" />
      <el-table-column :show-overflow-tooltip="true" label="提单号" align="center" prop="fMblno" width="120px"/>
      <el-table-column :show-overflow-tooltip="true" label="箱号" align="center" prop="fNo" width="120px"/>
      <el-table-column label="铅封号" align="center" prop="" width="120px"/>
      <el-table-column :show-overflow-tooltip="true" label="箱型" align="center" prop="typeidName" width="100px"
      />
      <el-table-column :show-overflow-tooltip="true" label="尺寸" align="center" width="100px" prop="cntrsizeName" />
      <el-table-column :show-overflow-tooltip="true" label="箱主" align="center" prop="ownerName" />
      <el-table-column :show-overflow-tooltip="true" label="船名" align="center" prop="fVsl" />

      <el-table-column label="航次" align="center" prop="fVoy" />
      <el-table-column label="最新时间" align="center" prop="fUpdatetime" width="100"/>
      <el-table-column label="地点" align="center" prop="addressName" width="100px"/>
      <el-table-column label="空重" align="center" prop="updateEFName" width="100px"/>
      <el-table-column label="箱状态" align="center" prop="cntrstatusName" width="100px"/>
      <el-table-column label="操作" align="center" min-width="120px" fixed="right">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            v-hasPermi="['shipping:cntrtracking:remove']"
            @click="handleDelete(scope.row)"
          >移除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
  import { listCorps, getaddress, delCorps } from "@/api/kaihe/containerNews/historyBoxNews";

  export default {
    name: "historyBoxNews",
    components: {
    },
    data() {
      return {
        //默认显示第一行
        queryParamsHidden:false,
        //模糊下拉查询地点
        addressOptions:[],

        //全屏放大
        dialogFull:false,
        contactList:[],
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 客户详情表格数据
        corpsList: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          fNo:null,
          fUpdateaddress:null
        },
      };
    },
    created() {
      this.getList();
      this.addressMethod()
    },
    methods: {
      /** 删除按钮操作 */
      handleDelete(row) {
        const fIds = row.fId || this.ids;
        this.$confirm('是否确认删除客户详情编号为"' + fIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delCorps(fIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
      },
      //模糊查询地点
      addressMethod(){
        let queryParams = { pageNum: 1,};
        getaddress(queryParams).then(response=>{
          this.addressOptions = response.rows
        })
      },
      /** 查询客户详情列表 */
      getList() {
        this.loading = true;
        listCorps(this.queryParams).then(response => {
          this.corpsList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },

      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.fId)
        this.single = selection.length!==1
        this.multiple = !selection.length
      },

    }
  };
</script>
<style lang="scss">

</style>
