update 修改页面代码 去除ele的引入以及vue的类型声明

This commit is contained in:
LiuHao
2023-06-06 22:23:43 +08:00
parent 490d4ef47e
commit 6af68085ff
35 changed files with 704 additions and 773 deletions

View File

@ -22,52 +22,23 @@ export default {
<script setup lang="ts"> <script setup lang="ts">
import { scrollTo } from '@/utils/scroll-to' import { scrollTo } from '@/utils/scroll-to'
import { PropType } from "vue"; import { propTypes } from "@/utils/propTypes";
const props = defineProps({ const props = defineProps({
total: { total: propTypes.number,
required: true, page: propTypes.number.def(1),
type: Number limit: propTypes.number.def(20),
},
page: {
type: Number,
default: 1
},
limit: {
type: Number,
default: 20
},
pageSizes: { pageSizes: {
type: Array as PropType<number[]>, type: Array as PropType<number[]>,
default() { default: () => [10, 20, 30, 50]
return [10, 20, 30, 50]
}
}, },
// 移动端页码按钮的数量端默认值5 // 移动端页码按钮的数量端默认值5
pagerCount: { pagerCount: propTypes.number.def(document.body.clientWidth < 992 ? 5 : 7),
type: Number, layout: propTypes.string.def('total, sizes, prev, pager, next, jumper'),
default: document.body.clientWidth < 992 ? 5 : 7 background: propTypes.bool.def(true),
}, autoScroll: propTypes.bool.def(true),
layout: { hidden: propTypes.bool.def(false),
type: String, float: propTypes.string.def('right')
default: 'total, sizes, prev, pager, next, jumper'
},
background: {
type: Boolean,
default: true
},
autoScroll: {
type: Boolean,
default: true
},
hidden: {
type: Boolean,
default: false
},
float: {
type: String,
default: 'right'
}
}) })
const emit = defineEmits(['update:page', 'update:limit', 'pagination']); const emit = defineEmits(['update:page', 'update:limit', 'pagination']);

View File

@ -69,7 +69,7 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination v-show="total>0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" /> <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card> </el-card>
<!-- 添加或修改测试单对话框 --> <!-- 添加或修改测试单对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body> <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
@ -103,8 +103,6 @@
<script setup name="Demo" lang="ts"> <script setup name="Demo" lang="ts">
import { listDemo, getDemo, delDemo, addDemo, updateDemo } from '@/api/demo/demo'; import { listDemo, getDemo, delDemo, addDemo, updateDemo } from '@/api/demo/demo';
import { DemoVO, DemoQuery, DemoForm } from '@/api/demo/demo/types'; import { DemoVO, DemoQuery, DemoForm } from '@/api/demo/demo/types';
import { ComponentInternalInstance } from 'vue';
import { ElForm } from 'element-plus';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -117,8 +115,8 @@ const single = ref(true);
const multiple = ref(true); const multiple = ref(true);
const total = ref(0); const total = ref(0);
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const demoFormRef = ref(ElForm); const demoFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({ const dialog = reactive<DialogOption>({
visible: false, visible: false,
@ -134,7 +132,7 @@ const initFormData: DemoForm = {
value: undefined, value: undefined,
} }
const data = reactive<PageData<DemoForm, DemoQuery>>({ const data = reactive<PageData<DemoForm, DemoQuery>>({
form: {...initFormData}, form: { ...initFormData },
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
@ -185,8 +183,8 @@ const cancel = () => {
/** 表单重置 */ /** 表单重置 */
const reset = () => { const reset = () => {
form.value = {...initFormData}; form.value = { ...initFormData };
demoFormRef.value.resetFields(); demoFormRef.value?.resetFields();
} }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
@ -197,7 +195,7 @@ const handleQuery = () => {
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
handleQuery(); handleQuery();
} }
@ -233,13 +231,13 @@ const handleUpdate = (row?: DemoVO) => {
/** 提交按钮 */ /** 提交按钮 */
const submitForm = () => { const submitForm = () => {
demoFormRef.value.validate(async (valid: boolean) => { demoFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
buttonLoading.value = true; buttonLoading.value = true;
if (form.value.id) { if (form.value.id) {
await updateDemo(form.value).finally(() => buttonLoading.value = false); await updateDemo(form.value).finally(() => buttonLoading.value = false);
} else { } else {
await addDemo(form.value).finally(() => buttonLoading.value = false); await addDemo(form.value).finally(() => buttonLoading.value = false);
} }
proxy?.$modal.msgSuccess("修改成功"); proxy?.$modal.msgSuccess("修改成功");
dialog.visible = false; dialog.visible = false;

View File

@ -91,8 +91,6 @@
<script setup name="Tree" lang="ts"> <script setup name="Tree" lang="ts">
import { listTree, getTree, delTree, addTree, updateTree } from "@/api/demo/tree"; import { listTree, getTree, delTree, addTree, updateTree } from "@/api/demo/tree";
import { TreeVO, TreeQuery, TreeForm } from '@/api/demo/tree/types'; import { TreeVO, TreeQuery, TreeForm } from '@/api/demo/tree/types';
import { ComponentInternalInstance } from 'vue';
import { ElForm, ElTable } from 'element-plus';
type TreeOption = { type TreeOption = {
@ -111,9 +109,9 @@ const showSearch = ref(true);
const isExpandAll = ref(true); const isExpandAll = ref(true);
const loading = ref(false); const loading = ref(false);
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const treeFormRef = ref(ElForm); const treeFormRef = ref<ElFormInstance>();
const treeTableRef = ref(ElTable) const treeTableRef = ref<ElTableInstance>()
const dialog = reactive<DialogOption>({ const dialog = reactive<DialogOption>({
visible: false, visible: false,
@ -187,7 +185,7 @@ const cancel = () => {
// 表单重置 // 表单重置
const reset = () => { const reset = () => {
form.value = {...initFormData} form.value = {...initFormData}
treeFormRef.value.resetFields(); treeFormRef.value?.resetFields();
} }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
@ -197,7 +195,7 @@ const handleQuery = () => {
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
handleQuery(); handleQuery();
} }
@ -225,7 +223,7 @@ const handleToggleExpandAll = () => {
/** 展开/折叠操作 */ /** 展开/折叠操作 */
const toggleExpandAll = (data: TreeVO[], status: boolean) => { const toggleExpandAll = (data: TreeVO[], status: boolean) => {
data.forEach((item) => { data.forEach((item) => {
treeTableRef.value.toggleRowExpansion(item, status) treeTableRef.value?.toggleRowExpansion(item, status)
if (item.children && item.children.length > 0) toggleExpandAll(item.children, status) if (item.children && item.children.length > 0) toggleExpandAll(item.children, status)
}) })
} }
@ -249,7 +247,7 @@ const handleUpdate = (row: TreeVO) => {
/** 提交按钮 */ /** 提交按钮 */
const submitForm = () => { const submitForm = () => {
treeFormRef.value.validate(async (valid: boolean) => { treeFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
buttonLoading.value = true; buttonLoading.value = true;
if (form.value.id) { if (form.value.id) {
@ -259,7 +257,7 @@ const submitForm = () => {
} }
proxy?.$modal.msgSuccess("操作成功"); proxy?.$modal.msgSuccess("操作成功");
dialog.visible = false; dialog.visible = false;
getList(); await getList();
} }
}); });
} }

View File

@ -21,7 +21,6 @@
<script setup lang="ts"> <script setup lang="ts">
import errImage from '@/assets/401_images/401.gif'; import errImage from '@/assets/401_images/401.gif';
import { ComponentInternalInstance } from "vue";
let { proxy } = getCurrentInstance() as ComponentInternalInstance; let { proxy } = getCurrentInstance() as ComponentInternalInstance;

View File

@ -50,7 +50,6 @@ import Cookies from 'js-cookie';
import { encrypt, decrypt } from '@/utils/jsencrypt'; import { encrypt, decrypt } from '@/utils/jsencrypt';
import { useUserStore } from '@/store/modules/user'; import { useUserStore } from '@/store/modules/user';
import { LoginData, TenantVO } from '@/api/types'; import { LoginData, TenantVO } from '@/api/types';
import { FormRules } from 'element-plus';
import { to } from 'await-to-js'; import { to } from 'await-to-js';
const userStore = useUserStore(); const userStore = useUserStore();
@ -65,7 +64,7 @@ const loginForm = ref<LoginData>({
uuid: '' uuid: ''
}); });
const loginRules: FormRules = { const loginRules: ElFormRules = {
tenantId: [{ required: true, trigger: "blur", message: "请输入您的租户编号" }], tenantId: [{ required: true, trigger: "blur", message: "请输入您的租户编号" }],
username: [{ required: true, trigger: 'blur', message: '请输入您的账号' }], username: [{ required: true, trigger: 'blur', message: '请输入您的账号' }],
password: [{ required: true, trigger: 'blur', message: '请输入您的密码' }], password: [{ required: true, trigger: 'blur', message: '请输入您的密码' }],

View File

@ -126,7 +126,6 @@
<script setup name="Cache" lang="ts"> <script setup name="Cache" lang="ts">
import { getCache } from '@/api/monitor/cache'; import { getCache } from '@/api/monitor/cache';
import * as echarts from 'echarts'; import * as echarts from 'echarts';
import { ComponentInternalInstance } from "vue";
const cache = ref<any>({}); const cache = ref<any>({});
const commandstats = ref(); const commandstats = ref();

View File

@ -100,9 +100,7 @@
<script setup name="Logininfor" lang="ts"> <script setup name="Logininfor" lang="ts">
import { list, delLoginInfo, cleanLoginInfo, unlockLoginInfo } from "@/api/monitor/loginInfo"; import { list, delLoginInfo, cleanLoginInfo, unlockLoginInfo } from "@/api/monitor/loginInfo";
import { ComponentInternalInstance } from "vue";
import { LoginInfoQuery, LoginInfoVO } from "@/api/monitor/loginInfo/types"; import { LoginInfoQuery, LoginInfoVO } from "@/api/monitor/loginInfo/types";
import { DateModelType } from 'element-plus';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { sys_common_status } = toRefs<any>(proxy?.useDict("sys_common_status")); const { sys_common_status } = toRefs<any>(proxy?.useDict("sys_common_status"));
@ -118,8 +116,8 @@ const total = ref(0);
const dateRange = ref<[DateModelType,DateModelType]>(['', '']); const dateRange = ref<[DateModelType,DateModelType]>(['', '']);
const defaultSort = ref<any>({ prop: "loginTime", order: "descending" }); const defaultSort = ref<any>({ prop: "loginTime", order: "descending" });
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const loginInfoTableRef = ref(ElTable); const loginInfoTableRef = ref<ElTableInstance>();
// 查询参数 // 查询参数
const queryParams = ref<LoginInfoQuery>({ const queryParams = ref<LoginInfoQuery>({
pageNum: 1, pageNum: 1,
@ -147,9 +145,9 @@ const handleQuery = () => {
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
dateRange.value = ['', '']; dateRange.value = ['', ''];
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
queryParams.value.pageNum = 1; queryParams.value.pageNum = 1;
loginInfoTableRef.value.sort(defaultSort.value.prop, defaultSort.value.order); loginInfoTableRef.value?.sort(defaultSort.value.prop, defaultSort.value.order);
} }
/** 多选框选中数据 */ /** 多选框选中数据 */
const handleSelectionChange = (selection: LoginInfoVO[]) => { const handleSelectionChange = (selection: LoginInfoVO[]) => {
@ -169,14 +167,14 @@ const handleDelete = async (row?: LoginInfoVO) => {
const infoIds = row?.infoId || ids.value; const infoIds = row?.infoId || ids.value;
await proxy?.$modal.confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?'); await proxy?.$modal.confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?');
await delLoginInfo(infoIds); await delLoginInfo(infoIds);
getList(); await getList();
proxy?.$modal.msgSuccess("删除成功"); proxy?.$modal.msgSuccess("删除成功");
} }
/** 清空按钮操作 */ /** 清空按钮操作 */
const handleClean = async () => { const handleClean = async () => {
await proxy?.$modal.confirm("是否确认清空所有登录日志数据项?"); await proxy?.$modal.confirm("是否确认清空所有登录日志数据项?");
await cleanLoginInfo(); await cleanLoginInfo();
getList(); await getList();
proxy?.$modal.msgSuccess("清空成功"); proxy?.$modal.msgSuccess("清空成功");
} }
/** 解锁按钮操作 */ /** 解锁按钮操作 */

View File

@ -56,7 +56,6 @@
<script setup name="Online" lang="ts"> <script setup name="Online" lang="ts">
import { forceLogout, list as initData } from "@/api/monitor/online"; import { forceLogout, list as initData } from "@/api/monitor/online";
import { ComponentInternalInstance } from "vue";
import { OnlineQuery, OnlineVO } from "@/api/monitor/online/types"; import { OnlineQuery, OnlineVO } from "@/api/monitor/online/types";
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -65,42 +64,42 @@ const onlineList = ref<OnlineVO[]>([]);
const loading = ref(true); const loading = ref(true);
const total = ref(0); const total = ref(0);
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const queryParams = ref<OnlineQuery>({ const queryParams = ref<OnlineQuery>({
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
ipaddr: '', ipaddr: '',
userName: '' userName: ''
}); });
/** 查询登录日志列表 */ /** 查询登录日志列表 */
const getList = async () => { const getList = async () => {
loading.value = true; loading.value = true;
const res = await initData(queryParams.value); const res = await initData(queryParams.value);
onlineList.value = res.rows; onlineList.value = res.rows;
total.value = res.total; total.value = res.total;
loading.value = false; loading.value = false;
} }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
queryParams.value.pageNum = 1; queryParams.value.pageNum = 1;
getList(); getList();
} }
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
handleQuery(); handleQuery();
} }
/** 强退按钮操作 */ /** 强退按钮操作 */
const handleForceLogout = async (row: OnlineVO) => { const handleForceLogout = async (row: OnlineVO) => {
await proxy?.$modal.confirm('是否确认强退名称为"' + row.userName + '"的用户?'); await proxy?.$modal.confirm('是否确认强退名称为"' + row.userName + '"的用户?');
await forceLogout(row.tokenId); await forceLogout(row.tokenId);
getList(); getList();
proxy?.$modal.msgSuccess("删除成功"); proxy?.$modal.msgSuccess("删除成功");
} }
onMounted(() => { onMounted(() => {
getList(); getList();
}) })
</script> </script>

View File

@ -134,7 +134,7 @@
<el-form-item label="操作方法:">{{ form.method }}</el-form-item> <el-form-item label="操作方法:">{{ form.method }}</el-form-item>
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="请求参数:">{{form.operParam}}</el-form-item> <el-form-item label="请求参数:">{{ form.operParam }}</el-form-item>
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="返回参数:">{{ form.jsonResult }}</el-form-item> <el-form-item label="返回参数:">{{ form.jsonResult }}</el-form-item>
@ -167,12 +167,10 @@
<script setup name="Operlog" lang="ts"> <script setup name="Operlog" lang="ts">
import { list, delOperlog, cleanOperlog } from '@/api/monitor/operlog'; import { list, delOperlog, cleanOperlog } from '@/api/monitor/operlog';
import { ComponentInternalInstance } from 'vue';
import { OperLogForm, OperLogQuery, OperLogVO } from '@/api/monitor/operlog/types'; import { OperLogForm, OperLogQuery, OperLogVO } from '@/api/monitor/operlog/types';
import { DateModelType } from 'element-plus';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { sys_oper_type, sys_common_status } = toRefs<any>(proxy?.useDict("sys_oper_type","sys_common_status")); const { sys_oper_type, sys_common_status } = toRefs<any>(proxy?.useDict("sys_oper_type", "sys_common_status"));
const operlogList = ref<OperLogVO[]>([]); const operlogList = ref<OperLogVO[]>([]);
const loading = ref(true); const loading = ref(true);
@ -183,116 +181,116 @@ const total = ref(0);
const dateRange = ref<[DateModelType, DateModelType]>(['', '']); const dateRange = ref<[DateModelType, DateModelType]>(['', '']);
const defaultSort = ref<any>({ prop: "operTime", order: "descending" }); const defaultSort = ref<any>({ prop: "operTime", order: "descending" });
const operLogTableRef = ref(ElTable); const operLogTableRef = ref<ElTableInstance>();
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({ const dialog = reactive<DialogOption>({
visible: false, visible: false,
title: '' title: ''
}); });
const data = reactive<PageData<OperLogForm, OperLogQuery>>({ const data = reactive<PageData<OperLogForm, OperLogQuery>>({
form: { form: {
operId: undefined, operId: undefined,
tenantId: undefined, tenantId: undefined,
title: '', title: '',
businessType: 0, businessType: 0,
businessTypes: undefined, businessTypes: undefined,
method: '', method: '',
requestMethod: '', requestMethod: '',
operatorType: 0, operatorType: 0,
operName: '', operName: '',
deptName: '', deptName: '',
operUrl: '', operUrl: '',
operIp: '', operIp: '',
operLocation: '', operLocation: '',
operParam: '', operParam: '',
jsonResult: '', jsonResult: '',
status: 0, status: 0,
errorMsg: '', errorMsg: '',
operTime: '', operTime: '',
costTime: 0 costTime: 0
}, },
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
title: '', title: '',
operName: '', operName: '',
businessType: '', businessType: '',
status: '', status: '',
orderByColumn: defaultSort.value.prop, orderByColumn: defaultSort.value.prop,
isAsc: defaultSort.value.order isAsc: defaultSort.value.order
}, },
rules: {} rules: {}
}); });
const { queryParams, form } = toRefs(data); const { queryParams, form } = toRefs(data);
/** 查询登录日志 */ /** 查询登录日志 */
const getList = async () => { const getList = async () => {
loading.value = true; loading.value = true;
const res = await list(proxy?.addDateRange(queryParams.value, dateRange.value)); const res = await list(proxy?.addDateRange(queryParams.value, dateRange.value));
operlogList.value = res.rows; operlogList.value = res.rows;
total.value = res.total; total.value = res.total;
loading.value = false; loading.value = false;
} }
/** 操作日志类型字典翻译 */ /** 操作日志类型字典翻译 */
const typeFormat = (row: OperLogForm) => { const typeFormat = (row: OperLogForm) => {
return proxy?.selectDictLabel(sys_oper_type.value, row.businessType); return proxy?.selectDictLabel(sys_oper_type.value, row.businessType);
} }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
queryParams.value.pageNum = 1; queryParams.value.pageNum = 1;
getList(); getList();
} }
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
dateRange.value = ['', '']; dateRange.value = ['', ''];
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
queryParams.value.pageNum = 1; queryParams.value.pageNum = 1;
operLogTableRef.value.sort(defaultSort.value.prop, defaultSort.value.order); operLogTableRef.value?.sort(defaultSort.value.prop, defaultSort.value.order);
} }
/** 多选框选中数据 */ /** 多选框选中数据 */
const handleSelectionChange = (selection: OperLogVO[]) => { const handleSelectionChange = (selection: OperLogVO[]) => {
ids.value = selection.map(item => item.operId); ids.value = selection.map(item => item.operId);
multiple.value = !selection.length; multiple.value = !selection.length;
} }
/** 排序触发事件 */ /** 排序触发事件 */
const handleSortChange = (column: any) => { const handleSortChange = (column: any) => {
queryParams.value.orderByColumn = column.prop; queryParams.value.orderByColumn = column.prop;
queryParams.value.isAsc = column.order; queryParams.value.isAsc = column.order;
getList(); getList();
} }
/** 详细按钮操作 */ /** 详细按钮操作 */
const handleView = (row: OperLogVO) => { const handleView = (row: OperLogVO) => {
dialog.visible = true; dialog.visible = true;
form.value = row; form.value = row;
} }
/** 删除按钮操作 */ /** 删除按钮操作 */
const handleDelete = async (row?: OperLogVO) => { const handleDelete = async (row?: OperLogVO) => {
const operIds = row?.operId || ids.value; const operIds = row?.operId || ids.value;
await proxy?.$modal.confirm('是否确认删除日志编号为"' + operIds + '"的数据项?'); await proxy?.$modal.confirm('是否确认删除日志编号为"' + operIds + '"的数据项?');
await delOperlog(operIds); await delOperlog(operIds);
getList(); await getList();
proxy?.$modal.msgSuccess("删除成功"); proxy?.$modal.msgSuccess("删除成功");
} }
/** 清空按钮操作 */ /** 清空按钮操作 */
const handleClean = async () => { const handleClean = async () => {
await proxy?.$modal.confirm("是否确认清空所有操作日志数据项?"); await proxy?.$modal.confirm("是否确认清空所有操作日志数据项?");
await cleanOperlog(); await cleanOperlog();
getList(); await getList();
proxy?.$modal.msgSuccess("清空成功"); proxy?.$modal.msgSuccess("清空成功");
} }
/** 导出按钮操作 */ /** 导出按钮操作 */
const handleExport = () => { const handleExport = () => {
proxy?.download("monitor/operlog/export", { proxy?.download("monitor/operlog/export", {
...queryParams.value, ...queryParams.value,
}, `config_${new Date().getTime()}.xlsx`); }, `config_${new Date().getTime()}.xlsx`);
} }
onMounted(() => { onMounted(() => {
getList(); getList();
}) })
</script> </script>

View File

@ -58,7 +58,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { getCodeImg, register, getTenantList } from '@/api/login'; import { getCodeImg, register, getTenantList } from '@/api/login';
import { RegisterForm, TenantVO } from '@/api/types'; import { RegisterForm, TenantVO } from '@/api/types';
import { FormRules } from 'element-plus';
import { to } from 'await-to-js'; import { to } from 'await-to-js';
const router = useRouter(); const router = useRouter();
@ -85,7 +84,7 @@ const equalToPassword = (rule: any, value: string, callback: any) => {
} }
}; };
const registerRules: FormRules = { const registerRules: ElFormRules = {
tenantId: [ tenantId: [
{ required: true, trigger: "blur", message: "请输入您的租户编号" } { required: true, trigger: "blur", message: "请输入您的租户编号" }
], ],

View File

@ -125,8 +125,6 @@
<script setup name="Config" lang="ts"> <script setup name="Config" lang="ts">
import { listConfig, getConfig, delConfig, addConfig, updateConfig, refreshCache } from "@/api/system/config"; import { listConfig, getConfig, delConfig, addConfig, updateConfig, refreshCache } from "@/api/system/config";
import { ConfigForm, ConfigQuery, ConfigVO } from "@/api/system/config/types"; import { ConfigForm, ConfigQuery, ConfigVO } from "@/api/system/config/types";
import { ComponentInternalInstance } from "vue";
import { DateModelType } from 'element-plus';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { sys_yes_no } = toRefs<any>(proxy?.useDict("sys_yes_no")); const { sys_yes_no } = toRefs<any>(proxy?.useDict("sys_yes_no"));
@ -140,124 +138,124 @@ const multiple = ref(true);
const total = ref(0); const total = ref(0);
const dateRange = ref<[DateModelType, DateModelType]>(['', '']); const dateRange = ref<[DateModelType, DateModelType]>(['', '']);
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const configFormRef = ref(ElForm); const configFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({ const dialog = reactive<DialogOption>({
visible: false, visible: false,
title: '' title: ''
}); });
const initFormData: ConfigForm = { const initFormData: ConfigForm = {
configId: undefined, configId: undefined,
configName: '', configName: '',
configKey: '', configKey: '',
configValue: '', configValue: '',
configType: "Y", configType: "Y",
remark: '' remark: ''
} }
const data = reactive<PageData<ConfigForm, ConfigQuery>>({ const data = reactive<PageData<ConfigForm, ConfigQuery>>({
form: {...initFormData}, form: { ...initFormData },
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
configName: '', configName: '',
configKey: '', configKey: '',
configType: '', configType: '',
}, },
rules: { rules: {
configName: [{ required: true, message: "参数名称不能为空", trigger: "blur" }], configName: [{ required: true, message: "参数名称不能为空", trigger: "blur" }],
configKey: [{ required: true, message: "参数键名不能为空", trigger: "blur" }], configKey: [{ required: true, message: "参数键名不能为空", trigger: "blur" }],
configValue: [{ required: true, message: "参数键值不能为空", trigger: "blur" }] configValue: [{ required: true, message: "参数键值不能为空", trigger: "blur" }]
} }
}); });
const { queryParams, form, rules } = toRefs(data); const { queryParams, form, rules } = toRefs(data);
/** 查询参数列表 */ /** 查询参数列表 */
const getList = async () => { const getList = async () => {
loading.value = true; loading.value = true;
const res = await listConfig(proxy?.addDateRange(queryParams.value, dateRange.value)); const res = await listConfig(proxy?.addDateRange(queryParams.value, dateRange.value));
configList.value = res.rows; configList.value = res.rows;
total.value = res.total; total.value = res.total;
loading.value = false; loading.value = false;
} }
/** 取消按钮 */ /** 取消按钮 */
const cancel = () => { const cancel = () => {
reset(); reset();
dialog.visible = false; dialog.visible = false;
} }
/** 表单重置 */ /** 表单重置 */
const reset = () => { const reset = () => {
form.value = {...initFormData}; form.value = { ...initFormData };
configFormRef.value.resetFields(); configFormRef.value?.resetFields();
} }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
queryParams.value.pageNum = 1; queryParams.value.pageNum = 1;
getList(); getList();
} }
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
dateRange.value = ['', '']; dateRange.value = ['', ''];
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
handleQuery(); handleQuery();
} }
/** 多选框选中数据 */ /** 多选框选中数据 */
const handleSelectionChange = (selection: ConfigVO[]) => { const handleSelectionChange = (selection: ConfigVO[]) => {
ids.value = selection.map(item => item.configId); ids.value = selection.map(item => item.configId);
single.value = selection.length != 1; single.value = selection.length != 1;
multiple.value = !selection.length; multiple.value = !selection.length;
} }
/** 新增按钮操作 */ /** 新增按钮操作 */
const handleAdd = () => { const handleAdd = () => {
dialog.visible = true; dialog.visible = true;
dialog.title = "添加参数"; dialog.title = "添加参数";
nextTick(() => { nextTick(() => {
reset(); reset();
}) })
} }
/** 修改按钮操作 */ /** 修改按钮操作 */
const handleUpdate = (row?: ConfigVO) => { const handleUpdate = (row?: ConfigVO) => {
dialog.visible = true; dialog.visible = true;
dialog.title = "修改参数"; dialog.title = "修改参数";
const configId = row?.configId || ids.value[0]; const configId = row?.configId || ids.value[0];
nextTick(async () => { nextTick(async () => {
reset(); reset();
const res = await getConfig(configId); const res = await getConfig(configId);
form.value = res.data; form.value = res.data;
}) })
} }
/** 提交按钮 */ /** 提交按钮 */
const submitForm = () => { const submitForm = () => {
configFormRef.value.validate(async (valid: boolean) => { configFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
form.value.configId ? await updateConfig(form.value) : await addConfig(form.value); form.value.configId ? await updateConfig(form.value) : await addConfig(form.value);
proxy?.$modal.msgSuccess("操作成功"); proxy?.$modal.msgSuccess("操作成功");
dialog.visible = false; dialog.visible = false;
getList(); await getList();
} }
}); });
} }
/** 删除按钮操作 */ /** 删除按钮操作 */
const handleDelete = async (row?: ConfigVO) => { const handleDelete = async (row?: ConfigVO) => {
const configIds = row?.configId || ids.value; const configIds = row?.configId || ids.value;
await proxy?.$modal.confirm('是否确认删除参数编号为"' + configIds + '"的数据项?'); await proxy?.$modal.confirm('是否确认删除参数编号为"' + configIds + '"的数据项?');
await delConfig(configIds); await delConfig(configIds);
getList(); await getList();
proxy?.$modal.msgSuccess("删除成功"); proxy?.$modal.msgSuccess("删除成功");
} }
/** 导出按钮操作 */ /** 导出按钮操作 */
const handleExport = () => { const handleExport = () => {
proxy?.download("system/config/export", { proxy?.download("system/config/export", {
...queryParams.value ...queryParams.value
}, `config_${new Date().getTime()}.xlsx`); }, `config_${new Date().getTime()}.xlsx`);
} }
/** 刷新缓存按钮操作 */ /** 刷新缓存按钮操作 */
const handleRefreshCache = async () => { const handleRefreshCache = async () => {
await refreshCache(); await refreshCache();
proxy?.$modal.msgSuccess("刷新缓存成功"); proxy?.$modal.msgSuccess("刷新缓存成功");
} }
onMounted(() => { onMounted(() => {
getList(); getList();
}) })
</script> </script>

