This commit is contained in:
‘huanghaiixia’
2025-11-21 16:38:17 +08:00
parent 0f112bc78e
commit 65575b40ad
7 changed files with 903 additions and 36 deletions

View File

@ -0,0 +1,130 @@
<template>
<BasicModal v-bind="$attrs" destroyOnClose @register="registerModal" showFooter :title="getTitle" width="40%" @ok="handleSubmit">
<a-form ref="formRef" :model="formState" :rules="rules" v-bind="{labelCol: { span: 8 },wrapperCol: { span: 16 },}">
<a-row>
<a-col :span="24">
<a-form-item label="证书名称" name="docTypeCode" :label-col="{ span: 4 }" :wrapper-col="{ span: 24 }">
<a-select v-model:value="formState.docTypeCode" placeholder="请选择证书名称" style="width: 100%" allow-clear>
<a-select-option v-for="item in optionList" :key="item.code" :value="item.code">
{{ item.fullName }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="有效期开始" name="dateFrom" :label-col="{ span: 8 }" :wrapper-col="{ span: 24 }">
<a-date-picker v-model:value="formState.dateFrom" format="YYYY-MM-DD" :disabled-date="disabledDateStart" style="width: 100%" placeholder="请选择有效期开始" />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="有效期结束" name="dateTo" :label-col="{ span: 8 }" :wrapper-col="{ span: 24 }">
<a-date-picker v-model:value="formState.dateTo" format="YYYY-MM-DD" :disabled-date="disabledDateEnd" style="width: 100%" placeholder="请选择有效期结束" />
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="备注" name="note" :label-col="{ span: 4 }" :wrapper-col="{ span: 24 }">
<a-textarea v-model:value="formState.note" placeholder="请输入备注最多50字" :maxlength="50" :auto-size="{ minRows: 2, maxRows: 5 }"/>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="上传附件" name="parentNname" :label-col="{ span: 4 }" :wrapper-col="{ span: 24 }">
<Upload :fileList="formState.fileList" :maxSize="200" :accept="accept"></Upload>
<div style="color: #ccc; font-size: 12px">{{ fileTip }}</div>
</a-form-item>
</a-col>
</a-row>
</a-form>
</BasicModal>
</template>
<script setup lang="ts">
import { ref, onMounted, computed, unref,reactive } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { Form } from 'ant-design-vue';
import { useI18n } from '/@/hooks/web/useI18n';
import type { Rule } from 'ant-design-vue/es/form';
import { useMessage } from '/@/hooks/web/useMessage';
import Upload from '/@/components/Form/src/components/Upload.vue';
import { getDocCpList } from '/@/api/sales/Customer';
import type { FormInstance } from 'ant-design-vue';
import dayjs from 'dayjs';
const { t } = useI18n();
const isUpdate = ref(true);
let optionList = reactive([])
const fileTip = '支持格式.rar .zip .doc .docx .pdf 单个文件不能超过20MB';
const accept ='.rar,.zip, .doc, .docx, .pdf, .RAR, .ZIP, .DOC, .DOCX, .PDF'
const formRef = ref()
const { notification } = useMessage();
const emit = defineEmits(['success','register']);
const getTitle = computed(() => (!unref(isUpdate) ? t('新增证书') : t('编辑证书')));
let formState = reactive({
docTypeCode: '',
});
const rules = {
docTypeCode: [{ required: true, message: "该项为必填项", trigger: 'change' }],
// email: [
// { required: true, message: '请输入邮箱', trigger: 'blur' },
// { type: 'email', message: '请输入正确的邮箱格式', trigger: 'blur' },
// ],
};
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
getOption()
setModalProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
if (unref(isUpdate)) {
formState=data.record || {}
}
});
onMounted(() => {
getOption()
});
const disabledDateStart = (startValue) => {
const endValue = formState.dateTo;
if (!startValue || !endValue) {
return false
}
return startValue.valueOf() >= endValue.valueOf();
}
const disabledDateEnd = (endValue) => {
const startValue = formState.dateFrom;
if (!endValue || !startValue) {
return false
}
return endValue.valueOf() <= startValue.valueOf();
}
const handleChangeFile = (val) => {
}
async function getOption() {
optionList = await getDocCpList({'valid': 'Y'})
}
const handleSubmit = async () => {
try {
await formRef.value.validate();
// 验证通过,提交表单
console.log('表单数据:', formState);
let docNo = (optionList.find(v=>v.code === formState.docTypeCode) || {}).fullName
let obj = {
...formState,
docNo: docNo,
dateFrom: formState.dateFrom ? dayjs(formState.dateFrom).format('YYYY-MM-DD') : null,
dateTo: formState.dateTo ? dayjs(formState.dateTo).format('YYYY-MM-DD') : null,
}
emit('success', obj);
notification.success({
message: t('操作'),
description:!unref(isUpdate)? t('新增成功') : t('编辑成功')
}); //提示消息
formRef.value.resetFields();
closeModal();
} catch (error) {
console.log('验证失败:', error);
}
};
</script>

