公共组件

This commit is contained in:
‘huanghaiixia’
2025-12-19 09:11:04 +08:00
parent a1151e18a3
commit 13e7a928c7
7 changed files with 11 additions and 11 deletions

View File

@ -0,0 +1,163 @@
<template>
<div class="bankListTb">
<BasicModal v-bind="$attrs" :zIndex="1001" @register="registerModal" width="60%" :title="getTitle" @ok="handleSubmit"
@visible-change="handleVisibleChange" >
<BasicTable @register="registerTable" class="bankListModal"></BasicTable>
</BasicModal>
</div>
</template>
<script lang="ts" setup>
import { ref, computed, unref, nextTick } from 'vue';
import { BasicModal, useModalInner, useModal } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index';
import { BasicTable, useTable, FormSchema, BasicColumn, TableAction } from '/@/components/Table';
import { addCodeRule, getCodeRuleInfo, editCodeRule } from '/@/api/system/code';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { getLngBBankPage } from '/@/api/mdm/Bank';
const { t } = useI18n();
const codeFormSchema: FormSchema[] = [
{
field: 'shortName',
label: '银行名称/简称',
component: 'Input',
},
];
const columns: BasicColumn[] = [
{
dataIndex: 'code',
title: '编码',
componentType: 'input',
align: 'left',
sorter: true,
},
{
dataIndex: 'fullName',
title: '名称',
componentType: 'input',
align: 'left',
sorter: true,
},
{
dataIndex: 'shortName',
title: '简称',
componentType: 'input',
align: 'left',
sorter: true,
},
{
dataIndex: 'bankCode',
title: '联行号',
componentType: 'input',
align: 'left',
sorter: true,
},
{
dataIndex: 'regionName',
title: '所属国家和地区',
componentType: 'input',
align: 'left',
sorter: true,
},
{
dataIndex: 'swift',
title: 'SWIFT',
componentType: 'input',
align: 'left',
sorter: true,
},
];
const emit = defineEmits(['success', 'register']);
const { notification } = useMessage();
const isUpdate = ref(true);
const rowId = ref('');
const selectedKeys = ref<string[]>([]);
const selectedValues = ref([]);
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
setModalProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
});
const [registerTable, { getDataSource, setTableData, updateTableDataRecord, reload }] = useTable({
title: t('银行列表'),
api: getLngBBankPage,
columns,
bordered: true,
pagination: true,
canResize: false,
formConfig: {
labelCol:{span: 9, offSet:10},
schemas: codeFormSchema,
showResetButton: true,
},
immediate: false, // 设置为不立即调用
beforeFetch: (params) => {
return { ...params, valid: 'Y'};
},
rowSelection: {
type: 'radio',
onChange: onSelectChange
},
});
const handleVisibleChange = (visible: boolean) => {
if (visible) {
nextTick(() => {
reload();
});
}
};
function onSelectChange(rowKeys: string[], e) {
selectedKeys.value = rowKeys;
selectedValues.value = e
}
const getTitle = computed(() => (!unref(isUpdate) ? t('银行列表') : t('')));
async function handleSubmit() {
if (!selectedValues.value.length) {
notification.warning({
message: t('提示'),
description: t('请选择银行')
});
return
}
closeModal();
emit('success', selectedValues.value);
}
</script>
<style >
.bankListModal .basicCol{
position: inherit !important;
top: 0;
}
.bankListTb .ant-modal-wrap{
z-index: 1001 !important;
}
.bankListModal .ant-modal-mask {
z-index: 1001 !important;
}
</style>

View File

