<template>
	<view>
		<view class="sm-box">
			<view class="content-box-card">
				<view class="content-box-card-ul-two">
					<view class="content-box-card-list">
						<view class="content-box-card-title">物料编号:</view>
						<text>{{ CyInfo.product_number }}</text>
					</view>
				</view>
				<view class="content-box-card-ul-two">
					<view class="content-box-card-list">
						<view class="content-box-card-title">生产线:</view>
						<text>{{ CyInfo.line_title }}</text>
					</view>
					<view class="content-box-card-list">
						<view class="content-box-card-title">物料名称:</view>
						<text>{{ CyInfo.product_name }}</text>
					</view>
				</view>
			</view>
		</view>
		<view class="big-title">
			停线记录
		</view>
		<view class="white-card">
			<view class="lists" v-for="(item,index) in list" :key="index">
				<view class="list-left">
					<view class="list-left-up">
						<view class="list-left-up-left">班次:{{item.frequency==0?'夜班':'白班'}}</view>
						<view class="list-left-up-mid">停线原因:{{item.reason}}</view>
					</view>
					<view class="list-left-dow">
						<view class="list-left-dow-left">产线状态:{{item.status==0?'已停线':'已恢复开线'}}</view>
						<view class="list-left-dow-btn">
							<view  @tap="editRecord(item.id)">
								查看详情
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="submit-btn">
				<button type="primary"  @tap="addRecord()">新增停线记录</button>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		stopList
	} from "../../api/user.js"
	import {
		mapGetters,
		mapMutations
	} from 'vuex';
	export default {
		data() {
			return {
				plan_id: '',
				CyInfo: {},
				info: {},
				power: [],
				jurisdiction: [],
				product_id:0,
				list: [],
				limit: 10,
				page: 1
			};
		},
		computed: {
			...mapGetters(['userInfo', 'roleType'])

		},
		onShow() {
			this.getData()
		},
		onLoad(e) {
			
			this.CyInfo = JSON.parse(decodeURIComponent(e.planInfo));
			this.plan_id = this.CyInfo.plan_id;
			this.product_id=this.CyInfo.product_id;
			this.power = this.userInfo.power
			this.getArr();
			this.isMenu();
		},
		methods: {
			getArr() {
				let newArr = this.power.map(item => {
					if (item.children) {

						item.children.map(items => {
							this.jurisdiction.push(items.title)
							return items
						})
					}

				})
				console.log("xinshuzu", this.jurisdiction)
			},
			isMenu(title) {
				return this.jurisdiction.includes(title);
			},
			getData() {
				let param = {
					plan_id: this.plan_id,
				};
				stopList(param).then(res => {
					// this.info = res,
					this.list = res;
					console.log("详情", res)
				})
			},
			addRecord() {
				uni.navigateTo({
					url: `../stopLine/stopLine?plan_id=${this.plan_id}&type=1&planInfo=${encodeURIComponent(JSON.stringify(this.CyInfo))}`,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			},
			editRecord(id) {
				uni.navigateTo({
					url: `../stopLine/stopLine?plan_id=${this.plan_id}&type=1&id=${id}&planInfo=${encodeURIComponent(JSON.stringify(this.CyInfo))}`,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			},
		}
	}
</script>

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