<template>
	<view>
		<uni-list>
			<uni-list-item v-for="(item, index) in listData" :key="index" @click="goDetail(item.designChangesCode)" clickable>
				<view slot="body" class="slot-box">
					<view class="row">
						<view class="column-left">变更编号：</view>
						<view class="column-right section-title">{{item.designChangesNumber}}</view>
					</view>
					<view class="row">
						<view class="column-left">变更名称：</view>
						<view class="column-right">{{item.designChangesName}}</view>
					</view>
					<view class="row">
						<view class="column-left">变更日期：</view>
						<view class="column-right">{{item.designChangesDateStr}}</view>
					</view>
					<view class="row" v-show="$util.getQuery('type')=='2'">
						<view class="column-left">所属部门：</view>
						<view class="column-right">{{item.unitName}}</view>
					</view>
					<view class="row" v-show="$util.getQuery('type')=='2'">
						<view class="column-left">关联合同：</view>
						<view class="column-right">{{item.contractName}}</view>
					</view>
					<view class="row">
						<view class="column-left">当前状态：</view>
						<view class="column-right">{{item.stateName}}</view>
					</view>
				</view>
			</uni-list-item>
		</uni-list>
		<view style="bottom: 15px;right:10px;position: fixed;z-index: 50;">
			<router-link to="/pages/template/DesignChangesAdd/DesignChangesAdd" style="text-decoration: none;" title="待审变更添加">
				<uni-icons type="plus-filled" size="80" color="#F26C69"></uni-icons>
			</router-link>
		</view>

		<uni-load-more :status="status" :icon-size="16" :content-text="contentText" />
		<page-foot :isShow="true" :showIndex="4"></page-foot>
	</view>
</template>

<script>
	import {
		GetDesignChangesList
	} from "@/common/api/DesignChanges.js";
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';

	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				listData: [],
				searchvalue: '',
				last_id: '',
				reload: false,
				status: 'more',
			 


				contentText: {
					contentdown: '上拉加载更多',
					contentrefresh: '加载中',
					contentnomore: '没有更多'
				}
			};
		},
		onLoad() {
			console.info("当前登录状态:" + this.$store.state.isLogin);
			//console.info(this);
			this.$util.persistLogin(this);

		},
		onPullDownRefresh() {
			this.reload = true;
			this.last_id = '';

			this.getList();
		},
		onReachBottom() {
			this.status = 'more';
			this.getList();
		},
		created: function() {
			 
			this.getList();
		},
		methods: {
			getList() {
				let that = this;
				let projectCode = this.$util.getState(that,"projectCode");
				let userCode = this.$util.getState(that,"userCode");

				GetDesignChangesList(projectCode, userCode).then((res) => {
					console.info('GetDesignChangesList',res);
					that.listData = [];
					res.forEach(function(item, index, array) {
						that.$set(that.listData, index, item);
					});
					console.info(that.listData);
				});
			},
			goDetail: function(id) {
				console.info('待审变更godetail', id);
				uni.navigateTo({
					url: '/pages/template/GetDesignChanges/GetDesignChanges?id=' + id
				});
			},
			search(res) { //回车搜索
				this.searchvalue = res.value; //赋值

				this.getList(); //调用搜索方法
			},
			input(res) {
				this.searchVal = res.value
			},
			cancel(res) {
				console.info('点击取消，输入值为：' + res.value);

			},

		}
	};
</script>

<style  lang="scss" scoped>
.uni-list-item{
		border-bottom: $BgColorBlue;
	} 
</style>
