<!--
 * @Title: 
 * @Description: 人工派单
 * @Author: swp
 * @Date: 2022-08-24 10:49:21
 * @LastEditors: 
 * @LastEditTime: 2022-08-24 10:49:21
-->
<template>
	<view class="wrap">
		<uni-nav-bar dark :fixed="true" backgroundColor="#3F9EFF" statusBar="false" left-icon="left" left-text="返回"
			@clickLeft="toBack">
			<view style="width: 100%;display: flex;flex-direction: row;justify-content: center;align-items: center;">
				<text style="color: white;font-size: 1rem;">{{title}}</text>
			</view>
		</uni-nav-bar>
		<view class="container">
			<uni-section title="任务说明" type="circle">
				<view style="margin-top: 20px;margin-bottom: 40px;;padding-left: 10px;padding-right: 10px;">
					<uni-easyinput :styles="inputStyles" prefixIcon="search" v-model="orderDesc" placeholder="请输入任务说明">
					</uni-easyinput>
				</view>
			</uni-section>
			<view style="margin-top: 10px;margin-bottom: 10px;padding-left: 10px;padding-right: 10px;">
				<button style="background-color: lightcoral;" type="default"
					@click="onCheckOrderSubmitClick()">提交任务</button>
			</view>
		</view>
	</view>
</template>

<script>
	import http from '@/http/api.js';

	export default {
		components: {

		},
		onLoad(option) {
			this.rtuCode = option.rtuCode;
		},
		data() {
			return {
				rtuCode: '',
				orderDesc: '',
				title: '人工添加维修任务',
				inputStyles: {
					color: '#808080',
					borderColor: '#d3d3d3'
				},
				checkOrderForm: {
					id: '',
					rtuName: '',
					rtuCode: '',
					orderDesc: '',
				},
				query: {}
			}
		},
		computed: {

		},
		onShow() {

		},
		created() {

		},
		methods: {
			toBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			onCheckOrderSubmitClick() {
				let that = this;
				this.checkOrderForm['rtuCode'] = this.rtuCode;
				this.checkOrderForm['orderDesc'] = this.orderDesc;
				let postData = Object.assign(this.checkOrderForm, this.query);
				http.request({
					url: '/galaxy-business/rtu/check/order/manually',
					method: 'POST',
					data: postData
				}).then(res => {
					console.log(JSON.stringify(res))
					if (res.success) {
						uni.showModal({
							content: '人工派单操作已成功!',
							showCancel: true,
							success(res) {
								if (res.confirm) {
									that.toBack();
								}
							}
						});
					} else {
						uni.showModal({
							content: '人工派单操作失败!',
							showCancel: true,
							success(res) {
								if (res.confirm) {
									that.toBack();
								}
							}
						});
					}
				}).catch(err => {
					console.log("err" + JSON.stringify(err))
					uni.showModal({
						content: err.data.msg,
						showCancel: true,
						success(res) {
							if (res.confirm) {
								that.toBack();
							}
						}
					});
				})
			},
		}
	}
</script>

<style>
	/* page {
		background-color: rgb(240, 242, 244);
	} */
</style>

<style lang="scss" scoped>
	.container {
		padding: 0 0 150rpx;
	}
</style>