<template>
	<view>
		<view class="card" v-for="(item,index) in repairRecordList" :key="index">
			<view class="card-left">
				<view class="card-up-list">
					<view class="card-up-list-list">
						<view>物料名称:</view><text>{{item.name}}</text>
					</view>
					<view class="card-right" >
						<view  @tap="firstInspectionInfo(item)" v-if="isMenu(79)" style="padding: 5upx 10upx;color: white;background: red;border-radius: 5upx;font-size: 26upx;">立即审核</view>
					</view>
				</view>
				<view class="card-up-list">
					<view class="card-up-list-list">
						<view>物料编号:</view><text>{{item.number}}</text>
					</view>
				</view>
				<view class="card-up-list">
					<view class="card-up-list-list">
						<view>提交人员:</view><text>{{item.staff}}</text>
					</view>
				</view>
				<view class="card-up-list">
					<view class="card-up-list-list">
						<view>返修时间:</view><text>{{item.create_time}}</text>
					</view>
				</view>
			</view>
		</view>
		<view class="submit"  @tap="tjrsBtn()" v-if="isMenu(78)">新增返修记录</view>
	</view>
</template>

<script>
	import {repairRecord} from "../../api/user.js"
	import {
		mapGetters,
		mapMutations
	} from 'vuex';
	export default {
		computed: {
			...mapGetters(['userInfo', 'roleType'])
		
		},
		data() {
			return {
				repairRecordList:[],
				power:[],
				jurisdiction: [],
			};
		},
		onLoad() {
			this.getdata()
			this.power = this.userInfo.power
			
			this.getArr();
			this.isMenu();
		},
		methods:{
			getArr() {
							if (this.power.length > 0) {
								let newArr = this.power.map(item => {
									this.jurisdiction.push(item.id)
								})
								
							}	
						console.log("id",this.jurisdiction)
						},
						isMenu(id) {
							
							return this.jurisdiction.includes(id);
						},
			getdata(){
				repairRecord().then(res=>{
					this.repairRecordList=res
					console.log("列表",res)
				})
			},
			tjrsBtn(){
				uni.navigateTo({
					url: '../addRepairRecord/addRepairRecord',
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			},
			firstInspectionInfo(item){
				uni.navigateTo({
					url: `../repairExeam/repairExeam?planInfo=${encodeURIComponent(JSON.stringify(item))}`,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>

<style lang="scss">
@import "./index.scss"
</style>
