Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9845655
增加后端服务控制脚本service.sh,用于服务管控
4linuxfun Aug 15, 2024
15acfb5
update README.md
4linuxfun Aug 15, 2024
35c375a
Fixes #82: 菜单管理增加子菜单判断
4linuxfun Aug 15, 2024
de27e2b
playbook逻辑优化
4linuxfun Aug 15, 2024
99acddf
前端:脚本管理复制功能实现
4linuxfun Aug 15, 2024
2698c74
scheduler:task任务执行后删除对应的ansible目录
4linuxfun Aug 15, 2024
86be0a6
前端:任务管理功能共用
4linuxfun Aug 28, 2024
5f9d05b
前端:任务管理相关组件props调整,并增加注释
4linuxfun Aug 28, 2024
bb57991
update:更新Tree生成逻辑,加快菜单的生成
4linuxfun Jan 9, 2025
4488e8e
update:前端更新整体框架
4linuxfun Jan 9, 2025
9ee8824
update:前端美化layout布局
4linuxfun Jan 9, 2025
78a0534
update:前端更新layout排版,美化tab显示效果
4linuxfun Jan 9, 2025
f6dbb61
update:前端优化首页、tab页面效果
4linuxfun Jan 10, 2025
a6789a0
update:前端更新package.json
4linuxfun Jan 13, 2025
4c08ed1
update:前端优化404页面路由
4linuxfun Jan 13, 2025
b0e5683
update:前端优化menu相关配置
4linuxfun Jan 13, 2025
08269ec
update:前端增加404页面
4linuxfun Jan 13, 2025
602102b
update:前端-修复resetpassword报错
4linuxfun Jan 13, 2025
1ce1df1
update:前端-修复一级菜单显示问题
4linuxfun Jan 13, 2025
0862513
update:前端-菜单增加注释
4linuxfun Jan 13, 2025
5fb8da3
update:后端-数据字典删除接口实现
4linuxfun Jan 14, 2025
2ab640e
update:前端-数据字典增加部分验证
4linuxfun Jan 14, 2025
377b046
update:前端-修复el-checkbox废弃接口报错
4linuxfun Jan 14, 2025
3985d9e
update:前端优化permission代码逻辑
4linuxfun Jan 14, 2025
a103a2e
update:前端-使用新方法设置vue组件name属性
4linuxfun Jan 14, 2025
aa0756c
update:前端-修复common函数递归死循环错误
4linuxfun Jan 15, 2025
22573a5
update:前端-主机管理增加name属性值
4linuxfun Jan 15, 2025
f95998d
update:前端-优化ConfirmDel方法逻辑
4linuxfun Jan 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update:前端-数据字典增加部分验证
  • Loading branch information
4linuxfun committed Jan 14, 2025
commit 2ab640ed493b0468f1f16ebe0eee5b6c2307199f
3 changes: 2 additions & 1 deletion www/src/api/dictonary.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {GET, POST, PUT, DELETE} from '@/utils/request'

export const PostNewDict = (dict) => POST('/api/dict', dict)
export const PutDict = (dict) => PUT('/api/dict', dict)
export const DelDict = (id) => DELETE('/api/dict/' + id)
export const PostNewDictItem = (item) => POST('/api/dict/item', item)
export const PutDictItem = (item) => PUT('/api/dict/item', item)
export const DelDictItem = (id) => DELETE('/api/dict/item/' + id)
export const GetDictItems = (code) => GET('/api/dict/'+ code)
export const GetDictItems = (code) => GET('/api/dict/' + code)
67 changes: 42 additions & 25 deletions www/src/views/system/dictonary/AddDict.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<el-form :model="form" label-width="100px">
<el-form :model="form" :rules="rules" label-width="100px" ref="formRef">
<el-form-item label="字典名字:" prop="name">
<el-input v-model="form.name"/>
</el-form-item>
Expand All @@ -10,44 +10,61 @@
<el-input v-model="form.desc"/>
</el-form-item>
</el-form>
<el-button type="danger" @click="$emit('update:visible',false)">关闭</el-button>
<el-button type="danger" @click="$emit('update:visible', false)"
>关闭
</el-button
>
<el-button type="primary" @click="handleAdd">确定</el-button>
</template>

<script setup>

import {reactive} from 'vue'
import {reactive, ref} from 'vue'
import {PostNewDict, PutDict} from '@/api/dictonary'
import {ElNotification} from 'element-plus'

const props = defineProps(['dict', 'visible'])
const emit = defineEmits(['update:visible'])
const form = reactive(props.dict)
const formRef = ref(null)

const rules = {
name: [{required: true, message: '字典名称不能为空', trigger: 'blur'}],
code: [{required: true, message: '字典编码不能为空', trigger: 'blur'}],
}

