<template>
    <global-page
        title="新建例行维护工作单"
        :showNavRight="true"
        navRightText="今天签单"
        @handleRightClick="navigateTo('/panel/electronicBill/routineWork/list')"
        showFooterBtn
        footerBtnText="客户方代表签字"
        @handleFooterClick="handleFooterClick"
    >
        <up-form ref="formRef" labelPosition="left" labelWidth="auto" :model="formData" :rules="rules" errorType="toast">
            <view class="mocp-title">基本信息</view>
            <view class="mocp-form">
                <up-form-item label="航站" prop="station" :borderBottom="true" required>
                    <global-picker
                        pickAlign="right"
                        v-model="formData.station"
                        clearable
                        :options="baseStore.getTerminalSelect"
                        filter
                    ></global-picker>
                </up-form-item>
                <up-form-item label="日期" prop="date" :borderBottom="true" required>
                    <global-date pickAlign="right" clearable v-model="formData.date" defaultToday></global-date>
                </up-form-item>
                <up-form-item label="机号" prop="acreg" :borderBottom="true" required>
                    <global-picker pickAlign="right" v-model="formData.acreg" :options="allAc" clearable filter @change="changeAcreg"></global-picker>
                </up-form-item>
                <up-form-item label="飞机所属单位" prop="aircaraftoperator" :borderBottom="true" required>
                    <global-picker pickAlign="right" v-model="formData.aircaraftoperator" :options="allAirline" clearable filter></global-picker>
                </up-form-item>
                <up-form-item label="机型" prop="model" :borderBottom="true" required>
                    <global-picker v-model="formData.model" pickAlign="right" :options="allAcType" clearable filter></global-picker>
                </up-form-item>
                <up-form-item label="进港航班号" prop="flightNoIn" :borderBottom="true" required>
                    <up-input v-model="formData.flightNoIn" inputAlign="right" border="none" placeholder="请输入" clearable></up-input>
                </up-form-item>
                <up-form-item label="出港航班号" prop="flightNoOut" :borderBottom="true">
                    <up-input v-model="formData.flightNoOut" inputAlign="right" border="none" placeholder="请输入" clearable></up-input>
                </up-form-item>
                <up-form-item label="航段" prop="legs" :borderBottom="true">
                    <up-input v-model="formData.legs" inputAlign="right" border="none" placeholder="请输入" clearable></up-input>
                </up-form-item>
            </view>
            <view class="mocp-title">过站维护TR</view>
            <view class="mocp-form">
                <up-form-item label="过站TR" prop="tr" :borderBottom="true">
                    <global-switch v-model="formData.tr" switchAlign="right"></global-switch>
                </up-form-item>
                <up-form-item label="一般勤务" prop="serviceTr" :borderBottom="true">
                    <global-switch v-model="formData.serviceTr" switchAlign="right"></global-switch>
                </up-form-item>
            </view>
            <view class="mocp-title">航前维护PF</view>
            <view class="mocp-form">
                <up-form-item label="航前PR" prop="pf" :borderBottom="true">
                    <global-switch v-model="formData.pf" switchAlign="right"></global-switch>
                </up-form-item>
                <up-form-item label="一般勤务" prop="servicePf" :borderBottom="true">
                    <global-switch v-model="formData.servicePf" switchAlign="right"></global-switch>
                </up-form-item>
            </view>
            <view class="mocp-title">航后维护AF</view>
            <view class="mocp-form">
                <up-form-item label="航后AF" prop="af" :borderBottom="true">
                    <global-switch v-model="formData.af" switchAlign="right"></global-switch>
                </up-form-item>
                <up-form-item label="一般勤务" prop="serviceAf" :borderBottom="true">
                    <global-switch v-model="formData.serviceAf" switchAlign="right"></global-switch>
                </up-form-item>
            </view>
            <view class="mocp-title">设备使用记录</view>
            <view class="mocp-form">
                <up-form-item label="电源车(单位/小时)" prop="groundPower" :borderBottom="true">
                    <up-input type="number" v-model="formData.groundPower" inputAlign="right" border="none" placeholder="请输入" clearable></up-input>
                </up-form-item>
                <up-form-item label="气源车(单位/次)" prop="airStarter" :borderBottom="true">
                    <up-input type="number" v-model="formData.airStarter" inputAlign="right" border="none" placeholder="请输入" clearable></up-input>
                </up-form-item>
                <up-form-item label="牵引车(单位/次)" prop="towPus" :borderBottom="true">
                    <up-input type="number" v-model="formData.towPus" inputAlign="right" border="none" placeholder="请输入" clearable></up-input>
                </up-form-item>
                <up-form-item label="空调车(单位/小时)" prop="airConditioning" :borderBottom="true">
                    <up-input
                        type="number"
                        v-model="formData.airConditioning"
                        inputAlign="right"
                        border="none"
                        placeholder="请输入"
                        clearable
                    ></up-input>
                </up-form-item>
                <up-form-item label="其他" prop="others1" :borderBottom="true">
                    <up-input v-model="formData.others1" inputAlign="right" border="none" placeholder="请输入" clearable></up-input>
                </up-form-item>
                <up-form-item label="其他" prop="others2" :borderBottom="true">
                    <up-input v-model="formData.others2" inputAlign="right" border="none" placeholder="请输入" clearable></up-input>
                </up-form-item>
            </view>
            <view class="mocp-title">辅助信息</view>
            <view class="mocp-form">
                <up-form-item label="备降" prop="diversion" :borderBottom="true">
                    <global-switch v-model="formData.diversion" switchAlign="right"></global-switch>
                </up-form-item>
                <up-form-item label="返航" prop="returnFlight" :borderBottom="true">
                    <global-switch v-model="formData.returnFlight" switchAlign="right"></global-switch>
                </up-form-item>
                <up-form-item label="无故障过站待命" prop="onCall" :borderBottom="true">
                    <global-switch v-model="formData.onCall" switchAlign="right"></global-switch>
                </up-form-item>
                <up-form-item label="备注" prop="remark" :borderBottom="true">
                    <up-input v-model="formData.remark" inputAlign="right" border="none" placeholder="请输入" clearable></up-input>
                </up-form-item>
            </view>
        </up-form>
    </global-page>
</template>

<script setup>
import useBaseStore from 'mocp/store/base'
import useElectronicBillStore from 'mocp/store/electronicBill'
import { formData, rules } from './constants/add.compositions'
import { navigateTo } from 'mocp/utils/jump'
import { ref } from 'vue'
import { changeAcreg } from './constants/add.functionals'

const baseStore = useBaseStore()
const electronicBillStore = useElectronicBillStore()
const {
    selectList: { allAc, allAcType, allAirline }
} = electronicBillStore
//提交
const formRef = ref()
const handleFooterClick = async () => {
    await formRef.value?.validate()
    navigateTo('/panel/electronicBill/routineWork/sign')
}
</script>
<style lang="scss" scoped>
.mocp-form {
    background: #fff;
    margin-bottom: 24rpx;
    padding: 0 32rpx;
}
.mocp-title {
    padding: 0 32rpx 24rpx 32rpx;
    background-color: #f7f8fa;
}
</style>
