<!--  -->
<template>
  <view>
    <uni-forms ref="form" :modelValue="formData" :rules="rules" validateTrigger="bind" label-width="100%" label-align="left" label-position="top">
      <uni-forms-item label="期望岗位" name="positionId">
				<uni-data-picker popup-title="请选择期望岗位" v-model="formData.positionId" :localdata="dictObj?.positionTreeData || []" :clear-icon="false" :map="{ text: 'nameCn', value: 'id'}"></uni-data-picker>
			</uni-forms-item>
      <uni-forms-item label="期望行业" name="industryIdList">
				<uni-data-picker popup-title="请选择期望行业" v-model="formData.industryIdList" :localdata="dictObj?.industryTreeData || []" :clear-icon="false" :map="{ text: 'nameCn', value: 'id'}"></uni-data-picker>
			</uni-forms-item>
      <uni-forms-item label="期望薪资（最低要求）" name="payFrom">
        <uni-number-box v-model="formData.payFrom" :min="1" :max="999999999" :step="100" :width="150" @change="payChange"></uni-number-box>
			</uni-forms-item>
      <uni-forms-item label="期望薪资（最高要求）" name="payTo">
        <uni-number-box v-model="formData.payTo" :min="payToMin" :max="999999999" :step="100" :width="150"></uni-number-box>
			</uni-forms-item>
      <uni-forms-item label="求职类型" name="jobType">
				<uni-data-picker popup-title="请选择求职类型" v-model="formData.jobType" :localdata="dictObj?.jobType || []" :clear-icon="false" :map="{ text: 'label', value: 'value'}"></uni-data-picker>
			</uni-forms-item>
      <uni-forms-item label="工作城市" name="workAreaProvinceId">
				<uni-data-picker popup-title="请选择工作城市" v-model="formData.workAreaProvinceId" :localdata="dictObj?.areaTreeData || []" :clear-icon="false" :map="{ text: 'name', value: 'id'}"></uni-data-picker>
			</uni-forms-item>
      <uni-forms-item label="其它感兴趣的城市" name="interestedAreaIdList">
				<uni-data-picker popup-title="其它感兴趣的城市" v-model="formData.interestedAreaIdList" :localdata="dictObj?.areaTreeData || []" :clear-icon="false" :map="{ text: 'name', value: 'id'}"></uni-data-picker>
			</uni-forms-item>
    </uni-forms>
    <view class="f-horizon-center">
      <button type="primary" size="default" class="send-button"  @click="submit">确 认</button>
    </view>
    <!-- <view style="text-align: center; font-size: 13px; color: gray;">已加载全部</view> -->
  </view>
</template>

<script setup>
import { ref, reactive } from 'vue'
import { dictObj } from '@/utils/position.js'

const formData = reactive({ positionId: '', payFrom: 0, payTo: 0 })
const form = ref()
const submit = async () => {
  const valid = await unref(form).validate()
  if (!valid) return
}

const rules = {
	positionId:{
		rules: [{required: true, errorMessage: '请选择期望岗位' }]
	},
	payFrom:{
		rules: [{required: true, errorMessage: '请输入薪资最低要求' }]
	},
	payTo:{
		rules: [{required: true, errorMessage: '请输入薪资最高要求' }]
	},
	jobType:{
		rules: [{required: true, errorMessage: '请选择求职类型' }]
	},
	workAreaProvinceId:{
		rules: [{required: true, errorMessage: '请选择工作城市' }]
	},
}

const payToMin = ref(1)
const payChange = (val) => {
  payToMin.value = val
  if (val > formData.payTo) formData.payTo = val
}

</script>
<style lang="scss" scoped>
</style>