@ -0,0 +1,117 @@
<template>
<BasicModal v-bind="$attrs" destroyOnClose @register="registerModal" showFooter :title="getTitle" @ok="handleSubmit" @cancel="handleCancel">
<a-form ref="formRef" :model="formState" :rules="rules" v-bind="{labelCol: { span: 8 },wrapperCol: { span: 16 },}">
<a-row>
<a-col :span="12">
<a-form-item label="银行名称" name="bankName" :label-col="{ span: 8 }" :wrapper-col="{ span: 24 }">
<a-input-search v-model:value="formState.bankName" placeholder="请选择银行名称" readonly @search="onSearch"/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="联行号" name="aaaa" :label-col="{ span: 8 }" :wrapper-col="{ span: 24 }">
<a-input v-model:value="formState.aaaa" placeholder="请输入联行号" disabled />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="账户名称" name="accountName" :label-col="{ span: 8 }" :wrapper-col="{ span: 24 }">
<a-input v-model:value="formState.accountName" placeholder="请输入账户名称" />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="银行账号" name="account" :label-col="{ span: 8 }" :wrapper-col="{ span: 24 }">
<a-input v-model:value="formState.account" placeholder="请输入银行账号" />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="默认银行" name="defaultSign" :label-col="{ span: 8 }" :wrapper-col="{ span: 24 }">
<a-radio-group v-model:value="formState.defaultSign" style="display: flex;">
<a-radio v-for="item in optionList" :value="item.code">{{ item.name }}</a-radio>
</a-radio-group>
</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-row>
</a-form>
</BasicModal>
<bankListModal @register="registerModalBankList" @success="handleSuccessBankList" />
</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 { getDictionary } from '/@/api/sales/Customer';
import bankListModal from '/@/components/common/bankListModal.vue'
import { useModal } from '/@/components/Modal';
const { t } = useI18n();
const isUpdate = ref(true);
const disable = ref(false);
let optionList = reactive([])
const formRef = ref()
const { notification } = useMessage();
const emit = defineEmits(['success','register']);
const getTitle = computed(() => (!unref(isUpdate) ? t('新增银行') : t('编辑银行')));
let formState = reactive({
});
const rules = {
bankName: [{ required: true, message: "该项为必填项", trigger: 'change' }],
accountName: [{ required: true, message: "该项为必填项", trigger: 'change' }],
account: [{ required: true, message: "该项为必填项", trigger: 'change' }],
defaultSign: [{ required: true, message: "该项为必填项", trigger: 'change' }],
};
const [registerModalBankList, { openModal:openModalBankList }] = useModal();
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
getOption()
setModalProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
console.log(isUpdate, 8,!unref(isUpdate),data?.isUpdate )
disable.value = data?.btnType == 'view' ? true : false
if (unref(isUpdate)) {
Object.assign(formState, data.record || {})
}
});
onMounted(() => {
getOption()
});
async function getOption() {
optionList = await getDictionary('LNG_YN')
}
const onSearch = () => {
openModalBankList(true,{isUpdate: false})
}
const handleSuccessBankList = (val) => {
console.log(val, 414)
formState.bankCode = val[0].code
formState.bankName = val[0].fullName
formState.aaaa = val[0].bankCode
}
const handleCancel = () => {
formRef.value.resetFields();
}
const handleSubmit = async () => {
try {
await formRef.value.validate();
// 验证通过,提交表单
console.log('表单数据:', formState);
emit('success', {...formState});
notification.success({
message: t('操作'),
description:!unref(isUpdate)? t('新增成功') : t('编辑成功')
}); //提示消息
formRef.value.resetFields();
closeModal();
} catch (error) {
console.log('验证失败:', error);
}
};
</script>

View File

@ -0,0 +1,164 @@
<template>
<BasicModal v-bind="$attrs" destroyOnClose @register="registerModal" showFooter :title="getTitle" width="40%" @ok="handleSubmit" @cancel="handleCancel" :showOkBtn="!isDisable">
<a-form ref="formRef" class="formViewStyle" :model="formState" :rules="rules" v-bind="{labelCol: { span: 8 },wrapperCol: { span: 16 },}">
<a-row>
<a-col :span="12">
<a-form-item label="证书名称" name="docTypeCode" :label-col="{ span: 8 }" :wrapper-col="{ span: 24 }">
<a-select v-model:value="formState.docTypeCode" placeholder="请选择证书名称" :disabled="isDisable" 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="docNo" :label-col="{ span: 8 }" :wrapper-col="{ span: 24 }">
<a-input v-model:value="formState.docNo" placeholder="请输入资质证书编号" />
</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="isDisable" :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="isDisable" :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字" :disabled="isDisable" :maxlength="50" :auto-size="{ minRows: 2, maxRows: 5 }"/>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="上传附件" name="fileList" :label-col="{ span: 4 }" :wrapper-col="{ span: 24 }">
<div style="color: #ccc; font-size: 12px">{{ fileTip }}</div>
<Upload :disabled="isDisable" v-model:value="formState.filePath" v-model:tableName="tableName" v-model:columnName="columnName"
:multiple="true" @change="changeUplod" :dataDelete="true" :file-list="formState.fileList" :maxSize="200" :accept="accept"></Upload>
</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, message } 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 { getDocCpList } from '/@/api/sales/Customer';
import type { FormInstance } from 'ant-design-vue';
import dayjs from 'dayjs';
import Upload from '/@/components/Form/src/components/Upload.vue';
let tableName = 'Customer'
const columnName = 'fileList'
const { t } = useI18n();
const isUpdate = ref(true);
const isDisable = ref(false);
let optionList = reactive([])
const uploadRef = ref()
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: '',
fileList: [],
filePath: ''
});
const list = ref()
const rules = {
docTypeCode: [{ required: true, message: "该项为必填项", trigger: 'change' }],
};
const curData = ref()
const props = defineProps({
type: String
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
curData.value = ''
formState.filePath = ''
getOption()
setModalProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
isDisable.value = data?.btnType == 'view' ? true : false
list.value = data.list
if (unref(isUpdate)) {
let dateFrom = data.record?.dateFrom ? dayjs(data.record?.dateFrom) : null
let dateTo = data.record?.dateTo ? dayjs(data.record?.dateTo) : null
Object.assign(formState, {...data.record,dateFrom, dateTo})
let json = JSON.parse(JSON.stringify(data.record))
formState.filePath = (json?.fileList||[])[0]?.tableId
curData.value = json?.docTypeCode
}
});
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();
}
function changeUplod (val) {
formState.fileList = val
console.log(val, 532, )
}
async function getOption() {
let obj = {}
if (props.type == 'cuSign') {
obj = {'cuSign': 'Y'}
} else {
obj = {'suSign': 'Y'}
tableName = 'supplier'
}
optionList = await getDocCpList({'valid': 'Y',...obj })
}
const handleCancel = () => {
formRef.value.resetFields();
}
const handleSubmit = async () => {
try {
await formRef.value.validate();
// 验证通过,提交表单
let obj = {
...formState,
dateFrom: formState.dateFrom ? dayjs(formState.dateFrom).format('YYYY-MM-DD') : '',
dateTo: formState.dateTo ? dayjs(formState.dateTo).format('YYYY-MM-DD') : '',
fileList: formState.fileList || []
}
let idx =list.value.findIndex(v => v.docTypeCode == obj.docTypeCode)
if (idx > -1 && formState.docTypeCode !=curData.value) {
message.warn('证书已存在')
formRef.value.resetFields();
closeModal();
return
}
emit('success', obj);
notification.success({
message: t('操作'),
description:!unref(isUpdate)? t('新增成功') : t('编辑成功')
}); //提示消息
formRef.value.resetFields();
closeModal();
} catch (error) {
console.log('验证失败:', error);
}
};
</script>

