diff --git a/policeManagement/src/components/layout/layout.vue b/policeManagement/src/components/layout/layout.vue index 38befb7..f139d4e 100644 --- a/policeManagement/src/components/layout/layout.vue +++ b/policeManagement/src/components/layout/layout.vue @@ -24,30 +24,25 @@ --> - + 法制宣传 + + + + + \ No newline at end of file diff --git a/policeManagement/src/views/login.vue b/policeManagement/src/views/login.vue index 0ad4afd..66f9cda 100644 --- a/policeManagement/src/views/login.vue +++ b/policeManagement/src/views/login.vue @@ -10,7 +10,7 @@
欢迎来到超级后台
- +
@@ -38,8 +38,15 @@ import { QqOutlined, WechatOutlined } from '@ant-design/icons-vue' import TelephoneLogin from '@/components/login/TelephoneLogin.vue' import { ref } from 'vue' - +import { useRoute } from 'vue-router' +const route = useRoute() +const account = ref('') +const password = ref('') const activeKey = ref(0) +account.value = route.query.account as string +password.value = route.query.password as string +// console.log('Account:', account.value) +// console.log('Password:', password.value) diff --git a/securityManagement/src/components/table/TableProMax.vue b/securityManagement/src/components/table/TableProMax.vue new file mode 100644 index 0000000..c98ef55 --- /dev/null +++ b/securityManagement/src/components/table/TableProMax.vue @@ -0,0 +1,223 @@ + + + + + diff --git a/securityManagement/src/config/dict.ts b/securityManagement/src/config/dict.ts index 86dc984..e27fe55 100644 --- a/securityManagement/src/config/dict.ts +++ b/securityManagement/src/config/dict.ts @@ -13,5 +13,5 @@ export const initEnums = () => { }) } -export const enumSelectNodes = (enumType: DictType): SelectNodeVo[] => JSON.parse(sessionStorage.getItem('dictMap') as string)?.[enumType] || [] +export const dictSelectNodes = (enumType: DictType): SelectNodeVo[] => JSON.parse(sessionStorage.getItem('dictMap') as string)?.[enumType] || [] diff --git a/securityManagement/src/config/index.ts b/securityManagement/src/config/index.ts index 251a99c..7934799 100644 --- a/securityManagement/src/config/index.ts +++ b/securityManagement/src/config/index.ts @@ -12,13 +12,13 @@ export const SYSTEM_MENUS: SystemMenu[] = [ type: "menu", component: () => import('@/views/index.vue') }, { - title: '单位管理', + title: '用户管理', name: 'userManagement', path: '/userManagement', type: 'dir', children: [ { - title: '用户管理', + title: '后台管理', name: 'bgManagement', path: '/bgManagement', type: 'menu', diff --git a/securityManagement/src/hooks/useTableProMax.ts b/securityManagement/src/hooks/useTableProMax.ts new file mode 100644 index 0000000..360f18e --- /dev/null +++ b/securityManagement/src/hooks/useTableProMax.ts @@ -0,0 +1,134 @@ +import {ref, Ref} from "vue"; +import {Page, PageParams, PageResult} from "@/types/hooks/useTableProMax.ts"; +import {FormInstance} from "ant-design-vue"; +import {BaseTableRowRecord, RequestApiType} from "@/types/components/table"; + +/** + * + * @param api 查询方法 + * @param searchFormRef 表单校验 + * @param searchParams 查询的参数 + * @param isPageTable 是否分页 + * @param dataCallBack 查询到数据后的回调 + * @param requestError 查询出错回调 + */ +export default | PageParams

