<!-- 发布岗位 -->
<template>
    <view>
        <view class="u-demo-block__content">
            <!-- 注意，如果需要兼容微信小程序，最好通过setRules方法设置rules规则 -->
            <u--form labelPosition="left" :model="info" ref="form1" :rules="rules">
                <view style="font-size: 30rpx;font-weight: bold;padding: 20rpx 0 0;">岗位信息</view>
                <u-form-item label="岗位名称" prop="jobName" borderBottom labelWidth="80" ref="item1">
                    <u--input v-model="info.jobName" border="none" placeholder="请输入岗位名称"></u--input>
                </u-form-item>
                <u-form-item label="发布时间" labelWidth="80" prop="stime" borderBottom
                    @click="showStime = true; hideKeyboard()" ref="item1">
                    <u--input v-model="info.stime" disabledColor="#ffffff" placeholder="请选择发布时间"
                        border="none"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
                <u-form-item label="结束时间" labelWidth="80" prop="etime" borderBottom
                    @click="showEtime = true; hideKeyboard()" ref="item2">
                    <u--input v-model="info.etime" disabledColor="#ffffff" placeholder="请选择结束时间"
                        border="none"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
                <view style="font-size: 30rpx;font-weight: bold;padding: 20rpx 0 0;">岗位要求</view>
                <u-form-item label="招聘人数" prop="peopleNum" borderBottom labelWidth="80" ref="item3">
                    <u--input type="number" v-model="info.peopleNum" border="none" maxlength="7"
                        placeholder="请输入招聘人数"></u--input>
                </u-form-item>
                <!-- <u-form-item label="参考工资" prop="wage" labelWidth="80" borderBottom
					@click="showWage = true; hideKeyboard()" ref="item4">
					<u--input v-model="info.wage" disabledColor="#ffffff" placeholder="请选择参考工资"
						border="none"></u--input>
					<u-icon slot="right" name="arrow-right"></u-icon>
				</u-form-item> -->
                <u-form-item label="参考工资" prop="wage" borderBottom labelWidth="80" ref="item1">
                    <u--input v-model="info.wage" border="none" type="number" maxlength="7" @blur="onBlurWage"
                        placeholder="请输入参考工资">
                        <template slot="suffix">
                            <u-form-item class="wageunitLeft" prop="wageUnitCategory" labelWidth="0" border="surround"
                                @click="showWage = true; hideKeyboard()" ref="item4">
                                <u--input v-model="info.wageUnitCategoryName" disabledColor="#ffffff"
                                    placeholder="请选择单位" style="width: 80px;" border="none"></u--input>
                                <u-icon slot="right" name="arrow-right"></u-icon>
                            </u-form-item>
                        </template>
                    </u--input>
                </u-form-item>
                <u-form-item label="行业类型" prop="tradeNames" labelWidth="80" borderBottom
                    @click="showTrade = true; hideKeyboard()" ref="item4">
                    <u--input v-model="info.tradeNames" disabledColor="#ffffff" placeholder="请选择行业类型"
                        border="none"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>

                <u-form-item label="工种" prop="skillNames" labelWidth="80" borderBottom
                    @click="showSkills = true; hideKeyboard()" ref="item4">
                    <u--input v-model="info.skillNames" disabledColor="#ffffff" placeholder="请选择工种"
                        border="none"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>

                <u-form-item label="岗位描述" labelWidth="80" ref="item1">
                </u-form-item>
                <view>
                    <u--textarea v-model="info.jobDescription"
                        placeholder="参考示例:岗位名称:保姆 工作内容: 一日三餐,卫生打扫 工资: 200元/天 年龄要求: 25-40岁 工作经验要求: 有过住家保姆经验, 会做饭,受过高等教育的优先"
                        count height="100" maxlength="200"></u--textarea>
                </view>
                <u-form-item prop="jobDescription" borderBottom labelWidth="80" ref="item1">
                </u-form-item>
                <view style="font-size: 30rpx;font-weight: bold;padding: 20rpx 0 0;">人员要求</view>
                <!-- <u-form-item label="人员属性" prop="userNature" labelWidth="80" borderBottom
					@click="showNature = true; hideKeyboard()" ref="item4">
					<u--input v-model="info.userNature"  disabledColor="#ffffff" placeholder="请选择人员属性"
						border="none"></u--input>
					<u-icon slot="right" name="arrow-right"></u-icon>
				</u-form-item> -->
                <u-form-item label="年龄要求" prop="ageDesc" labelWidth="80" borderBottom
                    @click="showAge = true; hideKeyboard()" ref="item4">
                    <u--input v-model="info.ageDesc" disabledColor="#ffffff" placeholder="请选择年龄要求"
                        border="none"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
                <u-form-item label="学历要求" prop="educationLabel" labelWidth="80" borderBottom
                    @click="showEdu = true; hideKeyboard()" ref="item4">
                    <u--input v-model="info.educationLabel" disabledColor="#ffffff" placeholder="请选择学历要求"
                        border="none"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
                <u-form-item label="经验要求" prop="experienceDesc" labelWidth="80" borderBottom
                    @click="showExpe = true; hideKeyboard()" ref="item4">
                    <u--input v-model="info.experienceDesc" disabledColor="#ffffff" placeholder="请选择学历要求"
                        border="none"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
                <view style="font-size: 30rpx;font-weight: bold;padding: 20rpx 0 0;">企业信息</view>
                <u-form-item label="用工单位" prop="jobCompanyName" borderBottom labelWidth="80" ref="item1">
                    <u--input v-model="info.jobCompanyName" border="none" :disabled="true" disabledColor="#ffffff"
                        placeholder="请输入用工单位"></u--input>
                </u-form-item>
                <u-form-item label="企业信用代码" prop="jobCompanyScale" borderBottom labelWidth="80" ref="item1">
                    <u--input v-model="info.jobCompanyScale" border="none" :disabled="true" disabledColor="#ffffff"
                        placeholder="请输入企业信用代码"></u--input>
                </u-form-item>
                <u-form-item label="所属行业" prop="jobCompanyIndustry" borderBottom labelWidth="80" ref="item1">
                    <u--input v-model="info.jobCompanyIndustry" border="none" placeholder="请输入所属行业" :disabled="true"
                        disabledColor="#ffffff"></u--input>
                </u-form-item>
                <u-form-item label="所属社区" prop="createDept" borderBottom labelWidth="80" ref="item1">
                    <custom-tree-select style="width: 100%;" ceilStyle="border: 0;" :listData="deptTreeData"
                        v-model="info.createDept" data-label="title" data-value="id"
                        boxStyle="border: 0; paddingLeft: 0;" search border placeholder="请选择所属社区" />
                </u-form-item>
                <u-form-item label="企业性质" prop="jobCompanyNature" borderBottom labelWidth="80" ref="item1">
                    <u--input v-model="info.jobCompanyNature" border="none" placeholder="请输入企业性质" :disabled="true"
                        disabledColor="#ffffff"></u--input>
                </u-form-item>
                <u-form-item label="企业介绍" labelWidth="80" ref="item1"></u-form-item>
                <view>
                    <u--textarea v-model="info.jobCompanyDescription" placeholder="请输入企业介绍" count height="100"
                        maxlength="200"></u--textarea>
                </view>
                <u-form-item prop="jobCompanyDescription" borderBottom labelWidth="80" ref="item1"></u-form-item>
                <u-form-item label="联系人" prop="callName" borderBottom labelWidth="80" ref="item1">
                    <u--input v-model="info.callName" border="none" placeholder="请输入联系人"></u--input>
                </u-form-item>
                <u-form-item label="手机号" prop="callTel" borderBottom labelWidth="80" ref="item1">
                    <u--input v-model="info.callTel" border="none" placeholder="请输入手机号"></u--input>
                </u-form-item>
                <u-form-item label="座机" prop="callNumber" borderBottom labelWidth="80" ref="item1">
                    <u--input v-model="info.callNumber" border="none" placeholder="请输入座机"></u--input>
                </u-form-item>
                <u-form-item label="工作地址" labelWidth="70" prop="cityId" borderBottom ref="item1"
                    @click="showCityId = true; hideKeyboard()">
                    <PickerTree placeholder="请选择注册地址" :tree="area.data" valueName="value" :visibel="showCityId"
                        v-model="info.cityId" @cancel="showCityId = false" border="none" returnValue="label" :deep="3">
                    </PickerTree>
                </u-form-item>
                <u-form-item label="详细地址" prop="address" borderBottom labelWidth="80" ref="item1">
                    <view class="addressinfo" @click="selectMap"
                        :style="`fontSize: 15px;color: ${info.address ? '#333333' : '#c0c4cc'}`">
                        {{info.address || '请选择'}}
                    </view>
                    <!-- <u--input v-model="info.address" border="none" placeholder="请输入详细地址"></u--input> -->
                </u-form-item>
                <!--   <view class="map">
                    <super-map ref="uMap" style="width: 100%;height: 100%;" :latitude="latitude" :longitude="longitude"
                        :open="true" :zoom="14" :min-zoom="10" :max-zoom="20" :MapUrl="$config.supperMap"
                        :flag-tip="false"></super-map>
                </view> -->
                <!-- <map class="map" :latitude="latitude" :longitude="longitude" :markers="covers"></map> -->
            </u--form>
            <u-button type="primary" text="提交" customStyle="margin-top: 50px" @click="submit"></u-button>
            <u-button type="error" text="重置" customStyle="margin-top: 10px" @click="reset"></u-button>
            <u-picker :show="showWage" ref="wagePicker" keyName="label" :columns="wageColumns" @confirm="wageConfirm"
                @cancel="wageClose" @close="wageClose">
            </u-picker>
            <u-picker :show="showTrade" ref="tradePicker" keyName="name" :columns="tradeColumns" @confirm="tradeConfirm"
                @cancel="tradeClose" @close="tradeClose">
            </u-picker>
            <u-picker :show="showSkills" ref="skillPicker" keyName="name" :columns="skillColumns" @change="skillsChange"
                @confirm="skillConfirm" @cancel="skillClose" @close="skillClose">
            </u-picker>
            <!-- <u-picker :show="showNature" ref="naturePicker"  :columns="natureColumns"
				@confirm="natureConfirm" @cancel="natureClose" @close="natureClose">
			</u-picker> -->
            <u-picker :show="showAge" ref="agePicker" keyName="label" :columns="ageColumns" @confirm="ageConfirm"
                @cancel="ageClose" @close="ageClose">
            </u-picker>
            <u-picker :show="showEdu" ref="eduPicker" keyName="label" :columns="eduColumns" @confirm="eduConfirm"
                @cancel="eduClose" @close="eduClose">
            </u-picker>
            <u-picker :show="showExpe" ref="expePicker" keyName="label" :columns="expeColumns" @confirm="expeConfirm"
                @cancel="expeClose" @close="expeClose">
            </u-picker>
            <u-datetime-picker :show="showStime" :value="birthday" mode="date" closeOnClickOverlay
                @confirm="stimeConfirm" @cancel="stimeClose" @close="stimeClose"></u-datetime-picker>
            <u-datetime-picker :show="showEtime" :value="birthday" mode="date" closeOnClickOverlay
                @confirm="etimeConfirm" @cancel="etimeClose" @close="etimeClose"></u-datetime-picker>
        </view>
        <sylj-selectLocation ref="selectLocationPop" @ok="selectedOk" :apikey="$config.apiKey"></sylj-selectLocation>
    </view>