function handleAdd() {
if (form.id === null) {
PostNewDict(form).then(() => {
ElNotification({
title: 'success',
message: '数据字典添加成功',
type: 'success'
})
})
} else {
PutDict(form).then(() => {
formRef.value.validate((valid) => {
if (valid) {
// 验证通过
if (form.id === null) {
PostNewDict(form).then(() => {
ElNotification({
title: 'success',
message: '数据字典添加成功',
type: 'success',
})
})
} else {
PutDict(form).then(() => {
ElNotification({
title: 'success',
message: '数据字典更新成功',
type: 'success',
})
})
}

emit('update:visible', false)
} else {
// 验证不通过
ElNotification({
title: 'success',
message: '数据字典更新成功',
type: 'success'
title: 'error',
message: '请填写必填项',
type: 'error',
})
})
}

emit('update:visible', false)
}
})
}

</script>

<style scoped>

</style>
<style scoped></style>
103 changes: 66 additions & 37 deletions www/src/views/system/dictonary/AddItem.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<template>
<el-dialog v-model="visible" width="30%" destroy-on-close>
<el-form v-model="form" label-width="100px">
<el-form-item label="名称" prop="name">
<el-dialog v-model="visible" :title="title" width="30%" destroy-on-close>
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
<el-form-item label="名称" prop="label">
<el-input v-model="form.label"/>
</el-form-item>
<el-form-item label="数据值" prop="data">
<el-form-item label="数据值" prop="value">
<el-input v-model="form.value"/>
</el-form-item>
<el-form-item label="描述" prop="desc">
Expand All @@ -17,8 +17,11 @@
<el-switch v-model="form.enable" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>
</el-form-item>
</el-form>
<el-button @click="$emit('update:visible',false)">关闭</el-button>
<el-button type="primary" @click="handleAdd">确定</el-button>
<el-row justify="center">
<el-button @click="visible=false" type="danger">关闭</el-button>
<el-button type="primary" @click="handleAdd">确定</el-button>
</el-row>

</el-dialog>
</template>

Expand All @@ -31,44 +34,68 @@
const emit = defineEmits(['success'])
const visible = ref(false)
const form = reactive({})
const formRef = ref(null)
const title = ref('')
const rules = reactive({
label: [
{required: true, message: '请输入名称', trigger: 'blur'}
],
value: [
{required: true, message: '请输入数据值', trigger: 'blur'}
]
})

/*
* 添加或更新字典元素
*/
async function handleAdd() {
if (form.id === null) {
try {
await PostNewDictItem(form)
ElNotification({
title: 'success',
message: '字典元素添加成功',
type: 'success'
})
} catch (e) {
ElNotification({
title: 'error',
message: '字典元素添加失败',
type: 'error'
})
}
} else {
try {
await PutDictItem(form)
ElNotification({
title: 'success',
message: '字典元素更新成功',
type: 'success'
})
} catch (e) {
ElNotification({
title: 'error',
message: '字典元素更新失败',
type: 'error'
})
try {
await formRef.value.validate()
if (form.id === null) {
try {
await PostNewDictItem(form)
ElNotification({
title: 'success',
message: '字典元素添加成功',
type: 'success'
})
} catch (e) {
ElNotification({
title: 'error',
message: '字典元素添加失败',
type: 'error'
})
}
} else {
try {
await PutDictItem(form)
ElNotification({
title: 'success',
message: '字典元素更新成功',
type: 'success'
})
} catch (e) {
ElNotification({
title: 'error',
message: '字典元素更新失败',
type: 'error'
})
}
}
visible.value = false
emit('success')
} catch (e) {
ElNotification({
title: 'error',
message: '请填写必填项',
type: 'error'
})
}
visible.value = false
emit('success')
}

/*对外开放的添加字典接口*/
function add(dictId) {
title.value = '新增字典元素'
Object.assign(form, {
id: null,
label: null,
Expand All @@ -81,7 +108,9 @@
visible.value = true
}

/*对外开放的编辑字典接口*/
function edit(dictItem) {
title.value = '编辑字典元素'
Object.assign(form, dictItem)
visible.value = true
}
Expand Down
18 changes: 17 additions & 1 deletion www/src/views/system/dictonary/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<el-button text type="primary" style="padding: 0" :icon="Setting" @click="handleItem(scope.row)">字典配置
</el-button>
<el-divider direction="vertical"/>
<el-button text type="danger" style="padding: 0" :icon="Delete">删除</el-button>
<el-button text type="danger" style="padding: 0" :icon="Delete" @click="handleDel(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
Expand Down Expand Up @@ -79,6 +79,8 @@
import usePagination from '@/composables/usePagination'
import AddDict from '@/views/system/dictonary/AddDict'
import DictItem from '@/views/system/dictonary/DictItem'
import {DelDict} from '@/api/dictonary'
import {ConfirmDel} from '@/utils/request'


const addDialog = ref(false)
Expand Down Expand Up @@ -119,17 +121,31 @@
handleSearch()
}

/*
* 编辑数据字典
*/
function handleEdit(dict) {
dialogTitle.value = '编辑数据字典'
selectDict.value = dict
console.log(dict)
addDialog.value = true
}

/*
* 字典元素配置
*/
function handleItem(dict) {
dictItemRef.value.edit(dict)
}

/*
*删除字典
*/
async function handleDel(dict) {
await ConfirmDel('删除字典会一起删除对应的元素', DelDict, dict.id)
await freshCurrentPage()
}

watch(addDialog, (newValue) => {
if (newValue === false) {
freshCurrentPage()
Expand Down