<template>
	<view class="order-handle form-box">
		<uni-forms label-position="top" :modelValue="formData">
			<uni-forms-item label="处理内容" name="remark">
				<uni-easyinput type="textarea" v-model="formData.remark" placeholder="请输入处理内容"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item label="附件">
				<upload ref="upload" :list="attachment" type="insert"></upload>
			</uni-forms-item>
		</uni-forms>
		<view class="hui-button-box">
			<view class="hui-button" @click="submit">提交处理</view>
		</view>
	</view>
</template>

<script>
	import {
		putOrderProcess
	} from '@/request/api/order.js'
	import upload from '@/components/common/upload.vue';
	export default {
		data() {
			return {
				formData: {
					remark: ''
				},
				attachment: [],
				operationId: ''
			}
		},
		onLoad(body) {
			if (body.operationId) this.operationId = body.operationId;
		},
		methods: {
			submit() {
				if (!this.operationId) return;
				if (!this.formData.remark) return this.$toast('请输入处理内容');
				let postData = {
					id: this.operationId,
					remark: this.formData.remark,
					attachment: JSON.stringify(this.$refs.upload.getFile()),
					status: 1
				}
				putOrderProcess(postData).then(res => {
					if (res.code === 200) {
						this.$toast('操作成功');
						uni.$emit('reloadOrderDetail');
						setTimeout(() => {
							this.$navigateBack();
						}, 400)
					}
				})
			}
		},
		components: {
			upload
		},
	}
</script>

<style lang="scss">
	.order-handle {
		padding: 30rpx;
	}
</style>