diff --git a/src/views/pms/brand/index.vue b/src/views/pms/brand/index.vue
index 4b8911a3..10213b4e 100644
--- a/src/views/pms/brand/index.vue
+++ b/src/views/pms/brand/index.vue
@@ -2,7 +2,7 @@
-
@@ -138,11 +137,12 @@
import {listBrandsWithPage, getBrandDetail, updateBrand, addBrand, deleteBrands} from '@/api/pms/brand'
import SingleUpload from "@/components/Upload/SingleUpload.vue"
import {onMounted, reactive, ref, toRefs, unref} from "vue";
-import {ElForm, ElMessage, ElMessageBox} from "element-plus";
+import {ElForm, ElTable, ElMessage, ElMessageBox} from "element-plus";
import {Search, Plus, Edit, Refresh, Delete} from '@element-plus/icons'
-const dataForm = ref(ElForm) // 属性名必须和元素的ref属性值一致
-const dataTable = ref()
+const dataTableRef = ref(ElTable)
+const queryFormRef = ref(ElForm) // 属性名必须和元素的ref属性值一致
+const dataFormRef = ref(ElForm) // 属性名必须和元素的ref属性值一致
const state = reactive({
loading: true,
@@ -189,16 +189,14 @@ function handleQuery() {
}
function resetQuery() {
- state.queryParams = {
- pageNum: 1,
- pageSize: 10,
- title: undefined
- }
+ const dataTable = unref(dataTableRef)
+ dataTable.resetFields()
handleQuery()
}
function handleRowClick(row: any) {
- dataTable.value.toggleRowSelection(row);
+ const dataTable = unref(dataTableRef)
+ dataTable.toggleRowSelection(row);
}
function handleSelectionChange(selection: any) {
@@ -208,7 +206,6 @@ function handleSelectionChange(selection: any) {
}
function handleAdd() {
- resetForm()
state.dialog = {
title: '添加品牌',
visible: true
@@ -216,7 +213,6 @@ function handleAdd() {
}
function handleUpdate(row: any) {
- resetForm()
state.dialog = {
title: '修改品牌',
visible: true,
@@ -228,19 +224,21 @@ function handleUpdate(row: any) {
}
function submitForm() {
- const form = unref(dataForm)
- form.validate((valid: any) => {
+ const dataForm = unref(dataFormRef)
+ dataForm.validate((valid: any) => {
if (valid) {
if (state.formData.id) {
updateBrand(state.formData.id as any, state.formData).then(response => {
ElMessage.success('修改成功')
state.dialog.visible = false
+ resetForm()
handleQuery()
})
} else {
addBrand(state.formData).then(response => {
ElMessage.success('新增成功')
state.dialog.visible = false
+ resetForm()
handleQuery()
})
}
@@ -248,18 +246,17 @@ function submitForm() {
})
}
+/**
+ * 重置表单
+ */
function resetForm() {
- state.formData = {
- id: undefined,
- name: undefined,
- logoUrl: undefined,
- sort: 1
- }
+ const dataForm = unref(dataFormRef)
+ dataForm.resetFields()
}
function cancel() {
- resetForm()
state.dialog.visible = false
+ resetForm()
}
function handleDelete(row: any) {
@@ -285,5 +282,4 @@ onMounted(() => {
diff --git a/src/views/pms/category/components/Attribute.vue b/src/views/pms/category/components/Attribute.vue
index f199cd2f..17db3953 100644
--- a/src/views/pms/category/components/Attribute.vue
+++ b/src/views/pms/category/components/Attribute.vue
@@ -1,5 +1,5 @@
-
+
@@ -158,7 +158,7 @@ function submitForm() {
diff --git a/src/views/system/menu/components/Menu.vue b/src/views/system/menu/components/Menu.vue
index 7272f7cf..96ed0136 100644
--- a/src/views/system/menu/components/Menu.vue
+++ b/src/views/system/menu/components/Menu.vue
@@ -2,7 +2,7 @@
新增
-
+
@@ -177,7 +177,9 @@ import IconSelect from '@/components/IconSelect/index.vue';
const emit = defineEmits(['menuClick'])
const showChooseIcon = ref(false);
const iconSelectRef = ref(null);
-const dataForm = ref(ElForm)
+
+const queryFormRef = ref(ElForm)
+const dataFormRef = ref(ElForm)
const state = reactive({
loading: true,
@@ -207,7 +209,7 @@ const state = reactive({
sort: 1,
component: 'Layout',
path: undefined,
- redirect:''
+ redirect: ''
},
rules: {
parentId: [
@@ -224,7 +226,7 @@ const state = reactive({
currentRow: undefined
})
-const {loading,single,multiple,queryParams,menuList,total,dialog,formData,rules,menuOptions} =toRefs(state)
+const {loading, single, multiple, queryParams, menuList, total, dialog, formData, rules, menuOptions} = toRefs(state)
function handleQuery() {
// 重置父组件
@@ -250,12 +252,12 @@ async function loadTreeSelectMenuOptions() {
})
}
+/**
+ * 重置查询
+ */
function resetQuery() {
- state.queryParams = {
- pageNum: 1,
- pageSize: 10,
- name: undefined
- }
+ const queryForm = unref(queryFormRef)
+ queryForm.resetFields()
handleQuery()
}
@@ -271,7 +273,6 @@ function handleRowClick(row: any) {
}
async function handleAdd(row: any) {
- resetForm()
await loadTreeSelectMenuOptions()
state.dialog = {
title: '添加菜单',
@@ -299,7 +300,6 @@ async function handleAdd(row: any) {
}
async function handleUpdate(row: any) {
- resetForm()
await loadTreeSelectMenuOptions()
state.dialog = {
title: '修改菜单',
@@ -312,8 +312,8 @@ async function handleUpdate(row: any) {
}
function submitForm() {
- const form = unref(dataForm)
- form.validate((valid: any) => {
+ const dataForm = unref(dataFormRef)
+ dataForm.validate((valid: any) => {
if (valid) {
if (state.formData.id) {
updateMenu(state.formData.id, state.formData).then(response => {
@@ -348,23 +348,17 @@ function handleDelete(row: any) {
)
}
+/**
+ * 重置表单
+ */
function resetForm() {
- state.formData = {
- id: undefined,
- parentId: 0,
- name: undefined,
- visible: 1,
- icon: '',
- sort: 1,
- component: 'Layout',
- path: undefined,
- redirect:''
- }
+ const dataForm = unref(dataFormRef)
+ dataForm.resetFields
}
function cancel() {
- resetForm()
state.dialog.visible = false
+ resetForm()
}
function showSelectIcon() {
diff --git a/src/views/system/menu/components/Perm.vue b/src/views/system/menu/components/Perm.vue
index f82a1a94..117bebaa 100644
--- a/src/views/system/menu/components/Perm.vue
+++ b/src/views/system/menu/components/Perm.vue
@@ -1,22 +1,23 @@
-
+
- 新增
- 删除
+ 新增
+ 删除
-
+
+ @keyup.enter.native="handleQuery"
+ />
搜索
@@ -26,9 +27,8 @@
+
+ ref="dataFormRef"
+ :model="formData"
+ :rules="rules"
+ label-width="120px"
+ >
-
+
-
-
+
-
+
-
- {{ state.urlPerm.requestMethod }}:/{{ state.urlPerm.serviceName }}{{ state.urlPerm.requestPath }}
+
+ {{ urlPerm.requestMethod }}:/{{ urlPerm.serviceName }}{{ urlPerm.requestPath }}
-
+
@@ -142,14 +143,13 @@ import {ElForm, ElMessage, ElMessageBox} from "element-plus"
const {proxy}: any = getCurrentInstance();
+const queryFormRef = ref(ElForm)
+const dataFormRef = ref(ElForm)
+
const props = defineProps({
menuId: {
type: String,
default: ''
- },
- menuName: {
- type: String,
- default: ''
}
})
@@ -196,9 +196,8 @@ const state = reactive({
{required: true, message: '请选择请求方式', trigger: 'blur'}
]
},
- microServiceOptions: [],
+ microServiceOptions: [] as Array,
requestMethodOptions: [] as Array,
- menuName: undefined,
urlPerm: {
requestMethod: undefined,
serviceName: undefined,
@@ -206,8 +205,21 @@ const state = reactive({
},
})
- toRefs(state)
-
+const {
+ loading,
+ ids,
+ single,
+ multiple,
+ pageList,
+ total,
+ dialog,
+ formData,
+ rules,
+ microServiceOptions,
+ requestMethodOptions,
+ urlPerm,
+ queryParams
+} = toRefs(state)
function handleQuery() {
if (state.queryParams.menuId) {
@@ -227,12 +239,8 @@ function handleQuery() {
}
function resetQuery() {
- state.queryParams = {
- pageNum: 1,
- pageSize: 10,
- menuId: undefined,
- name: undefined
- }
+ const queryForm = unref(queryFormRef)
+ queryForm.resetFields()
handleQuery()
}
@@ -242,11 +250,10 @@ function handleSelectionChange(selection: any) {
state.multiple = !selection.length
}
-
/**
- * 字典数据准备
+ * 加载字典数据
*/
-function loadDictData() {
+function loadDictOptions() {
proxy.$listDictsByCode('micro_service').then((response: any) => {
state.microServiceOptions = response.data
})
@@ -257,8 +264,7 @@ function loadDictData() {
}
function handleAdd() {
- resetForm()
- loadDictData()
+ loadDictOptions()
state.dialog = {
title: '添加权限',
visible: true
@@ -266,8 +272,7 @@ function handleAdd() {
}
function handleUpdate(row: any) {
- resetForm()
- loadDictData()
+ loadDictOptions()
state.dialog = {
title: '修改权限',
visible: true
@@ -286,11 +291,9 @@ function handleUpdate(row: any) {
})
}
-const dataForm = ref(ElForm)
-
function submitForm() {
- const form = unref(dataForm)
- form.validate((valid: any) => {
+ const dataForm = unref(dataFormRef)
+ dataForm.validate((valid: any) => {
if (valid) {
// 接口权限和按钮权限必填其一
console.log(state.urlPerm.requestPath, state.formData.btnPerm)
@@ -298,7 +301,6 @@ function submitForm() {
ElMessage.warning('请至少填写一种权限')
return false
}
-
// 如果填写了URL权限,完整性校验
if (!state.urlPerm.requestPath) {
if (!state.urlPerm.requestMethod) {
@@ -317,12 +319,14 @@ function submitForm() {
updatePerm(state.formData.id, state.formData).then(response => {
ElMessage.success('修改成功')
state.dialog.visible = false
+ resetForm()
handleQuery()
})
} else {
addPerm(state.formData).then(response => {
ElMessage.success('新增成功')
state.dialog.visible = false
+ resetForm()
handleQuery()
})
}
@@ -330,14 +334,13 @@ function submitForm() {
})
}
+/**
+ * 重置表单
+ */
function resetForm() {
- state.formData = {
- id: undefined,
- name: undefined,
- urlPerm: '',
- btnPerm: '',
- menuId: ''
- }
+ const dataForm = unref(dataFormRef)
+ dataForm.resetFields()
+
}
function cancel() {
@@ -366,7 +369,7 @@ onMounted(() => {
diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue
index 04de6488..9832dd01 100644
--- a/src/views/system/user/index.vue
+++ b/src/views/system/user/index.vue
@@ -442,9 +442,9 @@ const state = reactive({
],
email: [
{
- type: 'email',
- message: '\'请输入正确的邮箱地址',
- trigger: ['blur', 'change']
+ pattern: /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/,
+ message: '请输入正确的邮箱地址',
+ trigger: 'blur'
}
],
mobile: [