<template>
  <view class="content">
    <view class="search card">
      <u--input
          prefixIcon="search"
          placeholder="请输入关键字"
          border="surround"
          v-model="KEYWORDS"
          clearable
          shape="circle"
      ></u--input>
      <u-button class="bth-mini ml-10" type="success" text="确定" @click="resetList"></u-button>
    </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.OUTSOURCED_NAME }}</text>
          </view>
		  <view v-show="item.IS_CORP_TYPE== '1'" class="flex-between mt-10 subtitle">
		    <text>
		  	主管部门：{{ item.Q_COMPETENT_DEPT_NAME }}
		    </text>
		  </view>
		  <view v-show="item.IS_CORP_TYPE== '1'" class="flex-between mt-10 subtitle">
		    <text>
		      监督部门：{{ item.DEPARTMENT_NAME }}
		    </text>
		  </view>
		  <view v-show="item.IS_CORP_TYPE== '0'" class="flex-between mt-10 subtitle">
		    <text>
		  	主管部门：{{ item.MANAGER_DEPARTMENT_NAME }}
		    </text>
		  </view>
		  <view v-show="item.IS_CORP_TYPE== '0'" class="flex-between mt-10 subtitle">
		    <text>
		      监管部门：{{ item.DEPARTMENT_NAME }}
		    </text>
		  </view>
          <view class="flex-between mt-10 subtitle">
            <text>相关方单位负责人：{{item.UNITS_PIC_NAME}}</text>
            <text>电话：{{item.UNITS_PHONE}}</text>
          </view>
          <view class="flex-between mt-10 subtitle">
            <text>安全环保检查次数：{{item.CHECK_COUNT}}</text>
            <u-button type="primary" text="进入" size="mini" class="bth-mini" @click="fnNavigatorDetail(item.OUTSOURCED_ID)"></u-button>
          </view>
        </view>
      </u-list-item>
    </u-list>
    <empty v-else></empty>
  </view>
</template>

<script>
import {getKeyProjectsListOutsourced} from "../../../api";

export default {
  data() {
    return {
      KEYWORDS: '',
      pageSize: 10,
      currentPage: 1,
      totalPage: 0,
      list: [],
    }
  },
  onShow() {
    this.resetList()
  },
  computed: {
    userInfo() {
      return this.$store.getters.getUserInfo
    }
  },
  methods:{
    async getData(){
      let resData = await getKeyProjectsListOutsourced({
        KEYWORDS: this.KEYWORDS,
        showCount: this.pageSize,
        currentPage: this.currentPage,
		UserId: this.userInfo.USER_ID,
		STATE:'1'
      });
      this.list = [...this.list,...resData.varList];
      this.totalPage = resData.page.totalPage;
    },
    resetList() {
      this.pageSize= 10
      this.currentPage= 1
      this.list = []
      this.getData()
    },
    fnNavigatorDetail(OUTSOURCED_ID){
      uni.$u.route({
        url: '/pages/key-project-management/safety-environmental-inspection/detail-list',
        params: {
          OUTSOURCED_ID,
        }
      })
    },
    scrolltolower() {
      this.currentPage++;
      if(this.totalPage >= this.currentPage) this.getData();
    },
  }
}
</script>

<style scoped>

</style>
