import { NForm, NFormItem, NInput, NSpace, NButton, useMessage, NAlert, NCascader } from 'naive-ui'; import { Prop, PropType, defineComponent, reactive, ref } from 'vue'; import { api_teacherAdd } from '../../api'; import { useUserStore } from '/src/store/modules/users'; export default defineComponent({ name: 'teacher-operation', emits: ['close'], props: { areaList: { type: Array as PropType, default: () => [] } }, setup(props, { emit }) { const user = useUserStore(); const forms = reactive({ provinceCode: '', cityCode: '', regionCode: '', tenantId: user.info.schoolInfos?.[0]?.tenantId, phone: null, schoolId: user.info.schoolInfos?.[0]?.id, nickname: null, gender: 1 }); const btnLoading = ref(false); const formsRef = ref(); const message = useMessage(); // 提交记录 const onSubmit = async () => { formsRef.value.validate(async (error: any) => { if (error) return; try { btnLoading.value = true; await api_teacherAdd({ ...forms }); message.success('添加成功'); } catch (e) { console.log(e); } setTimeout(() => { btnLoading.value = false; emit('close'); }, 100); }); }; // const formatParentAreaId = (id: any, list: any, ids = [] as any) => { // for (const item of list) { // if (item.code === id) { // return [...ids, id]; // } // if (item.areas && item.areas.length > 0) { // const cIds: any = formatParentAreaId(id, item.areas, [ // ...ids, // item.code // ]); // if (cIds.includes(id)) { // return cIds; // } // } // } // return ids; // }; return () => (
{ forms.gender = 1; }}> 男 { forms.gender = 0; }}> 女 { forms.provinceCode = pathValues[0]?.code; forms.cityCode = pathValues[1]?.code; forms.regionCode = pathValues[2]?.code; }} />
默认密码为ktyq+手机号后四位
emit('close')}> 取消 onSubmit()} loading={btnLoading.value}> 确定
); } });