This commit is contained in:
ailanyin
2023-06-12 16:03:09 +08:00
parent 830e2e9054
commit 2f1a48b088
9 changed files with 803 additions and 715 deletions

View File

@ -1,5 +1,13 @@
<script setup> <script setup>
import {nextTick, onMounted, onUnmounted, ref, toRefs, watch, watchEffect,} from "vue"; import {
nextTick,
onMounted,
onUnmounted,
ref,
toRefs,
watch,
watchEffect,
} from "vue";
import InfiniteLoading from "v3-infinite-loading"; import InfiniteLoading from "v3-infinite-loading";
import "v3-infinite-loading/lib/style.css"; import "v3-infinite-loading/lib/style.css";
import { debounce } from "lodash-es"; //required if you're not going to override default slots import { debounce } from "lodash-es"; //required if you're not going to override default slots
@ -42,7 +50,7 @@ const emit = defineEmits(["update:modelValue", "change", "confirm"]);
const showPopOver = ref(false); const showPopOver = ref(false);
const inputRefWhenShowPop = ref(); const inputRefWhenShowPop = ref();
const inputRefWhenNotShowPop = ref() const inputRefWhenNotShowPop = ref();
const placeholderWhenShowPop = ref(""); const placeholderWhenShowPop = ref("");
const placeholderWhenNotShowPop = ref(""); const placeholderWhenNotShowPop = ref("");
const optionLabelWhenShowPop = ref(""); const optionLabelWhenShowPop = ref("");
@ -86,7 +94,7 @@ const loadMore = async ($state) => {
}; };
const handleInputClick = (event) => { const handleInputClick = (event) => {
event.stopPropagation() event.stopPropagation();
showPopOver.value = true; showPopOver.value = true;
placeholderWhenShowPop.value = optionLabelWhenNotShowPop.value; placeholderWhenShowPop.value = optionLabelWhenNotShowPop.value;
nextTick(() => { nextTick(() => {
@ -152,7 +160,6 @@ watch(modelValue, (value) => {
emit("change", value); emit("change", value);
}); });
/** /**
* 点击空白关闭弹出选项列表 * 点击空白关闭弹出选项列表
* @param event * @param event
@ -173,17 +180,25 @@ onMounted(() => {
page.value++; page.value++;
initOptions(); initOptions();
document.body.addEventListener("click", handleBodyClick); document.body.addEventListener("click", handleBodyClick);
watch(showPopOver, (show) => { watch(
showPopOver,
(show) => {
if (show) { if (show) {
inputRefWhenNotShowPop.value?.input?.parentNode?.removeEventListener('click', handleInputClick) inputRefWhenNotShowPop.value?.input?.parentNode?.removeEventListener(
"click",
handleInputClick
);
} else { } else {
nextTick(() => { nextTick(() => {
inputRefWhenNotShowPop.value?.input?.parentNode?.addEventListener('click', handleInputClick) inputRefWhenNotShowPop.value?.input?.parentNode?.addEventListener(
}) "click",
handleInputClick
);
});
} }
}, {immediate: true}) },
{ immediate: true }
);
}); });
onUnmounted(() => { onUnmounted(() => {

View File

@ -1,36 +1,75 @@
export const sys_normal_disable = [{ export const sys_normal_disable = [
label: "正常", value: "1", elTagType: "success", {
}, { label: "正常",
label: "禁用", value: "0", elTagType: "danger", value: "1",
},]; elTagType: "success",
export const sys_user_gender = [{
label: "男", value: "0",
}, {
label: "女", value: "1",
}, {
label: "未知", value: "2",
},];
export const menu_show_hide = [{
label: "隐藏", value: "0", elTagType: "warning",
}, {
label: "显示", value: "1", elTagType: "success",
},];
export const sys_yes_no = [{
label: "否", value: "N",
}, {
label: "是", value: "Y", elTagType: "danger",
},];
export const database_type_dict = [{
label: "MySQL", value: "MySQL", elTagType: "",
}, {
label: "Oracle", value: "Oracle", elTagType: "",
}, {
label: "PostgreSQL", value: "PostgreSQL", elTagType: "",
}, },
{ {
label: "Microsoft SQL Server", value: "Microsoft SQL Server", elTagType: "", label: "禁用",
}]; value: "0",
elTagType: "danger",
},
];
export const sys_user_gender = [
{
label: "男",
value: "0",
},
{
label: "女",
value: "1",
},
{
label: "未知",
value: "2",
},
];
export const menu_show_hide = [
{
label: "隐藏",
value: "0",
elTagType: "warning",
},
{
label: "显示",
value: "1",
elTagType: "success",
},
];
export const sys_yes_no = [
{
label: "否",
value: "N",
},
{
label: "是",
value: "Y",
elTagType: "danger",
},
];
export const database_type_dict = [
{
label: "MySQL",
value: "MySQL",
elTagType: "",
},
{
label: "Oracle",
value: "Oracle",
elTagType: "",
},
{
label: "PostgreSQL",
value: "PostgreSQL",
elTagType: "",
},
{
label: "Microsoft SQL Server",
value: "Microsoft SQL Server",
elTagType: "",
},
];

View File

@ -78,6 +78,7 @@ const useUserStore = defineStore("user", {
this.roles = []; this.roles = [];
this.permissions = []; this.permissions = [];
this.userInfoRes = null; this.userInfoRes = null;
this.tenant = null;
removeToken(); removeToken();
resolve(); resolve();
}) })

View File

@ -1,5 +1,10 @@
import axios from "axios"; import axios from "axios";
import {ElLoading, ElMessage, ElMessageBox, ElNotification,} from "element-plus"; import {
ElLoading,
ElMessage,
ElMessageBox,
ElNotification,
} from "element-plus";
import { getToken } from "@/utils/auth"; import { getToken } from "@/utils/auth";
import errorCode from "@/utils/errorCode"; import errorCode from "@/utils/errorCode";
import { blobValidate, tansParams } from "@/utils/ruoyi"; import { blobValidate, tansParams } from "@/utils/ruoyi";

View File

@ -231,12 +231,12 @@ const handleTenantConfirm = (option) => {
}; };
watchEffect(() => { watchEffect(() => {
console.log(loginForm.value.tenant) console.log(loginForm.value.tenant);
if (loginForm.value.tenant) { if (loginForm.value.tenant) {
console.log('getcode') console.log("getcode");
getCode(); getCode();
} }
}) });
getCookie(); getCookie();
defaultTenantNamt.value = useUserStore().tempTenantName; defaultTenantNamt.value = useUserStore().tempTenantName;
</script> </script>

View File

@ -13,19 +13,16 @@
<el-form-item> <el-form-item>
<el-button icon="Search" type="primary" @click="handleQuery" <el-button icon="Search" type="primary" @click="handleQuery"
>搜索 >搜索
</el-button </el-button>
>
<el-button icon="Refresh" @click="resetQuery">重置</el-button> <el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table <el-table v-loading="loading" :data="onlineList" style="width: 100%">
v-loading="loading"
:data="onlineList"
style="width: 100%"
>
<el-table-column align="center" label="序号" type="index" width="100"> <el-table-column align="center" label="序号" type="index" width="100">
<template #default="scope"> <template #default="scope">
<span>{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}</span> <span>{{
(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1
}}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
@ -87,8 +84,7 @@
type="primary" type="primary"
@click="handleForceLogout(scope.row)" @click="handleForceLogout(scope.row)"
>强退 >强退
</el-button </el-button>
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -153,8 +149,7 @@ function handleForceLogout(row) {
getList(); getList();
proxy.$modal.msgSuccess("删除成功"); proxy.$modal.msgSuccess("删除成功");
}) })
.catch(() => { .catch(() => {});
});
} }
getList(); getList();

View File

@ -26,8 +26,7 @@
<el-form-item> <el-form-item>
<el-button icon="Search" type="primary" @click="handleQuery" <el-button icon="Search" type="primary" @click="handleQuery"
>搜索 >搜索
</el-button </el-button>
>
<el-button icon="Refresh" @click="resetQuery">重置</el-button> <el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -41,8 +40,7 @@
type="primary" type="primary"
@click="handleAdd" @click="handleAdd"
>新增 >新增
</el-button </el-button>
>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -53,8 +51,7 @@
type="success" type="success"
@click="handleUpdate" @click="handleUpdate"
>修改 >修改
</el-button </el-button>
>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -65,8 +62,7 @@
type="danger" type="danger"
@click="handleDelete" @click="handleDelete"
>删除 >删除
</el-button </el-button>
>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -76,8 +72,7 @@
type="warning" type="warning"
@click="handleExport" @click="handleExport"
>导出 >导出
</el-button </el-button>
>
</el-col> </el-col>
<right-toolbar <right-toolbar
v-model:showSearch="showSearch" v-model:showSearch="showSearch"
@ -120,8 +115,7 @@
type="primary" type="primary"
@click="handleSetting(scope.row)" @click="handleSetting(scope.row)"
>设置 >设置
</el-button </el-button>
>
<el-button <el-button
v-hasPermi="['tenant:edit']" v-hasPermi="['tenant:edit']"
icon="Edit" icon="Edit"
@ -129,8 +123,7 @@
type="primary" type="primary"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
>修改 >修改
</el-button </el-button>
>
<el-button <el-button
v-hasPermi="['tenant:remove']" v-hasPermi="['tenant:remove']"
icon="Delete" icon="Delete"
@ -138,8 +131,7 @@
type="primary" type="primary"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
>删除 >删除
</el-button </el-button>
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -213,8 +205,18 @@
</el-dialog> </el-dialog>
<!-- 添加或修改租户对话框 --> <!-- 添加或修改租户对话框 -->
<el-dialog v-model="showTenantSetting" append-to-body title="租户设置" width="500px"> <el-dialog
<el-form ref="tenantSettingRef" :model="tenantSettingForm" :rules="tenantSettingRules" label-width="130px"> v-model="showTenantSetting"
append-to-body
title="租户设置"
width="500px"
>
<el-form
ref="tenantSettingRef"
:model="tenantSettingForm"
:rules="tenantSettingRules"
label-width="130px"
>
<!--TODO:--> <!--TODO:-->
<el-form-item label="模式"> <el-form-item label="模式">
<el-radio-group v-model="tenantSettingForm.mode"> <el-radio-group v-model="tenantSettingForm.mode">
@ -224,19 +226,41 @@
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<template v-if="tenantSettingForm.mode === '3'"> <template v-if="tenantSettingForm.mode === '3'">
<div v-for="item in tenantSettingForm.datasourceList" :key="`${item.ip}-${item.port}-${item.name}`" <div
class="data-source-item"> v-for="item in tenantSettingForm.datasourceList"
:key="`${item.ip}-${item.port}-${item.name}`"
class="data-source-item"
>
<div class="left"> <div class="left">
<div class="database-type">{{ "MySQL" }}</div> <div class="database-type">{{ "MySQL" }}</div>
<div class="database-url">{{ "127.0.0.1" }} : {{ 3306 }}</div> <div class="database-url">{{ "127.0.0.1" }} : {{ 3306 }}</div>
<div class="database-name">{{ "ry-vue" }}</div> <div class="database-name">{{ "ry-vue" }}</div>
</div> </div>
<div class="right"> <div class="right">
<el-button circle icon="edit" plain size="small" type="primary"></el-button> <el-button
<el-button circle icon="delete" plain size="small" type="danger"></el-button> circle
icon="edit"
plain
size="small"
type="primary"
></el-button>
<el-button
circle
icon="delete"
plain
size="small"
type="danger"
></el-button>
</div> </div>
</div> </div>
<el-button icon="plus" plain size="small" style="margin-top: 18px" type="primary">新增数据源</el-button> <el-button
icon="plus"
plain
size="small"
style="margin-top: 18px"
type="primary"
>新增数据源</el-button
>
<!-- <el-form-item label="数据库类型" prop="type">--> <!-- <el-form-item label="数据库类型" prop="type">-->
<!-- <el-select v-model="tenantSettingForm.host">--> <!-- <el-select v-model="tenantSettingForm.host">-->
<!-- <el-option v-for="option in database_type_dict" :key="option.value" :label="option.label"--> <!-- <el-option v-for="option in database_type_dict" :key="option.value" :label="option.label"-->
@ -262,7 +286,9 @@
</el-form> </el-form>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
<el-button type="primary" @click="submitTenantSetting">确 定</el-button> <el-button type="primary" @click="submitTenantSetting"
>确 定</el-button
>
<el-button @click="cancelSettingTenant"> </el-button> <el-button @click="cancelSettingTenant"> </el-button>
</div> </div>
</template> </template>
@ -271,7 +297,14 @@
</template> </template>
<script name="Tenant" setup> <script name="Tenant" setup>
import {addTenant, delTenant, getSetting, getTenant, listTenant, updateTenant,} from "@/api/tenant/tenant"; import {
addTenant,
delTenant,
getSetting,
getTenant,
listTenant,
updateTenant,
} from "@/api/tenant/tenant";
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
@ -284,9 +317,9 @@ const single = ref(true);
const multiple = ref(true); const multiple = ref(true);
const total = ref(0); const total = ref(0);
const title = ref(""); const title = ref("");
const showTenantSetting = ref(false) /*是否显示租户设置对话框*/ const showTenantSetting = ref(false); /*是否显示租户设置对话框*/
const tenantSettingRef = ref() const tenantSettingRef = ref();
const editDatasourceIndex = ref(-1) const editDatasourceIndex = ref(-1);
const data = reactive({ const data = reactive({
form: {}, form: {},
queryParams: { queryParams: {
@ -323,14 +356,14 @@ const data = reactive({
// } // }
// ], // ],
// mode: '3' // mode: '3'
} },
,
tenantSettingRules: { tenantSettingRules: {
/*TODO:*/ /*TODO:*/
} },
}); });
const {queryParams, form, rules, tenantSettingForm, tenantSettingRules} = toRefs(data); const { queryParams, form, rules, tenantSettingForm, tenantSettingRules } =
toRefs(data);
/** 查询租户列表 */ /** 查询租户列表 */
function getList() { function getList() {
@ -352,9 +385,9 @@ function cancel() {
* 取消租户设置 * 取消租户设置
*/ */
const cancelSettingTenant = () => { const cancelSettingTenant = () => {
showTenantSetting.value = false showTenantSetting.value = false;
resetSettingTenant() resetSettingTenant();
} };
// 表单重置 // 表单重置
function reset() { function reset() {
@ -385,17 +418,19 @@ function reset() {
const resetSettingTenant = () => { const resetSettingTenant = () => {
form.value = { form.value = {
/*TODO:*/ /*TODO:*/
datasourceList: [{ datasourceList: [
{
type: null, type: null,
ip: null, ip: null,
port: null, port: null,
name: null, name: null,
username: null, username: null,
password: null, password: null,
}] },
} ],
tenantSettingRef.value?.resetFields() };
} tenantSettingRef.value?.resetFields();
};
/** 搜索按钮操作 */ /** 搜索按钮操作 */
function handleQuery() { function handleQuery() {
@ -440,12 +475,12 @@ function handleUpdate(row) {
*/ */
const handleSetting = (row) => { const handleSetting = (row) => {
// editDatasourceIndex.value = 0 // editDatasourceIndex.value = 0
resetSettingTenant() resetSettingTenant();
getSetting(row.tenantId).then(resp => { getSetting(row.tenantId).then((resp) => {
tenantSettingForm.value = resp.data tenantSettingForm.value = resp.data;
showTenantSetting.value = true showTenantSetting.value = true;
}) });
} };
/** 提交按钮 */ /** 提交按钮 */
function submitForm() { function submitForm() {
@ -473,8 +508,8 @@ function submitForm() {
*/ */
const submitTenantSetting = () => { const submitTenantSetting = () => {
/*TODO:*/ /*TODO:*/
showTenantSetting.value = false showTenantSetting.value = false;
} };
/** 删除按钮操作 */ /** 删除按钮操作 */
function handleDelete(row) { function handleDelete(row) {
@ -488,8 +523,7 @@ function handleDelete(row) {
getList(); getList();
proxy.$modal.msgSuccess("删除成功"); proxy.$modal.msgSuccess("删除成功");
}) })
.catch(() => { .catch(() => {});
});
} }
/** 导出按钮操作 */ /** 导出按钮操作 */
@ -539,6 +573,5 @@ getList();
display: flex; display: flex;
align-items: center; align-items: center;
} }
} }
</style> </style>