92 lines
3.3 KiB
Vue
92 lines
3.3 KiB
Vue
<!--迁移用户-->
|
||
<template>
|
||
<BasicModal :width="700" destroyOnClose title="迁移用户" v-bind="$attrs" @ok="handleSubmit" @register="registerModal">
|
||
<BasicForm @register="registerForm">
|
||
<template #isBind="{ model, schema }">
|
||
<div style="margin-left: 50px">
|
||
<h3 style="font-weight: 700">当前员工已绑定手表,是否解除绑定?</h3>
|
||
<a-radio-group v-model:value="model.isBind" :options="schema.componentProps.options">
|
||
<template #label="{ label }">
|
||
<span>{{ label }}</span>
|
||
</template>
|
||
</a-radio-group>
|
||
</div>
|
||
</template>
|
||
</BasicForm>
|
||
</BasicModal>
|
||
</template>
|
||
|
||
<script lang="ts" setup>
|
||
import { ref, unref } from 'vue';
|
||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||
import { migrateUserFormSchema } from '/@/views/system/user/HealthUserEmployeeEx/HealthUserEmployeeEx.data';
|
||
import { updateUserDepart } from '/@/views/system/user/HealthUserEmployeeEx/HealthUserEmployeeEx.api';
|
||
|
||
// Emits声明
|
||
const emit = defineEmits(['register', 'success']);
|
||
const isUpdate = ref(true);
|
||
//表单配置
|
||
const [registerForm, { setProps, resetFields, setFieldsValue, validate, updateSchema, clearValidate }] = useForm({
|
||
schemas: migrateUserFormSchema,
|
||
showActionButtonGroup: false,
|
||
baseColProps: { span: 24 },
|
||
});
|
||
//表单赋值
|
||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||
//重置表单
|
||
await resetFields();
|
||
setModalProps({ confirmLoading: false, showCancelBtn: !!data?.showFooter, showOkBtn: !!data?.showFooter });
|
||
isUpdate.value = !!data?.isUpdate;
|
||
// 如果未绑定手表,则隐藏解绑提示
|
||
if (data.record.hasWatch === true) {
|
||
await updateSchema([
|
||
{
|
||
field: 'isBind',
|
||
show: true,
|
||
},
|
||
]);
|
||
}
|
||
if (unref(isUpdate)) {
|
||
//表单赋值
|
||
await setFieldsValue({
|
||
...data.record,
|
||
userId: data.record.id,
|
||
fromDepartCode: data.record.depart?.orgCode || data.record.secondDepart?.orgCode,
|
||
fromDepartId: data.record.depart?.id || data.record.secondDepart?.id,
|
||
});
|
||
}
|
||
await clearValidate();
|
||
// 隐藏底部时禁用整个表单
|
||
await setProps({ disabled: !data?.showFooter });
|
||
});
|
||
|
||
//表单提交事件
|
||
async function handleSubmit() {
|
||
try {
|
||
let values = await validate();
|
||
values.watchStatus = values.isBind == '1';
|
||
setModalProps({ confirmLoading: true });
|
||
//提交表单
|
||
await updateUserDepart(values, isUpdate.value);
|
||
//关闭弹窗
|
||
closeModal();
|
||
//刷新列表
|
||
emit('success');
|
||
} finally {
|
||
setModalProps({ confirmLoading: false });
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="less" scoped>
|
||
/** 时间和数字输入框样式 */
|
||
:deep(.ant-input-number) {
|
||
width: 100%;
|
||
}
|
||
|
||
:deep(.ant-calendar-picker) {
|
||
width: 100%;
|
||
}
|
||
</style>
|