>(api: RequestApiType, + searchFormRef: Ref, + searchParams: Ref

, + isPageTable: boolean = true, + dataCallBack?: (data: T[]) => T[], + requestError?: (errorMsg: any) => void) => { + + const dataSource = ref([]) as Ref; + const loading = ref(false); + const pageParams = ref({ + current: 1, + size: 10, + total: 0 + }) + + /** + * 获取表格数据 + */ + const requestGetTableData = async (isInit: boolean = false) => { + try { + //校验表单 + !isInit && await searchFormRef.value?.validate(); + //组装参数 + let totalSearchParams; + if (isPageTable) { + totalSearchParams = { + params: searchParams.value, + page: { + current: pageParams.value.current, + size: pageParams.value.size + } + } as PageParams

; + } else { + totalSearchParams = searchParams.value + } + + loading.value = true; + + const resp = await api(totalSearchParams as P); + let tableData: T[]; + + if (isPageTable) { + const {current, records, size, total} = resp.data as PageResult; + isPageTable && updatePageParams({ + current: parseInt(current), + size: parseInt(size), + total: parseInt(total) + }); + tableData = records; + } else { + tableData = resp.data as T[] + } + dataCallBack && (tableData = dataCallBack(tableData)); + dataSource.value = tableData; + } catch (error) { + requestError && requestError(error); + } finally { + loading.value = false; + } + } + + /** + * 更新分页信息 + */ + const updatePageParams = (ps: Page) => Object.assign(pageParams.value, ps) + + /** + * 重置表格状态 包括 dataSource loading pageParams + */ + const resetState = () => { + dataSource.value = []; + loading.value = false; + pageParams.value = { + current: 1, + size: 10, + total: 0 + } + } + + /** + * 表格数据查询 与 requestGetTableData 区别是会将页面重置为1 + * 如果只做刷新数据请用 requestGetTableData + */ + const search = async () => { + pageParams.value.current = 1; + await requestGetTableData(); + }; + + /** + * @description 每页条数改变 + * @param _ + * @param {Number} size 页显示数量 + */ + const handleSizeChange = async (_: number, size: number) => { + pageParams.value.current = 1; + pageParams.value.size = size; + await requestGetTableData(); + }; + + /** + * @description 当前页改变 + * @param current 当前页 + */ + const handleCurrentChange = async (current: number) => { + pageParams.value.current = current; + await requestGetTableData(); + }; + + return { + dataSource, + loading, + pageParams, + requestGetTableData, + search, + handleSizeChange, + handleCurrentChange, + resetState + }; + +} diff --git a/securityManagement/src/main.ts b/securityManagement/src/main.ts index b636b33..ed5c439 100644 --- a/securityManagement/src/main.ts +++ b/securityManagement/src/main.ts @@ -4,6 +4,7 @@ import '@/reset.css' import './index.css' // 公共样式 import '@/assets/scss/common.scss' +import '@/assets/scss/myAntD.scss' // iconfont css import "@/assets/iconfont/iconfont.css"; // vue Router diff --git a/securityManagement/src/router/index.ts b/securityManagement/src/router/index.ts index 3864660..106f0ed 100644 --- a/securityManagement/src/router/index.ts +++ b/securityManagement/src/router/index.ts @@ -32,7 +32,7 @@ router.beforeEach(async (to, from, next) => { // 不在白名单内需要查看是否携带token 没有token需要返回登录页进行登录 if (!userStore.getTokenInfo?.value) { await message.warn('未找到token,请重新登陆!') - return next('/login'); + return next('/enterprise'); } //放行 return next(); diff --git a/securityManagement/src/router/staticRouters.ts b/securityManagement/src/router/staticRouters.ts index 2739b4f..8b53ef5 100644 --- a/securityManagement/src/router/staticRouters.ts +++ b/securityManagement/src/router/staticRouters.ts @@ -51,4 +51,9 @@ export const staticRouter: RouteRecordRaw[] = [ name: 'test', component: () => import("@/views/test.vue"), }, + { + path: '/enterprise', + name: 'enterprise', + component: () => import("@/views/enterprise.vue"), + }, ] diff --git a/securityManagement/src/types/components/form/index.ts b/securityManagement/src/types/components/form/index.ts new file mode 100644 index 0000000..0477415 --- /dev/null +++ b/securityManagement/src/types/components/form/index.ts @@ -0,0 +1,73 @@ +import { + FormProps, + RangePicker, + Input, + InputNumber, + Textarea, + InputPassword, + RadioGroup, + Select, + TreeSelect, + Cascader, + CheckboxGroup, + DatePicker, + FormItem, TimeRangePicker, TimePicker, +} from "ant-design-vue"; +import {Ref, UnwrapRef, VNode} from "vue"; +import {ComponentProps} from "vue-component-type-helpers"; + +type FormProMaxItemType = + | 'custom' + | 'input' + | 'inputPassword' + | 'inputNumber' + | 'inputTextArea' + | 'radioGroup' + | 'select' + | 'selectIcon' + | 'selectUser' + | 'treeSelect' + | 'cascader' + | 'checkboxGroup' + | 'datePicker' + | 'rangePicker' + | 'timeRangePicker' + | 'timePicker'; + +interface FormProMaxItemCommonProps extends ComponentProps { + label?: string, + grid?: Grid, + placeholder?: string, + remarkRender?: () => VNode | string, + customRender?: () => VNode; + options?: (SelectNodeVo | TreeNodeVo) [] | Ref<(SelectNodeVo | TreeNodeVo)[]> +} + +export interface FormProMaxItemProps extends FormProMaxItemCommonProps { + type: T + componentsProps?: C +} + +export type FormProMaxItemOptions = { + [key in keyof T | string]: + FormProMaxItemProps<'custom', ComponentProps>> + | FormProMaxItemProps<'input', ComponentProps> + | FormProMaxItemProps<'inputPassword', ComponentProps> + | FormProMaxItemProps<'inputNumber', ComponentProps> + | FormProMaxItemProps<'inputTextArea', ComponentProps> + | FormProMaxItemProps<'radioGroup', ComponentProps> + | FormProMaxItemProps<'select', ComponentProps> + | FormProMaxItemProps<'treeSelect', ComponentProps> + | FormProMaxItemProps<'cascader', ComponentProps> + | FormProMaxItemProps<'checkboxGroup', ComponentProps> + | FormProMaxItemProps<'datePicker', ComponentProps> + | FormProMaxItemProps<'rangePicker', ComponentProps> + | FormProMaxItemProps<'timeRangePicker', ComponentProps> + | FormProMaxItemProps<'timePicker', ComponentProps> +} + +export interface FormProMaxProps extends FormProps { + grid?: Grid + gutter?: number; + formItemOptions?: FormProMaxItemOptions | Ref> | UnwrapRef> +} diff --git a/securityManagement/src/types/components/table/index.ts b/securityManagement/src/types/components/table/index.ts new file mode 100644 index 0000000..20c3793 --- /dev/null +++ b/securityManagement/src/types/components/table/index.ts @@ -0,0 +1,55 @@ +import {PaginationProps, Table, TableProps} from "ant-design-vue"; +import {TableRowSelection} from "ant-design-vue/lib/table/interface"; +import {Ref, UnwrapRef} from "vue"; +import {ColumnType} from "ant-design-vue/es/table/interface"; +import {ComponentSlots} from "vue-component-type-helpers"; +import {FormProMaxItemOptions, FormProMaxProps} from "@/types/components/form"; +import {PageParams, PageResult} from "@/types/hooks/useTableProMax.ts"; + + +export type TableProMaxColumnType = Omit, 'dataIndex'> & { + dataIndex: keyof T | string | string[] | number | number[]; +} + + +export type TableProMaxProps< + T extends BaseTableRowRecord = {}, + P extends { [key: string]: any } = {} +> = Partial, "dataSource" | 'pagination' | 'loading' | 'rowKey' | 'columns'>> & { + rowKey?: keyof T, + columns?: TableProMaxColumnType[], + searchFormProps?: Omit, 'formItems'> + searchFormOptions?: FormProMaxItemOptions

