feat: 细节优化

This commit is contained in:
lbw 2023-03-02 12:59:11 +08:00
parent 41949ba4e3
commit 3c0824b0a3
6 changed files with 177 additions and 175 deletions

View File

@ -80,47 +80,47 @@ export const rule = {
/* 数字 */
number(rule, value, callback) {
validateFn('number', rule, value, callback, '[' + rule.label + ']包含非数字字符')
validateFn('number', rule, value, callback, '包含非数字字符')
},
/* 字母 */
letter(rule, value, callback) {
validateFn('letter', rule, value, callback, '[' + rule.label + ']包含非字母字符')
validateFn('letter', rule, value, callback, '包含非字母字符')
},
/* 字母和数字 */
letterAndNumber(rule, value, callback) {
validateFn('letterAndNumber', rule, value, callback, '[' + rule.label + ']只能输入字母或数字')
validateFn('letterAndNumber', rule, value, callback, '只能输入字母或数字')
},
/* 手机号码 */
mobilePhone(rule, value, callback) {
validateFn('mobilePhone', rule, value, callback, '[' + rule.label + ']手机号码格式有误')
validateFn('mobilePhone', rule, value, callback, '手机号码格式有误')
},
/* 字母开头,仅可包含数字 */
letterStartNumberIncluded(rule, value, callback) {
validateFn('letterStartNumberIncluded', rule, value, callback, '[' + rule.label + ']必须以字母开头,可包含数字')
validateFn('letterStartNumberIncluded', rule, value, callback, '必须以字母开头,可包含数字')
},
/* 禁止中文输入 */
noChinese(rule, value, callback) {
validateFn('noChinese', rule, value, callback, '[' + rule.label + ']不可输入中文字符')
validateFn('noChinese', rule, value, callback, '不可输入中文字符')
},
/* 必须中文输入 */
chinese(rule, value, callback) {
validateFn('chinese', rule, value, callback, '[' + rule.label + ']只能输入中文字符')
validateFn('chinese', rule, value, callback, '只能输入中文字符')
},
/* 电子邮箱 */
email(rule, value, callback) {
validateFn('email', rule, value, callback, '[' + rule.label + ']邮箱格式有误')
validateFn('email', rule, value, callback, '邮箱格式有误')
},
/* URL网址 */
url(rule, value, callback) {
validateFn('url', rule, value, callback, '[' + rule.label + ']URL格式有误')
validateFn('url', rule, value, callback, 'URL格式有误')
},
regExp(rule, value, callback) {
@ -131,7 +131,7 @@ export const rule = {
}
const pattern = eval(rule.regExp)
if (!pattern.test(value)) {
let errTxt = rule.errorMsg || '[' + rule.label + ']invalid value'
let errTxt = rule.errorMsg || 'invalid value'
callback(new Error(errTxt))
} else {
callback()

View File

@ -21,7 +21,7 @@
</el-col>
<el-col :span="12" class="mb20">
<el-form-item :label="$t('sysmenu.name')" prop="name">
<el-input v-model="state.ruleForm.name" clearable placeholder="格式router.xxx"></el-input>
<el-input v-model="state.ruleForm.name" clearable :placeholder="$t('sysmenu.inputNameTip')"></el-input>
</el-form-item>
</el-col>
<el-col :span="12" class="mb20" v-if="state.ruleForm.menuType === '0'">
@ -106,7 +106,7 @@ const state = reactive({
sortOrder: 0,
menuType: '0',
keepAlive: '0',
visible: '0',
visible: '1',
embedded: '0',
},
parentData: [] as any[], //
@ -132,7 +132,7 @@ const getMenuData = () => {
sortOrder: 0,
updateBy: "",
updateTime: "",
visible: "",
visible: "1",
id: '-1', name: '根菜单', children: []
};
menu.children = res.data;

View File

@ -1,7 +1,7 @@
<template>
<el-dialog :title="form.id ? $t('common.editBtn') : $t('common.addBtn')" v-model="visible"
:close-on-click-modal="false" draggable>
<el-form ref="dataFormRef" :model="form" :rules="dataRules" label-width="90px">
<el-dialog :title="form.id ? $t('common.editBtn') : $t('common.addBtn')" v-model="visible" :close-on-click-modal="false"
draggable>
<el-form ref="dataFormRef" :model="form" :rules="dataRules" label-width="90px">
<el-row :gutter="20">
<el-col :span="12" class="mb20">
<el-form-item :label="t('tenant.name')" prop="name">
@ -25,6 +25,18 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="12" class="mb20">
<el-form-item :label="t('tenant.startTime')" prop="startTime">
<el-date-picker v-model="form.startTime" type="date" :placeholder="t('tenant.inputstartTimeTip')"
:value-format="dateTimeStr" />
</el-form-item>
</el-col>
<el-col :span="12" class="mb20">
<el-form-item :label="t('tenant.endTime')" prop="endTime">
<el-date-picker v-model="form.endTime" type="date" :placeholder="t('tenant.inputendTimeTip')"
:value-format="dateTimeStr" />
</el-form-item>
</el-col>
<el-col :span="12" class="mb20">
<el-form-item :label="t('tenant.status')" prop="status">
@ -34,23 +46,12 @@
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12" class="mb20">
<el-form-item :label="t('tenant.startTime')" prop="startTime">
<el-date-picker v-model="form.startTime" type="date" :placeholder="t('tenant.inputstartTimeTip')" :value-format="dateTimeStr" />
</el-form-item>
</el-col>
<el-col :span="12" class="mb20">
<el-form-item :label="t('tenant.endTime')" prop="endTime">
<el-date-picker v-model="form.endTime" type="date" :placeholder="t('tenant.inputendTimeTip')" :value-format="dateTimeStr"/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="visible = false" >{{ $t('common.cancelButtonText') }}</el-button>
<el-button type="primary" @click="onSubmit" >{{ $t('common.confirmButtonText') }}</el-button>
<el-button @click="visible = false">{{ $t('common.cancelButtonText') }}</el-button>
<el-button type="primary" @click="onSubmit">{{ $t('common.confirmButtonText') }}</el-button>
</span>
</template>
</el-dialog>

View File

@ -6,7 +6,7 @@
<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList" ref="queryRef">
<el-form-item :label="$t('systoken.username')" prop="username">
<el-input :placeholder="$t('systoken.inputUsernameTip')"
v-model="state.queryForm.username"></el-input>
v-model="state.queryForm.username"></el-input>
</el-form-item>
<el-form-item>
<el-button @click="getDataList" icon="Search" type="primary">{{ $t('common.queryBtn') }}
@ -17,35 +17,34 @@
</el-row>
<el-row>
<div class="mb8" style="width: 100%">
<el-button :disabled="multiple" @click="handleDelete(selectObjs)" class="ml10" icon="Delete" type="primary"
v-auth="'sys_user_del'">
<el-button :disabled="multiple" @click="handleDelete(selectObjs)" class="ml10" icon="Delete"
type="primary" v-auth="'sys_user_del'">
{{ $t('common.delBtn') }}
</el-button>
<right-toolbar @queryTable="getDataList" class="ml10" style="float: right;margin-right: 20px"
v-model:showSearch="showSearch"></right-toolbar>
v-model:showSearch="showSearch"></right-toolbar>
</div>
</el-row>
<el-table :data="state.dataList" @selection-change="handleSelectionChange" @sort-change="sortChangeHandle"
style="width: 100%" v-loading="state.loading">
<el-table-column align="center" type="selection" width="50"/>
<el-table-column :label="$t('systoken.index')" type="index" width="80"/>
style="width: 100%" v-loading="state.loading">
<el-table-column align="center" type="selection" width="50" />
<el-table-column :label="$t('systoken.index')" type="index" width="80" />
<el-table-column :label="$t('systoken.username')" prop="username" show-overflow-tooltip
width="150"></el-table-column>
width="150"></el-table-column>
<el-table-column :label="$t('systoken.clientId')" prop="clientId" show-overflow-tooltip
width="100"></el-table-column>
width="100"></el-table-column>
<el-table-column :label="$t('systoken.accessToken')" prop="accessToken" show-overflow-tooltip>
<template #default="scope">
<el-button link type="success" v-if="Session.get('token') === scope.row.accessToken">
<el-button link type="success" v-if="filterOwnToken(scope.row)">
{{ scope.row.accessToken }}
</el-button>
</template>
</el-table-column>
<el-table-column :label="$t('systoken.expiresAt')" prop="expiresAt"
show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('systoken.expiresAt')" prop="expiresAt" show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('common.action')" width="100">
<template #default="scope">
<el-button @click="handleDelete([scope.row.accessToken])" size="small" text type="primary"
v-auth="'sys_user_del'">
v-auth="'sys_user_del'">
{{ $t('common.delBtn') }}
</el-button>
</template>
@ -59,65 +58,66 @@
</template>
<script lang="ts" setup>
import {BasicTableProps, useTable} from "/@/hooks/table";
import {delObj, fetchList} from "/@/api/admin/token";
import {useI18n} from 'vue-i18n'
import {useMessage, useMessageBox} from "/@/hooks/message";
import { BasicTableProps, useTable } from "/@/hooks/table";
import { delObj, fetchList } from "/@/api/admin/token";
import { useI18n } from 'vue-i18n'
import { useMessage, useMessageBox } from "/@/hooks/message";
import { Session } from "/@/utils/storage";
const {t} = useI18n()
//
const queryRef = ref()
const showSearch = ref(true)
const { t } = useI18n()
//
const queryRef = ref()
const showSearch = ref(true)
// rows
const selectObjs = ref([]) as any
//
const multiple = ref(true)
// rows
const selectObjs = ref([]) as any
//
const multiple = ref(true)
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {
username: ''
},
pageList: fetchList
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {
username: ''
},
pageList: fetchList
});
// table hook
const {
getDataList,
currentChangeHandle,
sortChangeHandle,
sizeChangeHandle
} = useTable(state)
//
const resetQuery = () => {
queryRef.value.resetFields()
getDataList()
}
//
const handleSelectionChange = (objs: any) => {
objs.forEach((val: any) => {
selectObjs.value.push(val.accessToken)
});
multiple.value = !objs.length
}
// table hook
const {
getDataList,
currentChangeHandle,
sortChangeHandle,
sizeChangeHandle
} = useTable(state)
//
const resetQuery = () => {
queryRef.value.resetFields()
getDataList()
}
//
const handleSelectionChange = (objs: any) => {
objs.forEach((val: any) => {
selectObjs.value.push(val.accessToken)
});
multiple.value = !objs.length
}
//
const handleDelete = (accessTokens: string[]) => {
useMessageBox().confirm(t('common.delConfirmText'))
.then(() => {
delObj(accessTokens).then(() => {
getDataList();
useMessage().success(t('common.delSuccessText'));
}).catch((err: any) => {
useMessage().error(err.msg)
})
//
const handleDelete = (accessTokens: string[]) => {
useMessageBox().confirm(t('common.delConfirmText'))
.then(() => {
delObj(accessTokens).then(() => {
getDataList();
useMessage().success(t('common.delSuccessText'));
}).catch((err: any) => {
useMessage().error(err.msg)
})
};
</script>
})
};
<style scoped>
</style>
// token token
const filterOwnToken = (row: any) => {
return Session.get('token') === row.accessToken
}
</script>

View File

@ -123,6 +123,7 @@ const dataForm = reactive({
const dataRules = ref(
{
// 5-20
username: [{ required: true, message: "用户名不能为空", trigger: "blur" }
, { min: 5, max: 20, message: "用户名称长度必须介于 5 和 20 之间", trigger: "blur" }
, {
@ -130,13 +131,15 @@ const dataRules = ref(
validateUsername(rule, value, callback, dataForm.userId !== '')
}, trigger: 'blur'
}],
password: [{ required: true, message: "密码不能为空", trigger: "blur" }, { min: 6, max: 20, message: "用户密码长度必须介于 6 和 20 之间", trigger: "blur" }],
password: [{ required: true, message: "密码不能为空", trigger: "blur" }, { min: 6, max: 20, message: "用户密码长度必须介于 5 和 20 之间", trigger: "blur" }],
//
name: [{ required: true, message: "姓名不能为空", trigger: "blur" }
, { validator: rule.chinese, trigger: 'blur' }
],
deptId: [{ required: true, message: "部门不能为空", trigger: "blur" }],
role: [{ required: true, message: "角色不能为空", trigger: "blur" }],
post: [{ required: true, message: "岗位不能为空", trigger: "blur" }],
//
phone: [{ required: true, message: "手机号不能为空", trigger: "blur" }
, { validator: rule.validatePhone, trigger: 'blur' }
, {

View File

@ -4,9 +4,8 @@
<el-row class="mb8" v-show="showSearch">
<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList" ref="queryRef">
<el-form-item :label="$t('datasourceconf.dsName')" prop="dsName">
<el-input :placeholder="$t('datasourceconf.inputdsNameTip')" formDialogRef
style="max-width: 180px"
v-model="state.queryForm.dsName"/>
<el-input :placeholder="$t('datasourceconf.inputdsNameTip')" formDialogRef style="max-width: 180px"
v-model="state.queryForm.dsName" />
</el-form-item>
<el-form-item class="ml2">
<el-button @click="getDataList" icon="search" type="primary">
@ -23,117 +22,116 @@
{{ $t('common.addBtn') }}
</el-button>
<el-button :disabled="multiple" @click="handleDelete(undefined)" class="ml10" icon="Delete"
type="primary">
type="primary">
{{ $t('common.delBtn') }}
</el-button>
<right-toolbar @queryTable="getDataList" class="ml10" style="float: right;margin-right: 20px"
v-model:showSearch="showSearch"></right-toolbar>
v-model:showSearch="showSearch"></right-toolbar>
</div>
</el-row>
<el-table :data="state.dataList" @selection-change="handleSelectionChange" style="width: 100%"
v-loading="state.loading">
<el-table-column align="center" type="selection" width="50"/>
<el-table-column :label="t('datasourceconf.index')" type="index" width="80"/>
<el-table-column :label="t('datasourceconf.name')" prop="name" show-overflow-tooltip/>
<el-table-column :label="t('datasourceconf.dsName')" prop="dsName" show-overflow-tooltip/>
<el-table-column :label="t('datasourceconf.dsType')" prop="dsType" show-overflow-tooltip/>
<el-table-column :label="t('datasourceconf.username')" prop="username" show-overflow-tooltip/>
<el-table-column :label="t('datasourceconf.createTime')" prop="createTime" show-overflow-tooltip/>
v-loading="state.loading">
<el-table-column align="center" type="selection" width="50" />
<el-table-column :label="t('datasourceconf.index')" type="index" width="80" />
<el-table-column :label="t('datasourceconf.name')" prop="name" show-overflow-tooltip />
<el-table-column :label="t('datasourceconf.dsName')" prop="dsName" show-overflow-tooltip />
<el-table-column :label="t('datasourceconf.dsType')" prop="dsType" show-overflow-tooltip />
<el-table-column :label="t('datasourceconf.username')" prop="username" show-overflow-tooltip />
<el-table-column :label="t('datasourceconf.createTime')" prop="createTime" show-overflow-tooltip />
<el-table-column :label="$t('common.action')" width="150">
<template #default="scope">
<el-button @click="downloadDoc(scope.row.name)" text type="primary">{{
$t('datasourceconf.docBtn')
}}
}}
</el-button>
<el-button @click="formDialogRef.openDialog(scope.row.id)" text type="primary">{{
$t('common.editBtn')
}}
}}
</el-button>
<el-button @click="handleDelete(scope.row)" text type="primary">{{
$t('common.delBtn')
}}
}}
</el-button>
</template>
</el-table-column>
</el-table>
<pagination @current-change="currentChangeHandle" @size-change="sizeChangeHandle"
v-bind="state.pagination"/>
<pagination @current-change="currentChangeHandle" @size-change="sizeChangeHandle" v-bind="state.pagination" />
</el-card>
<!-- 编辑新增 -->
<form-dialog @refresh="getDataList()" ref="formDialogRef"/>
<form-dialog @refresh="getDataList()" ref="formDialogRef" />
</div>
</template>
<script lang="ts" name="systemDatasourceConf" setup>
import {BasicTableProps, useTable} from "/@/hooks/table";
import {delObj, fetchList} from "/@/api/gen/datasource";
import {useMessage, useMessageBox} from "/@/hooks/message";
import {useI18n} from "vue-i18n";
import {downBlobFile} from "/@/utils/other";
import { BasicTableProps, useTable } from "/@/hooks/table";
import { delObj, fetchList } from "/@/api/gen/datasource";
import { useMessage, useMessageBox } from "/@/hooks/message";
import { useI18n } from "vue-i18n";
import { downBlobFile } from "/@/utils/other";
//
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
const {t} = useI18n()
//
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
const { t } = useI18n()
//
const formDialogRef = ref()
//
const queryRef = ref()
const showSearch = ref(true)
//
const selectObjs = ref([])
const multiple = ref(true)
//
const formDialogRef = ref()
//
const queryRef = ref()
const showSearch = ref(true)
//
const selectObjs = ref([])
const multiple = ref(true)
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {},
pageList: fetchList
})
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {},
pageList: fetchList
})
// table hook
const {
getDataList,
currentChangeHandle,
sizeChangeHandle,
} = useTable(state)
// table hook
const {
getDataList,
currentChangeHandle,
sizeChangeHandle,
} = useTable(state)
const downloadDoc = (dsName: string) => {
downBlobFile('/gen/dsconf/doc', {dsName}, `${dsName}.html`)
const downloadDoc = (dsName: string) => {
downBlobFile('/gen/dsconf/doc', { dsName }, `${dsName}.html`)
}
//
const resetQuery = () => {
queryRef.value.resetFields()
getDataList()
}
//
const handleSelectionChange = (val: any) => {
selectObjs.value = val
multiple.value = !val.length
}
//
const handleDelete = (row: any) => {
if (!row) {
selectObjs.value.forEach((val: any) => {
handleDelete(val)
});
return
}
//
const resetQuery = () => {
queryRef.value.resetFields()
getDataList()
}
//
const handleSelectionChange = (val: any) => {
selectObjs.value = val
multiple.value = !val.length
}
//
const handleDelete = (row: any) => {
if (!row) {
selectObjs.value.forEach((val: any) => {
handleDelete(val)
});
return
}
useMessageBox().confirm(t('common.delConfirmText') + row.id)
.then(() => {
delObj(row.id).then(() => {
getDataList();
useMessage().success(t('common.delSuccessText'));
}).catch((err: any) => {
useMessage().error(err.msg)
})
useMessageBox().confirm(t('common.delConfirmText') + row.id)
.then(() => {
delObj(row.id).then(() => {
getDataList();
useMessage().success(t('common.delSuccessText'));
}).catch((err: any) => {
useMessage().error(err.msg)
})
};
})
};
</script>