This commit is contained in:
2025-11-27 23:50:26 +08:00
parent 40243abb84
commit 489b2314ab
86 changed files with 9534 additions and 266 deletions

View File

@@ -0,0 +1,169 @@
<!--
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
* @author gaoxq
-->
<template>
<BasicDrawer
v-bind="$attrs"
:showFooter="true"
:okAuth="'biz:municipalities:edit'"
@register="registerDrawer"
@ok="handleSubmit"
width="70%"
>
<template #title>
<Icon :icon="getTitle.icon" class="m-1 pr-1" />
<span> {{ getTitle.value }} </span>
</template>
<BasicForm @register="registerForm" />
</BasicDrawer>
</template>
<script lang="ts" setup name="ViewsBizMunicipalitiesForm">
import { ref, unref, computed } from 'vue';
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
import { router } from '@jeesite/core/router';
import { Icon } from '@jeesite/core/components/Icon';
import { BasicForm, FormSchema, useForm } from '@jeesite/core/components/Form';
import { BasicDrawer, useDrawerInner } from '@jeesite/core/components/Drawer';
import { BizMunicipalities, bizMunicipalitiesSave, bizMunicipalitiesForm } from '@jeesite/biz/api/biz/municipalities';
const emit = defineEmits(['success', 'register']);
const { t } = useI18n('biz.municipalities');
const { showMessage } = useMessage();
const { meta } = unref(router.currentRoute);
const record = ref<BizMunicipalities>({} as BizMunicipalities);
const getTitle = computed(() => ({
icon: meta.icon || 'i-ant-design:book-outlined',
value: record.value.isNewRecord ? t('新增地市信息') : t('编辑地市信息'),
}));
const inputFormSchemas: FormSchema<BizMunicipalities>[] = [
{
label: t('县区名称'),
field: 'countyName',
component: 'Input',
componentProps: {
maxlength: 65,
},
required: true,
},
{
label: t('省份编码'),
field: 'provinceCode',
component: 'Select',
componentProps: {
dictType: '',
allowClear: true,
},
required: true,
},
{
label: t('市区编码'),
field: 'cityCode',
component: 'Select',
componentProps: {
dictType: '',
allowClear: true,
},
required: true,
},
{
label: t('县区编码'),
field: 'countyCode',
component: 'Input',
componentProps: {
maxlength: 24,
},
required: true,
},
{
label: t('街道名称'),
field: 'townName',
component: 'Input',
componentProps: {
maxlength: 125,
},
required: true,
},
{
label: t('街道编号'),
field: 'townCode',
component: 'Input',
componentProps: {
maxlength: 32,
},
required: true,
},
{
label: t('社区名称'),
field: 'villageName',
component: 'Input',
componentProps: {
maxlength: 125,
},
required: true,
},
{
label: t('社区编号'),
field: 'villageCode',
component: 'Input',
componentProps: {
maxlength: 32,
},
required: true,
},
{
label: t('数据状态'),
field: 'dataStatus',
component: 'Select',
componentProps: {
dictType: '',
allowClear: true,
},
required: true,
},
];
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm<BizMunicipalities>({
labelWidth: 120,
schemas: inputFormSchemas,
baseColProps: { md: 24, lg: 12 },
});
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
setDrawerProps({ loading: true });
await resetFields();
const res = await bizMunicipalitiesForm(data);
record.value = (res.bizMunicipalities || {}) as BizMunicipalities;
record.value.__t = new Date().getTime();
await setFieldsValue(record.value);
setDrawerProps({ loading: false });
});
async function handleSubmit() {
try {
const data = await validate();
setDrawerProps({ confirmLoading: true });
const params: any = {
isNewRecord: record.value.isNewRecord,
id: record.value.id || data.id,
};
// console.log('submit', params, data, record);
const res = await bizMunicipalitiesSave(params, data);
showMessage(res.message);
setTimeout(closeDrawer);
emit('success', data);
} catch (error: any) {
if (error && error.errorFields) {
showMessage(error.message || t('common.validateError'));
}
console.log('error', error);
} finally {
setDrawerProps({ confirmLoading: false });
}
}
</script>

View File