View File

@ -132,9 +132,7 @@
<script setup name="Dept" lang="ts"> <script setup name="Dept" lang="ts">
import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept" import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept"
import { ComponentInternalInstance } from 'vue';
import { DeptForm, DeptQuery, DeptVO } from "@/api/system/dept/types"; import { DeptForm, DeptQuery, DeptVO } from "@/api/system/dept/types";
import { ElTable, ElForm } from "element-plus";
interface DeptOptionsType { interface DeptOptionsType {
deptId: number | string; deptId: number | string;
@ -158,9 +156,9 @@ const dialog = reactive<DialogOption>({
title: '' title: ''
}); });
const deptTableRef = ref(ElTable); const deptTableRef = ref<ElTableInstance>();
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const deptFormRef = ref(ElForm); const deptFormRef = ref<ElFormInstance>();
const initFormData: DeptForm = { const initFormData: DeptForm = {
deptId: undefined, deptId: undefined,
@ -209,7 +207,7 @@ const cancel = () => {
/** 表单重置 */ /** 表单重置 */
const reset = () => { const reset = () => {
form.value = {...initFormData}; form.value = {...initFormData};
deptFormRef.value.resetFields(); deptFormRef.value?.resetFields();
} }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
@ -218,7 +216,7 @@ const handleQuery = () => {
} }
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
handleQuery() handleQuery()
} }
/** 新增按钮操作 */ /** 新增按钮操作 */
@ -246,7 +244,7 @@ const handleToggleExpandAll = () => {
/** 展开/折叠所有 */ /** 展开/折叠所有 */
const toggleExpandAll = (data: DeptVO[], status: boolean) => { const toggleExpandAll = (data: DeptVO[], status: boolean) => {
data.forEach((item) => { data.forEach((item) => {
deptTableRef.value.toggleRowExpansion(item, status) deptTableRef.value?.toggleRowExpansion(item, status)
if(item.children && item.children.length > 0) toggleExpandAll(item.children, status) if(item.children && item.children.length > 0) toggleExpandAll(item.children, status)
}) })
} }
@ -256,28 +254,32 @@ const handleUpdate = async (row: DeptVO) => {
const res = await getDept(row.deptId); const res = await getDept(row.deptId);
dialog.visible = true; dialog.visible = true;
dialog.title = "修改部门"; dialog.title = "修改部门";
nextTick(async () => { await nextTick(async () => {
reset(); reset();
form.value = res.data form.value = res.data
const response = await listDeptExcludeChild(row.deptId); const response = await listDeptExcludeChild(row.deptId);
const data = proxy?.handleTree<DeptOptionsType>(response.data, "deptId") const data = proxy?.handleTree < DeptOptionsType > (response.data, "deptId")
if (data) { if (data) {
deptOptions.value = data; deptOptions.value = data;
if (data.length === 0) { if (data.length === 0) {
const noResultsOptions: DeptOptionsType = { deptId: res.data.parentId, deptName: res.data.parentName, children: [] }; const noResultsOptions: DeptOptionsType = {
deptOptions.value.push(noResultsOptions); deptId: res.data.parentId,
} deptName: res.data.parentName,
children: []
};
deptOptions.value.push(noResultsOptions);
} }
}
}) })
} }
/** 提交按钮 */ /** 提交按钮 */
const submitForm = () => { const submitForm = () => {
deptFormRef.value.validate(async (valid: boolean) => { deptFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
form.value.deptId ? await updateDept(form.value) : await addDept(form.value); form.value.deptId ? await updateDept(form.value) : await addDept(form.value);
proxy?.$modal.msgSuccess("操作成功"); proxy?.$modal.msgSuccess("操作成功");
dialog.visible = false; dialog.visible = false;
getList(); await getList();
} }
}) })
} }
@ -285,7 +287,7 @@ const submitForm = () => {
const handleDelete = async (row: DeptVO) => { const handleDelete = async (row: DeptVO) => {
await proxy?.$modal.confirm('是否确认删除名称为"' + row.deptName + '"的数据项?'); await proxy?.$modal.confirm('是否确认删除名称为"' + row.deptName + '"的数据项?');
await delDept(row.deptId); await delDept(row.deptId);
getList(); await getList();
proxy?.$modal.msgSuccess("删除成功"); proxy?.$modal.msgSuccess("删除成功");
} }

View File

@ -138,9 +138,7 @@ import useDictStore from '@/store/modules/dict'
import { optionselect as getDictOptionselect, getType } from "@/api/system/dict/type"; import { optionselect as getDictOptionselect, getType } from "@/api/system/dict/type";
import { listData, getData, delData, addData, updateData } from "@/api/system/dict/data"; import { listData, getData, delData, addData, updateData } from "@/api/system/dict/data";
import { DictTypeVO } from '@/api/system/dict/type/types'; import { DictTypeVO } from '@/api/system/dict/type/types';
import { ComponentInternalInstance } from "vue";
import { DictDataForm, DictDataQuery, DictDataVO } from "@/api/system/dict/data/types"; import { DictDataForm, DictDataQuery, DictDataVO } from "@/api/system/dict/data/types";
import { ElForm } from 'element-plus';
const { proxy } = getCurrentInstance() as ComponentInternalInstance const { proxy } = getCurrentInstance() as ComponentInternalInstance
const { sys_normal_disable } = toRefs<any>(proxy?.useDict("sys_normal_disable")); const { sys_normal_disable } = toRefs<any>(proxy?.useDict("sys_normal_disable"));
@ -156,8 +154,8 @@ const total = ref(0);
const defaultDictType = ref(""); const defaultDictType = ref("");
const typeOptions = ref<DictTypeVO[]>([]); const typeOptions = ref<DictTypeVO[]>([]);
const dataFormRef = ref(ElForm); const dataFormRef = ref<ElFormInstance>();
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({ const dialog = reactive<DialogOption>({
@ -233,7 +231,7 @@ const cancel = () => {
/** 表单重置 */ /** 表单重置 */
const reset = () => { const reset = () => {
form.value = { ...initFormData }; form.value = { ...initFormData };
dataFormRef.value.resetFields(); dataFormRef.value?.resetFields();
} }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
@ -247,7 +245,7 @@ const handleClose = () => {
} }
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
queryParams.value.dictType = defaultDictType.value; queryParams.value.dictType = defaultDictType.value;
handleQuery(); handleQuery();
} }
@ -279,13 +277,13 @@ const handleUpdate = (row?: DictDataVO) => {
} }
/** 提交按钮 */ /** 提交按钮 */
const submitForm = () => { const submitForm = () => {
dataFormRef.value.validate(async (valid: boolean) => { dataFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
form.value.dictCode ? await updateData(form.value) : await addData(form.value); form.value.dictCode ? await updateData(form.value) : await addData(form.value);
useDictStore().removeDict(queryParams.value.dictType); useDictStore().removeDict(queryParams.value.dictType);
proxy?.$modal.msgSuccess("操作成功"); proxy?.$modal.msgSuccess("操作成功");
dialog.visible = false; dialog.visible = false;
getList(); await getList();
} }
}); });
@ -295,7 +293,7 @@ const handleDelete = async (row?: DictDataVO) => {
const dictCodes = row?.dictCode || ids.value; const dictCodes = row?.dictCode || ids.value;
await proxy?.$modal.confirm('是否确认删除字典编码为"' + dictCodes + '"的数据项?'); await proxy?.$modal.confirm('是否确认删除字典编码为"' + dictCodes + '"的数据项?');
await delData(dictCodes); await delData(dictCodes);
getList(); await getList();
proxy?.$modal.msgSuccess("删除成功"); proxy?.$modal.msgSuccess("删除成功");
useDictStore().removeDict(queryParams.value.dictType); useDictStore().removeDict(queryParams.value.dictType);

View File

@ -125,9 +125,7 @@
<script setup name="Dict" lang="ts"> <script setup name="Dict" lang="ts">
import useDictStore from '@/store/modules/dict' import useDictStore from '@/store/modules/dict'
import { listType, getType, delType, addType, updateType, refreshCache } from "@/api/system/dict/type"; import { listType, getType, delType, addType, updateType, refreshCache } from "@/api/system/dict/type";
import { ComponentInternalInstance } from "vue";
import { DictTypeForm, DictTypeQuery, DictTypeVO } from "@/api/system/dict/type/types"; import { DictTypeForm, DictTypeQuery, DictTypeVO } from "@/api/system/dict/type/types";
import { DateModelType } from 'element-plus';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { sys_normal_disable } = toRefs<any>(proxy?.useDict("sys_normal_disable")) const { sys_normal_disable } = toRefs<any>(proxy?.useDict("sys_normal_disable"))
@ -141,8 +139,8 @@ const multiple = ref(true);
const total = ref(0); const total = ref(0);
const dateRange = ref<[DateModelType, DateModelType]>(['', '']); const dateRange = ref<[DateModelType, DateModelType]>(['', '']);
const dictFormRef = ref(ElForm); const dictFormRef = ref<ElFormInstance>();
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({ const dialog = reactive<DialogOption>({
@ -191,7 +189,7 @@ const cancel = () => {
/** 表单重置 */ /** 表单重置 */
const reset = () => { const reset = () => {
form.value = {...initFormData}; form.value = {...initFormData};
dictFormRef.value.resetFields(); dictFormRef.value?.resetFields();
} }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
@ -201,7 +199,7 @@ const handleQuery = () => {
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
dateRange.value = ['', '']; dateRange.value = ['', ''];
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
handleQuery(); handleQuery();
} }
/** 新增按钮操作 */ /** 新增按钮操作 */
@ -232,7 +230,7 @@ const handleUpdate = (row?: DictTypeVO) => {
} }
/** 提交按钮 */ /** 提交按钮 */
const submitForm = () => { const submitForm = () => {
dictFormRef.value.validate(async (valid: boolean) => { dictFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
form.value.dictId ? await updateType(form.value) : await addType(form.value); form.value.dictId ? await updateType(form.value) : await addType(form.value);
proxy?.$modal.msgSuccess("操作成功"); proxy?.$modal.msgSuccess("操作成功");

View File

@ -263,9 +263,7 @@
<script setup name="Menu" lang="ts"> <script setup name="Menu" lang="ts">
import { addMenu, delMenu, getMenu, listMenu, updateMenu } from '@/api/system/menu'; import { addMenu, delMenu, getMenu, listMenu, updateMenu } from '@/api/system/menu';
import { MenuForm, MenuQuery, MenuVO } from '@/api/system/menu/types'; import { MenuForm, MenuQuery, MenuVO } from '@/api/system/menu/types';
import { ComponentInternalInstance } from 'vue';
import { MenuTypeEnum } from '@/enums/MenuTypeEnum'; import { MenuTypeEnum } from '@/enums/MenuTypeEnum';
import { ElTable, ElForm } from 'element-plus';
interface MenuOptionsType { interface MenuOptionsType {
menuId: number; menuId: number;
@ -287,8 +285,8 @@ const dialog = reactive<DialogOption>({
title: '' title: ''
}); });
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const menuFormRef = ref(ElForm); const menuFormRef = ref<ElFormInstance>();
const initFormData = { const initFormData = {
path: '', path: '',
menuId: undefined, menuId: undefined,
@ -315,7 +313,7 @@ const data = reactive<PageData<MenuForm, MenuQuery>>({
}, },
}) })
const menuTableRef = ref(ElTable); const menuTableRef = ref<ElTableInstance>();
const { queryParams, form, rules } = toRefs<PageData<MenuForm, MenuQuery>>(data) const { queryParams, form, rules } = toRefs<PageData<MenuForm, MenuQuery>>(data)
/** 查询菜单列表 */ /** 查询菜单列表 */
@ -344,7 +342,7 @@ const cancel = () => {
/** 表单重置 */ /** 表单重置 */
const reset = () => { const reset = () => {
form.value = { ...initFormData }; form.value = { ...initFormData };
menuFormRef.value.resetFields(); menuFormRef.value?.resetFields();
} }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
@ -353,7 +351,7 @@ const handleQuery = () => {
} }
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
handleQuery(); handleQuery();
} }
/** 新增按钮操作 */ /** 新增按钮操作 */
@ -375,7 +373,7 @@ const handleToggleExpandAll = () => {
/** 展开/折叠所有 */ /** 展开/折叠所有 */
const toggleExpandAll = (data: MenuVO[], status: boolean) => { const toggleExpandAll = (data: MenuVO[], status: boolean) => {
data.forEach((item: MenuVO) => { data.forEach((item: MenuVO) => {
menuTableRef.value.toggleRowExpansion(item, status) menuTableRef.value?.toggleRowExpansion(item, status)
if (item.children && item.children.length > 0) toggleExpandAll(item.children, status) if (item.children && item.children.length > 0) toggleExpandAll(item.children, status)
}) })
} }
@ -395,12 +393,12 @@ const handleUpdate = async (row: MenuVO) => {
} }
/** 提交按钮 */ /** 提交按钮 */
const submitForm = () => { const submitForm = () => {
menuFormRef.value.validate(async (valid: boolean) => { menuFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
form.value.menuId ? await updateMenu(form.value) : await addMenu(form.value); form.value.menuId ? await updateMenu(form.value) : await addMenu(form.value);
proxy?.$modal.msgSuccess("操作成功"); proxy?.$modal.msgSuccess("操作成功");
dialog.visible = false; dialog.visible = false;
getList(); await getList();
} }
}) })
} }
@ -408,7 +406,7 @@ const submitForm = () => {
const handleDelete = async (row: MenuVO) => { const handleDelete = async (row: MenuVO) => {
await proxy?.$modal.confirm('是否确认删除名称为"' + row.menuName + '"的数据项?'); await proxy?.$modal.confirm('是否确认删除名称为"' + row.menuName + '"的数据项?');
await delMenu(row.menuId); await delMenu(row.menuId);
getList(); await getList();
proxy?.$modal.msgSuccess("删除成功"); proxy?.$modal.msgSuccess("删除成功");
} }

View File

@ -121,9 +121,7 @@
<script setup name="Notice" lang="ts"> <script setup name="Notice" lang="ts">
import { listNotice, getNotice, delNotice, addNotice, updateNotice } from "@/api/system/notice"; import { listNotice, getNotice, delNotice, addNotice, updateNotice } from "@/api/system/notice";
import { ComponentInternalInstance } from "vue";
import { NoticeForm, NoticeQuery, NoticeVO } from "@/api/system/notice/types"; import { NoticeForm, NoticeQuery, NoticeVO } from "@/api/system/notice/types";
import { ElForm } from 'element-plus';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { sys_notice_status, sys_notice_type } = toRefs<any>(proxy?.useDict("sys_notice_status", "sys_notice_type")); const { sys_notice_status, sys_notice_type } = toRefs<any>(proxy?.useDict("sys_notice_status", "sys_notice_type"));
@ -136,8 +134,8 @@ const single = ref(true);
const multiple = ref(true); const multiple = ref(true);
const total = ref(0); const total = ref(0);
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const noticeFormRef = ref(ElForm); const noticeFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({ const dialog = reactive<DialogOption>({
@ -188,7 +186,7 @@ const cancel = () => {
/** 表单重置 */ /** 表单重置 */
const reset = () => { const reset = () => {
form.value = { ...initFormData }; form.value = { ...initFormData };
noticeFormRef.value.resetFields(); noticeFormRef.value?.resetFields();
} }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
@ -197,7 +195,7 @@ const handleQuery = () => {
} }
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
handleQuery(); handleQuery();
} }
/** 多选框选中数据 */ /** 多选框选中数据 */
@ -227,12 +225,12 @@ const handleUpdate = (row?: NoticeVO) => {
} }
/** 提交按钮 */ /** 提交按钮 */
const submitForm = () => { const submitForm = () => {
noticeFormRef.value.validate(async (valid: boolean) => { noticeFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
form.value.noticeId ? await updateNotice(form.value) : await addNotice(form.value); form.value.noticeId ? await updateNotice(form.value) : await addNotice(form.value);
proxy?.$modal.msgSuccess("修改成功"); proxy?.$modal.msgSuccess("修改成功");
dialog.visible = false; dialog.visible = false;
getList(); await getList();
} }
}); });
} }
@ -241,7 +239,7 @@ const handleDelete = async (row?: NoticeVO) => {
const noticeIds = row?.noticeId || ids.value const noticeIds = row?.noticeId || ids.value
await proxy?.$modal.confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项?'); await proxy?.$modal.confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项?');
await delNotice(noticeIds); await delNotice(noticeIds);
getList(); await getList();
proxy?.$modal.msgSuccess("删除成功"); proxy?.$modal.msgSuccess("删除成功");
} }

