<template>
	<view>
		<uni-card>
			<text>{{ title }}</text>
		</uni-card>
		<uni-list style="width: 100%">
			<uni-list-item v-for="(item, index) in taskList" :key="index" :title="item.title" :note="item.note" :rightText="item.rightText"></uni-list-item>
		</uni-list>
	</view>
</template>

<script>
import { getTaskInfoList } from '@/api/preparationTask/index.js';
export default {
	onLoad: function (option) {
		this.taskCode = option.taskCode;
		this.title = option.title;
		
	},
	onShow:function(){
		this.$nextTick(() => {
			this.doGetTaskInfoList();
		});
	},
	data() {
		return {
			title:'',
			taskCode: '',
			taskList: []
		};
	},
	methods: {
		doGetTaskInfoList() {
			uni.showLoading();
			const params = {
				task_code: this.taskCode
			};
			getTaskInfoList(params)
				.then((res) => {
					if (res.code === 200) {
						this.taskList = res.data.map((item) => {
							return {
								id: item.id,
								title: `物料号:${item.materialCode}`,
								note: `描述:${item.materialName ?? ''} 规格:${item.specification ?? ''}`,
								rightText: `配料数量:${item.quantity}`
							};
						});
					}
				})
				.finally(() => {
					uni.hideLoading();
				});
		}
	}
};
</script>

<style></style>