</template>

<script>
    import dic from '@/common/dic.js'
    import {
        submitInfo,
        getWorktypesBaseList,
        findTradeList,
        getDictionary,
        getDeptAllTree
    } from '@/api/userrecruit.js'
    import PickerTree from './enterpriceCertification/pickerTree.vue'
    import syljSelectLocation from '@/components/sylj-selectLocation/sylj-selectLocation.vue'
    import {
        mapGetters
    } from 'vuex'
    export default {
        data() {
            return {
                deptTreeData: [],
                latitude: 31.05, //中心点
                longitude: 104.20,
                covers: [{ //marker标记位置
                    id: 0,
                    latitude: 0,
                    longitude: 0,
                    // width:30,
                    // height:30,
                    iconPath: '../../../static/img/location.png'
                }],
                value2: '招工内容',
                fileList1: [],
                disabled1: false,
                tips: '',
                value: '',
                showCalendar: false,
                showStime: false,
                showEtime: false,
                showCityId: false,
                info: {
                    jobName: '', // 招工名称
                    stime: '', // 发布时间
                    etime: '', // 结束时间
                    peopleNum: '', // 招聘人数
                    wage: '', // 参考工资
                    wageUnitCategory: '', // 工资单位
                    wageUnitCategoryName: '',
                    tradeId: '', // 行业类型id
                    tradeNames: '', // 行业类型名称
                    worktypeIds: '', // 工种一级id
                    skillIds: '', // 工种二级id
                    worktypeNames: '', // 工种名称
                    skillNames: '', // 工种二级名称
                    jobDescription: '', // 任务描述
                    // userNature: '', // 人员属性
                    educationLabel: dic.eduArr[0][0].label, // 学历要求前端显示
                    ageDesc: dic.ageArr[0][0].label, // 年龄要求
                    education: dic.eduArr[0][0].value, // 学历要求
                    experienceDesc: dic.expeArr[0][0].label, // 经验要求
                    cityId: '',
                    jobCompanyName: '', // 用工单位
                    jobCompanyScale: '', // 企业信用代码
                    jobCompanyIndustry: '', // 所属行业
                    jobCompanyNature: '', // 企业性质
                    jobCompanyDescription: '', // 企业介绍
                    callName: '', // 联系人
                    callTel: '', // 手机号
                    callNumber: '', // 座机
                    address: '', // 公司详细地址
                    // userInfo: {
                    // 	name: '楼兰',
                    // 	sex: '',
                    // 	birthday: ''
                    // },
                    // radiovalue1: '苹果',
                    // checkboxValue1: [],
                    // intro: '',
                    // code: ''
                },
                showWage: false, // 参考工资选项是否展示
                showTrade: false, // 行业类型是否显示
                showSkills: false, // 工种类型是否显示
                showNature: false, // 人员属性
                showAge: false, // 年龄要求
                showEdu: false, // 学历要求
                showExpe: false, // 经验要求
                birthday: Number(new Date()),
                wageColumns: dic.workwageUnitCategoryState,
                tradeColumns: dic.tradeArr,
                skillColumns: [],
                skillColumnsIndex: [0, 0, 0],
                natureColumns: dic.natureArr,
                ageColumns: dic.ageArr,
                eduColumns: dic.eduArr,
                expeColumns: dic.expeArr,
                wallMaxAndMin: [],
                rules: {
                    jobName: {
                        type: 'string',
                        required: true,
                        message: '请输入招工名称',
                        trigger: ['change']
                    },
                    stime: {
                        type: 'string',
                        required: true,
                        message: '请输入开始时间',
                        trigger: ['change']
                    },
                    etime: {
                        type: 'string',
                        required: true,
                        message: '请选择结束时间',
                        trigger: ['change']
                    },
                    peopleNum: {
                        type: 'number',
                        required: true,
                        message: '请输入招聘人数',
                        trigger: ['change']
                    },
                    wage: {
                        type: 'string',
                        required: true,
                        message: '请输入参考工资',
                        trigger: ['change']
                    },
                    tradeNames: {
                        type: 'string',
                        required: true,
                        message: '请选择行业类型',
                        trigger: ['change']
                    },
                    skillNames: {
                        type: 'string',
                        required: true,
                        message: '请选择工种',
                        trigger: ['change']
                    },
                    jobDescription: {
                        type: 'string',
                        min: 20,
                        required: true,
                        message: '请输入任务描述，最少20个字符',
                        trigger: ['change']
                    },
                    ageDesc: {
                        type: 'string',
                        required: true,
                        message: '请选择年龄',
                        trigger: ['change']
                    },
                    educationLabel: {
                        type: 'string',
                        required: true,
                        message: '请选择学历',
                        trigger: ['change']
                    },
                    experienceDesc: {
                        type: 'string',
                        required: true,
                        message: '请选择经验要求',
                        trigger: ['change']
                    },
                    cityId: {
                        type: 'string',
                        required: true,
                        message: '请选择注册地址',
                        trigger: ['change']
                    },
                    jobCompanyName: {
                        type: 'string',
                        required: true,
                        message: '请输入用工单位',
                        trigger: ['change']
                    },
                    jobCompanyScale: {
                        type: 'string',
                        required: true,
                        message: '请输入企业信用代码',
                        trigger: ['change']
                    },
                    jobCompanyIndustry: {
                        type: 'string',
                        required: true,
                        message: '请输入所属行业',
                        trigger: ['change']
                    },
                    jobCompanyNature: {
                        type: 'string',
                        required: true,
                        message: '请输入企业性质',
                        trigger: ['change']
                    },
                    jobCompanyDescription: {
                        type: 'string',
                        required: true,
                        message: '请输入企业介绍',
                        trigger: ['change']
                    },
                    callName: {
                        type: 'string',
                        required: true,
                        message: '请输入联系人',
                        trigger: ['change']
                    },
                    callTel: {
                        type: 'string',
                        required: true,
                        message: '请输入手机号',
                        trigger: ['change']
                    },
                    address: {
                        type: 'string',
                        required: true,
                        message: '请输入工作地址',
                        trigger: ['change']
                    },
                    createDept: {
                        type: 'array',
                        required: true,
                        message: '请选择所属社区',
                        trigger: ['change']
                    }
                },
            }
        },
        props: {
            company: {
                default: null,
            }
        },
        watch: {
            company(val) {
                if (!val) return;
                this.getDataInit(val)
            }
        },
        components: {
            PickerTree,
            syljSelectLocation
        },
        computed: {
            ...mapGetters(['area'])
        },
        created() {
            const {
                id: staId,
                label: staLabel
            } = dic.wageUnitCategoryState[0].filter(item => item.id == 3)[0]
            this.info.wageUnitCategory = staId
            this.info.wageUnitCategoryName = staLabel
            console.log(this.area)
            this.getTreeDept()
            this.getWorkTypes()
            this.dictionary()
            if (this.company) {
                this.getDataInit(this.company)
            }
        },
        methods: {
            selectedOk(data) {
                const {
                    infomation,
                    location,
                    name,
                    address
                } = data
                const {
                    lon,
                    lat
                } = location
                this.latitude = lat
                this.longitude = lon
                this.info.address = `${data.address}${ data.name && '(' + data.name + ')' }`
            },
            selectMap() {
                const that = this
                // uni.getLocation({
                //     type: 'wgs84',
                //     success: function(res) {
                //         console.log(res)
                //         uni.hideLoading();
                //         console.log('当前位置的经度：' + res.longitude);
                //         console.log('当前位置的纬度：' + res.latitude);
                //         // that.$refs.selectLocationPop.open(res.longitude, res.latitude, that.$config.apiKey);

                //     },
                //     fail: function(err) {
                //         console.log('获取失败');
                //         uni.hideLoading();

                //     },

                // });
                that.$refs.selectLocationPop.open(that.longitude, that.latitude, that.$config.apiKey);
            },
            async getTreeDept() {
                let resData = await getDeptAllTree()
                if (resData.data.code === 200) {
                    this.deptTreeData = resData.data.data
                }
            },
            onBlurWage(value) {
                const val = this.wallMaxAndMin
                if (!val.length) {
                    return;
                }
                switch (true) {
                    case value < Math.min(...val):
                        this.info.wage = String(Math.min(...val))
                        return
                    case value > Math.max(...val):
                        this.info.wage = String(Math.max(...val))
                        return
                }
            },
            async dictionary() {
                let params = {
                    code: `wages_limit_${this.info.wageUnitCategory}`
                }
                this.info.wage = ''
                let resData = await getDictionary(params)
                if (resData.data.code === 200) {
                    const arr = resData.data.data.map((item) => Number(item.dictKey))
                    this.wallMaxAndMin = arr
                }
            },
            async getDataInit(info) {
                if (info.reviewState === 9) {
                    this.info.wage = info.wage
                    this.info.jobName = info.jobName
                    this.info.stime = info.stime
                    this.info.etime = info.etime
                    this.info.peopleNum = info.peopleNum
                    this.info.tradeId = info.tradeId
                    this.info.tradeNames = info.tradeNames
                    this.info.worktypeIds = info.worktypeIds
                    this.info.skillNames = info.skillNames
                    this.info.jobDescription = info.jobDescription
                    this.info.ageDesc = info.ageDesc
                    this.info.education = info.education
                    this.info.educationLabel = dic.eduArr[0].filter((vitem) => vitem.value === info.education)[0]
                        .label
                    this.info.experienceDesc = info.experienceDesc
                    this.info.cityId = info.cityId
                    this.info.jobCompanyName = info.jobCompanyName
                    this.info.jobCompanyScale = info.jobCompanyScale
                    this.info.jobCompanyIndustry = info.jobCompanyIndustry
                    this.info.jobCompanyNature = info.jobCompanyNature
                    this.info.jobCompanyDescription = info.jobCompanyDescription
                    this.info.callName = info.callName
                    this.info.createDept = [String(info.createDept)]
                    this.info.callTel = info.callTel
                    this.info.callNumber = info.callNumber
                    this.info.address = info.address
                } else {
                    this.info.jobCompanyScale = info.companyTid
                    this.info.jobCompanyName = info.comname
                    this.info.callName = info.manager
                    this.info.callTel = info.telphone
                    this.info.jobCompanyDescription = info.companyDesc
                    this.info.jobCompanyNature = info.companyNature
                    // this.info.tradeId = info.tradeId
                    // this.info.tradeNames = info.tradeNames
                    this.info.jobCompanyIndustry = info.tradeNames
                }
            },

            wageConfirm(e) {
                const {
                    value
                } = e
                this.info.wageUnitCategoryName = value[0].label
                this.info.wageUnitCategory = value[0].id
                this.showWage = false
                this.dictionary()
            },
            tradeConfirm(e) {
                const {
                    value
                } = e
                this.info.tradeId = value[0].id
                this.info.tradeNames = value[0].name
                this.showTrade = false
            },
            skillConfirm(e) {
                const {
                    value,
                    indexs
                } = e
                this.skillColumnsIndex = indexs
                this.info.skillNames = this.getSkilDataNameWhereId(indexs).join('-')
                this.showSkills = false
            },
            // natureConfirm(e) {
            // 	const { value } = e
            // 	this.info.userNature = value[0]
            // 	this.showNature = false
            // },
            ageConfirm(e) {
                const {
                    value
                } = e
                this.info.ageDesc = value[0].label
                this.showAge = false
            },
            eduConfirm(e) {
                const {
                    value
                } = e
                this.info.education = value[0].value
                this.info.educationLabel = value[0].label
                this.showEdu = false
            },
            expeConfirm(e) {
                const {
                    value
                } = e
                this.info.experienceDesc = value[0].label
                this.showExpe = false
            },
            expeClose() {
                this.showExpe = false
            },
            eduClose() {
                this.showEdu = false
            },
            ageClose() {
                this.showAge = false
            },
            // natureClose() {
            // 	this.showNature = false
            // },
            skillClose() {
                this.showSkills = false
            },
            wageClose(e) {
                this.showWage = false
            },
            tradeClose(e) {
                this.showTrade = false
            },
            sexSelect(e) {
                this.info.userInfo.sex = e.name
                this.$refs.form1.validateField('userInfo.sex')
            },
            change(e) {
                // console.log(e);
            },
            formatter(day) {
                const d = new Date()
                let month = d.getMonth() + 1
                const date = d.getDate()
                if (day.month == month && day.day == date + 3) {
                    day.bottomInfo = '有优惠'
                    day.dot = true
                }
                return day
            },
            calendarConfirm(e) {
                this.showCalendar = false
                this.info.hotel = `${e[0]} / ${e[e.length - 1]}`
                this.$refs.form1.validateField('hotel')
            },
            codeChange(text) {
                this.tips = text;
            },
            getCode() {
                if (this.$refs.uCode.canGetCode) {
                    // 模拟向后端请求验证码
                    uni.showLoading({
                        title: '正在获取验证码'
                    })
                    setTimeout(() => {
                        uni.hideLoading();
                        // 这里此提示会被this.start()方法中的提示覆盖
                        uni.$u.toast('验证码已发送');
                        // 通知验证码组件内部开始倒计时
                        this.$refs.uCode.start();
                    }, 2000);
                } else {
                    uni.$u.toast('倒计时结束后再发送');
                }
            },
            calendarClose() {
                this.showCalendar = false
                this.$refs.form1.validateField('hotel')
            },
            stimeClose() {
                this.showStime = false
                this.$refs.form1.validateField('userInfo.birthday')
            },
            stimeConfirm(e) {
                this.showStime = false
                this.info.stime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd') + ' 00:00:00'
                this.$refs.form1.validateField('userInfo.birthday')
            },
            etimeClose() {
                this.showEtime = false
                this.$refs.form1.validateField('userInfo.birthday')
            },
            etimeConfirm(e) {
                this.showEtime = false
                this.info.etime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd') + ' 23:59:59'
                this.$refs.form1.validateField('userInfo.birthday')
            },
            submit() {
                // 如果有错误，会在catch中返回报错信息数组，校验通过则在then中返回true
                // this.$refs.form1.validate().then(res => {
                // 	uni.$u.toast('校验通过')
                // }).catch(errors => {
                // 	uni.$u.toast('校验失败')
                // })
                const names = this.getSkilDataNameWhereId(this.skillColumnsIndex, true)
                const ids = this.getSkilDataNameWhereId(this.skillColumnsIndex, false)
                this.info.jobType = 1
                let params = {
                    ...this.info,
                    worktypeIds: ids.join(','),
                    worktypeNames: names.join(',')
                }
                console.log(this.company)
                if (this.company.reviewState === 9) {
                    params.id = this.company.id
                }
                let that = this
                this.$refs.form1.validate().then(res => {
                    if (!this.info.wageUnitCategory) {
                        return this.$api.msg('请选择参考工资单位')
                    }
                    params.lon = that.longitude
                    params.lat = that.latitude
                    params.createDept = params.createDept[0]
                    submitInfo(params).then(res => {
                        if (res.data.code == 200) {
                            that.reset()
                            uni.$u.toast('发布成功')
                            setTimeout(() => {
                                this.navTo('/pages/recruit/subPage/index')
                            }, 1000)
                        }
                    })
                }).catch(errors => {
                    uni.$u.toast('请完善内容')
                })

            },
            getSkilDataNameWhereId(Indexs, type = true) {
                if (!this.skillData) {
                    return
                }
                const [index1, index2, index3] = Indexs
                const work1 = this.skillData[index1]
                const work2 = work1.child[index2]
                const work3 = work2.child[index3]
                if (type) {
                    return [work1.name, work2.name, work3.name]
                } else {
                    return [work1.id, work2.id, work3.id]
                }
            },
            reset() {
                const validateList = [
                    'jobName',
                    'stime',
                    'etime',
                    'peopleNum',
                    'wage',
                    'tradeId',
                    'tradeNames',
                    'worktypeIds',
                    'skillIds',
                    'worktypeNames',
                    'skillNames',
                    'jobDescription',
                    'ageDesc',
                    'education',
                    'educationLabel',
                    'experienceDesc',
                    'cityId',
                    'jobCompanyName',
                    'jobCompanyScale',
                    'jobCompanyIndustry',
                    'jobCompanyNature',
                    'jobCompanyDescription',
                    'callName',
                    'createDept',
                    'callTel',
                    'callNumber',
                    'address'
                ]
                this.$refs.form1.resetFields()
                this.$refs.form1.clearValidate()
                setTimeout(() => {
                    this.$refs.form1.clearValidate(validateList)
                    // 或者使用 this.$refs.form1.clearValidate()
                }, 10)
            },
            hideKeyboard() {
                uni.hideKeyboard()
            },
            skillsChange(e) {
                const {
                    columnIndex,
                    index,
                    picker = this.$refs.uPicker
                } = e
                let [index1, index2, index3] = this.skillColumnsIndex
                switch (columnIndex) {
                    case 0:
                        index1 = index;
                        index2 = 0
                        index3 = 0
                        break
                    case 1:
                        index2 = index;
                        index3 = 0
                        break
                    case 2:
                        index3 = index
                        break
                }
                const Indexs = [index1, index2, index3]
                picker.setColumnValues(1, this.skillData[index1].child.map((item) => item.name))
                picker.setColumnValues(2, this.skillData[index1].child[index2].child.map((item) => item.name))
                this.skillColumnsIndex = Indexs
            },
            async getWorkTypes() {
                let resData = await getWorktypesBaseList({
                    type: 2
                })
                if (resData.data.code === 200) {
                    const {
                        data
                    } = resData.data
                    const arr = []
                    // 1、 空间换时间策略/user/userrecruit/saveApp
                    arr.push(data.map((item) => item.name));
                    arr.push(data[0].child.map((item) => item.name))
                    arr.push(data[0].child[0].child.map((item) => item.name))
                    this.skillColumnsIndex = [0, 0, 0]
                    this.skillData = data
                    this.skillColumns = arr
                }
            }
        }
    }
</script>

<style>
    .map {
        width: 100%;
        height: 350rpx;
        margin-top: 30rpx;
    }

    .wageunitLeft {
        border-left: 3rpx solid rgb(192, 196, 204, 0.6);
        padding-left: 20rpx;
    }

    /deep/.wageunitLeft .u-form-item__body {
        padding: 0;
    }

    .addressinfo {
        width: 100%;
        height: fit-content;
        min-height: 21px;
    }
</style>