| Ref> | UnwrapRef>, + defaultSearchParams?: { [key in keyof P | string]: any }; + requestAuto?: boolean, + requestApi: RequestApiType, + requestError?: (errorMsg: any) => void, + dataCallback?: (data: T[]) => T[], + isPagination?: boolean, + paginationProps?: TableProMaxPaginationProps, + isSelection?: boolean, + selectionProps?: TableProMaxRowSelect, + isPrinter?: boolean, + needIndex?: boolean +} + +export type TableProMaxSlots = ComponentSlots & { + tableHeader: (scope: { selectKeys: string[], selectRows: T[] }) => any, + tableHeaderRight: (scope: { selectKeys: string[], selectRows: T[] }) => any, +} + +export type RequestApiType = (params: P | PageParams

) => Promise>>; + +export type TableProMaxPaginationProps = Partial>; + +export type TableProMaxRowSelect = TableRowSelection; + +export interface BaseTableRowRecord { + snowFlakeId?: string; + createUserName?: string; + createTime?: Date | string; + updateUserName?: string; + updateTime?: Date | string +} diff --git a/securityManagement/src/types/hooks/useTableProMax.ts b/securityManagement/src/types/hooks/useTableProMax.ts new file mode 100644 index 0000000..3989828 --- /dev/null +++ b/securityManagement/src/types/hooks/useTableProMax.ts @@ -0,0 +1,26 @@ +/** + * 分页对象 + */ +export interface Page { + current: number, + size: number, + total: number +} + +/** + * 分页参数 + */ +export interface PageParams = {}> { + params: T & { [key: string]: any }, + page: Omit +} + +/** + * 分页结果 + */ +export interface PageResult { + current: string, + records: T[], + size: string, + total: string +} \ No newline at end of file diff --git a/securityManagement/src/types/views/bgManagement.ts b/securityManagement/src/types/views/bgManagement.ts new file mode 100644 index 0000000..6986e6d --- /dev/null +++ b/securityManagement/src/types/views/bgManagement.ts @@ -0,0 +1,22 @@ +import {BaseTableRowRecord} from "@/types/components/table"; + +export interface BgManagementPagerQueryParams extends BaseTableRowRecord{ + /** 名称 **/ + name?: string; + /** 社会编码 **/ + socialCode?: string; + /** 行政区划编码 **/ + administrativeDivisionCodes?: string[]; + /** 是否启用 **/ + isEnable?: number; + /** 审核状态 **/ + checkStatus?: number; + /** 账号 **/ + account?:string, + sex?:BaseEnum, + telephone?:string, + createTime?:string, + snowFlakeId?:string, + remark?:string, +} + diff --git a/securityManagement/src/views/test.vue b/securityManagement/src/views/test.vue index ba851b8..057eb32 100644 --- a/securityManagement/src/views/test.vue +++ b/securityManagement/src/views/test.vue @@ -1,11 +1,264 @@ - +