8
0
ZaiZai vor 1 Jahr
Ursprung
Commit
d94bf256fe

+ 37 - 0
src/api/modules/system/param.js

@@ -0,0 +1,37 @@
+import { HcApi } from '../../request/index'
+
+export default {
+    async page(form) {
+        return HcApi({
+            url: '/api/blade-system/param/list',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    //菜单详情
+    async detail(id) {
+        return HcApi({
+            url: '/api/blade-system/param/detail',
+            method: 'get',
+            params: {
+                id,
+            },
+        }, false)
+    },
+    async submit(form) {
+        return HcApi({
+            url: '/api/blade-system/param/submit',
+            method: 'post',
+            data: form,
+        }, false)
+    },
+    async del(ids) {
+        return HcApi({
+            url: '/api/blade-system/param/remove',
+            method: 'post',
+            params: {
+                ids,
+            },
+        }, false)
+    },
+}

+ 6 - 0
src/router/modules/base.js

@@ -46,6 +46,12 @@ export default [
                 meta: { title: '应用管理' },
                 component: () => import('~src/views/system/client.vue'),
             },
+            {
+                path: '/system/param',
+                name: 'param',
+                meta: { title: '参数管理' },
+                component: () => import('~src/views/system/param.vue'),
+            },
             {
                 path: '/system/menu',
                 name: 'menu',

+ 3 - 3
src/views/system/client.vue

@@ -23,7 +23,7 @@
             <hc-pages :pages="searchForm" @change="pageChange" />
         </template>
 
-        <!-- 新增/修改 菜单 -->
+        <!-- 新增/修改 -->
         <hc-new-dialog v-model="isDialogShow" widths="800px" is-footer-center :title="dialogTitle" @close="dialogClose">
             <el-form ref="formRef" :model="formModel" :rules="formRules" label-position="top" label-width="auto">
                 <el-row :gutter="20">
@@ -215,7 +215,7 @@ const formRules = {
 
 //新增
 const addClick = () => {
-    dialogTitle.value = '新增菜单'
+    dialogTitle.value = '新增应用'
     formModel.value = {
         category: 1, isOpen: 1, isLayout: 1, isShowButton: 1,
         sort: 1,
@@ -229,7 +229,7 @@ const addClick = () => {
 //修改菜单
 const editRowClick = (row) => {
     formModel.value = {}
-    dialogTitle.value = '修改菜单'
+    dialogTitle.value = '修改应用'
     formModel.value = { ...row }
     formModel.value.authorizedGrantTypes = row.authorizedGrantTypes.split(',')
     //显示表单弹窗

+ 212 - 0
src/views/system/param.vue

@@ -0,0 +1,212 @@
+<template>
+    <hc-new-card>
+        <template #header>
+            <div class="w-60">
+                <hc-search-input v-model="searchForm.paramName" placeholder="请输入参数名称关键词" @search="searchClick" />
+            </div>
+        </template>
+        <template #extra>
+            <el-button hc-btn type="primary" @click="addClick">新增</el-button>
+            <el-button hc-btn type="danger" @click="delClick">删除</el-button>
+        </template>
+        <hc-table
+            ref="tableRef" :column="tableColumn" :datas="tableData" :loading="tableLoading"
+            is-new is-check :check-style="{ width: 29 }" :index-style="{ width: 60 }"
+            @selection-change="tableCheckChange"
+        >
+            <template #action="{ row }">
+                <el-link type="warning" @click="editRowClick(row)">修改</el-link>
+                <el-link type="danger" @click="delRowClick(row)">删除</el-link>
+            </template>
+        </hc-table>
+        <template #action>
+            <hc-pages :pages="searchForm" @change="pageChange" />
+        </template>
+
+        <!-- 新增/修改 -->
+        <hc-new-dialog v-model="isDialogShow" widths="800px" is-footer-center :title="dialogTitle" @close="dialogClose">
+            <el-form ref="formRef" :model="formModel" :rules="formRules" label-position="top" label-width="auto">
+                <el-form-item label="参数名称:" prop="paramName">
+                    <el-input v-model="formModel.paramName" clearable placeholder="请输入参数名称" />
+                </el-form-item>
+                <el-form-item label="参数键名:" prop="paramKey">
+                    <el-input v-model="formModel.paramKey" clearable placeholder="请输入参数键名" />
+                </el-form-item>
+                <el-form-item label="参数键值:" prop="paramValue">
+                    <el-input v-model="formModel.paramValue" :autosize="{ minRows: 2, maxRows: 4 }" type="textarea" placeholder="请输入参数键值" />
+                </el-form-item>
+            </el-form>
+            <template #footer>
+                <el-button hc-btn @click="dialogClose">取消</el-button>
+                <el-button hc-btn type="primary" :loading="submitLoading" @click="dialogSubmit">提交</el-button>
+            </template>
+        </hc-new-dialog>
+    </hc-new-card>
+</template>
+
+<script setup>
+import { nextTick, onActivated, ref } from 'vue'
+import { arrToId, formValidate, getArrValue } from 'js-fast-way'
+import { delMessage, reloadPage } from '~uti/tools'
+import mainApi from '~api/system/param'
+
+//激活
+onActivated(() => {
+    searchForm.value.current = 1
+    getTableData()
+})
+
+//搜索表单
+const searchForm = ref({ current: 1, size: 30, total: 0 })
+
+//搜索
+const searchClick = () => {
+    searchForm.value.current = 1
+    getTableData()
+}
+
+//分页
+const pageChange = ({ current, size }) => {
+    searchForm.value.current = current
+    searchForm.value.size = size
+    getTableData()
+}
+
+//表格数据
+const tableRef = ref(null)
+const tableColumn = ref([
+    { key: 'paramName', name: '参数名称' },
+    { key: 'paramKey', name: '参数键名' },
+    { key: 'paramValue', name: '参数键值' },
+    { key: 'action', name: '操作', width: 100, align: 'center' },
+])
+
+//获取表格数据
+const tableLoading = ref(false)
+const tableData = ref([{}])
+const getTableData = async () => {
+    tableData.value = []
+    tableLoading.value = true
+    const { error, code, data } = await mainApi.page({
+        ...searchForm.value,
+        total: null,
+    })
+    tableLoading.value = false
+    if (!error && code === 200) {
+        tableData.value = getArrValue(data['records'])
+        searchForm.value.total = data['total']
+    } else {
+        tableData.value = []
+        searchForm.value.total = 0
+    }
+}
+
+//表格被选择
+const tableCheckKeys = ref([])
+const tableCheckChange = (rows) => {
+    tableCheckKeys.value = rows
+}
+
+//新增/修改 弹窗
+const isDialogShow = ref(false)
+const dialogTitle = ref('')
+
+//菜单表单
+const formRef = ref(null)
+const formModel = ref({})
+const formRules = {
+    paramName: {
+        required: true,
+        trigger: 'blur',
+        message: '请输入参数名称',
+    },
+    paramKey: {
+        required: true,
+        trigger: 'blur',
+        message: '请输入参数键名',
+    },
+    paramValue: {
+        required: true,
+        trigger: 'blur',
+        message: '请输入参数键值',
+    },
+}
+
+//新增
+const addClick = () => {
+    dialogTitle.value = '新增参数'
+    formModel.value = {}
+    //显示表单弹窗
+    nextTick(() => {
+        isDialogShow.value = true
+    })
+}
+
+//修改菜单
+const editRowClick = (row) => {
+    formModel.value = {}
+    dialogTitle.value = '修改参数'
+    formModel.value = { ...row }
+    //显示表单弹窗
+    nextTick(() => {
+        isDialogShow.value = true
+    })
+}
+
+//删除菜单
+const delRowClick = (row) => {
+    delMessage(async () => {
+        const { code, msg } = await mainApi.del(row.id)
+        if (code === 200) {
+            window.$message.success('删除成功')
+            reloadPage()
+        } else {
+            window.$message.error(msg ?? '删除失败')
+        }
+    })
+}
+
+//批量删除菜单
+const delClick = () => {
+    const rows = tableCheckKeys.value
+    if (rows.length <= 0) {
+        window.$message.warning('请选择要删除的菜单')
+        return false
+    }
+    //确认删除菜单
+    delMessage(async () => {
+        const ids = arrToId(rows)
+        const { code, msg } = await mainApi.del(ids)
+        if (code === 200) {
+            window.$message.success('删除成功')
+            reloadPage()
+        } else {
+            window.$message.error(msg ?? '删除失败')
+        }
+    })
+}
+
+//提交表单
+const submitLoading = ref(false)
+const dialogSubmit = async () => {
+    const formRes = await formValidate(formRef.value)
+    if (!formRes) return false
+    submitLoading.value = true
+    //发起请求
+    const { error, code, msg } = await mainApi.submit(formModel.value)
+    if (!error && code === 200) {
+        submitLoading.value = false
+        window?.$message?.success('操作成功')
+        reloadPage()
+    } else {
+        window?.$message?.error(msg ?? '操作失败')
+    }
+}
+
+//关闭弹窗
+const dialogClose = () => {
+    isDialogShow.value = false
+    submitLoading.value = false
+    formModel.value = {}
+}
+</script>