@@ -0,0 +1,103 @@
<!--
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
* @author gaoxq
-->
<template>
<BasicModal
v-bind="$attrs"
:title="t('导入地市信息')"
:okText="t('导入')"
@register="registerModal"
@ok="handleSubmit"
:minHeight="120"
:width="400"
>
<Upload accept=".xls,.xlsx" :file-list="fileList" :before-upload="beforeUpload" @remove="handleRemove">
<a-button> <Icon icon="ant-design:upload-outlined" /> {{ t('选择文件') }} </a-button>
<span class="ml-4">{{ uploadInfo }}</span>
</Upload>
<div class="ml-4 mt-4">
{{ t('提示仅允许导入“xls”或“xlsx”格式文件') }}
</div>
<div class="mt-4">
<a-button @click="handleDownloadTemplate()" type="text">
<Icon icon="i-fa:file-excel-o" />
{{ t('下载模板') }}
</a-button>
</div>
</BasicModal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { Upload } from 'ant-design-vue';
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
import { useGlobSetting } from '@jeesite/core/hooks/setting';
import { downloadByUrl } from '@jeesite/core/utils/file/download';
import { Icon } from '@jeesite/core/components/Icon';
import { BasicModal, useModalInner } from '@jeesite/core/components/Modal';
import { bizMunicipalitiesImportData } from '@jeesite/biz/api/biz/municipalities';
import { FileType } from 'ant-design-vue/es/upload/interface';
import { AxiosProgressEvent } from 'axios';
const emit = defineEmits(['success', 'register']);
const { t } = useI18n('biz.municipalities');
const { showMessage, showMessageModal } = useMessage();
const fileList = ref<FileType[]>([]);
const uploadInfo = ref('');
const beforeUpload = (file: FileType) => {
fileList.value = [file];
return false;
};
const handleRemove = () => {
fileList.value = [];
};
const [registerModal, { setModalProps, closeModal }] = useModalInner(() => {
fileList.value = [];
uploadInfo.value = '';
});
async function handleDownloadTemplate() {
const { ctxAdminPath } = useGlobSetting();
downloadByUrl({ url: ctxAdminPath + '/biz/municipalities/importTemplate' });
}
function onUploadProgress(progressEvent: AxiosProgressEvent) {
const complete = ((progressEvent.loaded / (progressEvent.total || 1)) * 100) | 0;
if (complete != 100) {
uploadInfo.value = t('正在导入,请稍候') + ' ' + complete + '%...';
} else {
uploadInfo.value = '';
}
}
async function handleSubmit() {
try {
if (fileList.value.length == 0) {
showMessage(t('请选择要导入的数据文件'));
return;
}
setModalProps({ confirmLoading: true });
const params = {
file: fileList.value[0],
};
const { data } = await bizMunicipalitiesImportData(params, onUploadProgress);
showMessageModal({ content: data.message });
setTimeout(closeModal);
emit('success');
} catch (error: any) {
if (error && error.errorFields) {
showMessage(error.message || t('common.validateError'));
}
console.log('error', error);
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

View File

@@ -0,0 +1,312 @@
<!--
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
* @author gaoxq
-->
<template>
<div>
<BasicTable @register="registerTable">
<template #tableTitle>
<Icon :icon="getTitle.icon" class="m-1 pr-1" />
<span> {{ getTitle.value }} </span>
</template>
<template #toolbar>
<a-button type="default" :loading="loading" @click="handleExport()">
<Icon icon="i-ant-design:download-outlined" /> {{ t('导出') }}
</a-button>
<a-button type="default" @click="handleImport()">
<Icon icon="i-ant-design:import-outlined" /> {{ t('导入') }}
</a-button>
<a-button type="primary" @click="handleForm({})" v-auth="'biz:municipalities:edit'">
<Icon icon="i-fluent:add-12-filled" /> {{ t('新增') }}
</a-button>
</template>
<template #firstColumn="{ record }">
<a @click="handleForm({ id: record.id })" :title="record.createTime">
{{ record.createTime }}
</a>
</template>
</BasicTable>
<InputForm @register="registerDrawer" @success="handleSuccess" />
<FormImport @register="registerImportModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" setup name="ViewsBizMunicipalitiesList">
import { onMounted, ref, unref } from 'vue';
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
import { useGlobSetting } from '@jeesite/core/hooks/setting';
import { downloadByUrl } from '@jeesite/core/utils/file/download';
import { router } from '@jeesite/core/router';
import { Icon } from '@jeesite/core/components/Icon';
import { BasicTable, BasicColumn, useTable } from '@jeesite/core/components/Table';
import { BizMunicipalities, bizMunicipalitiesList } from '@jeesite/biz/api/biz/municipalities';
import { bizMunicipalitiesDelete, bizMunicipalitiesListData } from '@jeesite/biz/api/biz/municipalities';
import { useDrawer } from '@jeesite/core/components/Drawer';
import { useModal } from '@jeesite/core/components/Modal';
import { FormProps } from '@jeesite/core/components/Form';
import InputForm from './form.vue';
import FormImport from './formImport.vue';
const { t } = useI18n('biz.municipalities');
const { showMessage } = useMessage();
const { meta } = unref(router.currentRoute);
const record = ref<BizMunicipalities>({} as BizMunicipalities);
const getTitle = {
icon: meta.icon || 'i-ant-design:book-outlined',
value: meta.title || t('地市信息管理'),
};
const loading = ref(false);
const searchForm: FormProps<BizMunicipalities> = {
baseColProps: { md: 8, lg: 6 },
labelWidth: 90,
schemas: [
{
label: t('记录时间起'),
field: 'createTime_gte',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
{
label: t('记录时间止'),
field: 'createTime_lte',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
{
label: t('县区名称'),
field: 'countyName',
component: 'Input',
},
{
label: t('省份编码'),
field: 'provinceCode',
component: 'Select',
componentProps: {
dictType: '',
allowClear: true,
},
},
{
label: t('市区编码'),
field: 'cityCode',
component: 'Select',
componentProps: {
dictType: '',
allowClear: true,
},
},
{
label: t('县区编码'),
field: 'countyCode',
component: 'Input',
},
{
label: t('街道名称'),
field: 'townName',
component: 'Input',
},
{
label: t('街道编号'),
field: 'townCode',
component: 'Input',
},
{
label: t('社区名称'),
field: 'villageName',
component: 'Input',
},
{
label: t('社区编号'),
field: 'villageCode',
component: 'Input',
},
{
label: t('数据状态'),
field: 'dataStatus',
component: 'Select',
componentProps: {
dictType: '',
allowClear: true,
},
},
],
};
const tableColumns: BasicColumn<BizMunicipalities>[] = [
{
title: t('记录时间'),
dataIndex: 'createTime',
key: 'a.create_time',
sorter: true,
width: 230,
align: 'left',
slot: 'firstColumn',
},
{
title: t('县区名称'),
dataIndex: 'countyName',
key: 'a.county_name',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('省份编码'),
dataIndex: 'provinceCode',
key: 'a.province_code',
sorter: true,
width: 130,
align: 'left',
dictType: '',
},
{
title: t('市区编码'),
dataIndex: 'cityCode',
key: 'a.city_code',
sorter: true,
width: 130,
align: 'left',
dictType: '',
},
{
title: t('县区编码'),
dataIndex: 'countyCode',
key: 'a.county_code',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('街道名称'),
dataIndex: 'townName',
key: 'a.town_name',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('街道编号'),
dataIndex: 'townCode',
key: 'a.town_code',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('社区名称'),
dataIndex: 'villageName',
key: 'a.village_name',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('社区编号'),
dataIndex: 'villageCode',
key: 'a.village_code',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('更新时间'),
dataIndex: 'updateTime',
key: 'a.update_time',
sorter: true,
width: 130,
align: 'center',
},
{
title: t('数据状态'),
dataIndex: 'dataStatus',
key: 'a.data_status',
sorter: true,
width: 130,
align: 'left',
dictType: '',
},
];
const actionColumn: BasicColumn<BizMunicipalities> = {
width: 160,
actions: (record: BizMunicipalities) => [
{
icon: 'i-clarity:note-edit-line',
title: t('编辑地市信息'),
onClick: handleForm.bind(this, { id: record.id }),
auth: 'biz:municipalities:edit',
},
{
icon: 'i-ant-design:delete-outlined',
color: 'error',
title: t('删除地市信息'),
popConfirm: {
title: t('是否确认删除地市信息'),
confirm: handleDelete.bind(this, record),
},
auth: 'biz:municipalities:edit',
},
],
};
const [registerTable, { reload, getForm }] = useTable<BizMunicipalities>({
api: bizMunicipalitiesListData,
beforeFetch: (params) => {
return params;
},
columns: tableColumns,
actionColumn: actionColumn,
formConfig: searchForm,
showTableSetting: true,
useSearchForm: true,
canResize: true,
});
onMounted(async () => {
const res = await bizMunicipalitiesList();
record.value = (res.bizMunicipalities || {}) as BizMunicipalities;
await getForm().setFieldsValue(record.value);
});
const [registerDrawer, { openDrawer }] = useDrawer();
function handleForm(record: Recordable) {
openDrawer(true, record);
}
async function handleExport() {
loading.value = true;
const { ctxAdminPath } = useGlobSetting();
await downloadByUrl({
url: ctxAdminPath + '/biz/municipalities/exportData',
params: getForm().getFieldsValue(),
});
loading.value = false;
}
const [registerImportModal, { openModal: importModal }] = useModal();
function handleImport() {
importModal(true, {});
}
async function handleDelete(record: Recordable) {
const params = { id: record.id };
const res = await bizMunicipalitiesDelete(params);
showMessage(res.message);
await handleSuccess(record);
}
async function handleSuccess(record: Recordable) {
await reload({ record });
}
</script>

View File

@@ -0,0 +1,205 @@
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '@jeesite/core/components/Table';
import { BizMunicipalities, bizMunicipalitiesListData } from '@jeesite/biz/api/biz/municipalities';
const { t } = useI18n('biz.municipalities');
const modalProps = {
title: t('地市信息选择'),
};
const searchForm: FormProps<BizMunicipalities> = {
baseColProps: { md: 8, lg: 6 },
labelWidth: 90,
schemas: [
{
label: t('记录时间起'),
field: 'createTime_gte',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
{
label: t('记录时间止'),
field: 'createTime_lte',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
{
label: t('县区名称'),
field: 'countyName',
component: 'Input',
},
{
label: t('省份编码'),
field: 'provinceCode',
component: 'Select',
componentProps: {
dictType: '',
allowClear: true,
},
},
{
label: t('市区编码'),
field: 'cityCode',
component: 'Select',
componentProps: {
dictType: '',
allowClear: true,
},
},
{
label: t('县区编码'),
field: 'countyCode',
component: 'Input',
},
{
label: t('街道名称'),
field: 'townName',
component: 'Input',
},
{
label: t('街道编号'),
field: 'townCode',
component: 'Input',
},
{
label: t('社区名称'),
field: 'villageName',
component: 'Input',
},
{
label: t('社区编号'),
field: 'villageCode',
component: 'Input',
},
{
label: t('数据状态'),
field: 'dataStatus',
component: 'Select',
componentProps: {
dictType: '',
allowClear: true,
},
},
],
};
const tableColumns: BasicColumn<BizMunicipalities>[] = [
{
title: t('记录时间'),
dataIndex: 'createTime',
key: 'a.create_time',
sorter: true,
width: 230,
align: 'left',
slot: 'firstColumn',
},
{
title: t('县区名称'),
dataIndex: 'countyName',
key: 'a.county_name',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('省份编码'),
dataIndex: 'provinceCode',
key: 'a.province_code',
sorter: true,
width: 130,
align: 'left',
dictType: '',
},
{
title: t('市区编码'),
dataIndex: 'cityCode',
key: 'a.city_code',
sorter: true,
width: 130,
align: 'left',
dictType: '',
},
{
title: t('县区编码'),
dataIndex: 'countyCode',
key: 'a.county_code',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('街道名称'),
dataIndex: 'townName',
key: 'a.town_name',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('街道编号'),
dataIndex: 'townCode',
key: 'a.town_code',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('社区名称'),
dataIndex: 'villageName',
key: 'a.village_name',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('社区编号'),
dataIndex: 'villageCode',
key: 'a.village_code',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('更新时间'),
dataIndex: 'updateTime',
key: 'a.update_time',
sorter: true,
width: 130,
align: 'center',
},
{
title: t('数据状态'),
dataIndex: 'dataStatus',
key: 'a.data_status',
sorter: true,
width: 130,
align: 'left',
dictType: '',
},
];
const tableProps: BasicTableProps = {
api: bizMunicipalitiesListData,
beforeFetch: (params) => {
params['isAll'] = true;
return params;
},
columns: tableColumns,
formConfig: searchForm,
rowKey: 'id',
};
export default {
modalProps,
tableProps,
itemCode: 'id',
itemName: 'id',
isShowCode: false,
};