View File

@ -0,0 +1,123 @@
<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',
required: true,
colProps: { lg: 12, md: 12 }
},
{
field: 'email',
label: t('电子邮箱'),
component: 'Input',
colProps: { lg: 12, md: 12 },
rules: [{ type: 'email', 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>

View File

@ -0,0 +1,138 @@
<template>
<div>
<BasicModal v-bind="$attrs" @register="registerModal" width="60%" :title="getTitle" @ok="handleSubmit"
@visible-change="handleVisibleChange" >
<BasicTable @register="registerTable" class="customerListModal"></BasicTable>
</BasicModal>
</div>
</template>
<script lang="ts" setup>
import { ref, computed, unref, nextTick } from 'vue';
import { BasicModal, useModalInner, useModal } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index';
import { BasicTable, useTable, FormSchema, BasicColumn, TableAction } from '/@/components/Table';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { getLngCustomerPage} from '/@/api/sales/Customer';
const { t } = useI18n();
const codeFormSchema: FormSchema[] = [
{
field: 'cuName',
label: '客户名称',
component: 'Input',
},
];
const columns: BasicColumn[] = [
{
dataIndex: 'cuCode',
title: '客户编码',
align: 'left',
sorter: true,
},
{
dataIndex: 'cuName',
title: '客户名称',
align: 'left',
sorter: true,
},
{
dataIndex: 'cuSname',
title: '客户简称',
align: 'left',
sorter: true,
},
{
dataIndex: 'dI',
title: '国内/国际',
align: 'left',
sorter: true,
},
{
dataIndex: 'classCode',
title: '客户分类',
align: 'left',
sorter: true,
},
];
const emit = defineEmits(['success', 'register']);
const { notification } = useMessage();
const isUpdate = ref(true);
const rowId = ref('');
const selectedKeys = ref<string[]>([]);
const selectedValues = ref([]);
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
setModalProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
});
const [registerTable, { getDataSource, setTableData, updateTableDataRecord, reload }] = useTable({
title: t('客户列表'),
api: getLngCustomerPage,
columns,
bordered: true,
pagination: true,
canResize: false,
formConfig: {
labelCol:{span: 9, offSet:10},
schemas: codeFormSchema,
showResetButton: true,
},
immediate: false, // 设置为不立即调用
beforeFetch: (params) => {
return { ...params, valid: 'Y',approCode: 'YSP'};
},
rowSelection: {
type: 'checkBox',
onChange: onSelectChange
},
});
const handleVisibleChange = (visible: boolean) => {
if (visible) {
nextTick(() => {
reload();
});
}
};
function onSelectChange(rowKeys: string[], e) {
selectedKeys.value = rowKeys;
selectedValues.value = e
}
const getTitle = computed(() => (!unref(isUpdate) ? t('客户列表') : t('')));
async function handleSubmit() {
if (!selectedValues.value.length) {
notification.warning({
message: t('提示'),
description: t('请选择客户')
});
return
}
closeModal();
emit('success', selectedValues.value);
}
</script>
<style >
.customerListModal .basicCol{
position: inherit !important;
top: 0;
}
</style>