View File

@ -6,46 +6,12 @@ export const formConfig = {
};
export const searchFormSchema: FormSchema[] = [
{
field: 'cuCode',
label: '客户编码',
component: 'Input',
},
{
field: 'cuName',
label: '客户名称',
component: 'Input',
},
{
field: 'cuSname',
label: '客户简称',
component: 'Input',
},
{
field: 'cuMcode',
label: '企业性质',
component: 'Input',
},
{
field: 'classCode',
label: '客户分类',
component: 'Input',
},
{
field: 'typeCode',
label: '客户类别',
component: 'Input',
},
{
field: 'natureCode',
label: '国内国际',
component: 'Input',
},
{
field: 'valid',
label: '有效',
component: 'Input',
},
{
field: 'approCode',
label: '审批状态',

View File

@ -0,0 +1,122 @@
<template>
<BasicModal v-bind="$attrs" destroyOnClose @register="registerDrawer" showFooter :title="getTitle" width="40%" @ok="handleSubmit">
<BasicForm @register="registerForm" :style="{ 'margin-right': '10px' }" />
</BasicModal>
</template>
<script lang="ts">
import { defineComponent, ref, computed, unref } from 'vue';
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { useMessage } from '/@/hooks/web/useMessage';
import { usePermissionStore } from '/@/store/modules/permission';
import { addSubSystem, updateSubSystem } from '/@/api/system/subSystem';
import { useI18n } from '/@/hooks/web/useI18n';
import { useMenuSetting } from '/@/hooks/setting/useMenuSetting';
import { useAppInject } from '/@/hooks/web/useAppInject';
const { t } = useI18n();
export const formSchema: FormSchema[] = [
{
field: 'contactName',
label: t('联系人姓名'),
component: 'Input',
required: true,
colProps: { lg: 12, md: 12 }
},
{
field: 'tel',
label: t('联系人电话'),
component: 'Input',
colProps: { lg: 12, md: 12 }
},
{
field: 'email',
label: t('电子邮箱'),
component: 'Input',
colProps: { lg: 12, md: 12 },
componentProps: {
rules: [{ pattern: '/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/', message: '邮箱格式错误\n' }],
},
},
{
field: 'position',
label: t('职位'),
component: 'Input',
colProps: { lg: 12, md: 12 }
},
{
field: 'addrMail',
label: t('通讯地址'),
component: 'InputTextArea',
colProps: { lg: 24, md: 24 }
},
{
field: 'note',
label: t('备注'),
component: 'InputTextArea',
colProps: { lg: 24, md: 24 }
},
];
export default defineComponent({
name: 'MenuDrawer',
components: {
BasicModal,
BasicForm
},
emits: ['success', 'register'],
setup(_, { emit }) {
const isUpdate = ref(true);
const { notification } = useMessage();
const permissionStore = usePermissionStore();
const { t } = useI18n();
const { getShowTopMenu } = useMenuSetting();
const { getIsMobile } = useAppInject();
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
labelWidth: 100,
schemas: formSchema,
showActionButtonGroup: false,
baseColProps: { lg: 12, md: 24 }
});
const [registerDrawer, { setModalProps, closeModal }] = useModalInner(async (data) => {
resetFields();
setModalProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
if (unref(isUpdate)) {
setFieldsValue({
...data.record
});
}
});
const getTitle = computed(() => (!unref(isUpdate) ? t('新增联系人') : t('编辑联系人')));
async function handleSubmit() {
try {
const values = await validate();
setModalProps({ confirmLoading: true });
notification.success({
message: t('操作'),
description:!unref(isUpdate)? t('新增成功') : t('编辑成功')
}); //提示消息
closeModal();
emit('success', values);
} catch (error) {
setModalProps({ confirmLoading: false });
}
}
return {
registerDrawer,
registerForm,
getTitle,
handleSubmit,
t
};
}
});
</script>
<style scoped></style>