View File

@ -140,9 +140,7 @@ import {
updateOssConfig, updateOssConfig,
changeOssConfigStatus changeOssConfigStatus
} from "@/api/system/ossConfig"; } from "@/api/system/ossConfig";
import { ComponentInternalInstance } from "vue";
import { OssConfigForm, OssConfigQuery, OssConfigVO } from "@/api/system/ossConfig/types"; import { OssConfigForm, OssConfigQuery, OssConfigVO } from "@/api/system/ossConfig/types";
import { ElForm } from 'element-plus';
const { proxy } = getCurrentInstance() as ComponentInternalInstance const { proxy } = getCurrentInstance() as ComponentInternalInstance
@ -157,8 +155,8 @@ const single = ref(true);
const multiple = ref(true); const multiple = ref(true);
const total = ref(0); const total = ref(0);
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const ossConfigFormRef = ref(ElForm); const ossConfigFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({ const dialog = reactive<DialogOption>({
visible: false, visible: false,
@ -264,7 +262,7 @@ const cancel = () => {
/** 表单重置 */ /** 表单重置 */
const reset = () => { const reset = () => {
form.value = { ...initFormData }; form.value = { ...initFormData };
ossConfigFormRef.value.resetFields(); ossConfigFormRef.value?.resetFields();
} }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
@ -273,7 +271,7 @@ const handleQuery = () => {
} }
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
handleQuery(); handleQuery();
} }
/** 选择条数 */ /** 选择条数 */
@ -305,7 +303,7 @@ const handleUpdate = (row?: OssConfigVO) => {
} }
/** 提交按钮 */ /** 提交按钮 */
const submitForm = () => { const submitForm = () => {
ossConfigFormRef.value.validate(async (valid: boolean) => { ossConfigFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
buttonLoading.value = true; buttonLoading.value = true;
if (form.value.ossConfigId) { if (form.value.ossConfigId) {

View File

@ -135,9 +135,7 @@
<script setup name="Oss" lang="ts"> <script setup name="Oss" lang="ts">
import { listOss, delOss } from "@/api/system/oss"; import { listOss, delOss } from "@/api/system/oss";
import ImagePreview from "@/components/ImagePreview/index.vue"; import ImagePreview from "@/components/ImagePreview/index.vue";
import { ComponentInternalInstance } from "vue";
import { OssForm, OssQuery, OssVO } from "@/api/system/oss/types"; import { OssForm, OssQuery, OssVO } from "@/api/system/oss/types";
import { DateModelType } from 'element-plus';
const router = useRouter(); const router = useRouter();
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -163,8 +161,8 @@ const dialog = reactive<DialogOption>({
// 默认排序 // 默认排序
const defaultSort = ref({ prop: 'createTime', order: 'ascending' }); const defaultSort = ref({ prop: 'createTime', order: 'ascending' });
const ossFormRef = ref(ElForm); const ossFormRef = ref<ElFormInstance>();
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const initFormData = { const initFormData = {
file: undefined, file: undefined,
@ -217,7 +215,7 @@ function cancel() {
/** 表单重置 */ /** 表单重置 */
function reset() { function reset() {
form.value = { ...initFormData }; form.value = { ...initFormData };
ossFormRef.value.resetFields(); ossFormRef.value?.resetFields();
} }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
function handleQuery() { function handleQuery() {
@ -228,7 +226,7 @@ function handleQuery() {
function resetQuery() { function resetQuery() {
showTable.value = false; showTable.value = false;
daterangeCreateTime.value = ['', '']; daterangeCreateTime.value = ['', ''];
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
queryParams.value.orderByColumn = defaultSort.value.prop; queryParams.value.orderByColumn = defaultSort.value.prop;
queryParams.value.isAsc = defaultSort.value.order; queryParams.value.isAsc = defaultSort.value.order;
handleQuery(); handleQuery();

View File

@ -109,7 +109,6 @@
<script setup name="Post" lang="ts"> <script setup name="Post" lang="ts">
import { listPost, addPost, delPost, getPost, updatePost } from "@/api/system/post"; import { listPost, addPost, delPost, getPost, updatePost } from "@/api/system/post";
import { PostForm, PostQuery, PostVO } from "@/api/system/post/types"; import { PostForm, PostQuery, PostVO } from "@/api/system/post/types";
import { ComponentInternalInstance } from "vue";
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { sys_normal_disable } = toRefs<any>(proxy?.useDict("sys_normal_disable")); const { sys_normal_disable } = toRefs<any>(proxy?.useDict("sys_normal_disable"));
@ -122,8 +121,8 @@ const single = ref(true);
const multiple = ref(true); const multiple = ref(true);
const total = ref(0); const total = ref(0);
const postFormRef = ref(ElForm); const postFormRef = ref<ElFormInstance>();
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({ const dialog = reactive<DialogOption>({
visible: false, visible: false,
@ -173,7 +172,7 @@ const cancel = () => {
/** 表单重置 */ /** 表单重置 */
const reset = () => { const reset = () => {
form.value = {...initFormData}; form.value = {...initFormData};
postFormRef.value.resetFields(); postFormRef.value?.resetFields();
} }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
@ -182,7 +181,7 @@ const handleQuery = () => {
} }
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
handleQuery(); handleQuery();
} }
/** 多选框选中数据 */ /** 多选框选中数据 */
@ -212,12 +211,12 @@ const handleUpdate = (row?: PostVO) => {
} }
/** 提交按钮 */ /** 提交按钮 */
const submitForm = () => { const submitForm = () => {
postFormRef.value.validate(async (valid: boolean) => { postFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
form.value.postId ? await updatePost(form.value) : await addPost(form.value); form.value.postId ? await updatePost(form.value) : await addPost(form.value);
proxy?.$modal.msgSuccess("操作成功"); proxy?.$modal.msgSuccess("操作成功");
dialog.visible = false; dialog.visible = false;
getList(); await getList();
} }
}); });
} }
@ -226,7 +225,7 @@ const handleDelete = async (row?: PostVO) => {
const postIds = row?.postId || ids.value; const postIds = row?.postId || ids.value;
await proxy?.$modal.confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?'); await proxy?.$modal.confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?');
await delPost(postIds); await delPost(postIds);
getList(); await getList();
proxy?.$modal.msgSuccess("删除成功"); proxy?.$modal.msgSuccess("删除成功");
} }
/** 导出按钮操作 */ /** 导出按钮操作 */

View File

@ -58,13 +58,7 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
v-show="total > 0"
:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
<select-user ref="selectRef" :roleId="queryParams.roleId" @ok="handleQuery" /> <select-user ref="selectRef" :roleId="queryParams.roleId" @ok="handleQuery" />
</el-card> </el-card>
</div> </div>
@ -73,10 +67,8 @@
<script setup name="AuthUser" lang="ts"> <script setup name="AuthUser" lang="ts">
import { allocatedUserList, authUserCancel, authUserCancelAll } from "@/api/system/role"; import { allocatedUserList, authUserCancel, authUserCancelAll } from "@/api/system/role";
import { UserQuery } from "@/api/system/user/types"; import { UserQuery } from "@/api/system/user/types";
import { ComponentInternalInstance } from "vue";
import { UserVO } from "@/api/system/user/types"; import { UserVO } from "@/api/system/user/types";
import SelectUser from "./selectUser.vue"; import SelectUser from "./selectUser.vue";
// import { ElForm, ElSelect} from 'element-plus';
const route = useRoute(); const route = useRoute();
@ -90,8 +82,8 @@ const multiple = ref(true);
const total = ref(0); const total = ref(0);
const userIds = ref<Array<string | number>>([]); const userIds = ref<Array<string | number>>([]);
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const selectRef = ref(SelectUser); const selectRef = ref<InstanceType<typeof SelectUser>>();
const queryParams = reactive<UserQuery>({ const queryParams = reactive<UserQuery>({
pageNum: 1, pageNum: 1,
@ -121,7 +113,7 @@ const handleQuery=() => {
} }
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery=() =>{ const resetQuery=() =>{
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
handleQuery(); handleQuery();
} }
// 多选框选中数据 // 多选框选中数据
@ -137,7 +129,7 @@ const openSelectUser = () => {
const cancelAuthUser = async (row: UserVO) => { const cancelAuthUser = async (row: UserVO) => {
await proxy?.$modal.confirm('确认要取消该用户"' + row.userName + '"角色吗?'); await proxy?.$modal.confirm('确认要取消该用户"' + row.userName + '"角色吗?');
await authUserCancel({ userId: row.userId, roleId: queryParams.roleId }); await authUserCancel({ userId: row.userId, roleId: queryParams.roleId });
getList(); await getList();
proxy?.$modal.msgSuccess("取消授权成功"); proxy?.$modal.msgSuccess("取消授权成功");
} }
/** 批量取消授权按钮操作 */ /** 批量取消授权按钮操作 */
@ -146,7 +138,7 @@ const cancelAuthUserAll = async () => {
const uIds = userIds.value.join(","); const uIds = userIds.value.join(",");
await proxy?.$modal.confirm("是否取消选中用户授权数据项?"); await proxy?.$modal.confirm("是否取消选中用户授权数据项?");
await authUserCancelAll({ roleId: roleId, userIds: uIds }); await authUserCancelAll({ roleId: roleId, userIds: uIds });
getList(); await getList();
proxy?.$modal.msgSuccess("取消授权成功"); proxy?.$modal.msgSuccess("取消授权成功");
} }

View File

@ -198,8 +198,6 @@ import { addRole, changeRoleStatus, dataScope, delRole, getRole, listRole, updat
import { roleMenuTreeselect, treeselect as menuTreeselect } from '@/api/system/menu/index'; import { roleMenuTreeselect, treeselect as menuTreeselect } from '@/api/system/menu/index';
import { RoleVO, RoleForm, RoleQuery, DeptTreeOption } from '@/api/system/role/types'; import { RoleVO, RoleForm, RoleQuery, DeptTreeOption } from '@/api/system/role/types';
import { MenuTreeOption, RoleMenuTree } from '@/api/system/menu/types'; import { MenuTreeOption, RoleMenuTree } from '@/api/system/menu/types';
import { ComponentInternalInstance } from 'vue';
import { ElTree, ElForm, DateModelType } from 'element-plus';
const router = useRouter(); const router = useRouter();
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -230,11 +228,11 @@ const dataScopeOptions = ref([
{ value: "5", label: "仅本人数据权限" } { value: "5", label: "仅本人数据权限" }
]) ])
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const roleFormRef = ref(ElForm); const roleFormRef = ref<ElFormInstance>();
const dataScopeRef = ref(ElForm); const dataScopeRef = ref<ElFormInstance>();
const menuRef = ref(ElTree); const menuRef = ref<ElTreeInstance>();
const deptRef = ref(ElTree); const deptRef = ref<ElTreeInstance>();
const initForm: RoleForm = { const initForm: RoleForm = {
roleId: undefined, roleId: undefined,
@ -297,7 +295,7 @@ const handleQuery = () => {
/** 重置 */ /** 重置 */
const resetQuery = () => { const resetQuery = () => {
dateRange.value = ['', ''] dateRange.value = ['', '']
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
handleQuery(); handleQuery();
} }
/**删除按钮操作 */ /**删除按钮操作 */
@ -345,23 +343,25 @@ const getMenuTreeselect = async () => {
menuOptions.value = res.data; menuOptions.value = res.data;
} }
/** 所有部门节点数据 */ /** 所有部门节点数据 */
const getDeptAllCheckedKeys = () => { const getDeptAllCheckedKeys = (): any => {
// 目前被选中的部门节点 // 目前被选中的部门节点
let checkedKeys = deptRef.value.getCheckedKeys(); let checkedKeys = deptRef.value?.getCheckedKeys();
// 半选中的部门节点 // 半选中的部门节点
let halfCheckedKeys = deptRef.value.getHalfCheckedKeys(); let halfCheckedKeys = deptRef.value?.getHalfCheckedKeys();
checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys); if(halfCheckedKeys) {
checkedKeys?.unshift.apply(checkedKeys, halfCheckedKeys);
}
return checkedKeys return checkedKeys
} }
/** 重置新增的表单以及其他数据 */ /** 重置新增的表单以及其他数据 */
const reset = () => { const reset = () => {
menuRef.value.setCheckedKeys([]); menuRef.value?.setCheckedKeys([]);
menuExpand.value = false menuExpand.value = false
menuNodeAll.value = false menuNodeAll.value = false
deptExpand.value = true deptExpand.value = true
deptNodeAll.value = false deptNodeAll.value = false
form.value = { ...initForm }; form.value = { ...initForm };
roleFormRef.value.resetFields(); roleFormRef.value?.resetFields();
} }
@ -381,19 +381,19 @@ const handleUpdate = async (row?: RoleVO) => {
const { data } = await getRole(roleId); const { data } = await getRole(roleId);
dialog.visible = true; dialog.visible = true;
dialog.title = "修改角色"; dialog.title = "修改角色";
nextTick(() => { await nextTick(() => {
reset(); reset();
Object.assign(form.value, data); Object.assign(form.value, data);
form.value.roleSort = Number(form.value.roleSort); form.value.roleSort = Number(form.value.roleSort);
nextTick(async () => { nextTick(async () => {
const res = await roleMenu; const res = await roleMenu;
let checkedKeys = res.checkedKeys; let checkedKeys = res.checkedKeys;
checkedKeys.forEach((v) => { checkedKeys.forEach((v) => {
nextTick(() => { nextTick(() => {
menuRef.value.setChecked(v, true, false); menuRef.value?.setChecked(v, true, false);
}) })
})
}) })
})
}) })
} }
/** 根据角色ID查询菜单树结构 */ /** 根据角色ID查询菜单树结构 */
@ -410,25 +410,29 @@ const getRoleDeptTreeSelect = async (roleId: string | number) => {
return res.data; return res.data;
} }
/** 树权限(展开/折叠)*/ /** 树权限(展开/折叠)*/
const handleCheckedTreeExpand = (value: any, type: string) => { const handleCheckedTreeExpand = (value: boolean, type: string) => {
if (type == "menu") { if (type == "menu") {
let treeList = menuOptions.value; let treeList = menuOptions.value;
for (let i = 0; i < treeList.length; i++) { for (let i = 0; i < treeList.length; i++) {
if (menuRef.value) {
menuRef.value.store.nodesMap[treeList[i].id].expanded = value; menuRef.value.store.nodesMap[treeList[i].id].expanded = value;
}
} }
} else if (type == "dept") { } else if (type == "dept") {
let treeList = deptOptions.value; let treeList = deptOptions.value;
for (let i = 0; i < treeList.length; i++) { for (let i = 0; i < treeList.length; i++) {
deptRef.value.store.nodesMap[treeList[i].id].expanded = value; if (deptRef.value) {
deptRef.value.store.nodesMap[treeList[i].id].expanded = value;
}
} }
} }
} }
/** 树权限(全选/全不选) */ /** 树权限(全选/全不选) */
const handleCheckedTreeNodeAll = (value: any, type: string) => { const handleCheckedTreeNodeAll = (value: any, type: string) => {
if (type == "menu") { if (type == "menu") {
menuRef.value.setCheckedNodes(value ? menuOptions.value : []); menuRef.value?.setCheckedNodes(value ? menuOptions.value as any : []);
} else if (type == "dept") { } else if (type == "dept") {
deptRef.value.setCheckedNodes(value ? deptOptions.value : []); deptRef.value?.setCheckedNodes(value ? deptOptions.value as any : []);
} }
} }
/** 树权限(父子联动) */ /** 树权限(父子联动) */
@ -440,17 +444,19 @@ const handleCheckedTreeConnect = (value: any, type: string) => {
} }
} }
/** 所有菜单节点数据 */ /** 所有菜单节点数据 */
const getMenuAllCheckedKeys = () => { const getMenuAllCheckedKeys = (): any => {
// 目前被选中的菜单节点 // 目前被选中的菜单节点
let checkedKeys = menuRef.value.getCheckedKeys(); let checkedKeys = menuRef.value?.getCheckedKeys();
// 半选中的菜单节点 // 半选中的菜单节点
let halfCheckedKeys = menuRef.value.getHalfCheckedKeys(); let halfCheckedKeys = menuRef.value?.getHalfCheckedKeys();
checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys); if (halfCheckedKeys) {
checkedKeys?.unshift.apply(checkedKeys, halfCheckedKeys);
}
return checkedKeys; return checkedKeys;
} }
/** 提交按钮 */ /** 提交按钮 */
const submitForm = () => { const submitForm = () => {
roleFormRef.value.validate(async (valid: boolean) => { roleFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
form.value.menuIds = getMenuAllCheckedKeys() form.value.menuIds = getMenuAllCheckedKeys()
form.value.roleId ? await updateRole(form.value) : await addRole(form.value); form.value.roleId ? await updateRole(form.value) : await addRole(form.value);
@ -468,7 +474,7 @@ const cancel = () => {
/** 选择角色权限范围触发 */ /** 选择角色权限范围触发 */
const dataScopeSelectChange = (value: string) => { const dataScopeSelectChange = (value: string) => {
if (value !== "2") { if (value !== "2") {
deptRef.value.setCheckedKeys([]) deptRef.value?.setCheckedKeys([])
} }
} }
/** 分配数据权限操作 */ /** 分配数据权限操作 */
@ -478,13 +484,13 @@ const handleDataScope = async (row: RoleVO) => {
Object.assign(form.value, response.data); Object.assign(form.value, response.data);
openDataScope.value = true; openDataScope.value = true;
dialog.title = "分配数据权限"; dialog.title = "分配数据权限";
nextTick(async () => { await nextTick(async () => {
const res = await roleDeptTreeselect; const res = await roleDeptTreeselect;
nextTick(() => { await nextTick(() => {
if (deptRef.value) { if (deptRef.value) {
deptRef.value.setCheckedKeys(res.checkedKeys); deptRef.value.setCheckedKeys(res.checkedKeys);
} }
}) })
}) })
} }
/** 提交按钮(数据权限) */ /** 提交按钮(数据权限) */
@ -499,7 +505,7 @@ const submitDataScope = async () => {
} }
/** 取消按钮(数据权限)*/ /** 取消按钮(数据权限)*/
const cancelDataScope = () => { const cancelDataScope = () => {
dataScopeRef.value.resetFields(); dataScopeRef.value?.resetFields();
form.value = {...initForm}; form.value = {...initForm};
openDataScope.value = false; openDataScope.value = false;
} }

View File

@ -47,8 +47,6 @@
import { authUserSelectAll, unallocatedUserList } from "@/api/system/role"; import { authUserSelectAll, unallocatedUserList } from "@/api/system/role";
import { UserVO } from '@/api/system/user/types'; import { UserVO } from '@/api/system/user/types';
import { UserQuery } from '@/api/system/user/types'; import { UserQuery } from '@/api/system/user/types';
import { ComponentInternalInstance } from 'vue';
import { ElForm, ElTable } from 'element-plus';
const props = defineProps({ const props = defineProps({
@ -73,8 +71,8 @@ const queryParams = reactive<UserQuery>({
phonenumber: undefined phonenumber: undefined
}) })
const tableRef = ref(ElTable); const tableRef = ref<ElTableInstance>();
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const show = () => { const show = () => {
queryParams.roleId = props.roleId; queryParams.roleId = props.roleId;
@ -86,7 +84,8 @@ const show = () => {
* 选择行 * 选择行
*/ */
const clickRow = (row: any) => { const clickRow = (row: any) => {
tableRef.value.toggleRowSelection(row); // ele的bug
tableRef.value?.toggleRowSelection(row);
} }
/** 多选框选中数据 */ /** 多选框选中数据 */
const handleSelectionChange = (selection: UserVO[]) => { const handleSelectionChange = (selection: UserVO[]) => {
@ -106,7 +105,7 @@ const handleQuery = () => {
} }
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
getList(); getList();
} }

View File

@ -145,8 +145,6 @@ import { listTenant, getTenant, delTenant, addTenant, updateTenant, changeTenant
import { selectTenantPackage } from '@/api/system/tenantPackage'; import { selectTenantPackage } from '@/api/system/tenantPackage';
import { TenantForm, TenantQuery, TenantVO } from '@/api/system/tenant/types'; import { TenantForm, TenantQuery, TenantVO } from '@/api/system/tenant/types';
import { TenantPkgVO } from '@/api/system/tenantPackage/types'; import { TenantPkgVO } from '@/api/system/tenantPackage/types';
import { ComponentInternalInstance } from 'vue';
import { ElForm } from 'element-plus';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -160,8 +158,8 @@ const single = ref(true);
const multiple = ref(true); const multiple = ref(true);
const total = ref(0); const total = ref(0);
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const tenantFormRef = ref(ElForm); const tenantFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({ const dialog = reactive<DialogOption>({
visible: false, visible: false,
@ -253,7 +251,7 @@ const cancel = () => {
// 表单重置 // 表单重置
const reset = () => { const reset = () => {
form.value = {...initFormData}; form.value = {...initFormData};
tenantFormRef.value.resetFields(); tenantFormRef.value?.resetFields();
} }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
@ -264,7 +262,7 @@ const handleQuery = () => {
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
handleQuery(); handleQuery();
} }
@ -292,7 +290,7 @@ const handleUpdate = (row?: TenantVO) => {
dialog.title = "修改租户"; dialog.title = "修改租户";
nextTick(async () => { nextTick(async () => {
reset(); reset();
getTenantPackage(); await getTenantPackage();
const _id = row?.id || ids.value[0]; const _id = row?.id || ids.value[0];
const res = await getTenant(_id); const res = await getTenant(_id);
loading.value = false; loading.value = false;
@ -302,7 +300,7 @@ const handleUpdate = (row?: TenantVO) => {
/** 提交按钮 */ /** 提交按钮 */
const submitForm = () => { const submitForm = () => {
tenantFormRef.value.validate(async (valid: boolean) => { tenantFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
buttonLoading.value = true; buttonLoading.value = true;
if (form.value.id) { if (form.value.id) {
@ -323,7 +321,7 @@ const handleDelete = async (row?: TenantVO) => {
await proxy?.$modal.confirm('是否确认删除租户编号为"' + _ids + '"的数据项?') await proxy?.$modal.confirm('是否确认删除租户编号为"' + _ids + '"的数据项?')
loading.value = true; loading.value = true;
await delTenant(_ids).finally(() => loading.value = false); await delTenant(_ids).finally(() => loading.value = false);
getList(); await getList();
proxy?.$modal.msgSuccess("删除成功"); proxy?.$modal.msgSuccess("删除成功");
@ -335,7 +333,7 @@ const handleSyncTenantPackage = async (row: TenantVO) => {
await proxy?.$modal.confirm('是否确认同步租户套餐租户编号为"' + row.tenantId + '"的数据项?'); await proxy?.$modal.confirm('是否确认同步租户套餐租户编号为"' + row.tenantId + '"的数据项?');
loading.value = true; loading.value = true;
await syncTenantPackage(row.tenantId, row.packageId); await syncTenantPackage(row.tenantId, row.packageId);
getList(); await getList();
proxy?.$modal.msgSuccess("同步成功"); proxy?.$modal.msgSuccess("同步成功");
} catch {return} finally { } catch {return} finally {
loading.value = false; loading.value = false;

View File

@ -20,20 +20,20 @@
<template #header> <template #header>
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:tenantPackage:add']">新增</el-button> <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:tenantPackage:add']"> 新增 </el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['system:tenantPackage:edit']" <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['system:tenantPackage:edit']">
>修改</el-button 修改
> </el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:tenantPackage:remove']" <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:tenantPackage:remove']">
>删除</el-button 删除
> </el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['system:tenantPackage:export']">导出</el-button> <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['system:tenantPackage:export']">导出 </el-button>
</el-col> </el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
@ -55,7 +55,7 @@
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:tenantPackage:edit']"></el-button> <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:tenantPackage:edit']"></el-button>
</el-tooltip> </el-tooltip>
<el-tooltip content="删除" placement="top"> <el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:tenantPackage:remove']"> </el-button> <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:tenantPackage:remove']"></el-button>
</el-tooltip> </el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
@ -72,8 +72,8 @@
</el-form-item> </el-form-item>
<el-form-item label="关联菜单"> <el-form-item label="关联菜单">
<el-checkbox v-model="menuExpand" @change="handleCheckedTreeExpand($event, 'menu')">展开/折叠</el-checkbox> <el-checkbox v-model="menuExpand" @change="handleCheckedTreeExpand($event, 'menu')">展开/折叠</el-checkbox>
<el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event, 'menu')">全选/全不选</el-checkbox> <el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event, 'menu')">全选/全不选 </el-checkbox>
<el-checkbox v-model="form.menuCheckStrictly" @change="handleCheckedTreeConnect($event, 'menu')">父子联动</el-checkbox> <el-checkbox v-model="form.menuCheckStrictly" @change="handleCheckedTreeConnect($event, 'menu')">父子联动 </el-checkbox>
<el-tree <el-tree
class="tree-border" class="tree-border"
:data="menuOptions" :data="menuOptions"
@ -100,12 +100,17 @@
</template> </template>
<script setup name="TenantPackage" lang="ts"> <script setup name="TenantPackage" lang="ts">
import { listTenantPackage, getTenantPackage, delTenantPackage, addTenantPackage, updateTenantPackage, changePackageStatus } from "@/api/system/tenantPackage"; import {
listTenantPackage,
getTenantPackage,
delTenantPackage,
addTenantPackage,
updateTenantPackage,
changePackageStatus
} from "@/api/system/tenantPackage";
import { treeselect as menuTreeselect, tenantPackageMenuTreeselect } from "@/api/system/menu"; import { treeselect as menuTreeselect, tenantPackageMenuTreeselect } from "@/api/system/menu";
import { ComponentInternalInstance } from "vue";
import { TenantPkgForm, TenantPkgQuery, TenantPkgVO } from "@/api/system/tenantPackage/types"; import { TenantPkgForm, TenantPkgQuery, TenantPkgVO } from "@/api/system/tenantPackage/types";
import { MenuTreeOption } from "@/api/system/menu/types"; import { MenuTreeOption } from "@/api/system/menu/types";
import { CheckboxValueType, ElTree, ElForm } from 'element-plus';
import to from "await-to-js"; import to from "await-to-js";
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -122,212 +127,216 @@ const menuExpand = ref(false);
const menuNodeAll = ref(false); const menuNodeAll = ref(false);
const menuOptions = ref<MenuTreeOption[]>([]); const menuOptions = ref<MenuTreeOption[]>([]);
const menuTreeRef = ref(ElTree); const menuTreeRef = ref<ElTreeInstance>();
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const tenantPackageFormRef = ref(ElForm); const tenantPackageFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({ const dialog = reactive<DialogOption>({
visible: false, visible: false,
title: '' title: ""
}); });
const initFormData: TenantPkgForm = { const initFormData: TenantPkgForm = {
packageId: undefined, packageId: undefined,
packageName: '', packageName: "",
menuIds: '', menuIds: "",
remark: '', remark: "",
menuCheckStrictly: true menuCheckStrictly: true
}; };
const data = reactive<PageData<TenantPkgForm, TenantPkgQuery>>({ const data = reactive<PageData<TenantPkgForm, TenantPkgQuery>>({
form: {...initFormData}, form: { ...initFormData },
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
packageName: '' packageName: ""
}, },
rules: { rules: {
packageId: [{ required: true, message: "租户套餐id不能为空", trigger: "blur" }], packageId: [{ required: true, message: "租户套餐id不能为空", trigger: "blur" }],
packageName: [{ required: true, message: "套餐名称不能为空", trigger: "blur" }] packageName: [{ required: true, message: "套餐名称不能为空", trigger: "blur" }]
} }
}); });
const { queryParams, form, rules } = toRefs(data); const { queryParams, form, rules } = toRefs(data);
/** 查询菜单树结构 */ /** 查询菜单树结构 */
const getMenuTreeselect = async() => { const getMenuTreeselect = async () => {
const { data } = await menuTreeselect(); const { data } = await menuTreeselect();
menuOptions.value = data; menuOptions.value = data;
} };
// 所有菜单节点数据 // 所有菜单节点数据
const getMenuAllCheckedKeys = () => { const getMenuAllCheckedKeys = (): any => {
// 目前被选中的菜单节点 // 目前被选中的菜单节点
let checkedKeys = menuTreeRef.value.getCheckedKeys(); let checkedKeys = menuTreeRef.value?.getCheckedKeys();
// 半选中的菜单节点 // 半选中的菜单节点
let halfCheckedKeys = menuTreeRef.value.getHalfCheckedKeys(); let halfCheckedKeys = menuTreeRef.value?.getHalfCheckedKeys();
checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys); if (halfCheckedKeys) {
return checkedKeys; checkedKeys?.unshift.apply(checkedKeys, halfCheckedKeys);
} }
return checkedKeys;
};
/** 根据租户套餐ID查询菜单树结构 */ /** 根据租户套餐ID查询菜单树结构 */
const getPackageMenuTreeselect = async(packageId: string | number) => { const getPackageMenuTreeselect = async (packageId: string | number) => {
const res = await tenantPackageMenuTreeselect(packageId); const res = await tenantPackageMenuTreeselect(packageId);
menuOptions.value = res.data.menus; menuOptions.value = res.data.menus;
return Promise.resolve(res); return Promise.resolve(res);
} };
/** 查询租户套餐列表 */ /** 查询租户套餐列表 */
const getList = async () => { const getList = async () => {
loading.value = true; loading.value = true;
const res = await listTenantPackage(queryParams.value); const res = await listTenantPackage(queryParams.value);
tenantPackageList.value = res.rows; tenantPackageList.value = res.rows;
total.value = res.total; total.value = res.total;
loading.value = false; loading.value = false;
} };
// 租户套餐状态修改 // 租户套餐状态修改
const handleStatusChange = async (row: TenantPkgVO) => { const handleStatusChange = async (row: TenantPkgVO) => {
let text = row.status === "0" ? "启用" : "停用"; let text = row.status === "0" ? "启用" : "停用";
const [err] = await to(proxy?.$modal.confirm('确认要"' + text + '""' + row.packageName + '"套餐吗?') as Promise<any>) const [err] = await to(proxy?.$modal.confirm("确认要\"" + text + "\"\"" + row.packageName + "\"套餐吗?") as Promise<any>);
if (err) { if (err) {
row.status = row.status === "0" ? "1" : "0"; row.status = row.status === "0" ? "1" : "0";
} else { } else {
await changePackageStatus(row.packageId, row.status); await changePackageStatus(row.packageId, row.status);
proxy?.$modal.msgSuccess(text + "成功"); proxy?.$modal.msgSuccess(text + "成功");
} }
} };
// 取消按钮 // 取消按钮
const cancel = () => { const cancel = () => {
reset(); reset();
dialog.visible = false; dialog.visible = false;
} };
// 表单重置 // 表单重置
const reset = () => { const reset = () => {
menuTreeRef.value.setCheckedKeys([]); menuTreeRef.value?.setCheckedKeys([]);
menuExpand.value = false; menuExpand.value = false;
menuNodeAll.value = false; menuNodeAll.value = false;
form.value = {...initFormData}; form.value = { ...initFormData };
tenantPackageFormRef.value.resetFields(); tenantPackageFormRef.value?.resetFields();
} };
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
queryParams.value.pageNum = 1; queryParams.value.pageNum = 1;
getList(); getList();
} };
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
handleQuery(); handleQuery();
} };
// 多选框选中数据 // 多选框选中数据
const handleSelectionChange = (selection: TenantPkgVO[]) => { const handleSelectionChange = (selection: TenantPkgVO[]) => {
ids.value = selection.map(item => item.packageId); ids.value = selection.map(item => item.packageId);
single.value = selection.length != 1; single.value = selection.length != 1;
multiple.value = !selection.length; multiple.value = !selection.length;
} };
// 树权限(展开/折叠) // 树权限(展开/折叠)
const handleCheckedTreeExpand = (value: CheckboxValueType, type: string) => { const handleCheckedTreeExpand = (value: CheckboxValueType, type: string) => {
if (type == 'menu') { if (type == "menu") {
let treeList = menuOptions.value; let treeList = menuOptions.value;
for (let i = 0; i < treeList.length; i++) { for (let i = 0; i < treeList.length; i++) {
menuTreeRef.value.store.nodesMap[treeList[i].id].expanded = value; if (menuTreeRef.value) {
} menuTreeRef.value.store.nodesMap[treeList[i].id].expanded = value as boolean;
}
} }
} }
};
// 树权限(全选/全不选) // 树权限(全选/全不选)
const handleCheckedTreeNodeAll = (value: CheckboxValueType, type: string) => { const handleCheckedTreeNodeAll = (value: CheckboxValueType, type: string) => {
if (type == 'menu') { if (type == "menu") {
menuTreeRef.value.setCheckedNodes(value ? menuOptions.value: []); menuTreeRef.value?.setCheckedNodes(value ? menuOptions.value as any : []);
} }
} };
// 树权限(父子联动) // 树权限(父子联动)
const handleCheckedTreeConnect = (value: CheckboxValueType, type: string) => { const handleCheckedTreeConnect = (value: CheckboxValueType, type: string) => {
if (type == 'menu') { if (type == "menu") {
form.value.menuCheckStrictly = value as boolean; form.value.menuCheckStrictly = value as boolean;
} }
} };
/** 新增按钮操作 */ /** 新增按钮操作 */
const handleAdd = () => { const handleAdd = () => {
dialog.visible = true; dialog.visible = true;
dialog.title = "添加租户套餐"; dialog.title = "添加租户套餐";
nextTick(() => { nextTick(() => {
reset(); reset();
getMenuTreeselect(); getMenuTreeselect();
}) });
} };
/** 修改按钮操作 */ /** 修改按钮操作 */
const handleUpdate = (row?: TenantPkgVO) => { const handleUpdate = (row?: TenantPkgVO) => {
loading.value = true loading.value = true;
dialog.visible = true; dialog.visible = true;
dialog.title = "修改租户套餐"; dialog.title = "修改租户套餐";
nextTick(async () => { nextTick(async () => {
reset(); reset();
const _packageId = row?.packageId || ids.value[0]; const _packageId = row?.packageId || ids.value[0];
const packageMenu = getPackageMenuTreeselect(_packageId); const packageMenu = getPackageMenuTreeselect(_packageId);
const response = await getTenantPackage(_packageId); const response = await getTenantPackage(_packageId);
loading.value = false; loading.value = false;
form.value = response.data; form.value = response.data;
nextTick(async () => { await nextTick(async () => {
const res = await packageMenu; const res = await packageMenu;
let checkedKeys = res.data.checkedKeys let checkedKeys = res.data.checkedKeys;
checkedKeys.forEach((v) => { checkedKeys.forEach((v) => {
nextTick(() => { nextTick(() => {
menuTreeRef.value.setChecked(v, true ,false); menuTreeRef.value?.setChecked(v, true, false);
})
})
}); });
}) });
} });
});
};
/** 提交按钮 */ /** 提交按钮 */
const submitForm = () => { const submitForm = () => {
tenantPackageFormRef.value.validate(async (valid: boolean) => { tenantPackageFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
buttonLoading.value = true; buttonLoading.value = true;
form.value.menuIds = getMenuAllCheckedKeys(); form.value.menuIds = getMenuAllCheckedKeys();
if (form.value.packageId != null) { if (form.value.packageId != null) {
await updateTenantPackage(form.value).finally(() => buttonLoading.value = false); await updateTenantPackage(form.value).finally(() => buttonLoading.value = false);
} else { } else {
await addTenantPackage(form.value).finally(() => buttonLoading.value = false); await addTenantPackage(form.value).finally(() => buttonLoading.value = false);
} }
proxy?.$modal.msgSuccess("操作成功"); proxy?.$modal.msgSuccess("操作成功");
dialog.visible = false; dialog.visible = false;
getList(); await getList();
} }
}); });
} };
/** 删除按钮操作 */ /** 删除按钮操作 */
const handleDelete = async (row?: TenantPkgVO) => { const handleDelete = async (row?: TenantPkgVO) => {
const _packageIds = row?.packageId || ids.value; const _packageIds = row?.packageId || ids.value;
await proxy?.$modal.confirm('是否确认删除租户套餐编号为"' + _packageIds + '"的数据项?').finally(() => { await proxy?.$modal.confirm("是否确认删除租户套餐编号为\"" + _packageIds + "\"的数据项?").finally(() => {
loading.value = false; loading.value = false;
}); });
await delTenantPackage(_packageIds); await delTenantPackage(_packageIds);
loading.value = true; loading.value = true;
getList(); await getList();
proxy?.$modal.msgSuccess("删除成功"); proxy?.$modal.msgSuccess("删除成功");
} };
/** 导出按钮操作 */ /** 导出按钮操作 */
const handleExport = () => { const handleExport = () => {
proxy?.download('system/tenantPackage/export', { proxy?.download("system/tenantPackage/export", {
...queryParams.value ...queryParams.value
}, `tenantPackage_${new Date().getTime()}.xlsx`) }, `tenantPackage_${new Date().getTime()}.xlsx`);
} };
onMounted(() => { onMounted(() => {
getList(); getList();
}) });
</script> </script>

View File

@ -55,11 +55,10 @@
</template> </template>
<script setup name="AuthRole" lang="ts"> <script setup name="AuthRole" lang="ts">
import { RoleVO } from '@/api/system/role/types'; import { RoleVO } from "@/api/system/role/types";
import { getAuthRole, updateAuthRole } from '@/api/system/user'; import { getAuthRole, updateAuthRole } from "@/api/system/user";
import { UserForm } from '@/api/system/user/types'; import { UserForm } from "@/api/system/user/types";
import { ElTable } from "element-plus";
import { ComponentInternalInstance } from 'vue';
const route = useRoute(); const route = useRoute();
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -70,58 +69,59 @@ const pageSize = ref(10);
const roleIds = ref<Array<string | number>>([]); const roleIds = ref<Array<string | number>>([]);
const roles = ref<RoleVO[]>([]); const roles = ref<RoleVO[]>([]);
const form = ref<Partial<UserForm>>({ const form = ref<Partial<UserForm>>({
nickName: undefined, nickName: undefined,
userName: '', userName: "",
userId: undefined userId: undefined
}); });
const tableRef = ref(ElTable) const tableRef = ref<ElTableInstance>();
/** 单击选中行数据 */ /** 单击选中行数据 */
const clickRow = (row: RoleVO) => { const clickRow = (row: RoleVO) => {
tableRef.value.toggleRowSelection(row); // ele的方法有问题selected应该为可选参数
tableRef.value?.toggleRowSelection(row);
}; };
/** 多选框选中数据 */ /** 多选框选中数据 */
const handleSelectionChange = (selection: RoleVO[]) => { const handleSelectionChange = (selection: RoleVO[]) => {
roleIds.value = selection.map(item => item.roleId); roleIds.value = selection.map(item => item.roleId);
}; };
/** 保存选中的数据编号 */ /** 保存选中的数据编号 */
const getRowKey = (row: RoleVO): string => { const getRowKey = (row: RoleVO): string => {
return String(row.roleId); return String(row.roleId);
}; };
/** 关闭按钮 */ /** 关闭按钮 */
const close = () => { const close = () => {
const obj = { path: "/system/user" }; const obj = { path: "/system/user" };
proxy?.$tab.closeOpenPage(obj); proxy?.$tab.closeOpenPage(obj);
}; };
/** 提交按钮 */ /** 提交按钮 */
const submitForm = async () => { const submitForm = async () => {
const userId = form.value.userId; const userId = form.value.userId;
const rIds = roleIds.value.join(","); const rIds = roleIds.value.join(",");
await updateAuthRole({ userId: userId as string, roleIds: rIds }) await updateAuthRole({ userId: userId as string, roleIds: rIds });
proxy?.$modal.msgSuccess("授权成功"); proxy?.$modal.msgSuccess("授权成功");
close(); close();
}; };
const getList = async() => { const getList = async () => {
const userId = route.params && route.params.userId; const userId = route.params && route.params.userId;
if (userId) { if (userId) {
loading.value = true; loading.value = true;
const res = await getAuthRole(userId as string); const res = await getAuthRole(userId as string);
Object.assign(form.value, res.data.user) Object.assign(form.value, res.data.user);
Object.assign(roles.value, res.data.roles) Object.assign(roles.value, res.data.roles);
total.value = roles.value.length; total.value = roles.value.length;
await nextTick(() => { await nextTick(() => {
roles.value.forEach(row => { roles.value.forEach(row => {
if (row?.flag) { if (row?.flag) {
tableRef.value.toggleRowSelection(row); tableRef.value?.toggleRowSelection(row, true);
} }
}); });
}); });
loading.value = false; loading.value = false;
} }
} };
onMounted(() => { onMounted(() => {
getList(); getList();
}) });
</script> </script>

View File

@ -297,30 +297,19 @@
</template> </template>
<script setup name="User" lang="ts"> <script setup name="User" lang="ts">
import { import api from "@/api/system/user"
changeUserStatus,
listUser,
resetUserPwd,
delUser,
getUser,
updateUser,
addUser,
deptTreeSelect
} from "@/api/system/user"
import { UserForm, UserQuery, UserVO } from '@/api/system/user/types'; import { UserForm, UserQuery, UserVO } from '@/api/system/user/types';
import { ComponentInternalInstance } from "vue";
import { getToken } from "@/utils/auth"; import { getToken } from "@/utils/auth";
import { treeselect } from "@/api/system/dept"; import { treeselect } from "@/api/system/dept";
import { DeptVO } from "@/api/system/dept/types"; import { DeptVO } from "@/api/system/dept/types";
import { RoleVO } from "@/api/system/role/types"; import { RoleVO } from "@/api/system/role/types";
import { PostVO } from "@/api/system/post/types"; import { PostVO } from "@/api/system/post/types";
import { DateModelType, ElTree, ElUpload, UploadFile, ElForm } from 'element-plus';
import { to } from "await-to-js"; import { to } from "await-to-js";
const router = useRouter(); const router = useRouter();
const { proxy } = getCurrentInstance() as ComponentInternalInstance const { proxy } = getCurrentInstance() as ComponentInternalInstance
const { sys_normal_disable, sys_user_sex } = toRefs<any>(proxy?.useDict('sys_normal_disable', 'sys_user_sex')); const { sys_normal_disable, sys_user_sex } = toRefs<any>(proxy?.useDict('sys_normal_disable', 'sys_user_sex'));
const userList = ref<UserVO[]>(); const userList = ref<UserVO[]>();
const loading = ref(true); const loading = ref(true);
const showSearch = ref(true) const showSearch = ref(true)
@ -361,10 +350,10 @@ const columns = ref<FieldOption[]>([
]) ])
const deptTreeRef = ref(ElTree); const deptTreeRef = ref<ElTreeInstance>();
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const userFormRef = ref(ElForm); const userFormRef = ref<ElFormInstance>();
const uploadRef = ref(ElUpload); const uploadRef = ref<ElUploadInstance>();
const dialog = reactive<DialogOption>({ const dialog = reactive<DialogOption>({
visible: false, visible: false,
@ -413,7 +402,7 @@ const filterNode = (value: string, data: any) => {
} }
/** 根据名称筛选部门树 */ /** 根据名称筛选部门树 */
watchEffect( watchEffect(
() => {deptTreeRef.value.filter(deptName.value);}, () => {deptTreeRef.value?.filter(deptName.value);},
{ {
flush: 'post' // watchEffect会在DOM挂载或者更新之前就会触发此属性控制在DOM元素更新后运行 flush: 'post' // watchEffect会在DOM挂载或者更新之前就会触发此属性控制在DOM元素更新后运行
} }
@ -421,14 +410,14 @@ watchEffect(
/** 查询部门下拉树结构 */ /** 查询部门下拉树结构 */
const getTreeSelect = async () => { const getTreeSelect = async () => {
const res = await deptTreeSelect(); const res = await api.deptTreeSelect();
deptOptions.value = res.data; deptOptions.value = res.data;
}; };
/** 查询用户列表 */ /** 查询用户列表 */
const getList = async () => { const getList = async () => {
loading.value = true; loading.value = true;
const res = await listUser(proxy?.addDateRange(queryParams.value, dateRange.value)); const res = await api.listUser(proxy?.addDateRange(queryParams.value, dateRange.value));
loading.value = false; loading.value = false;
userList.value = res.rows; userList.value = res.rows;
total.value = res.total; total.value = res.total;
@ -449,10 +438,10 @@ const handleQuery = () => {
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
dateRange.value = ['',''] dateRange.value = ['','']
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
queryParams.value.pageNum = 1; queryParams.value.pageNum = 1;
queryParams.value.deptId = undefined; queryParams.value.deptId = undefined;
deptTreeRef.value.setCurrentKey(null); deptTreeRef.value?.setCurrentKey(undefined);
handleQuery(); handleQuery();
} }
@ -461,7 +450,7 @@ const handleDelete = async (row?: UserVO) => {
const userIds = row?.userId || ids.value; const userIds = row?.userId || ids.value;
const [err] = await to(proxy?.$modal.confirm('是否确认删除用户编号为"' + userIds + '"的数据项?') as any); const [err] = await to(proxy?.$modal.confirm('是否确认删除用户编号为"' + userIds + '"的数据项?') as any);
if (!err) { if (!err) {
await delUser(userIds); await api.delUser(userIds);
await getList(); await getList();
proxy?.$modal.msgSuccess("删除成功"); proxy?.$modal.msgSuccess("删除成功");
} }
@ -472,7 +461,7 @@ const handleStatusChange = async (row: UserVO) => {
let text = row.status === "0" ? "启用" : "停用" let text = row.status === "0" ? "启用" : "停用"
try { try {
await proxy?.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?'); await proxy?.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?');
await changeUserStatus(row.userId, row.status); await api.changeUserStatus(row.userId, row.status);
proxy?.$modal.msgSuccess(text + "成功"); proxy?.$modal.msgSuccess(text + "成功");
} catch (err) { } catch (err) {
row.status = row.status === "0" ? "1" : "0"; row.status = row.status === "0" ? "1" : "0";
@ -494,7 +483,7 @@ const handleResetPwd = async (row: UserVO) => {
inputErrorMessage: "用户密码长度必须介于 5 和 20 之间", inputErrorMessage: "用户密码长度必须介于 5 和 20 之间",
})) }))
if (!err) { if (!err) {
await resetUserPwd(row.userId, res.value); await api.resetUserPwd(row.userId, res.value);
proxy?.$modal.msgSuccess("修改成功,新密码是:" + res.value); proxy?.$modal.msgSuccess("修改成功,新密码是:" + res.value);
} }
} }
@ -531,14 +520,14 @@ const handleFileUploadProgress = () => {
const handleFileSuccess = (response: any, file: UploadFile) => { const handleFileSuccess = (response: any, file: UploadFile) => {
upload.open = false; upload.open = false;
upload.isUploading = false; upload.isUploading = false;
uploadRef.value.handleRemove(file); uploadRef.value?.handleRemove(file);
ElMessageBox.alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true }); ElMessageBox.alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
getList(); getList();
} }
/** 提交上传文件 */ /** 提交上传文件 */
function submitFileForm() { function submitFileForm() {
uploadRef.value.submit(); uploadRef.value?.submit();
} }
/** 初始化部门数据 */ /** 初始化部门数据 */
@ -554,7 +543,7 @@ const initTreeData = async () => {
/** 重置操作表单 */ /** 重置操作表单 */
const reset = () => { const reset = () => {
form.value = { ...initFormData }; form.value = { ...initFormData };
userFormRef.value.resetFields(); userFormRef.value?.resetFields();
} }
/** 取消按钮 */ /** 取消按钮 */
const cancel = () => { const cancel = () => {
@ -569,7 +558,7 @@ const handleAdd = () => {
nextTick(async () => { nextTick(async () => {
reset(); reset();
await initTreeData(); await initTreeData();
const { data } = await getUser(); const { data } = await api.getUser();
postOptions.value = data.posts; postOptions.value = data.posts;
roleOptions.value = data.roles; roleOptions.value = data.roles;
form.value.password = initPassword.value; form.value.password = initPassword.value;
@ -583,7 +572,7 @@ const handleUpdate = (row?: UserForm) => {
reset(); reset();
await initTreeData(); await initTreeData();
const userId = row?.userId || ids.value[0] const userId = row?.userId || ids.value[0]
const { data } = await getUser(userId) const { data } = await api.getUser(userId)
Object.assign(form.value, data.user); Object.assign(form.value, data.user);
postOptions.value = data.posts; postOptions.value = data.posts;
roleOptions.value = data.roles; roleOptions.value = data.roles;
@ -596,9 +585,9 @@ const handleUpdate = (row?: UserForm) => {
/** 提交按钮 */ /** 提交按钮 */
const submitForm = () => { const submitForm = () => {
userFormRef.value.validate(async (valid: boolean) => { userFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
form.value.userId ? await updateUser(form.value) : await addUser(form.value); form.value.userId ? await api.updateUser(form.value) : await api.addUser(form.value);
proxy?.$modal.msgSuccess("操作成功"); proxy?.$modal.msgSuccess("操作成功");
dialog.visible = false; dialog.visible = false;
await getList(); await getList();
@ -619,8 +608,8 @@ const closeDialog = () => {
* 重置表单 * 重置表单
*/ */
const resetForm = () => { const resetForm = () => {
userFormRef.value.resetFields(); userFormRef.value?.resetFields();
userFormRef.value.clearValidate(); userFormRef.value?.clearValidate();
form.value.id = undefined; form.value.id = undefined;
form.value.status = '1'; form.value.status = '1';

View File

@ -69,7 +69,7 @@ import resetPwd from "./resetPwd.vue";
import { getUserProfile } from "@/api/system/user"; import { getUserProfile } from "@/api/system/user";
const activeTab = ref("userinfo"); const activeTab = ref("userinfo");
const state = ref<{ user: any; roleGroup: string; postGroup: string}>({ const state = ref<Record<string, any>>({
user: {}, user: {},
roleGroup: '', roleGroup: '',
postGroup: '' postGroup: ''

View File

@ -17,46 +17,50 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { updateUserPwd } from '@/api/system/user'; import { updateUserPwd } from "@/api/system/user";
import { ComponentInternalInstance } from 'vue'; import type { ResetPwdForm } from "@/api/system/user/types";
import { ResetPwdForm } from '@/api/system/user/types'
import { ElForm } from 'element-plus';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const pwdRef = ref<ElFormInstance>();
const pwdRef = ref(ElForm);
const user = ref<ResetPwdForm>({ const user = ref<ResetPwdForm>({
oldPassword: '', oldPassword: "",
newPassword: '', newPassword: "",
confirmPassword: '' confirmPassword: ""
}); });
const equalToPassword = (rule: any, value: string, callback: any) => { const equalToPassword = (rule: any, value: string, callback: any) => {
if (user.value.newPassword !== value) { if (user.value.newPassword !== value) {
callback(new Error("两次输入的密码不一致")); callback(new Error("两次输入的密码不一致"));
} else { } else {
callback(); callback();
} }
}; };
const rules = ref({ const rules = ref({
oldPassword: [{ required: true, message: "旧密码不能为空", trigger: "blur" }], oldPassword: [{ required: true, message: "旧密码不能为空", trigger: "blur" }],
newPassword: [{ required: true, message: "新密码不能为空", trigger: "blur" }, { min: 6, max: 20, message: "长度在 6 到 20 个字符", trigger: "blur" }], newPassword: [{ required: true, message: "新密码不能为空", trigger: "blur" }, {
confirmPassword: [{ required: true, message: "确认密码不能为空", trigger: "blur" }, { required: true, validator: equalToPassword, trigger: "blur" }] min: 6,
max: 20,
message: "长度在 6 到 20 个字符",
trigger: "blur"
}],
confirmPassword: [{ required: true, message: "确认密码不能为空", trigger: "blur" }, {
required: true,
validator: equalToPassword,
trigger: "blur"
}]
}); });
/** 提交按钮 */ /** 提交按钮 */
const submit = () => { const submit = () => {
pwdRef.value.validate(async (valid: boolean) => { pwdRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
await updateUserPwd(user.value.oldPassword, user.value.newPassword) await updateUserPwd(user.value.oldPassword, user.value.newPassword);
proxy?.$modal.msgSuccess("修改成功"); proxy?.$modal.msgSuccess("修改成功");
} }
}); });
}; };
/** 关闭按钮 */ /** 关闭按钮 */
const close = () => { const close = () => {
proxy?.$tab.closePage(); proxy?.$tab.closePage();
}; };
</script> </script>

View File

@ -29,7 +29,9 @@
<el-upload action="#" :http-request="requestUpload" :show-file-list="false" :before-upload="beforeUpload"> <el-upload action="#" :http-request="requestUpload" :show-file-list="false" :before-upload="beforeUpload">
<el-button> <el-button>
选择 选择
<el-icon class="el-icon--right"><Upload /></el-icon> <el-icon class="el-icon--right">
<Upload />
</el-icon>
</el-button> </el-button>
</el-upload> </el-upload>
</el-col> </el-col>
@ -58,18 +60,17 @@ import "vue-cropper/dist/index.css";
import { VueCropper } from "vue-cropper"; import { VueCropper } from "vue-cropper";
import { uploadAvatar } from "@/api/system/user"; import { uploadAvatar } from "@/api/system/user";
import useUserStore from "@/store/modules/user"; import useUserStore from "@/store/modules/user";
import { ComponentInternalInstance } from "vue";
interface Options { interface Options {
img: string | ArrayBuffer | null // 裁剪图片的地址 img: string | ArrayBuffer | null; // 裁剪图片的地址
autoCrop: boolean // 是否默认生成截图框 autoCrop: boolean; // 是否默认生成截图框
autoCropWidth: number // 默认生成截图框宽度 autoCropWidth: number; // 默认生成截图框宽度
autoCropHeight: number // 默认生成截图框高度 autoCropHeight: number; // 默认生成截图框高度
fixedBox: boolean // 固定截图框大小 不允许改变 fixedBox: boolean; // 固定截图框大小 不允许改变
fileName: string fileName: string;
previews: any // 预览数据 previews: any; // 预览数据
outputType: string outputType: string;
visible: boolean visible: boolean;
} }
@ -83,75 +84,76 @@ const title = ref("修改头像");
const cropper = ref<any>({}); const cropper = ref<any>({});
//图片裁剪数据 //图片裁剪数据
const options = reactive<Options>({ const options = reactive<Options>({
img: userStore.avatar, img: userStore.avatar,
autoCrop: true, autoCrop: true,
autoCropWidth: 200, autoCropWidth: 200,
autoCropHeight: 200, autoCropHeight: 200,
fixedBox: true, fixedBox: true,
outputType: "png", outputType: "png",
fileName: '', fileName: "",
previews: {}, previews: {},
visible: false visible: false
}); });
/** 编辑头像 */ /** 编辑头像 */
const editCropper = () => { const editCropper = () => {
open.value = true; open.value = true;
} };
/** 打开弹出层结束时的回调 */ /** 打开弹出层结束时的回调 */
const modalOpened = () => { const modalOpened = () => {
visible.value = true; visible.value = true;
} };
/** 覆盖默认上传行为 */ /** 覆盖默认上传行为 */
const requestUpload = (): any => {} const requestUpload = (): any => {
};
/** 向左旋转 */ /** 向左旋转 */
const rotateLeft = () => { const rotateLeft = () => {
cropper.value.rotateLeft(); cropper.value.rotateLeft();
} };
/** 向右旋转 */ /** 向右旋转 */
const rotateRight = () => { const rotateRight = () => {
cropper.value.rotateRight(); cropper.value.rotateRight();
} };
/** 图片缩放 */ /** 图片缩放 */
const changeScale = (num: number) => { const changeScale = (num: number) => {
num = num || 1; num = num || 1;
cropper.value.changeScale(num); cropper.value.changeScale(num);
} };
/** 上传预处理 */ /** 上传预处理 */
const beforeUpload = (file: any) => { const beforeUpload = (file: any) => {
if (file.type.indexOf("image/") == -1) { if (file.type.indexOf("image/") == -1) {
proxy?.$modal.msgError("文件格式错误,请上传图片类型,如JPGPNG后缀的文件。"); proxy?.$modal.msgError("文件格式错误,请上传图片类型,如JPGPNG后缀的文件。");
} else { } else {
const reader = new FileReader(); const reader = new FileReader();
reader.readAsDataURL(file); reader.readAsDataURL(file);
reader.onload = () => { reader.onload = () => {
options.img = reader.result; options.img = reader.result;
options.fileName = file.name; options.fileName = file.name;
}; };
} }
} };
/** 上传图片 */ /** 上传图片 */
const uploadImg = async () => { const uploadImg = async () => {
cropper.value.getCropBlob(async (data: any) => { cropper.value.getCropBlob(async (data: any) => {
let formData = new FormData(); let formData = new FormData();
formData.append("avatarfile", data, options.fileName); formData.append("avatarfile", data, options.fileName);
const res = await uploadAvatar(formData); const res = await uploadAvatar(formData);
open.value = false; open.value = false;
options.img = res.data.imgUrl; options.img = res.data.imgUrl;
userStore.avatar = options.img as string; userStore.avatar = options.img as string
proxy?.$modal.msgSuccess("修改成功"); proxy?.$modal.msgSuccess("修改成功");
visible.value = false; visible.value = false;
}); });
} };
/** 实时预览 */ /** 实时预览 */
const realTime = (data: any) => { const realTime = (data: any) => {
options.previews = data; options.previews = data;
} };
/** 关闭窗口 */ /** 关闭窗口 */
const closeDialog = () => { const closeDialog = () => {
options.img = userStore.avatar; options.img = userStore.avatar;
options.visible = false; options.visible = false;
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -24,40 +24,42 @@
<script setup lang="ts"> <script setup lang="ts">
import { updateUserProfile } from "@/api/system/user"; import { updateUserProfile } from "@/api/system/user";
import { FormRules } from "element-plus";
import { ComponentInternalInstance } from "vue";
import { PropType } from "vue";
import { ElForm } from "element-plus";
const props = defineProps({ const props = defineProps({
user: { user: {
type: Object as PropType<any>, type: Object as PropType<any>,
} required: true
}
}); });
const userForm = computed(() => props.user); const userForm = computed(() => props.user);
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const userRef = ref<ElFormInstance>();
const userRef = ref(ElForm); const rules = ref<ElFormRules>({
nickName: [{ required: true, message: "用户昵称不能为空", trigger: "blur" }],
const rules = ref<FormRules>({ email: [{ required: true, message: "邮箱地址不能为空", trigger: "blur" }, {
nickName: [{ required: true, message: "用户昵称不能为空", trigger: "blur" }], type: "email",
email: [{ required: true, message: "邮箱地址不能为空", trigger: "blur" }, { type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }], message: "请输入正确的邮箱地址",
phonenumber: [{ required: true, message: "手机号码不能为空", trigger: "blur" }, { pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }], trigger: ["blur", "change"]
}],
phonenumber: [{
required: true,
message: "手机号码不能为空",
trigger: "blur"
}, { pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }]
}); });
/** 提交按钮 */ /** 提交按钮 */
const submit = () => { const submit = () => {
userRef.value.validate(async (valid: boolean) => { userRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
await updateUserProfile(props.user) await updateUserProfile(props.user);
proxy?.$modal.msgSuccess("修改成功"); proxy?.$modal.msgSuccess("修改成功");
} }
}); });
}; };
/** 关闭按钮 */ /** 关闭按钮 */
const close = () => { const close = () => {
proxy?.$tab.closePage(); proxy?.$tab.closePage();
}; };
</script> </script>

View File

@ -31,15 +31,10 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { PropType } from 'vue'; import { propTypes } from "@/utils/propTypes";
const prop = defineProps({ const prop = defineProps({
info: { info: propTypes.any.def({})
type: Object as PropType<any>,
default: () => {
return {};
}
}
}); });
const infoForm = computed(() => prop.info) const infoForm = computed(() => prop.info)

View File

@ -117,9 +117,8 @@ import { getGenTable, updateGenTable } from '@/api/tool/gen';
import { DbColumnVO, DbTableVO } from '@/api/tool/gen/types'; import { DbColumnVO, DbTableVO } from '@/api/tool/gen/types';
import { optionselect as getDictOptionselect } from '@/api/system/dict/type'; import { optionselect as getDictOptionselect } from '@/api/system/dict/type';
import { DictTypeVO } from '@/api/system/dict/type/types'; import { DictTypeVO } from '@/api/system/dict/type/types';
import basicInfoForm from './basicInfoForm.vue'; import BasicInfoForm from './basicInfoForm.vue';
import genInfoForm from "./genInfoForm.vue"; import GenInfoForm from "./genInfoForm.vue";
import { ComponentInternalInstance } from "vue";
const route = useRoute(); const route = useRoute();
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -131,8 +130,8 @@ const columns = ref<DbColumnVO[]>([]);
const dictOptions = ref<DictTypeVO[]>([]); const dictOptions = ref<DictTypeVO[]>([]);
const info = ref<Partial<DbTableVO>>({}); const info = ref<Partial<DbTableVO>>({});
const basicInfo = ref(basicInfoForm); const basicInfo = ref<InstanceType<typeof BasicInfoForm>>();
const genInfo = ref(genInfoForm); const genInfo = ref<InstanceType<typeof GenInfoForm>>();
/** 提交按钮 */ /** 提交按钮 */
const submitForm = () => { const submitForm = () => {

View File

@ -223,7 +223,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { listMenu } from '@/api/system/menu'; import { listMenu } from '@/api/system/menu';
import { ComponentInternalInstance, PropType } from 'vue'; import { propTypes } from "@/utils/propTypes";
interface MenuOptionsType { interface MenuOptionsType {
menuId: number | string; menuId: number | string;
@ -236,14 +236,8 @@ const menuOptions = ref<Array<MenuOptionsType>>([]);
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const props = defineProps({ const props = defineProps({
info: { info: propTypes.any.def(null),
type: Object as PropType<any>, tables: propTypes.any.def(null)
default: null
},
tables: {
type: Array as PropType<any[]>,
default: null
}
}); });
const infoForm = computed(() => props.info); const infoForm = computed(() => props.info);
@ -268,7 +262,7 @@ const tplSelectChange = (value: string) => {
} }
} }
const setSubTableColumns = (value: string) => { const setSubTableColumns = (value: string) => {
table.value.forEach(item => { table.value.forEach((item: any) => {
const name = item.tableName; const name = item.tableName;
if (value === name) { if (value === name) {
subColumns.value = item.columns; subColumns.value = item.columns;

View File

@ -3,11 +3,11 @@
<el-dialog title="导入表" v-model="visible" width="1100px" top="5vh" append-to-body> <el-dialog title="导入表" v-model="visible" width="1100px" top="5vh" append-to-body>
<el-form :model="queryParams" ref="queryFormRef" :inline="true"> <el-form :model="queryParams" ref="queryFormRef" :inline="true">
<el-form-item label="数据源" prop="dataName"> <el-form-item label="数据源" prop="dataName">
<el-select v-model="queryParams.dataName" filterable placeholder="请选择/输入数据源名称" style="width: 200px"> <el-select v-model="queryParams.dataName" filterable placeholder="请选择/输入数据源名称" style="width: 200px">
<el-option v-for="item in dataNameList" :key="item" :label="item" :value="item"> </el-option> <el-option v-for="item in dataNameList" :key="item" :label="item" :value="item"> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="表名称" prop="tableName"> <el-form-item label="表名称" prop="tableName">
<el-input v-model="queryParams.tableName" placeholder="请输入表名称" clearable @keyup.enter="handleQuery" /> <el-input v-model="queryParams.tableName" placeholder="请输入表名称" clearable @keyup.enter="handleQuery" />
</el-form-item> </el-form-item>
<el-form-item label="表描述" prop="tableComment"> <el-form-item label="表描述" prop="tableComment">
@ -40,8 +40,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { listDbTable, importTable, getDataNames } from '@/api/tool/gen'; import { listDbTable, importTable, getDataNames } from '@/api/tool/gen';
import { DbTableQuery, DbTableVO } from '@/api/tool/gen/types'; import { DbTableQuery, DbTableVO } from '@/api/tool/gen/types';
import { ComponentInternalInstance } from 'vue';
import { ElTable, ElForm } from 'element-plus';
const total = ref(0); const total = ref(0);
const visible = ref(false); const visible = ref(false);
@ -49,8 +47,8 @@ const tables = ref<Array<string>>([]);
const dbTableList = ref<Array<DbTableVO>>([]); const dbTableList = ref<Array<DbTableVO>>([]);
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const tableRef = ref(ElTable); const tableRef = ref<ElTableInstance>();
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const queryParams = reactive<DbTableQuery>({ const queryParams = reactive<DbTableQuery>({
pageNum: 1, pageNum: 1,
@ -76,7 +74,8 @@ const show = (dataName: string) => {
} }
/** 单击选择行 */ /** 单击选择行 */
const clickRow = (row: DbTableVO) => { const clickRow = (row: DbTableVO) => {
tableRef.value.toggleRowSelection(row); // ele bug
tableRef.value?.toggleRowSelection(row);
} }
/** 多选框选中数据 */ /** 多选框选中数据 */
const handleSelectionChange = (selection: DbTableVO[]) => { const handleSelectionChange = (selection: DbTableVO[]) => {
@ -95,7 +94,7 @@ const handleQuery = () => {
} }
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
handleQuery(); handleQuery();
} }
/** 导入按钮操作 */ /** 导入按钮操作 */

View File

@ -116,9 +116,7 @@
import { listTable, previewTable, delTable, genCode, synchDb, getDataNames } from '@/api/tool/gen'; import { listTable, previewTable, delTable, genCode, synchDb, getDataNames } from '@/api/tool/gen';
import { TableQuery, TableVO } from '@/api/tool/gen/types'; import { TableQuery, TableVO } from '@/api/tool/gen/types';
import router from '@/router'; import router from '@/router';
import importTable from './importTable.vue'; import ImportTable from './importTable.vue';
import { ComponentInternalInstance } from 'vue';
import { ElForm, DateModelType } from 'element-plus';
const route = useRoute(); const route = useRoute();
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -134,8 +132,8 @@ const dateRange = ref<[DateModelType, DateModelType]>(['', '']);
const uniqueId = ref(""); const uniqueId = ref("");
const dataNameList = ref<Array<string>>([]); const dataNameList = ref<Array<string>>([]);
const queryFormRef = ref(ElForm); const queryFormRef = ref<ElFormInstance>();
const importRef = ref(importTable); const importRef = ref<InstanceType<typeof ImportTable>>();
const queryParams = ref<TableQuery>({ const queryParams = ref<TableQuery>({
pageNum: 1, pageNum: 1,
@ -160,7 +158,7 @@ onActivated(() => {
uniqueId.value = time as string; uniqueId.value = time as string;
queryParams.value.pageNum = Number(route.query.pageNum); queryParams.value.pageNum = Number(route.query.pageNum);
dateRange.value = ['', '']; dateRange.value = ['', ''];
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
getList(); getList();
} }
}) })
@ -212,7 +210,7 @@ const openImportTable = () => {
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
dateRange.value = ['', '']; dateRange.value = ['', ''];
queryFormRef.value.resetFields(); queryFormRef.value?.resetFields();
handleQuery(); handleQuery();
} }
/** 预览按钮 */ /** 预览按钮 */