import { defineStore } from "pinia";
import { reactive, ref } from "vue";

export const useReleasePostionStore = defineStore("useReleasePostionStore", () => {
    /* let formData = ref( {
            workMode: 1,
            jobName: "",
            jobType: 1,
            jobTypeText: "",
            jobDesc: "",
            negotiableSalary: 0,
            settlementType: 4,
            minSalary: 0,
            maxSalary: 0,
            benefits: "",
            identityRequirement: 1,
            educationRequirement: 1,
            minAgeRequirement: 16,
            maxAgeRequirement: 60,
            recruitmentNumber: 1,
            accommodation: 1,
            provinceCode: "",
            cityCode: "",
            districtCode: "",
            town: "",
            street: "",
            address: "",
            locationLongitude: 0,
            locationLatitude: 0,
            contactPerson: "",
            contactPhone: ""
        }) */
    const formData = ref({
        workMode: 1,
        name: "",
        jobTypeId: null,
        jobTypePid: "",
        jobTypeName: "",
        postitDesc: "",
        negotiableSalary: 0,
        settlementType: 4,
        minSalary: null,
        maxSalary: null,
        benefits: "",
        identityRequirement: 1,
        educationRequirement: null,
        minAgeRequirement: null,
        maxAgeRequirement: null,
        recruitmentNumber: 1,
        accommodation: 0,
        provinceCode: "",
        cityName: "",
        majorRequirement: "",
        cityCode: "",
        districtCode: "",
        street: "",
        address: "",
        contactPerson: "",
        contactPhone: "",
        articleId: "",
        positionalTitle: "",
        professionalCertificates: "",
        specialCertificates: ""
    });
    function setFormDataKey(key, data) {
        formData.value[key] = data;
    }
    function resetForm() {
        formData.value = {
            workMode: 1,
            name: "",
            jobTypeId: null,
            jobTypePid: "",
            jobTypeName: "",
            postitDesc: "",
            negotiableSalary: 0,
            settlementType: 4,
            minSalary: null,
            maxSalary: null,
            majorRequirement: "",
            benefits: "",
            identityRequirement: 1,
            educationRequirement: 1,
            minAgeRequirement: null,
            maxAgeRequirement: null,
            recruitmentNumber: 1,
            accommodation: 0,
            provinceCode: "",
            cityCode: "",
            cityName: "",
            districtCode: "",
            street: "",
            address: "",
            contactPerson: "",
            contactPhone: "",
            articleId: "",
            positionalTitle: "",
            professionalCertificates: "",
            specialCertificates: ""
        };
        console.log("this.formthis.formDatathis.formDatathis.formDatathis.formDataData", formData.value);
    }
    function setForm(data) {
        formData.value = data;
        console.log("this.formData", formData.value);
    }
    return {
        formData,
        setFormDataKey,
        resetForm,
        setForm
    };
});
