| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <template>
- <div class="sysLdap-container">
- <el-dialog v-model="isShowDialog" :width="800" draggable="">
- <template #header>
- <div style="color: #fff">
- <!--<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>-->
- <span>{{ props.title }}</span>
- </div>
- </template>
- <el-form :model="ruleForm" ref="ruleFormRef" label-width="auto" :rules="rules">
- <el-row :gutter="35">
- <el-form-item v-show="false">
- <el-input v-model="ruleForm.id" />
- </el-form-item>
- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
- <el-form-item label="主机" prop="host">
- <el-input v-model="ruleForm.host" placeholder="请输入主机" maxlength="128" show-word-limit clearable />
-
- </el-form-item>
-
- </el-col>
- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
- <el-form-item label="端口" prop="port">
- <el-input v-model="ruleForm.port" placeholder="请输入端口" maxlength="0" show-word-limit clearable />
-
- </el-form-item>
-
- </el-col>
- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
- <el-form-item label="用户搜索基准" prop="baseDn">
- <el-input v-model="ruleForm.baseDn" placeholder="请输入用户搜索基准" maxlength="128" show-word-limit clearable />
-
- </el-form-item>
-
- </el-col>
- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
- <el-form-item label="用户过滤规则" prop="authFilter">
- <el-input v-model="ruleForm.authFilter" placeholder="请输入用户过滤规则" maxlength="128" show-word-limit clearable />
-
- </el-form-item>
-
- </el-col>
- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
- <el-form-item label="绑定DN" prop="bindDn">
- <el-input v-model="ruleForm.bindDn" placeholder="请输入有域管理权限的账户" maxlength="32" show-word-limit clearable />
-
- </el-form-item>
-
- </el-col>
- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
- <el-form-item label="绑定密码" prop="bindPass">
- <el-input v-model="ruleForm.bindPass" placeholder="请输入有域管理权限的密码" maxlength="512" show-word-limit clearable />
-
- </el-form-item>
-
- </el-col>
- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
- <el-form-item label="Ldap版本" prop="version">
- <el-input v-model="ruleForm.version" placeholder="请输入Ldap版本" maxlength="0" show-word-limit clearable />
-
- </el-form-item>
-
- </el-col>
- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
- <el-form-item label="状态" prop="status">
- <el-switch v-model="ruleForm.status" active-text="是" inactive-text="否" />
-
- </el-form-item>
-
- </el-col>
- </el-row>
- </el-form>
- <template #footer>
- <span class="dialog-footer">
- <el-button @click="cancel">取 消</el-button>
- <el-button type="primary" @click="submit">确 定</el-button>
- </span>
- </template>
- </el-dialog>
- </div>
- </template>
- <style scoped>
- :deep(.el-select),
- :deep(.el-input-number) {
- width: 100%;
- }
- </style>
- <script lang="ts" setup>
- import { ref,onMounted } from "vue";
- import { getDictDataItem as di, getDictDataList as dl } from '/@/utils/dict-utils';
- import { ElMessage } from "element-plus";
- import type { FormRules } from "element-plus";
- import { addSysLdap, updateSysLdap, detailSysLdap } from "../../../../api/system/sysLdap";
- //父级传递来的参数
- var props = defineProps({
- title: {
- type: String,
- default: "",
- },
- });
- //父级传递来的函数,用于回调
- const emit = defineEmits(["reloadTable"]);
- const ruleFormRef = ref();
- const isShowDialog = ref(false);
- const ruleForm = ref<any>({});
- //自行添加其他规则
- const rules = ref<FormRules>({
- host: [{required: true, message: '请输入主机!', trigger: 'blur',},],
- port: [{required: true, message: '请输入端口!', trigger: 'blur',},],
- baseDn: [{required: true, message: '请输入用户搜索基准!', trigger: 'blur',},],
- bindDn: [{required: true, message: '请输入绑定DN!', trigger: 'blur',},],
- bindPass: [{required: true, message: '请输入绑定密码!', trigger: 'blur',},],
- authFilter: [{required: true, message: '请输入用户过滤规则!', trigger: 'blur',},],
- version: [{required: true, message: '请输入Ldap版本!', trigger: 'blur',},],
- });
- // 打开弹窗
- const openDialog = async (row: any) => {
- // ruleForm.value = JSON.parse(JSON.stringify(row));
- // 改用detail获取最新数据来编辑
- let rowData = JSON.parse(JSON.stringify(row));
- if (rowData.id)
- ruleForm.value = (await detailSysLdap(rowData.id)).data.result;
- else
- ruleForm.value = rowData;
- isShowDialog.value = true;
- };
- // 关闭弹窗
- const closeDialog = () => {
- emit("reloadTable");
- isShowDialog.value = false;
- };
- // 取消
- const cancel = () => {
- isShowDialog.value = false;
- };
- // 提交
- const submit = async () => {
- ruleFormRef.value.validate(async (isValid: boolean, fields?: any) => {
- if (isValid) {
- let values = ruleForm.value;
- if (ruleForm.value.id == undefined || ruleForm.value.id == null || ruleForm.value.id == "" || ruleForm.value.id == 0) {
- await addSysLdap(values);
- } else {
- await updateSysLdap(values);
- }
- closeDialog();
- } else {
- ElMessage({
- message: `表单有${Object.keys(fields).length}处验证失败,请修改后再提交`,
- type: "error",
- });
- }
- });
- };
- // 页面加载时
- onMounted(async () => {
- });
- //将属性或者函数暴露给父组件
- defineExpose({ openDialog });
- </script>
|