| | |
| | | <ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData"> |
| | | <template #left> |
| | | <ElSpace wrap> |
| | | <ElButton v-auth="'add'" @click="showDialog('add')" v-ripple>新增企业</ElButton> |
| | | <ElButton v-auth="'add'" @click="showDialog('add')" v-ripple>{{ t('pages.basicInfo.companys.buttons.add') }}</ElButton> |
| | | <ElButton |
| | | v-auth="'delete'" |
| | | type="danger" |
| | |
| | | @click="handleBatchDelete" |
| | | v-ripple |
| | | > |
| | | 批量删除 |
| | | {{ t('common.actions.batchDelete') }} |
| | | </ElButton> |
| | | <ListExportPrint |
| | | class="inline-flex" |
| | |
| | | |
| | | <script setup> |
| | | import { computed, onMounted, ref } from 'vue' |
| | | import { useI18n } from 'vue-i18n' |
| | | import { ElMessage } from 'element-plus' |
| | | import { useUserStore } from '@/store/modules/user' |
| | | import { useAuth } from '@/hooks/core/useAuth' |
| | |
| | | import { createCompanysTableColumns } from './companysTable.columns' |
| | | import { |
| | | COMPANYS_REPORT_STYLE, |
| | | COMPANYS_REPORT_TITLE, |
| | | buildCompanysDialogModel, |
| | | buildCompanysPageQueryParams, |
| | | buildCompanysSavePayload, |
| | |
| | | buildCompanysTypeOptions, |
| | | createCompanysSearchState, |
| | | getCompanysPaginationKey, |
| | | getCompanysReportTitle, |
| | | normalizeCompanysListRow |
| | | } from './companysPage.helpers' |
| | | |
| | | defineOptions({ name: 'Companys' }) |
| | | |
| | | const { t } = useI18n() |
| | | const { hasAuth } = useAuth() |
| | | const userStore = useUserStore() |
| | | |
| | |
| | | const detailData = ref({}) |
| | | let handleDeleteAction = null |
| | | |
| | | const reportTitle = COMPANYS_REPORT_TITLE |
| | | const reportTitle = computed(() => getCompanysReportTitle(t)) |
| | | const reportQueryParams = computed(() => buildCompanysSearchParams(searchForm.value)) |
| | | const typeLabelMap = computed( |
| | | () => |
| | |
| | | |
| | | const searchItems = computed(() => [ |
| | | { |
| | | label: '关键字', |
| | | label: t('table.keyword'), |
| | | key: 'condition', |
| | | type: 'input', |
| | | props: { |
| | | clearable: true, |
| | | placeholder: '请输入企业名称/编码/联系人/电话' |
| | | placeholder: t('pages.basicInfo.companys.search.conditionPlaceholder') |
| | | } |
| | | }, |
| | | { label: '企业编码', key: 'code', type: 'input', props: { clearable: true, placeholder: '请输入企业编码' } }, |
| | | { label: '企业名称', key: 'name', type: 'input', props: { clearable: true, placeholder: '请输入企业名称' } }, |
| | | { label: '英文别名', key: 'nameEn', type: 'input', props: { clearable: true, placeholder: '请输入英文别名' } }, |
| | | { label: '助记码', key: 'breifCode', type: 'input', props: { clearable: true, placeholder: '请输入助记码' } }, |
| | | { label: t('pages.basicInfo.companys.table.code'), key: 'code', type: 'input', props: { clearable: true, placeholder: t('pages.basicInfo.companys.search.codePlaceholder') } }, |
| | | { label: t('pages.basicInfo.companys.table.name'), key: 'name', type: 'input', props: { clearable: true, placeholder: t('pages.basicInfo.companys.search.namePlaceholder') } }, |
| | | { label: t('pages.basicInfo.companys.table.nameEn'), key: 'nameEn', type: 'input', props: { clearable: true, placeholder: t('pages.basicInfo.companys.search.nameEnPlaceholder') } }, |
| | | { label: t('pages.basicInfo.companys.table.briefCode'), key: 'breifCode', type: 'input', props: { clearable: true, placeholder: t('pages.basicInfo.companys.search.briefCodePlaceholder') } }, |
| | | { |
| | | label: '企业类型', |
| | | label: t('pages.basicInfo.companys.table.type'), |
| | | key: 'type', |
| | | type: 'select', |
| | | props: { |
| | |
| | | options: typeOptions.value |
| | | } |
| | | }, |
| | | { label: '联系人', key: 'contact', type: 'input', props: { clearable: true, placeholder: '请输入联系人' } }, |
| | | { label: '联系电话', key: 'tel', type: 'input', props: { clearable: true, placeholder: '请输入联系电话' } }, |
| | | { label: '邮箱', key: 'email', type: 'input', props: { clearable: true, placeholder: '请输入邮箱' } }, |
| | | { label: '邮编', key: 'pcode', type: 'input', props: { clearable: true, placeholder: '请输入邮编' } }, |
| | | { label: '省份', key: 'province', type: 'input', props: { clearable: true, placeholder: '请输入省份' } }, |
| | | { label: '城市', key: 'city', type: 'input', props: { clearable: true, placeholder: '请输入城市' } }, |
| | | { label: '地址', key: 'address', type: 'input', props: { clearable: true, placeholder: '请输入地址' } }, |
| | | { label: t('pages.basicInfo.companys.table.contact'), key: 'contact', type: 'input', props: { clearable: true, placeholder: t('pages.basicInfo.companys.search.contactPlaceholder') } }, |
| | | { label: t('pages.basicInfo.companys.table.tel'), key: 'tel', type: 'input', props: { clearable: true, placeholder: t('pages.basicInfo.companys.search.telPlaceholder') } }, |
| | | { label: t('pages.basicInfo.companys.table.email'), key: 'email', type: 'input', props: { clearable: true, placeholder: t('pages.basicInfo.companys.search.emailPlaceholder') } }, |
| | | { label: t('pages.basicInfo.companys.table.postCode'), key: 'pcode', type: 'input', props: { clearable: true, placeholder: t('pages.basicInfo.companys.search.postCodePlaceholder') } }, |
| | | { label: t('pages.basicInfo.companys.table.province'), key: 'province', type: 'input', props: { clearable: true, placeholder: t('pages.basicInfo.companys.search.provincePlaceholder') } }, |
| | | { label: t('pages.basicInfo.companys.table.city'), key: 'city', type: 'input', props: { clearable: true, placeholder: t('pages.basicInfo.companys.search.cityPlaceholder') } }, |
| | | { label: t('pages.basicInfo.companys.table.address'), key: 'address', type: 'input', props: { clearable: true, placeholder: t('pages.basicInfo.companys.search.addressPlaceholder') } }, |
| | | { |
| | | label: '状态', |
| | | label: t('table.status'), |
| | | key: 'status', |
| | | type: 'select', |
| | | props: { |
| | | clearable: true, |
| | | options: [ |
| | | { label: '正常', value: 1 }, |
| | | { label: '冻结', value: 0 } |
| | | { label: t('common.status.normal'), value: 1 }, |
| | | { label: t('common.status.frozen'), value: 0 } |
| | | ] |
| | | } |
| | | }, |
| | | { label: '备注', key: 'memo', type: 'input', props: { clearable: true, placeholder: '请输入备注' } } |
| | | { label: t('table.remark'), key: 'memo', type: 'input', props: { clearable: true, placeholder: t('pages.basicInfo.companys.search.memoPlaceholder') } } |
| | | ]) |
| | | |
| | | async function openDetail(row) { |
| | |
| | | detailLoading.value = true |
| | | try { |
| | | const detail = await guardRequestWithMessage(fetchGetCompanysDetail(row.id), {}, { |
| | | timeoutMessage: '往来企业详情加载超时,已停止等待' |
| | | timeoutMessage: t('pages.basicInfo.companys.messages.detailTimeout') |
| | | }) |
| | | detailData.value = normalizeCompanysListRow(detail, resolveTypeLabel) |
| | | } catch (error) { |
| | | detailDrawerVisible.value = false |
| | | detailData.value = {} |
| | | ElMessage.error(error?.message || '获取往来企业详情失败') |
| | | ElMessage.error(error?.message || t('pages.basicInfo.companys.messages.detailFailed')) |
| | | } finally { |
| | | detailLoading.value = false |
| | | } |
| | |
| | | async function openEditDialog(row) { |
| | | try { |
| | | const detail = await guardRequestWithMessage(fetchGetCompanysDetail(row.id), {}, { |
| | | timeoutMessage: '往来企业详情加载超时,已停止等待' |
| | | timeoutMessage: t('pages.basicInfo.companys.messages.detailTimeout') |
| | | }) |
| | | showDialog('edit', detail) |
| | | } catch (error) { |
| | | ElMessage.error(error?.message || '获取往来企业详情失败') |
| | | ElMessage.error(error?.message || t('pages.basicInfo.companys.messages.detailFailed')) |
| | | } |
| | | } |
| | | |
| | |
| | | paginationKey: getCompanysPaginationKey(), |
| | | columnsFactory: () => |
| | | createCompanysTableColumns({ |
| | | t, |
| | | handleView: openDetail, |
| | | handleEdit: hasAuth('update') ? openEditDialog : null, |
| | | handleDelete: hasAuth('delete') ? (row) => handleDeleteAction?.(row) : null, |
| | |
| | | saveRequest: fetchSaveCompanys, |
| | | updateRequest: fetchUpdateCompanys, |
| | | deleteRequest: fetchDeleteCompanys, |
| | | entityName: '往来企业', |
| | | entityName: t('pages.basicInfo.companys.entity'), |
| | | resolveRecordLabel: (record) => record?.name || record?.code || record?.id, |
| | | refreshCreate, |
| | | refreshUpdate, |
| | |
| | | const buildPreviewMeta = (rows) => { |
| | | const now = new Date() |
| | | return { |
| | | reportTitle: reportTitle.value, |
| | | reportDate: now.toLocaleDateString('zh-CN'), |
| | | printedAt: now.toLocaleString('zh-CN', { hour12: false }), |
| | | operator: userStore.getUserInfo?.name || userStore.getUserInfo?.username || '', |
| | |
| | | status: 1 |
| | | }), |
| | | { records: [] }, |
| | | { timeoutMessage: '企业类型加载超时,已停止等待' } |
| | | { timeoutMessage: t('pages.basicInfo.companys.messages.typeOptionsTimeout') } |
| | | ) |
| | | typeOptions.value = buildCompanysTypeOptions(defaultResponseAdapter(response).records) |
| | | } |