<template>
  <view class="content">
    <view class="search card">
      <u--input
          prefixIcon="search"
          placeholder="请输入关键字"
          border="surround"
          v-model="keyword"
          clearable
          shape="circle"
      ></u--input>
      <view class="bth-mini ml-10">
        <u-button type="success" text="确定" @click="resetList"></u-button>
      </view>

    </view>
    <u-list @scrolltolower="scrolltolower" v-if="list.length > 0">
      <u-list-item v-for="(item, index) in list" :key="index">
        <view>
          <view class="flex-between main-title">
            <text>车牌号：{{ item.LICENCE_NO }}</text>
          </view>
          <view class="flex-between mt-10 subtitle">
            <text>车牌类型：{{ VEHICLE_LICENSE_PLATE_TYPE_MAP[item.LICENCE_TYPE] }}</text>
            <text>车辆类型：{{ VEHICLE_TYPE_MAP[item.VEHICLE_TYPE] }}</text>
          </view>
          <view class="flex-between mt-10 subtitle">
            <text>车辆所属部门：{{ item.DEPT_NAME }}</text>
            <text>车辆责任人：{{ item.U_NAME }}</text>
          </view>
          <view class="flex-between mt-10 subtitle">
            <text>访问起始时间：{{ item.VISIT_START_TIME }}</text>
          </view>
          <view class="flex-between mt-10 subtitle">
            <text>访问结束时间：{{ item.VISIT_END_TIME }}</text>
          </view>
          <view class="flex-between mt-10 subtitle">
            <text>审核状态：{{ AUDIT_STATUS_MAP[item.IS_AUDIT] }}</text>
          </view>
          <view class="mt-10 see_btn">
            <view class="wrap">
              <u-button type="primary" text="查看" size="mini"
                        @click="fnNavigatorView(item.VEHICLE_ID)"></u-button>
            </view>
            <view class="wrap ml-10">
              <u-button type="primary" text="重新申请" size="mini"
                        @click="fnNavigatorView(item.VEHICLE_ID)"></u-button>
            </view>
          </view>
        </view>
      </u-list-item>
    </u-list>
    <empty v-else></empty>
    <fab-button @click="fnNavigatorAdd('')"/>
  </view>
</template>

<script>
import FabButton from '@/components/fab_button/index.vue'

export default {
  components: {
    FabButton,
  },
  data() {
    return {
      VEHICLE_LICENSE_PLATE_TYPE_MAP: {
        0: "白牌",
        1: "蓝牌",
        2: "黄牌",
        3: "绿牌",
        4: "黑牌",
      },
      VEHICLE_TYPE_MAP: {
        0: "货车",
        1: "轿车",
        2: "大巴客车",
      },
      AUDIT_STATUS_MAP: {
        1: "待审核",
        2: "已审核",
        3: "审核驳回",
      },
      keyword: '',
      pageSize: 10,
      currentPage: 1,
      totalPage: 0,
      list: [],
    }
  },
  computed: {
    userInfo() {
      return this.$store.getters.getUserInfo
    }
  },
  onShow() {
    // this.resetList()
  },
  methods: {
    async getData() {
      const resData = {}
      this.list = [...this.list, ...resData.varList];
      this.totalPage = resData.page.totalPage;
    },
    resetList() {
      this.pageSize = 10
      this.currentPage = 1
      this.list = []
      this.getData()
    },
    fnNavigatorView(VEHICLE_ID) {
      uni.$u.route({
        url: '/pages/door_access_control/vehicle_info/view',
        params: {
          VEHICLE_ID,
        }
      })
    },
    fnNavigatorAdd(VEHICLE_ID) {
      uni.$u.route({
        url: '/pages/door_access_control/vehicle_info/add',
        params: {
          VEHICLE_ID,
        }
      })
    },
    scrolltolower() {
      this.currentPage++;
      if (this.totalPage >= this.currentPage) this.getData();
    },
  }
}
</script>

<style scoped lang="scss">
.ml-10 {
  margin-left: 10rpx;
}

.search {
  display: flex;

  .ml-10 {
    margin-left: 10rpx;
  }

  .bth-mini {
    width: 100rpx;
  }

}

.see_btn {
  display: flex;
  justify-content: flex-end;

  .wrap {
    //width: 200rpx;
    margin: 0 10rpx;
  }


}

</style>
