<template>
	<view>
		<uni-mall-list :dataList="dataList" :defaultHeadList="defaultHeadList" @change="handleChange" type="select">
		</uni-mall-list>
	</view>
</template>

<script>
	import {
		getPartList
	} from '@/request/api/organization.js'
	import {
		insertOrderProcess
	} from '@/request/api/order.js'
	import uniMallList from '@/components/uni-mall-list/uni-mall-list.vue';
	export default {
		components: {
			uniMallList
		},
		data() {
			return {
				defaultHeadList: {},
				dataList: [],
				orderId: ''
			};
		},
		onLoad(body) {
			if (body.orderId) this.orderId = body.orderId;
			this.defaultHeadList = {
				name: this.$store.getters.organization.name,
				id: new Date().getTime()
			}
			this.init();
		},
		methods: {
			init() {
				getPartList(38, 9).then(res => {
					if (res.code === 200) {
						this.dataList = res.data;
					}
				})
			},
			handleChange(type, item) {
				console.log(item);
				if (type === 'user') {
					uni.showLoading();
					insertOrderProcess({
						operatorId: item.id,
						workOrderId: this.orderId,
						status: 0,
						attachment: '[]'
					}).then(res => {
						if (res.code === 200) {
							this.$toast('操作成功');
							uni.$emit('reloadOrderDetail')
							setTimeout(() => {
								this.$navigateBack();
							}, 400)
						}
						uni.hideLoading();
					})
				}
			}
		}
	};
</script>

<style></style>