Merge remote-tracking branch 'origin/master'

This commit is contained in:
AN 2025-05-11 16:03:44 +08:00
commit 69a7db4599
6 changed files with 35 additions and 31 deletions

View File

@ -1,5 +1,5 @@
<script setup lang="tsx"> <script setup lang="tsx">
import { onMounted, ref, useAttrs } from 'vue'; import { onMounted, ref, useAttrs, watch } from 'vue';
import type { TreeSelectInst, TreeSelectProps } from 'naive-ui'; import type { TreeSelectInst, TreeSelectProps } from 'naive-ui';
import { useBoolean } from '@sa/hooks'; import { useBoolean } from '@sa/hooks';
import { fetchGetDeptTree } from '@/service/api/system/user'; import { fetchGetDeptTree } from '@/service/api/system/user';
@ -48,6 +48,16 @@ onMounted(() => {
} }
}); });
watch([expandAll, options], ([newVal]) => {
if (newVal) {
//
expandedKeys.value = getAllDeptIds(options.value);
} else {
//
expandedKeys.value = [100];
}
});
function getAllDeptIds(depts: any[]) { function getAllDeptIds(depts: any[]) {
const deptIds: CommonType.IdType[] = []; const deptIds: CommonType.IdType[] = [];
depts.forEach(item => { depts.forEach(item => {
@ -114,7 +124,6 @@ defineExpose({
:loading="loading" :loading="loading"
virtual-scroll virtual-scroll
:check-strategy="cascade ? 'child' : 'all'" :check-strategy="cascade ? 'child' : 'all'"
:default-expand-all="expandAll"
v-bind="attrs" v-bind="attrs"
/> />
</NSpin> </NSpin>

View File

@ -51,19 +51,14 @@ onMounted(() => {
}); });
// watch expandAll ,optionsexpandedKeys // watch expandAll ,optionsexpandedKeys
watch( watch([expandAll, options], ([newVal]) => {
[expandAll, options],
([newVal]) => {
if (newVal) { if (newVal) {
// //
expandedKeys.value = getAllMenuIds(options.value); expandedKeys.value = getAllMenuIds(options.value);
} else { } else {
//
expandedKeys.value = [0]; expandedKeys.value = [0];
} }
}, });
{ immediate: true }
);
function renderPrefix({ option }: { option: TreeOption }) { function renderPrefix({ option }: { option: TreeOption }) {
const renderLocalIcon = String(option.icon).startsWith('icon-'); const renderLocalIcon = String(option.icon).startsWith('icon-');

View File

@ -570,7 +570,7 @@ declare namespace Api {
/** 备注 */ /** 备注 */
remark: string; remark: string;
/** 菜单树选择项是否关联显示 */ /** 菜单树选择项是否关联显示 */
menuCheckStrictly: number; menuCheckStrictly: boolean;
/** 状态0正常 1停用 */ /** 状态0正常 1停用 */
status: string; status: string;
/** 删除标志0代表存在 1代表删除 */ /** 删除标志0代表存在 1代表删除 */

View File

@ -3,7 +3,6 @@ import { NDivider } from 'naive-ui';
import { fetchBatchDeleteNotice, fetchGetNoticeList } from '@/service/api/system/notice'; import { fetchBatchDeleteNotice, fetchGetNoticeList } from '@/service/api/system/notice';
import { useAppStore } from '@/store/modules/app'; import { useAppStore } from '@/store/modules/app';
import { useAuth } from '@/hooks/business/auth'; import { useAuth } from '@/hooks/business/auth';
import { useDownload } from '@/hooks/business/download';
import { useTable, useTableOperate } from '@/hooks/common/table'; import { useTable, useTableOperate } from '@/hooks/common/table';
import { useDict } from '@/hooks/business/dict'; import { useDict } from '@/hooks/business/dict';
import { $t } from '@/locales'; import { $t } from '@/locales';
@ -19,7 +18,6 @@ defineOptions({
useDict('sys_notice_type'); useDict('sys_notice_type');
useDict('sys_normal_disable'); useDict('sys_normal_disable');
const appStore = useAppStore(); const appStore = useAppStore();
const { download } = useDownload();
const { hasAuth } = useAuth(); const { hasAuth } = useAuth();
const { const {
@ -160,10 +158,6 @@ async function handleDelete(noticeId: CommonType.IdType) {
async function edit(noticeId: CommonType.IdType) { async function edit(noticeId: CommonType.IdType) {
handleEdit('noticeId', noticeId); handleEdit('noticeId', noticeId);
} }
async function handleExport() {
download('/system/notice/export', searchParams, `通知公告_${new Date().getTime()}.xlsx`);
}
</script> </script>
<template> <template>
@ -177,10 +171,9 @@ async function handleExport() {
:loading="loading" :loading="loading"
:show-add="hasAuth('system:notice:add')" :show-add="hasAuth('system:notice:add')"
:show-delete="hasAuth('system:notice:remove')" :show-delete="hasAuth('system:notice:remove')"
:show-export="hasAuth('system:notice:export')" :show-export="false"
@add="handleAdd" @add="handleAdd"
@delete="handleBatchDelete" @delete="handleBatchDelete"
@export="handleExport"
@refresh="getData" @refresh="getData"
/> />
</template> </template>

View File

@ -56,14 +56,15 @@ function createDefaultModel(): Model {
packageName: '', packageName: '',
menuIds: [], menuIds: [],
remark: '', remark: '',
menuCheckStrictly: null menuCheckStrictly: true
}; };
} }
type RuleKey = Extract<keyof Model, 'packageId'>; type RuleKey = Extract<keyof Model, 'packageId' | 'packageName'>;
const rules: Record<RuleKey, App.Global.FormRule> = { const rules: Record<RuleKey, App.Global.FormRule> = {
packageId: createRequiredRule('租户套餐id不能为空') packageId: createRequiredRule('租户套餐id不能为空'),
packageName: createRequiredRule('租户套餐名称不能为空')
}; };
async function handleUpdateModelWhenEdit() { async function handleUpdateModelWhenEdit() {
@ -78,7 +79,7 @@ async function handleUpdateModelWhenEdit() {
if (props.operateType === 'edit' && props.rowData) { if (props.operateType === 'edit' && props.rowData) {
startMenuLoading(); startMenuLoading();
Object.assign(model, props.rowData); Object.assign(model, { ...props.rowData, menuIds: [] });
const { data, error } = await fetchGetTenantPackageMenuTreeSelect(model.packageId!); const { data, error } = await fetchGetTenantPackageMenuTreeSelect(model.packageId!);
if (error) return; if (error) return;
model.menuIds = data.checkedKeys; model.menuIds = data.checkedKeys;
@ -94,15 +95,14 @@ function closeDrawer() {
async function handleSubmit() { async function handleSubmit() {
await validate(); await validate();
const { packageId, packageName, menuIds, remark, menuCheckStrictly } = model;
// request // request
if (props.operateType === 'add') { if (props.operateType === 'add') {
const { packageName, menuIds, remark, menuCheckStrictly } = model;
const { error } = await fetchCreateTenantPackage({ packageName, menuIds, remark, menuCheckStrictly }); const { error } = await fetchCreateTenantPackage({ packageName, menuIds, remark, menuCheckStrictly });
if (error) return; if (error) return;
} }
if (props.operateType === 'edit') { if (props.operateType === 'edit') {
const { packageId, packageName, menuIds, remark, menuCheckStrictly } = model;
const { error } = await fetchUpdateTenantPackage({ const { error } = await fetchUpdateTenantPackage({
packageId, packageId,
packageName, packageName,
@ -144,7 +144,7 @@ watch(visible, () => {
/> />
</NFormItem> </NFormItem>
<NFormItem label="备注" path="remark"> <NFormItem label="备注" path="remark">
<NInput v-model:value="model.remark" placeholder="请输入备注" /> <NInput v-model:value="model.remark" placeholder="请输入备注" type="textarea" />
</NFormItem> </NFormItem>
</NForm> </NForm>
<template #footer> <template #footer>

View File

@ -7,6 +7,7 @@ import { useAppStore } from '@/store/modules/app';
import { useTable, useTableOperate } from '@/hooks/common/table'; import { useTable, useTableOperate } from '@/hooks/common/table';
import { useDict } from '@/hooks/business/dict'; import { useDict } from '@/hooks/business/dict';
import { useAuth } from '@/hooks/business/auth'; import { useAuth } from '@/hooks/business/auth';
import { useDownload } from '@/hooks/business/download';
import ButtonIcon from '@/components/custom/button-icon.vue'; import ButtonIcon from '@/components/custom/button-icon.vue';
import { $t } from '@/locales'; import { $t } from '@/locales';
import StatusSwitch from '@/components/custom/status-switch.vue'; import StatusSwitch from '@/components/custom/status-switch.vue';
@ -22,6 +23,7 @@ useDict('sys_user_sex');
const { hasAuth } = useAuth(); const { hasAuth } = useAuth();
const appStore = useAppStore(); const appStore = useAppStore();
const { download } = useDownload();
const { bool: importVisible, setTrue: openImportModal } = useBoolean(); const { bool: importVisible, setTrue: openImportModal } = useBoolean();
@ -236,6 +238,10 @@ async function handleStatusChange(
getData(); getData();
} }
} }
function handleExport() {
download('/system/user/export', searchParams, `用户列表_${new Date().getTime()}.xlsx`);
}
</script> </script>
<template> <template>
@ -283,6 +289,7 @@ async function handleStatusChange(
:show-export="hasAuth('system:user:export')" :show-export="hasAuth('system:user:export')"
@add="handleAdd" @add="handleAdd"
@delete="handleBatchDelete" @delete="handleBatchDelete"
@export="handleExport"
@refresh="getData" @refresh="getData"
> >
<template #after> <template #after>