<template>
    <div>
        <van-row style="margin-top: 10px">
            <van-col :span="22" :offset="1" style="background-color: white">
                <div class="inforBox">
                    <p>归属年月：</p>
                    <div>
                        <!-- <van-datetime-picker-->
                        <!--     v-model="form.yf"-->
                        <!--     type="year-month"-->
                        <!--     title="选择年月"-->
                        <!--     :min-date="minDate"-->
                        <!--     :max-date="maxDate"-->
                        <!-- />-->

                        <van-field
                            right-icon="arrow-down"
                            v-model="form.yf"
                            placeholder="根据任务自动带出年、月"
                        />
                    </div>
                </div>
                <div class="inforBox" v-if="!form.isCf">
                    <p class="dataName">
                        <span>*</span>
                        本月营业收入
                        <span class="Company">（万元）</span>
                    </p>
                    <input v-model="form.yysr" type="number" class="input" placeholder="请填写" />
                </div>
                <div class="inforBox" v-if="form.isCf">
                    <p class="dataName">
                        <span>*</span>
                        本月餐费收入
                        <span class="Company">（万元）</span>
                    </p>
                    <input v-model="form.cfsr" type="number" class="input" placeholder="请填写" />
                </div>
                <div class="inforBox">
                    <p class="dataName">
                        <span>*</span>
                        本月总薪资
                        <span class="Company">（万元）</span>
                    </p>
                    <input v-model="form.xzze" type="number" class="input" placeholder="请填写" />
                </div>
                <div class="inforBox" v-if="!form.isCf">
                    <p class="dataName">
                        <span>*</span>
                        上年本月营业收入
                        <span class="Company">（万元）</span>
                    </p>
                    <input
                        v-model="form.qntqyysr"
                        type="number"
                        class="input"
                        placeholder="请填写/或自动带出"
                    />
                </div>
                <div class="inforBox" v-if="form.isCf">
                    <p class="dataName">
                        <span>*</span>
                        上年本月餐费收入
                        <span class="Company">（万元）</span>
                    </p>
                    <input
                        v-model="form.qntqyysr"
                        type="number"
                        class="input"
                        placeholder="请填写/或自动带出"
                    />
                </div>
                <div class="inforBox">
                    <div style="margin: 20px 0; text-align: center">
                        <van-button round type="primary" color="rgb(227 239 254)" @click="toHome">
                            <p class="off">返回</p>
                        </van-button>
                        <van-button round type="primary" color="rgb(26 76 218)" @click="save">
                            <p class="submit">提交</p>
                        </van-button>
                    </div>
                </div>
            </van-col>
        </van-row>
    </div>
</template>
<script>
import { Toast } from 'vant'
import apis from '@.mobile/api/apis'
import common from '@.mobile/plugin/axios/common'
export default {
    data() {
        return {
            minDate: new Date(2000, 0, 1),
            maxDate: new Date(),
            form: {
                rowguid: '',
                qymc: '',
                shxydm: '',
                tblx: '预估填报',
                yf: this.$common.formatDate('yyyyMM', new Date()),
                tbsj: '',
                yysr: '',
                qntqyysr: '',
                xzze: '',
                cfsr: '',
                dxcb: '未发送',
                tbrid: '--',
                tbr: '--',
                ejgm: '--',
                yjgm: '--',
                lxdh: '--',
                qylxr: '--',
                qyzt: '--',
                ssbk: '--',
                isCf: false
            }
        }
    },
    mounted() {
        const user = common.currUser()
        this.form.qymc = user.qymc
        this.form.shxydm = user.shxydm
        this.form.ejgm = user.ejgm
        this.form.yjgm = user.yjgm
        this.form.lxdh = user.lxdh
        this.form.qylxr = user.qylxr
        this.form.qyzt = user.qyzt
        this.form.ssbk = user.ssbk
        this.form.qntqyysr = user.qntqyysr
        console.log(user.hymc)
        this.form.isCf = user.hymc === '住宿餐饮'
    },
    methods: {
        toHome() {
            this.$router.push('/mobile-home')
        },
        save() {
            if (!this.form.shxydm) {
                Toast('请重新登录后重试')
                this.$router.push('/mobile-login')
                return
            }
            if (this.form.isCf) {
                if (!this.form.cfsr) {
                    Toast('请填写餐费收入')
                    return
                }
            } else {
                if (!this.form.yysr) {
                    Toast('请填写营业收入')
                    return
                }
            }

            if (!this.form.xzze) {
                Toast('请填写薪资总额')
                return
            }
            apis.requestData('EcCompanyPredictController', 'save', this.form).then(res => {
                const data = res.data
                if (data.code == 200) {
                    Toast('预估数据填报成功')
                } else {
                    Toast(data.msg)
                }
            })
        }
    }
}
</script>
<style scoped>
.inforBody {
    background: white;
    margin: 10vw 5vw;
    padding: 0 0 5vw 0;
}
.inforBox {
    padding: 1vw 5vw;
    position: relative;
}
.input {
    width: 100%;
    padding: 1vw;
    border: 1px solid #e6e6e6;
}
.van-field {
    width: 100%;
    padding: 1vw;
    border: 1px solid #e6e6e6;
}
.down {
}
.dataName::first-letter {
    color: #ff4343;
}
.Company {
    color: #999999;
}

.buttonBox {
    display: flex;
    justify-content: space-evenly;
}

.van-button {
    width: 35vw;
    cursor: pointer;
    border: 1px solid rgb(209 220 250);
}
input::-webkit-input-placeholder {
    color: #cccccc;
    font-size: 2.5vw;
}
::v-deep .van-field__control::-webkit-input-placeholder {
    color: #cccccc;
    font-size: 2.5vw;
}
.off {
    display: flex;
    justify-content: center;
    color: rgb(66 107 224);
    width: 30vw;
    letter-spacing: 2vw;
    margin-left: 1vw;
}
.submit {
    display: flex;
    justify-content: center;
    width: 30vw;
    letter-spacing: 2vw;
    margin-left: 1vw;
}
</style>
