import { SubmitCountryModel } from "@/api/country/CountryModle";
import { reactive } from "vue";

export default function useBaseModel() {

  //表单验证
    const rules = reactive({       
        id:[{
            required: true,
            type:'number',
            message: '编码需有效数字',
            trigger:'change',
            transform:(value)=>Number(value)
        }],
        twCode:[{required: true,
            message: '请填写二字简码',                        
            trigger:'change'},
            { pattern: /^[A-Z]{2}$/, message: '请输入两位大写字母' }
        ],            
     
        cnName:[{
            required: true,
            message: '请填写中文名称',
            trigger:'change'
        },
        { pattern: /^[\u4e00-\u9fa5]{0,}$/, message: '请输入中文名称' }    
        ],
        enName:[{
            required: true,
            message: '请填写英文名称',
            trigger:'change'
        },
        { pattern: /^[A-Za-z]*(\s[A-Za-z]*)*$/, message: '请输入英文名称' }    ]
    });
    //表单数据
    const dialogModel = reactive<SubmitCountryModel>({
        id: "",       
        cnName: "",
        enName: "",       
        twCode:"",      
        type:""
    })

    return {
        rules,
        dialogModel
    }
}