<template>
  <view class="content">
    <view class="search card">
      <u--input
          prefixIcon="search"
          placeholder="请输入关键字"
          border="surround"
          v-model="KEYWORDS"
          clearable
          shape="circle"
      ></u--input>
      <view class="bth-mini ml-10">
        <u-button type="success" text="确定" @click="fnSearchList"></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 class="flex-between main-title" @click="fnKeyProjectApply(item.OUTSOURCED_ID)">
          <text>{{ item.OUTSOURCED_NAME }}</text>
        </view>
			<view v-show="item.IS_CORP_TYPE== '1'" class="flex-between mt-10 subtitle" @click="fnKeyProjectApply(item.OUTSOURCED_ID)">
			  <text>
				主管部门：{{ item.Q_COMPETENT_DEPT_NAME }}
			  </text>
			</view>
            <view v-show="item.IS_CORP_TYPE== '1'" class="flex-between mt-10 subtitle" @click="fnKeyProjectApply(item.OUTSOURCED_ID)">
              <text>
                监督部门：{{ item.DEPARTMENT_NAME }}
              </text>
            </view>
			<view v-show="item.IS_CORP_TYPE== '0'" class="flex-between mt-10 subtitle" @click="fnKeyProjectApply(item.OUTSOURCED_ID)">
			  <text>
				主管部门：{{ item.MANAGER_DEPARTMENT_NAME }}
			  </text>
			</view>
			<view v-show="item.IS_CORP_TYPE== '0'" class="flex-between mt-10 subtitle" @click="fnKeyProjectApply(item.OUTSOURCED_ID)">
			  <text>
			    监管部门：{{ item.DEPARTMENT_NAME }}
			  </text>
			</view>
        <view class="flex-between mt-10 subtitle" @click="fnKeyProjectApply(item.OUTSOURCED_ID)">
          <text>相关方单位负责人：{{ item.UNITS_PIC_NAME }}</text>
          <text>电话：{{ item.UNITS_PHONE }}</text>
        </view>
        <view class="flex-between mt-10 subtitle" @click="fnKeyProjectApply(item.OUTSOURCED_ID)">
          <text>定位坐标：{{ item.WORK_LONGITUDE?item.WORK_LONGITUDE+'*'+item.WORK_LATITUDE: ''}}</text>
        </view>
		<view class="flex-between mt-10 subtitle" @click="fnKeyProjectApply(item.OUTSOURCED_ID)">
		  <text>状态：{{ item.STATE == '-1'?'开工申请中':item.STATE == '-2'?'结束申请中': item.STATE == '0'?'未开工': item.STATE == '1'?'进行中': '已结束'}}</text>
		</view>
		<view class="flex-end">
			<view class="flex-between">
						  <u-button
						      size="mini"
						      round
						      type="primary"
						      class="bth-mini"
						      text="查看"
						      @click="fnKeyProjectApply(item.OUTSOURCED_ID)"
						  />
						  <u-button style="margin-left: 20upx;"
						      size="mini"
						      round
						      type="primary"
						      class="bth-mini"
						      text="播放"
						      @click="fnView(item.OUTSOURCED_ID)"
						  />
			</view>
		</view>
      </u-list-item>
    </u-list>
    <empty v-else></empty>
  </view>
</template>

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

export default {
  data() {
    return {
      KEYWORDS: '',
      list: [],
      pageSize: 10,
      currentPage: 1,
      totalPage: 0,
    }
  },
  onLoad(e) {
  	this.CORPINFO_ID = e.CORPINFO_ID
  },
  onShow() {
    this.fnSearchList()
  },
  computed: {
    userInfo() {
      return this.$store.getters.getUserInfo
    }
  },
  methods: {
    async fnGetData() {
      const resData = await getKeyProjectsListOutsourced({
       KEYWORDS: this.KEYWORDS,
       showCount: this.pageSize,
       currentPage: this.currentPage,
       CORPINFO_ID: this.CORPINFO_ID,
       UserId: this.userInfo.USER_ID,
      });
      this.list = [...this.list, ...resData.varList];
      this.totalPage = resData.page.totalPage;
    },
    scrolltolower() {
      this.currentPage++;
      if(this.totalPage >= this.currentPage) this.fnGetData();
    },
    fnSearchList(){
      this.pageSize = 10;
      this.currentPage = 1;
      this.list = [];
      this.fnGetData();
    },
    fnView(OUTSOURCED_ID){
      uni.$u.route({
        url: '/pages/key-project-management/positioning_management/list',
        params:{
          OUTSOURCED_ID
        }
      })
    },
	fnKeyProjectApply(OUTSOURCED_ID){
	  uni.$u.route({
	    url: '/pages/key-project-management/positioning_management/keyProjectApply',
	    params:{
	      OUTSOURCED_ID
	    }
	  })
	},
  },
}
</script>

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